MythTV  master
smartplaylist.h
Go to the documentation of this file.
1 #ifndef SMARTPLAYLIST_H_
2 #define SMARTPLAYLIST_H_
3 
4 // c/c++
5 #include <vector>
6 
7 class MythUIButton;using namespace std;
8 
9 // qt
10 #include <QDateTime>
11 #include <QVariant>
12 #include <QKeyEvent>
13 #include <QCoreApplication>
14 
15 // mythtv
16 #include <mythscreentype.h>
17 
18 struct SmartPLOperator;
19 struct SmartPLField;
20 
22 {
23  ftString = 1,
27 };
28 
29 // used by playlist.cpp
30 QString getCriteriaSQL(const QString& fieldName, const QString &operatorName,
31  QString value1, QString value2);
32 
33 QString getSQLFieldName(const QString &fieldName);
34 QString getOrderBySQL(const QString& orderByFields);
35 
36 // used by playbackbox.cpp
37 QString formattedFieldValue(const QVariant &value);
38 
39 /*
41 */
42 
44 {
45  Q_DECLARE_TR_FUNCTIONS(SmartPLCriteriaRow);
46 
47  public:
48 
49  SmartPLCriteriaRow(const QString &_Field, const QString &_Operator,
50  const QString &_Value1, const QString &_Value2)
51  : m_field(_Field), m_operator(_Operator),
52  m_value1(_Value1), m_value2(_Value2) {}
53  SmartPLCriteriaRow(void) = default;
54  ~SmartPLCriteriaRow(void) = default;
55 
56  QString getSQL(void);
57 
58  bool saveToDatabase(int smartPlaylistID);
59 
60  QString toString(void);
61 
62  public:
63  QString m_field;
64  QString m_operator;
65  QString m_value1;
66  QString m_value2;
67 };
68 
70 
72 {
73  Q_OBJECT
74  public:
75 
77  : MythScreenType(parent, "smartplaylisteditor") {}
78  ~SmartPlaylistEditor(void);
79 
80  bool Create(void) override; // MythScreenType
81 
82  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
83  void customEvent(QEvent *event) override; // MythUIType
84 
85  QString getSQL(const QString& fields);
86  QString getWhereClause(void);
87  QString getOrderByClause(void);
88  void getCategoryAndName(QString &category, QString &name);
89  void newSmartPlaylist(const QString& category);
90  void editSmartPlaylist(const QString& category, const QString& name);
91  static bool deleteSmartPlaylist(const QString &category, const QString& name);
92  static bool deleteCategory(const QString& category);
93  static int lookupCategoryID(const QString& category);
94 
95  signals:
96  void smartPLChanged(const QString &category, const QString &name);
97 
98  protected slots:
99 
100  void titleChanged(void);
101  void updateMatches(void);
102 // void categoryClicked(void);
103  void saveClicked(void);
104  void showResultsClicked(void);
105 
106  void showCategoryMenu(void);
107  void showCriteriaMenu(void);
108 
109  void newCategory(const QString &category);
110  void startDeleteCategory(const QString &category);
111  void renameCategory(const QString &category);
112 
113 // void categoryEditChanged(void);
114  void orderByClicked(void);
115 
116  void editCriteria(void);
117  void addCriteria(void);
118  void deleteCriteria(void);
119  void doDeleteCriteria(bool doit);
120  void criteriaChanged();
121  void orderByChanged(const QString& orderBy);
122 
123  private:
124  void getSmartPlaylistCategories(void);
125  void loadFromDatabase(const QString& category, const QString& name);
126 
127  QList<SmartPLCriteriaRow*> m_criteriaRows {nullptr};
128  SmartPLCriteriaRow* m_tempCriteriaRow {nullptr};
129 
130  int m_matchesCount {0};
131  bool m_newPlaylist {false};
132  bool m_playlistIsValid {false};
134  QString m_originalName;
135 
136  // gui stuff
137  MythUIButtonList *m_categorySelector {nullptr};
138  MythUIButton *m_categoryButton {nullptr};
139  MythUITextEdit *m_titleEdit {nullptr};
140  MythUIButtonList *m_matchSelector {nullptr};
141  MythUIButtonList *m_criteriaList {nullptr};
142  MythUIButtonList *m_orderBySelector {nullptr};
143  MythUIButton *m_orderByButton {nullptr};
144  MythUIText *m_matchesText {nullptr};
145  MythUISpinBox *m_limitSpin {nullptr};
146  MythUIButton *m_cancelButton {nullptr};
147  MythUIButton *m_saveButton {nullptr};
148  MythUIButton *m_showResultsButton {nullptr};
149 };
150 
152 {
153  Q_OBJECT
154  public:
155 
157  : MythScreenType(parent, "CriteriaRowEditor"),
158  m_criteriaRow(row) {}
159  ~CriteriaRowEditor(void) = default;
160 
161  bool Create(void) override; // MythScreenType
162 
163  protected slots:
164  void fieldChanged(void);
165  void operatorChanged(void);
166  void valueEditChanged(void);
167  void valueButtonClicked(void);
168  void setValue(const QString& value);
169  void setDate(const QString& date);
170  void saveClicked(void);
171 
172  signals:
173  void criteriaChanged();
174 
175  private:
176  void updateFields(void);
177  void updateOperators(void);
178  void updateValues(void);
179  void enableSaveButton(void);
180 
181  void getOperatorList(SmartPLFieldType fieldType);
182 
183  void editDate(void);
184 
185  SmartPLCriteriaRow* m_criteriaRow {nullptr};
186 
187  QStringList m_searchList;
188 
189  // gui stuff
190  MythUIButtonList *m_fieldSelector {nullptr};
191  MythUIButtonList *m_operatorSelector {nullptr};
192 
193  MythUITextEdit *m_value1Edit {nullptr};
194  MythUITextEdit *m_value2Edit {nullptr};
195 
196  MythUIButtonList *m_value1Selector {nullptr};
197  MythUIButtonList *m_value2Selector {nullptr};
198 
199  MythUISpinBox *m_value1Spinbox {nullptr};
200  MythUISpinBox *m_value2Spinbox {nullptr};
201 
202  MythUIButton *m_value1Button {nullptr};
203  MythUIButton *m_value2Button {nullptr};
204 
205  MythUIText *m_andText {nullptr};
206 
207  MythUIButton *m_cancelButton {nullptr};
208  MythUIButton *m_saveButton {nullptr};
209 };
210 
211 
213 {
214  Q_OBJECT
215 
216  public:
217 
219  : MythScreenType(parent, "SmartPLResultViewer") {}
220  ~SmartPLResultViewer(void) = default;
221 
222  bool Create(void) override; // MythScreenType
223  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
224  void setSQL(const QString& sql);
225 
226  private slots:
227  static void trackVisible(MythUIButtonListItem *item);
228  void trackSelected(MythUIButtonListItem *item);
229 
230  private:
231  void showTrackInfo(void);
232 
233  MythUIButtonList *m_trackList {nullptr};
234  MythUIText *m_positionText {nullptr};
235 };
236 
237 
239 {
240  Q_OBJECT
241 
242  public:
243 
245  :MythScreenType(parent, "SmartPLOrderByDialog") {}
246  ~SmartPLOrderByDialog() = default;
247 
248  bool Create(void) override; // MythScreenType
249 
250  QString getFieldList(void);
251  void setFieldList(const QString &fieldList);
252 
253  signals:
254  void orderByChanged(QString orderBy);
255 
256  protected slots:
257  void addPressed(void);
258  void deletePressed(void);
259  void moveUpPressed(void);
260  void moveDownPressed(void);
261  void ascendingPressed(void);
262  void descendingPressed(void);
263  void okPressed(void);
264  void orderByChanged(void);
265  void fieldListSelectionChanged(MythUIButtonListItem *item);
266 
267  private:
268  void getOrderByFields(void);
269 
270  MythUIButtonList *m_fieldList {nullptr};
271  MythUIButtonList *m_orderSelector {nullptr};
272  MythUIButton *m_addButton {nullptr};
273  MythUIButton *m_deleteButton {nullptr};
274  MythUIButton *m_moveUpButton {nullptr};
275  MythUIButton *m_moveDownButton {nullptr};
276  MythUIButton *m_ascendingButton {nullptr};
277  MythUIButton *m_descendingButton {nullptr};
278  MythUIButton *m_cancelButton {nullptr};
279  MythUIButton *m_okButton {nullptr};
280 };
281 
283 {
284  Q_OBJECT
285 
286  public:
287 
289  :MythScreenType(parent, "SmartPLDateDialog") {}
290  ~SmartPLDateDialog() = default;
291 
292  bool Create(void) override; // MythScreenType
293 
294  QString getDate(void);
295  void setDate(QString date);
296 
297  signals:
298  void dateChanged(QString date);
299 
300  protected slots:
301  void okPressed(void);
302  void fixedCheckToggled(bool on);
303  void nowCheckToggled(bool on);
304  void valueChanged(void);
305 
306  private:
307 
308  bool m_updating {false};
309 
310  MythUICheckBox *m_fixedRadio {nullptr};
311  MythUISpinBox *m_daySpin {nullptr};
312  MythUISpinBox *m_monthSpin {nullptr};
313  MythUISpinBox *m_yearSpin {nullptr};
314 
315  MythUICheckBox *m_nowRadio {nullptr};
316  MythUISpinBox *m_addDaysSpin {nullptr};
317 
318  MythUIText *m_statusText {nullptr};
319 
320  MythUIButton *m_cancelButton {nullptr};
321  MythUIButton *m_okButton {nullptr};
322 };
323 
324 #endif
QStringList m_searchList
unsigned int slots[4]
Definition: element.c:38
SmartPlaylistEditor(MythScreenStack *parent)
Definition: smartplaylist.h:76
QString getOrderBySQL(const QString &orderByFields)
A widget for offering a range of numerical values where only the the bounding values and interval are...
Definition: mythuispinbox.h:16
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
QString toString(MarkTypes type)
SmartPLDateDialog(MythScreenStack *parent)
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
SmartPLFieldType
Definition: smartplaylist.h:21
QString formattedFieldValue(const QVariant &value)
CriteriaRowEditor(MythScreenStack *parent, SmartPLCriteriaRow *row)
QString getCriteriaSQL(const QString &fieldName, const QString &operatorName, QString value1, QString value2)
A text entry and edit widget.
const char * name
Definition: ParseText.cpp:328
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
A single button widget.
Definition: mythuibutton.h:21
SmartPLOrderByDialog(MythScreenStack *parent)
SmartPLCriteriaRow(const QString &_Field, const QString &_Operator, const QString &_Value1, const QString &_Value2)
Definition: smartplaylist.h:49
QString getSQLFieldName(const QString &fieldName)
Screen in which all other widgets are contained and rendered.
Q_DECLARE_METATYPE(SmartPLCriteriaRow *)
SmartPLResultViewer(MythScreenStack *parent)