some more work on collabsible albums. I think I will need to optimize the playlist...
[amarok.git] / src / smartplaylisteditor.h
blob42547c55d136009a8db12460336851c046560f3f
1 // (c) Pierpaolo Di Panfilo 2004
2 // (c) Alexandre Pereira de Oliveira 2005
3 // (c) 2006 Peter C. Ndikuwera <pndiku@gmail.com>
4 // See COPYING file for licensing information
6 #ifndef SMARTPLAYLISTEDITOR_H
7 #define SMARTPLAYLISTEDITOR_H
9 #include <KDialog> //baseclass
10 #include <klineedit.h> //inline function
11 #include <KHBox> //baseclass
13 #include <QDomDocument>
14 #include <QDomElement>
15 #include <q3ptrlist.h> //definition required
17 class CriteriaEditor;
19 class KComboBox;
20 class KLineEdit;
22 class Q3DateEdit;
23 class Q3VGroupBox;
24 class QCheckBox;
25 class QLabel;
26 class QSpinBox;
27 class QToolButton;
30 class SmartPlaylistEditor : public KDialog
32 Q_OBJECT
33 friend class CriteriaEditor;
35 public:
36 SmartPlaylistEditor( QString defaultName, QWidget *parent, const char *name=0 );
37 SmartPlaylistEditor( QWidget *parent, QDomElement xml, const char *name=0 );
39 QDomElement result();
41 QString name() const { return m_nameLineEdit->text().replace( "\n", " " ); }
43 enum CriteriaType { criteriaAll = 0, criteriaAny = 1 };
45 public slots:
46 void addCriteriaAny();
47 void addCriteriaAny( QDomElement &xml);
48 void removeCriteriaAny( CriteriaEditor *criteria);
50 void addCriteriaAll();
51 void addCriteriaAll( QDomElement &xml);
52 void removeCriteriaAll( CriteriaEditor *criteria);
54 private slots:
55 void updateOrderTypes( int index );
57 private:
58 void init(QString defaultName);
59 void updateMatchWidgets();
61 KLineEdit *m_nameLineEdit;
63 QCheckBox *m_matchAnyCheck;
64 QCheckBox *m_matchAllCheck;
66 // matching boxes
67 Q3VGroupBox *m_criteriaAnyGroupBox;
68 Q3VGroupBox *m_criteriaAllGroupBox;
70 //limit widgets
71 QCheckBox *m_limitCheck;
72 QSpinBox *m_limitSpin;
73 //order by widgets
74 QCheckBox *m_orderCheck;
75 KComboBox *m_orderCombo;
76 KComboBox *m_orderTypeCombo;
77 //expand by
78 QCheckBox *m_expandCheck;
79 KComboBox *m_expandCombo;
81 Q3PtrList<CriteriaEditor> m_criteriaEditorAnyList;
82 Q3PtrList<CriteriaEditor> m_criteriaEditorAllList;
87 class CriteriaEditor : public KHBox
89 Q_OBJECT
90 public:
91 CriteriaEditor( SmartPlaylistEditor *editor, QWidget *parent, int criteriaType, QDomElement criteria = QDomElement() );
92 ~CriteriaEditor();
93 QString getSearchCriteria();
94 void setSearchCriteria( const QString &str );
95 QDomElement getDomSearchCriteria( QDomDocument &doc );
96 void enableRemove( bool );
98 private slots:
99 void slotRemoveCriteriaAny();
100 void slotRemoveCriteriaAll();
101 void slotAddCriteriaAny();
102 void slotAddCriteriaAll();
103 void slotFieldSelected( int );
104 void loadEditWidgets();
106 private:
107 enum ValueType { String, AutoCompletionString, Number, Year, Date, Rating, Length };
109 void loadCriteriaList( int valueType, QString condition = QString() );
110 int getValueType( int fieldIndex );
111 inline int indexToRating( int );
112 inline int ratingToIndex( int );
114 SmartPlaylistEditor *m_playlistEditor;
115 int m_currentValueType;
116 QString m_lastCriteria;
118 KComboBox *m_fieldCombo;
119 KComboBox *m_criteriaCombo;
120 QToolButton *m_addButton;
121 QToolButton *m_removeButton;
123 //editing widgets
124 KHBox *m_editBox;
125 KLineEdit *m_lineEdit;
126 KComboBox *m_comboBox;
127 KComboBox *m_comboBox2;
128 QSpinBox *m_intSpinBox1;
129 QSpinBox *m_intSpinBox2;
130 Q3DateEdit *m_dateEdit1;
131 Q3DateEdit *m_dateEdit2;
132 KComboBox *m_dateCombo;
133 QLabel *m_rangeLabel;
134 KComboBox *m_lengthCombo;
137 inline int
138 CriteriaEditor::indexToRating( int index )
140 if ( index <= 10 && index >= 0 ) return index;
141 return -1;
144 inline int
145 CriteriaEditor::ratingToIndex( int rating )
147 if ( rating <= 10 && rating >= 0 ) return rating;
148 return -1;
151 #endif