1 // (c) Pierpaolo Di Panfilo 2004
2 // (c) Alexandre Pereira de Oliveira 2005
3 // (c) 2006 Peter C. Ndikuwera <pndiku@gmail.com>
4 // (c) 2007 Seb Ruiz <ruiz@kde.org>
5 // See COPYING file for licensing information
7 #ifndef SMARTPLAYLISTEDITOR_H
8 #define SMARTPLAYLISTEDITOR_H
10 #include <KDialog> //baseclass
11 #include <klineedit.h> //inline function
12 #include <KHBox> //baseclass
15 #include <QDomDocument>
16 #include <QDomElement>
29 class SmartPlaylistEditor
: public KDialog
32 friend class CriteriaEditor
;
35 SmartPlaylistEditor( QString defaultName
, QWidget
*parent
, const char *name
=0 );
36 SmartPlaylistEditor( QWidget
*parent
, QDomElement xml
, const char *name
=0 );
40 QString
name() const { return m_nameLineEdit
->text().replace( "\n", " " ); }
42 enum CriteriaType
{ criteriaAll
= 0, criteriaAny
= 1 };
45 void addCriteriaAny();
46 void addCriteriaAny( QDomElement
&xml
);
47 void removeCriteriaAny( CriteriaEditor
*criteria
);
49 void addCriteriaAll();
50 void addCriteriaAll( QDomElement
&xml
);
51 void removeCriteriaAll( CriteriaEditor
*criteria
);
54 void updateOrderTypes( int index
);
57 void init(QString defaultName
);
58 void updateMatchWidgets();
60 KLineEdit
*m_nameLineEdit
;
62 QCheckBox
*m_matchAnyCheck
;
63 QCheckBox
*m_matchAllCheck
;
66 QGroupBox
*m_criteriaAnyGroupBox
;
67 QGroupBox
*m_criteriaAllGroupBox
;
70 QCheckBox
*m_limitCheck
;
71 QSpinBox
*m_limitSpin
;
73 QCheckBox
*m_orderCheck
;
74 KComboBox
*m_orderCombo
;
75 KComboBox
*m_orderTypeCombo
;
77 QCheckBox
*m_expandCheck
;
78 KComboBox
*m_expandCombo
;
80 QList
<CriteriaEditor
*> m_criteriaEditorAnyList
;
81 QList
<CriteriaEditor
*> m_criteriaEditorAllList
;
86 class CriteriaEditor
: public KHBox
90 CriteriaEditor( SmartPlaylistEditor
*editor
, QWidget
*parent
, int criteriaType
, QDomElement criteria
= QDomElement() );
92 QString
getSearchCriteria();
93 void setSearchCriteria( const QString
&str
);
94 QDomElement
getDomSearchCriteria( QDomDocument
&doc
);
95 void enableRemove( bool );
98 void slotRemoveCriteriaAny();
99 void slotRemoveCriteriaAll();
100 void slotAddCriteriaAny();
101 void slotAddCriteriaAll();
102 void slotFieldSelected( int );
103 void loadEditWidgets();
106 enum ValueType
{ String
, AutoCompletionString
, Number
, Year
, Date
, Rating
, Length
};
108 void loadCriteriaList( int valueType
, QString condition
= QString() );
109 int getValueType( int fieldIndex
);
110 inline int indexToRating( int );
111 inline int ratingToIndex( int );
113 SmartPlaylistEditor
*m_playlistEditor
;
114 int m_currentValueType
;
115 QString m_lastCriteria
;
117 KComboBox
*m_fieldCombo
;
118 KComboBox
*m_criteriaCombo
;
119 QToolButton
*m_addButton
;
120 QToolButton
*m_removeButton
;
124 KLineEdit
*m_lineEdit
;
125 KComboBox
*m_comboBox
;
126 KComboBox
*m_comboBox2
;
127 QSpinBox
*m_intSpinBox1
;
128 QSpinBox
*m_intSpinBox2
;
129 QDateEdit
*m_dateEdit1
;
130 QDateEdit
*m_dateEdit2
;
131 KComboBox
*m_dateCombo
;
132 QLabel
*m_rangeLabel
;
133 KComboBox
*m_lengthCombo
;
137 CriteriaEditor::indexToRating( int index
)
139 if ( index
<= 10 && index
>= 0 ) return index
;
144 CriteriaEditor::ratingToIndex( int rating
)
146 if ( rating
<= 10 && rating
>= 0 ) return rating
;