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
8class MythUIButton;
9
10// qt
11#include <QDateTime>
12#include <QVariant>
13#include <QKeyEvent>
14#include <QCoreApplication>
15
16// MythTV
18
19struct SmartPLOperator;
20struct SmartPLField;
21
22enum SmartPLFieldType : std::uint8_t
23{
28};
29
30// used by playlist.cpp
31QString getCriteriaSQL(const QString& fieldName, const QString &operatorName,
32 QString value1, QString value2);
33
34QString getSQLFieldName(const QString &fieldName);
35QString getOrderBySQL(const QString& orderByFields);
36
37// used by playbackbox.cpp
38QString formattedFieldValue(const QVariant &value);
39
40/*
42*/
43
45{
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
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:
99 void customEvent(QEvent *event) override; // MythUIType
100
101 protected slots:
102
103 void titleChanged(void);
104 void updateMatches(void);
105// void categoryClicked(void);
106 void saveClicked(void);
107 void showResultsClicked(void);
108
109 void showCategoryMenu(void);
110 void showCriteriaMenu(void);
111
112 void newCategory(const QString &category);
113 void startDeleteCategory(const QString &category);
114 void renameCategory(const QString &category);
115
116// void categoryEditChanged(void);
117 void orderByClicked(void);
118
119 void editCriteria(void);
120 void addCriteria(void);
121 void deleteCriteria(void);
122 void doDeleteCriteria(bool doit);
123 void criteriaChanged();
124 void orderByChanged(const QString& orderBy);
125
126 private:
128 void loadFromDatabase(const QString& category, const QString& name);
129
130 QList<SmartPLCriteriaRow*> m_criteriaRows;
132
134 bool m_newPlaylist {false};
135 bool m_playlistIsValid {false};
138
139 // gui stuff
152};
153
155{
156 Q_OBJECT
157 public:
158
160 : MythScreenType(parent, "CriteriaRowEditor"),
161 m_criteriaRow(row) {}
162 ~CriteriaRowEditor(void) override = default;
163
164 bool Create(void) override; // MythScreenType
165
166 protected slots:
167 void fieldChanged(void);
168 void operatorChanged(void);
169 void valueEditChanged(void);
170 void valueButtonClicked(void);
171 void setValue(const QString& value);
172 void setDate(const QString& date);
173 void saveClicked(void);
174
175 signals:
177
178 private:
179 void updateFields(void);
180 void updateOperators(void);
181 void updateValues(void);
182 void enableSaveButton(void);
183
184 void getOperatorList(SmartPLFieldType fieldType);
185
186 void editDate(void);
187
189
190 QStringList m_searchList;
191
192 // gui stuff
195
198
201
204
207
209
212};
213
214
216{
217 Q_OBJECT
218
219 public:
220
222 : MythScreenType(parent, "SmartPLResultViewer") {}
223 ~SmartPLResultViewer(void) override = default;
224
225 bool Create(void) override; // MythScreenType
226 bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
227 void setSQL(const QString& sql);
228
229 private slots:
230 static void trackVisible(MythUIButtonListItem *item);
232
233 private:
234 void showTrackInfo(void);
235
238};
239
240
242{
243 Q_OBJECT
244
245 public:
246
248 :MythScreenType(parent, "SmartPLOrderByDialog") {}
249 ~SmartPLOrderByDialog() override = default;
250
251 bool Create(void) override; // MythScreenType
252
253 QString getFieldList(void);
254 void setFieldList(const QString &fieldList);
255
256 signals:
257 void orderByChanged(QString orderBy);
258
259 protected slots:
260 void addPressed(void);
261 void deletePressed(void);
262 void moveUpPressed(void);
263 void moveDownPressed(void);
264 void ascendingPressed(void);
265 void descendingPressed(void);
266 void okPressed(void);
267 void orderByChanged(void);
268 void orderByChanged(MythUIButtonListItem */*item*/);
270
271 private:
272 void getOrderByFields(void);
273
284};
285
287{
288 Q_OBJECT
289
290 public:
291
293 :MythScreenType(parent, "SmartPLDateDialog") {}
294 ~SmartPLDateDialog() override = default;
295
296 bool Create(void) override; // MythScreenType
297
298 QString getDate(void);
299 void setDate(QString date);
300
301 signals:
302 void dateChanged(QString date);
303
304 protected slots:
305 void okPressed(void);
306 void fixedCheckToggled(bool on);
307 void nowCheckToggled(bool on);
308 void valueChanged(void);
309
310 private:
311
312 bool m_updating {false};
313
318
321
323
326};
327
328#endif
MythUIButton * m_cancelButton
MythUIButtonList * m_fieldSelector
void setDate(const QString &date)
MythUIButtonList * m_value1Selector
MythUIButton * m_value1Button
void valueEditChanged(void)
MythUITextEdit * m_value1Edit
MythUIButton * m_value2Button
void getOperatorList(SmartPLFieldType fieldType)
MythUIText * m_andText
CriteriaRowEditor(MythScreenStack *parent, SmartPLCriteriaRow *row)
MythUISpinBox * m_value1Spinbox
MythUIButtonList * m_value2Selector
void enableSaveButton(void)
bool Create(void) override
QStringList m_searchList
void setValue(const QString &value)
void operatorChanged(void)
MythUIButton * m_saveButton
SmartPLCriteriaRow * m_criteriaRow
MythUISpinBox * m_value2Spinbox
MythUITextEdit * m_value2Edit
~CriteriaRowEditor(void) override=default
void updateOperators(void)
MythUIButtonList * m_operatorSelector
void valueButtonClicked(void)
Screen in which all other widgets are contained and rendered.
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
A single button widget.
Definition: mythuibutton.h:22
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
A widget for offering a range of numerical values where only the the bounding values and interval are...
Definition: mythuispinbox.h:19
A text entry and edit widget.
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
SmartPLCriteriaRow(QString field, QString op, QString value1, QString value2)
Definition: smartplaylist.h:50
SmartPLCriteriaRow(void)=default
bool saveToDatabase(int smartPlaylistID) const
Q_DECLARE_TR_FUNCTIONS(SmartPLCriteriaRow)
QString toString(void) const
~SmartPLCriteriaRow(void)=default
QString getSQL(void) const
void setDate(QString date)
MythUICheckBox * m_fixedRadio
MythUICheckBox * m_nowRadio
MythUISpinBox * m_daySpin
MythUIText * m_statusText
~SmartPLDateDialog() override=default
MythUIButton * m_okButton
MythUISpinBox * m_monthSpin
SmartPLDateDialog(MythScreenStack *parent)
MythUIButton * m_cancelButton
MythUISpinBox * m_yearSpin
MythUISpinBox * m_addDaysSpin
void fixedCheckToggled(bool on)
void nowCheckToggled(bool on)
QString getDate(void)
bool Create(void) override
void dateChanged(QString date)
void orderByChanged(QString orderBy)
MythUIButtonList * m_orderSelector
QString getFieldList(void)
bool Create(void) override
MythUIButton * m_addButton
MythUIButtonList * m_fieldList
MythUIButton * m_descendingButton
void setFieldList(const QString &fieldList)
MythUIButton * m_moveUpButton
SmartPLOrderByDialog(MythScreenStack *parent)
void fieldListSelectionChanged(MythUIButtonListItem *item)
~SmartPLOrderByDialog() override=default
MythUIButton * m_cancelButton
MythUIButton * m_ascendingButton
MythUIButton * m_okButton
MythUIButton * m_moveDownButton
MythUIButton * m_deleteButton
void setSQL(const QString &sql)
SmartPLResultViewer(MythScreenStack *parent)
MythUIText * m_positionText
MythUIButtonList * m_trackList
~SmartPLResultViewer(void) override=default
void trackSelected(MythUIButtonListItem *item)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
static void trackVisible(MythUIButtonListItem *item)
bool Create(void) override
void startDeleteCategory(const QString &category)
void renameCategory(const QString &category)
MythUIButton * m_orderByButton
void editSmartPlaylist(const QString &category, const QString &name)
MythUIButton * m_cancelButton
QString getWhereClause(void)
void customEvent(QEvent *event) override
MythUIButton * m_saveButton
void loadFromDatabase(const QString &category, const QString &name)
void showCategoryMenu(void)
void doDeleteCriteria(bool doit)
void showResultsClicked(void)
void smartPLChanged(const QString &category, const QString &name)
QString getOrderByClause(void)
MythUIButton * m_showResultsButton
MythUIButtonList * m_categorySelector
void showCriteriaMenu(void)
QString getSQL(const QString &fields)
void newCategory(const QString &category)
static bool deleteCategory(const QString &category)
MythUIButtonList * m_matchSelector
MythUIButtonList * m_orderBySelector
void getSmartPlaylistCategories(void)
MythUIText * m_matchesText
bool Create(void) override
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
void orderByChanged(const QString &orderBy)
void getCategoryAndName(QString &category, QString &name)
QList< SmartPLCriteriaRow * > m_criteriaRows
SmartPlaylistEditor(MythScreenStack *parent)
Definition: smartplaylist.h:77
static int lookupCategoryID(const QString &category)
MythUITextEdit * m_titleEdit
MythUIButton * m_categoryButton
MythUIButtonList * m_criteriaList
~SmartPlaylistEditor(void) override
MythUISpinBox * m_limitSpin
void newSmartPlaylist(const QString &category)
static bool deleteSmartPlaylist(const QString &category, const QString &name)
SmartPLCriteriaRow * m_tempCriteriaRow
QString getOrderBySQL(const QString &orderByFields)
SmartPLFieldType
Definition: smartplaylist.h:23
@ ftDate
Definition: smartplaylist.h:26
@ ftBoolean
Definition: smartplaylist.h:27
@ ftNumeric
Definition: smartplaylist.h:25
@ ftString
Definition: smartplaylist.h:24
QString getSQLFieldName(const QString &fieldName)
QString getCriteriaSQL(const QString &fieldName, const QString &operatorName, QString value1, QString value2)
Q_DECLARE_METATYPE(SmartPLCriteriaRow *)
QString formattedFieldValue(const QVariant &value)