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