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
30 class SmartPlaylistEditor
: public KDialog
33 friend class CriteriaEditor
;
36 SmartPlaylistEditor( QString defaultName
, QWidget
*parent
, const char *name
=0 );
37 SmartPlaylistEditor( QWidget
*parent
, QDomElement xml
, const char *name
=0 );
41 QString
name() const { return m_nameLineEdit
->text().replace( "\n", " " ); }
43 enum CriteriaType
{ criteriaAll
= 0, criteriaAny
= 1 };
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
);
55 void updateOrderTypes( int index
);
58 void init(QString defaultName
);
59 void updateMatchWidgets();
61 KLineEdit
*m_nameLineEdit
;
63 QCheckBox
*m_matchAnyCheck
;
64 QCheckBox
*m_matchAllCheck
;
67 Q3VGroupBox
*m_criteriaAnyGroupBox
;
68 Q3VGroupBox
*m_criteriaAllGroupBox
;
71 QCheckBox
*m_limitCheck
;
72 QSpinBox
*m_limitSpin
;
74 QCheckBox
*m_orderCheck
;
75 KComboBox
*m_orderCombo
;
76 KComboBox
*m_orderTypeCombo
;
78 QCheckBox
*m_expandCheck
;
79 KComboBox
*m_expandCombo
;
81 Q3PtrList
<CriteriaEditor
> m_criteriaEditorAnyList
;
82 Q3PtrList
<CriteriaEditor
> m_criteriaEditorAllList
;
87 class CriteriaEditor
: public KHBox
91 CriteriaEditor( SmartPlaylistEditor
*editor
, QWidget
*parent
, int criteriaType
, QDomElement criteria
= QDomElement() );
93 QString
getSearchCriteria();
94 void setSearchCriteria( const QString
&str
);
95 QDomElement
getDomSearchCriteria( QDomDocument
&doc
);
96 void enableRemove( bool );
99 void slotRemoveCriteriaAny();
100 void slotRemoveCriteriaAll();
101 void slotAddCriteriaAny();
102 void slotAddCriteriaAll();
103 void slotFieldSelected( int );
104 void loadEditWidgets();
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
;
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
;
138 CriteriaEditor::indexToRating( int index
)
140 if ( index
<= 10 && index
>= 0 ) return index
;
145 CriteriaEditor::ratingToIndex( int rating
)
147 if ( rating
<= 10 && rating
>= 0 ) return rating
;