File indexing completed on 2024-05-19 04:49:57
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_NODUPES_CONSTRAINT 0018 #define APG_NODUPES_CONSTRAINT 0019 0020 #include "ui_PreventDuplicatesEditWidget.h" 0021 0022 #include "playlistgenerator/Constraint.h" 0023 0024 #include <QString> 0025 0026 class ConstraintFactoryEntry; 0027 class QWidget; 0028 0029 namespace ConstraintTypes { 0030 0031 /* Prevents duplicate tracks, albums, or artists from ending up in playlist */ 0032 0033 enum DupeField { DupeTrack, DupeAlbum, DupeArtist }; 0034 0035 class PreventDuplicates : public Constraint { 0036 Q_OBJECT 0037 0038 public: 0039 static Constraint* createFromXml( QDomElement&, ConstraintNode* ); 0040 static Constraint* createNew( ConstraintNode* ); 0041 static ConstraintFactoryEntry* registerMe(); 0042 0043 QWidget* editWidget() const override; 0044 void toXml( QDomDocument&, QDomElement& ) const override; 0045 0046 QString getName() const override; 0047 0048 double satisfaction( const Meta::TrackList& ) const override; 0049 0050 private Q_SLOTS: 0051 void setField( const int ); 0052 0053 private: 0054 PreventDuplicates( QDomElement&, ConstraintNode* ); 0055 explicit PreventDuplicates( ConstraintNode* ); 0056 0057 double penalty( const int ) const; 0058 0059 // constraint parameters 0060 DupeField m_field; 0061 }; 0062 0063 class PreventDuplicatesEditWidget : public QWidget { 0064 Q_OBJECT 0065 0066 public: 0067 explicit PreventDuplicatesEditWidget( const int ); 0068 0069 Q_SIGNALS: 0070 void updated(); 0071 void fieldChanged( const int ); 0072 0073 private Q_SLOTS: 0074 void on_comboBox_Field_currentIndexChanged( const int ); 0075 0076 private: 0077 Ui::PreventDuplicatesEditWidget ui; 0078 }; 0079 } // namespace ConstraintTypes 0080 0081 #endif