File indexing completed on 2024-05-19 04:49:56
0001 /**************************************************************************************** 0002 * Copyright (c) 2008-2012 Soren Harward <stharward@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef APG_PLAYLISTDURATION_CONSTRAINT 0018 #define APG_PLAYLISTDURATION_CONSTRAINT 0019 0020 #include "ui_PlaylistDurationEditWidget.h" 0021 0022 #include "playlistgenerator/Constraint.h" 0023 0024 #include <QString> 0025 0026 class ConstraintFactoryEntry; 0027 class QWidget; 0028 0029 namespace ConstraintTypes { 0030 0031 /* This constraint derives its name from the fact that it specifies the 0032 * duration (ie, total running time) of the Playlist. */ 0033 0034 class PlaylistDuration : public Constraint { 0035 Q_OBJECT 0036 0037 enum NumComparison { CompareNumLessThan, CompareNumEquals, CompareNumGreaterThan }; 0038 0039 public: 0040 static Constraint* createFromXml(QDomElement&, ConstraintNode*); 0041 static Constraint* createNew(ConstraintNode*); 0042 static ConstraintFactoryEntry* registerMe(); 0043 0044 QWidget* editWidget() const override; 0045 void toXml(QDomDocument&, QDomElement&) const override; 0046 0047 QString getName() const override; 0048 0049 double satisfaction(const Meta::TrackList&) const override; 0050 quint32 suggestPlaylistSize() const override; 0051 0052 private Q_SLOTS: 0053 void setComparison( const int ); 0054 void setDuration( const int ); 0055 void setStrictness( const int ); 0056 0057 private: 0058 PlaylistDuration(QDomElement&, ConstraintNode*); 0059 explicit PlaylistDuration(ConstraintNode*); 0060 0061 // constraint parameters 0062 qint64 m_duration; // time in msec 0063 int m_comparison; 0064 double m_strictness; 0065 }; 0066 0067 class PlaylistDurationEditWidget : public QWidget { 0068 Q_OBJECT 0069 0070 public: 0071 PlaylistDurationEditWidget( const int, const int, const int ); 0072 0073 Q_SIGNALS: 0074 void updated(); 0075 void durationChanged( const int ); 0076 void comparisonChanged( const int ); 0077 void strictnessChanged( const int ); 0078 0079 private Q_SLOTS: 0080 void on_timeEdit_Duration_timeChanged( const QTime& ); 0081 void on_comboBox_Comparison_currentIndexChanged( const int ); 0082 void on_slider_Strictness_valueChanged( const int ); 0083 0084 private: 0085 Ui::PlaylistDurationEditWidget ui; 0086 }; 0087 } // namespace ConstraintTypes 0088 0089 #endif