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 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:
126 void loadFromDatabase(const QString& category, const QString& name);
127
128 QList<SmartPLCriteriaRow*> m_criteriaRows;
130
132 bool m_newPlaylist {false};
133 bool m_playlistIsValid {false};
136
137 // gui stuff
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:
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
187
188 QStringList m_searchList;
189
190 // gui stuff
193
196
199
202
205
207
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);
230
231 private:
232 void showTrackInfo(void);
233
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 orderByChanged(MythUIButtonListItem */*item*/);
268
269 private:
270 void getOrderByFields(void);
271
282};
283
285{
286 Q_OBJECT
287
288 public:
289
291 :MythScreenType(parent, "SmartPLDateDialog") {}
292 ~SmartPLDateDialog() override = default;
293
294 bool Create(void) override; // MythScreenType
295
296 QString getDate(void);
297 void setDate(QString date);
298
299 signals:
300 void dateChanged(QString date);
301
302 protected slots:
303 void okPressed(void);
304 void fixedCheckToggled(bool on);
305 void nowCheckToggled(bool on);
306 void valueChanged(void);
307
308 private:
309
310 bool m_updating {false};
311
316
319
321
324};
325
326#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:23
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
STL namespace.
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)