/
videofilter.h
275 lines (234 loc) · 7 KB
/
videofilter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#ifndef VIDEOFILTER_H_
#define VIDEOFILTER_H_
#include <mythscreentype.h>
#include <metadata/parentalcontrols.h>
class MythUIButtonList;
class MythUIButtonListItem;
class MythUIButton;
class MythUIText;
class VideoMetadata;
class VideoList;
class VideoFilterSettings
{
public:
static const unsigned int FILTER_MASK = 0xFFFE;
static const unsigned int SORT_MASK = 0x1;
enum FilterChanges {
kSortOrderChanged = (1 << 0),
kFilterCategoryChanged = (1 << 1),
kFilterGenreChanged = (1 << 2),
kFilterCountryChanged = (1 << 3),
kFilterYearChanged = (1 << 4),
kFilterRuntimeChanged = (1 << 5),
kFilterUserRatingChanged = (1 << 6),
kFilterBrowseChanged = (1 << 7),
kFilterInetRefChanged = (1 << 8),
kFilterCoverFileChanged = (1 << 9),
kFilterParentalLevelChanged = (1 << 10),
kFilterCastChanged = (1 << 11),
kFilterWatchedChanged = (1 << 12),
kFilterTextFilterChanged = (1 << 13)
};
public:
VideoFilterSettings(bool loaddefaultsettings = true,
const QString &_prefix = "");
VideoFilterSettings(const VideoFilterSettings &rhs);
VideoFilterSettings &operator=(const VideoFilterSettings &rhs);
bool matches_filter(const VideoMetadata &mdata) const;
bool meta_less_than(const VideoMetadata &lhs, const VideoMetadata &rhs,
bool sort_ignores_case) const;
void saveAsDefault();
enum ordering
{
// These values must be explicitly assigned; they represent
// database values
kOrderByTitle = 0,
kOrderByYearDescending = 1,
kOrderByUserRatingDescending = 2,
kOrderByLength = 3,
kOrderByFilename = 4,
kOrderByID = 5,
kOrderBySeasonEp = 6,
kOrderByDateAddedDescending = 7
};
int GetCategory() const { return category; }
void SetCategory(int lcategory)
{
m_changed_state |= kFilterCategoryChanged;
category = lcategory;
}
int getGenre() const { return genre; }
void setGenre(int lgenre)
{
m_changed_state |= kFilterGenreChanged;
genre = lgenre;
}
int GetCast() const { return cast; }
void SetCast(int lcast)
{
m_changed_state |= kFilterCastChanged;
cast = lcast;
}
int getCountry() const { return country; }
void setCountry(int lcountry)
{
m_changed_state |= kFilterCountryChanged;
country = lcountry;
}
int getYear() const { return year; }
void SetYear(int lyear)
{
m_changed_state |= kFilterYearChanged;
year = lyear;
}
int getRuntime() const { return runtime; }
void setRuntime(int lruntime)
{
m_changed_state |= kFilterRuntimeChanged;
runtime = lruntime;
}
int GetUserRating() const { return userrating; }
void SetUserRating(int luserrating)
{
m_changed_state |= kFilterUserRatingChanged;
userrating = luserrating;
}
int GetBrowse() const {return browse; }
void SetBrowse(int lbrowse)
{
m_changed_state |= kFilterBrowseChanged;
browse = lbrowse;
}
int GetWatched() const {return watched; }
void SetWatched(int lwatched)
{
m_changed_state |= kFilterWatchedChanged;
watched = lwatched;
}
ordering getOrderby() const { return orderby; }
void setOrderby(ordering lorderby)
{
m_changed_state |= kSortOrderChanged;
orderby = lorderby;
}
QString getTextFilter() const { return textfilter; }
void setTextFilter(QString val);
ParentalLevel::Level getParentalLevel() const { return m_parental_level; }
void setParentalLevel(ParentalLevel::Level parental_level)
{
m_changed_state |= kFilterParentalLevelChanged;
m_parental_level = parental_level;
}
int getInteRef() const { return m_inetref; }
void SetInetRef(int inetref)
{
m_inetref = inetref;
m_changed_state |= kFilterInetRefChanged;
}
int GetCoverFile() const { return m_coverfile; }
void SetCoverFile(int coverfile)
{
m_coverfile = coverfile;
m_changed_state |= kFilterCoverFileChanged;
}
unsigned int getChangedState()
{
unsigned int ret = m_changed_state;
m_changed_state = 0;
return ret;
}
private:
int category;
int genre;
int country;
int cast;
int year;
int runtime;
int userrating;
int browse;
int watched;
int m_inetref;
int m_coverfile;
ordering orderby;
ParentalLevel::Level m_parental_level;
QString prefix;
QString textfilter;
int season;
int episode;
QDate insertdate;
QRegExp re_season;
QRegExp re_date;
unsigned int m_changed_state;
};
struct FilterSettingsProxy
{
virtual ~FilterSettingsProxy() {}
virtual const VideoFilterSettings &getSettings() = 0;
virtual void setSettings(const VideoFilterSettings &settings) = 0;
};
template <typename T>
class BasicFilterSettingsProxy : public FilterSettingsProxy
{
public:
BasicFilterSettingsProxy(T &type) : m_type(type) {}
const VideoFilterSettings &getSettings()
{
return m_type.getCurrentVideoFilter();
}
void setSettings(const VideoFilterSettings &settings)
{
m_type.setCurrentVideoFilter(settings);
}
private:
T &m_type;
};
class VideoFilterDialog : public MythScreenType
{
Q_OBJECT
public:
VideoFilterDialog( MythScreenStack *lparent, QString lname,
VideoList *video_list);
~VideoFilterDialog();
bool Create();
signals:
void filterChanged();
public slots:
void saveAndExit();
void saveAsDefault();
void SetYear(MythUIButtonListItem *item);
void SetUserRating(MythUIButtonListItem *item);
void SetCategory(MythUIButtonListItem *item);
void setCountry(MythUIButtonListItem *item);
void setGenre(MythUIButtonListItem *item);
void SetCast(MythUIButtonListItem *item);
void setRunTime(MythUIButtonListItem *item);
void SetBrowse(MythUIButtonListItem *item);
void SetWatched(MythUIButtonListItem *item);
void SetInetRef(MythUIButtonListItem *item);
void SetCoverFile(MythUIButtonListItem *item);
void setOrderby(MythUIButtonListItem *item);
void setTextFilter();
private:
void fillWidgets();
void update_numvideo();
VideoFilterSettings m_settings;
MythUIButtonList *m_browseList;
MythUIButtonList *m_watchedList;
MythUIButtonList *m_orderbyList;
MythUIButtonList *m_yearList;
MythUIButtonList *m_userratingList;
MythUIButtonList *m_categoryList;
MythUIButtonList *m_countryList;
MythUIButtonList *m_genreList;
MythUIButtonList *m_castList;
MythUIButtonList *m_runtimeList;
MythUIButtonList *m_inetrefList;
MythUIButtonList *m_coverfileList;
MythUIButton *m_saveButton;
MythUIButton *m_doneButton;
MythUIText *m_numvideosText;
MythUITextEdit *m_textfilter;
const VideoList &m_videoList;
FilterSettingsProxy *m_fsp;
};
#endif