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.h> //baseclass
11 #include <khbox.h> //baseclass
12 #include <q3ptrlist.h> //definition required
15 #include <klineedit.h> //inline function
28 class SmartPlaylistEditor
: public KDialog
31 friend class CriteriaEditor
;
34 SmartPlaylistEditor( QString defaultName
, QWidget
*parent
, const char *name
=0 );
35 SmartPlaylistEditor( QWidget
*parent
, QDomElement xml
, const char *name
=0 );
39 QString
name() const { return m_nameLineEdit
->text().replace( "\n", " " ); }
41 enum CriteriaType
{ criteriaAll
= 0, criteriaAny
= 1 };
44 void addCriteriaAny();
45 void addCriteriaAny( QDomElement
&xml
);
46 void removeCriteriaAny( CriteriaEditor
*criteria
);
48 void addCriteriaAll();
49 void addCriteriaAll( QDomElement
&xml
);
50 void removeCriteriaAll( CriteriaEditor
*criteria
);
53 void updateOrderTypes( int index
);
56 void init(QString defaultName
);
57 void updateMatchWidgets();
59 KLineEdit
*m_nameLineEdit
;
61 QCheckBox
*m_matchAnyCheck
;
62 QCheckBox
*m_matchAllCheck
;
65 Q3VGroupBox
*m_criteriaAnyGroupBox
;
66 Q3VGroupBox
*m_criteriaAllGroupBox
;
69 QCheckBox
*m_limitCheck
;
70 QSpinBox
*m_limitSpin
;
72 QCheckBox
*m_orderCheck
;
73 KComboBox
*m_orderCombo
;
74 KComboBox
*m_orderTypeCombo
;
76 QCheckBox
*m_expandCheck
;
77 KComboBox
*m_expandCombo
;
79 Q3PtrList
<CriteriaEditor
> m_criteriaEditorAnyList
;
80 Q3PtrList
<CriteriaEditor
> m_criteriaEditorAllList
;
85 class CriteriaEditor
: public KHBox
89 CriteriaEditor( SmartPlaylistEditor
*editor
, QWidget
*parent
, int criteriaType
, QDomElement criteria
= QDomElement() );
91 QString
getSearchCriteria();
92 void setSearchCriteria( const QString
&str
);
93 QDomElement
getDomSearchCriteria( QDomDocument
&doc
);
94 void enableRemove( bool );
97 void slotRemoveCriteriaAny();
98 void slotRemoveCriteriaAll();
99 void slotAddCriteriaAny();
100 void slotAddCriteriaAll();
101 void slotFieldSelected( int );
102 void loadEditWidgets();
105 enum ValueType
{ String
, AutoCompletionString
, Number
, Year
, Date
, Rating
, Length
};
107 void loadCriteriaList( int valueType
, QString condition
= QString() );
108 int getValueType( int fieldIndex
);
109 inline int indexToRating( int );
110 inline int ratingToIndex( int );
112 SmartPlaylistEditor
*m_playlistEditor
;
113 int m_currentValueType
;
114 QString m_lastCriteria
;
116 KComboBox
*m_fieldCombo
;
117 KComboBox
*m_criteriaCombo
;
118 QToolButton
*m_addButton
;
119 QToolButton
*m_removeButton
;
123 KLineEdit
*m_lineEdit
;
124 KComboBox
*m_comboBox
;
125 KComboBox
*m_comboBox2
;
126 QSpinBox
*m_intSpinBox1
;
127 QSpinBox
*m_intSpinBox2
;
128 Q3DateEdit
*m_dateEdit1
;
129 Q3DateEdit
*m_dateEdit2
;
130 KComboBox
*m_dateCombo
;
131 QLabel
*m_rangeLabel
;
132 KComboBox
*m_lengthCombo
;
136 CriteriaEditor::indexToRating( int index
)
138 if ( index
<= 9 && index
>= 1 ) return index
+ 1;
139 if ( index
== 0 ) return index
;
144 CriteriaEditor::ratingToIndex( int rating
)
146 if ( rating
<= 10 && rating
>= 2 ) return rating
- 1;
147 if ( rating
== 0 ) return rating
;