00001 #ifndef SMARTPLAYLIST_H_
00002 #define SMARTPLAYLIST_H_
00003
00004 #include <qdatetime.h>
00005 #include <qlayout.h>
00006 #include <qhbox.h>
00007 #include <qvariant.h>
00008
00009 #include <mythtv/mythwidgets.h>
00010 #include <mythtv/mythdialogs.h>
00011
00012
00013 struct SmartPLOperator;
00014 struct SmartPLField;
00015
00016
00017 enum SmartPLFieldType
00018 {
00019 ftString = 1,
00020 ftNumeric,
00021 ftDate,
00022 ftBoolean
00023 };
00024
00025
00026 QString getCriteriaSQL(QString fieldName, QString operatorName,
00027 QString value1, QString value2);
00028
00029 QString getSQLFieldName(QString orderBy);
00030 QString getOrderBySQL(QString orderByFields);
00031
00032
00033 QString formattedFieldValue(const QVariant &value);
00034
00035
00037
00038
00039 class SmartPLCriteriaRow : public QObject
00040 {
00041 Q_OBJECT
00042
00043 public:
00044
00045 SmartPLCriteriaRow(QWidget *parent, QHBoxLayout *hbox);
00046 ~SmartPLCriteriaRow(void);
00047
00048 QString getSQL(void);
00049 MythComboBox *fieldCombo;
00050 MythComboBox *operatorCombo;
00051 MythRemoteLineEdit *value1Edit;
00052 MythRemoteLineEdit *value2Edit;
00053 MythSpinBox *value1SpinEdit;
00054 MythSpinBox *value2SpinEdit;
00055 MythPushButton *value1Button;
00056 MythPushButton *value2Button;
00057 MythComboBox *value1Combo;
00058 MythComboBox *value2Combo;
00059
00060 bool saveToDatabase(int smartPlaylistID);
00061 void initValues(QString Field, QString Operator, QString Value1, QString Value2);
00062
00063 signals:
00064 void criteriaChanged(void);
00065
00066 protected slots:
00067
00068 void fieldChanged(void);
00069 void operatorChanged(void);
00070 void valueChanged(void);
00071 void value1ButtonClicked(void);
00072 void value2ButtonClicked(void);
00073
00074 private:
00075 bool showList(QString caption, QString &value);
00076 void searchGenre(MythRemoteLineEdit *editor);
00077 void searchArtist(MythRemoteLineEdit *editor);
00078 void searchCompilationArtist(MythRemoteLineEdit *editor);
00079 void searchAlbum(MythRemoteLineEdit *editor);
00080 void searchTitle(MythRemoteLineEdit *editor);
00081 void editDate(MythComboBox *combo);
00082 void getOperatorList(SmartPLFieldType fieldType);
00083
00084 QStringList searchList;
00085 bool bUpdating;
00086 };
00087
00088 class SmartPlaylistEditor : public MythDialog
00089 {
00090 Q_OBJECT
00091 public:
00092
00093 SmartPlaylistEditor(MythMainWindow *parent, const char *name = 0);
00094 ~SmartPlaylistEditor(void);
00095
00096 QString getSQL(QString fields);
00097 QString getWhereClause(void);
00098 QString getOrderByClause(void);
00099 void getCategoryAndName(QString &category, QString &name);
00100 void newSmartPlaylist(QString category);
00101 void editSmartPlaylist(QString category, QString name);
00102 static bool deleteSmartPlaylist(QString category, QString name);
00103 static bool deleteCategory(QString category);
00104 static int lookupCategoryID(QString category);
00105 signals:
00106
00107 void dismissWindow();
00108
00109 protected slots:
00110
00111 void titleChanged(void);
00112 void updateMatches(void);
00113 void categoryClicked(void);
00114 void saveClicked(void);
00115 void showResultsClicked(void);
00116
00117
00118 void newCategory(void);
00119 void deleteCategory(void);
00120 void renameCategory(void);
00121 void showCategoryPopup(void);
00122 void closeCategoryPopup(void);
00123 void categoryEditChanged(void);
00124 void orderByClicked(void);
00125
00126 private:
00127 void getSmartPlaylistCategories(void);
00128 void loadFromDatabase(QString category, QString name);
00129
00130
00131 MythComboBox *categoryCombo;
00132 MythPushButton *categoryButton;
00133 MythRemoteLineEdit *titleEdit;
00134 MythComboBox *matchCombo;
00135 MythPushButton *saveButton;
00136 MythPushButton *cancelButton;
00137 MythPushButton *showResultsButton;
00138 MythComboBox *orderByCombo;
00139 MythSpinBox *limitSpinEdit;
00140 QLabel *matchesLabel;
00141 MythPushButton *orderByButton;
00142
00143
00144 MythPopupBox *category_popup;
00145 MythRemoteLineEdit *categoryEdit;
00146 QButton *newCategoryButton;
00147 QButton *renameCategoryButton;
00148 QButton *deleteCategoryButton;
00149
00150 QPtrList<SmartPLCriteriaRow> criteriaRows;
00151 int matchesCount;
00152 bool bNewPlaylist;
00153 bool bPlaylistIsValid;
00154 QString originalCategory, originalName;
00155 };
00156
00157 class SmartPLResultViewer : public MythDialog
00158 {
00159 Q_OBJECT
00160 public:
00161
00162 SmartPLResultViewer(MythMainWindow *parent, const char *name = 0);
00163 ~SmartPLResultViewer(void);
00164
00165 void setSQL(QString sql);
00166 signals:
00167
00168 protected slots:
00169 void exitClicked(void);
00170
00171 private:
00172 MythListView *listView;
00173 MythPushButton *exitButton;
00174 };
00175
00176 class SmartPlaylistDialog: public MythPopupBox
00177 {
00178 Q_OBJECT
00179
00180 public:
00181
00182 SmartPlaylistDialog(MythMainWindow *parent, const char *name = 0);
00183 ~SmartPlaylistDialog();
00184
00185 void getSmartPlaylist(QString &category, QString &name);
00186 void setSmartPlaylist(QString category, QString name);
00187
00188 protected slots:
00189 void newPressed(void);
00190 void selectPressed(void);
00191 void deletePressed(void);
00192 void editPressed(void);
00193 void categoryChanged(void);
00194
00195 protected:
00196 void keyPressEvent(QKeyEvent *e);
00197
00198 private:
00199 void getSmartPlaylistCategories(void);
00200 void getSmartPlaylists(QString category);
00201
00202 QVBoxLayout *vbox;
00203 QLabel *caption;
00204 MythComboBox *categoryCombo;
00205 MythListBox *listbox;
00206 QButton *selectButton;
00207 QButton *editButton;
00208 QButton *deleteButton;
00209 QButton *newButton;
00210
00211 };
00212
00213 class SmartPLOrderByDialog: public MythPopupBox
00214 {
00215 Q_OBJECT
00216
00217 public:
00218
00219 SmartPLOrderByDialog(MythMainWindow *parent, const char *name = 0);
00220 ~SmartPLOrderByDialog();
00221
00222 QString getFieldList(void);
00223 void setFieldList(QString fieldList);
00224
00225 protected slots:
00226 void addPressed(void);
00227 void deletePressed(void);
00228 void moveUpPressed(void);
00229 void moveDownPressed(void);
00230 void ascendingPressed(void);
00231 void descendingPressed(void);
00232 void orderByChanged(void);
00233 void listBoxSelectionChanged(QListBoxItem *item);
00234
00235 protected:
00236 void keyPressEvent(QKeyEvent *e);
00237
00238 private:
00239 void getOrderByFields(void);
00240
00241 QVBoxLayout *vbox;
00242 QLabel *caption;
00243 MythComboBox *orderByCombo;
00244 MythListBox *listbox;
00245 QButton *addButton;
00246 QButton *deleteButton;
00247 QButton *moveUpButton;
00248 QButton *moveDownButton;
00249 QButton *ascendingButton;
00250 QButton *descendingButton;
00251 QButton *okButton;
00252 };
00253
00254 class SmartPLDateDialog: public MythPopupBox
00255 {
00256 Q_OBJECT
00257
00258 public:
00259
00260 SmartPLDateDialog(MythMainWindow *parent, const char *name = 0);
00261 ~SmartPLDateDialog();
00262
00263 QString getDate(void);
00264 void setDate(QString date);
00265
00266 protected slots:
00267 void fixedCheckToggled(bool on);
00268 void nowCheckToggled(bool on);
00269 void addDaysCheckToggled(bool on);
00270 void valueChanged(void);
00271
00272 protected:
00273 void keyPressEvent(QKeyEvent *e);
00274
00275 private:
00276 QString dateValue;
00277
00278 QVBoxLayout *vbox;
00279 QLabel *caption;
00280 QLabel *dayLabel;
00281 QLabel *monthLabel;
00282 QLabel *yearLabel;
00283 MythRadioButton *fixedRadio;
00284 MythSpinBox *daySpinEdit;
00285 MythSpinBox *monthSpinEdit;
00286 MythSpinBox *yearSpinEdit;
00287
00288 MythRadioButton *nowRadio;
00289
00290 MythCheckBox *addDaysCheck;
00291 MythSpinBox *addDaysSpinEdit;
00292 QLabel *statusLabel;
00293
00294 QButton *cancelButton;
00295 QButton *okButton;
00296 };
00297
00298 #endif