MythTV  master
videofilter.h
Go to the documentation of this file.
1 #ifndef VIDEOFILTER_H_
2 #define VIDEOFILTER_H_
3 
4 // MythTV headers
5 #include "mythscreentype.h"
6 #include "parentalcontrols.h"
7 
8 // Qt headers
9 #include <QCoreApplication>
10 #include <QDate>
11 
12 class MythUIButtonList;
14 class MythUIButton;
15 class MythUIText;
16 
17 class VideoMetadata;
18 class VideoList;
19 
23 };
24 
28 };
29 
30 enum CastFilter {
33 };
34 
38 };
39 
40 enum YearFilter {
43 };
44 
48 };
49 
52 };
53 
56 };
57 
60 };
61 
65 };
66 
70 };
71 
73 {
75 
76  public:
78  kSortOrderChanged = (1 << 0),
80  kFilterGenreChanged = (1 << 2),
82  kFilterYearChanged = (1 << 4),
89  kFilterCastChanged = (1 << 11),
90  kFilterWatchedChanged = (1 << 12),
92  };
93 
94  public:
95  explicit VideoFilterSettings(bool loaddefaultsettings = true,
96  const QString &_prefix = "");
99 
100  bool matches_filter(const VideoMetadata &mdata) const;
101  bool meta_less_than(const VideoMetadata &lhs, const VideoMetadata &rhs) const;
102 
103  void saveAsDefault();
104 
105  enum ordering
106  {
107  // These values must be explicitly assigned; they represent
108  // database values
117  };
118 
119  int GetCategory() const { return m_category; }
120  void SetCategory(int lcategory)
121  {
123  m_category = lcategory;
124  }
125 
126  int getGenre() const { return m_genre; }
127  void setGenre(int lgenre)
128  {
130  m_genre = lgenre;
131  }
132 
133  int GetCast() const { return m_cast; }
134  void SetCast(int lcast)
135  {
137  m_cast = lcast;
138  }
139 
140  int getCountry() const { return m_country; }
141  void setCountry(int lcountry)
142  {
144  m_country = lcountry;
145  }
146 
147  int getYear() const { return m_year; }
148  void SetYear(int lyear)
149  {
151  m_year = lyear;
152  }
153 
154  int getRuntime() const { return m_runtime; }
155  void setRuntime(int lruntime)
156  {
158  m_runtime = lruntime;
159  }
160 
161  int GetUserRating() const { return m_userRating; }
162  void SetUserRating(int luserrating)
163  {
165  m_userRating = luserrating;
166  }
167 
168  int GetBrowse() const {return m_browse; }
169  void SetBrowse(int lbrowse)
170  {
172  m_browse = lbrowse;
173  }
174 
175  int GetWatched() const {return m_watched; }
176  void SetWatched(int lwatched)
177  {
179  m_watched = lwatched;
180  }
181 
182  ordering getOrderby() const { return m_orderBy; }
183  void setOrderby(ordering lorderby)
184  {
186  m_orderBy = lorderby;
187  }
188 
189  QString getTextFilter() const { return m_textFilter; }
190  void setTextFilter(const QString& val);
191 
194  {
196  m_parentalLevel = parental_level;
197  }
198 
199  int getInteRef() const { return m_inetRef; }
200  void SetInetRef(int inetref)
201  {
202  m_inetRef = inetref;
204  }
205 
206  int GetCoverFile() const { return m_coverFile; }
207  void SetCoverFile(int coverfile)
208  {
209  m_coverFile = coverfile;
211  }
212 
213  unsigned int getChangedState()
214  {
215  unsigned int ret = m_changedState;
216  m_changedState = 0;
217  return ret;
218  }
219 
220  private:
234  QString m_prefix;
235  QString m_textFilter;
236  int m_season {-1};
237  int m_episode {-1};
239  const QRegExp m_reSeason {"(\\d+)[xX](\\d*)"};
240  const QRegExp m_reDate {"-(\\d+)([dmw])"};
241 
242  unsigned int m_changedState {0};
243 };
244 
246 {
247  virtual ~FilterSettingsProxy() = default;
248  virtual const VideoFilterSettings &getSettings() = 0;
249  virtual void setSettings(const VideoFilterSettings &settings) = 0;
250 };
251 
252 template <typename T>
254 {
255  public:
257 
258  const VideoFilterSettings &getSettings() override // FilterSettingsProxy
259  {
260  return m_type.getCurrentVideoFilter();
261  }
262 
263  void setSettings(const VideoFilterSettings &settings) override // FilterSettingsProxy
264  {
265  m_type.setCurrentVideoFilter(settings);
266  }
267 
268  private:
269  T &m_type;
270 };
271 
273 {
274 
275  Q_OBJECT
276 
277  public:
278  VideoFilterDialog( MythScreenStack *lparent, const QString& lname,
279  VideoList *video_list);
280  ~VideoFilterDialog() override;
281 
282  bool Create() override; // MythScreenType
283 
284  signals:
285  void filterChanged();
286 
287  public slots:
288  void saveAndExit();
289  void saveAsDefault();
290  void SetYear(MythUIButtonListItem *item);
292  void SetCategory(MythUIButtonListItem *item);
293  void setCountry(MythUIButtonListItem *item);
294  void setGenre(MythUIButtonListItem *item);
295  void SetCast(MythUIButtonListItem *item);
296  void setRunTime(MythUIButtonListItem *item);
297  void SetBrowse(MythUIButtonListItem *item);
298  void SetWatched(MythUIButtonListItem *item);
299  void SetInetRef(MythUIButtonListItem *item);
301  void setOrderby(MythUIButtonListItem *item);
302  void setTextFilter();
303 
304  private:
305  void fillWidgets();
306  void update_numvideo();
308 
325 
328 };
329 
330 #endif
VideoFilterDialog::SetWatched
void SetWatched(MythUIButtonListItem *item)
Definition: videofilter.cpp:791
VideoFilterSettings::VideoFilterSettings
VideoFilterSettings(bool loaddefaultsettings=true, const QString &_prefix="")
Definition: videofilter.cpp:19
RuntimeFilter
RuntimeFilter
Definition: videofilter.h:45
VideoMetadata
Definition: videometadata.h:24
VideoFilterSettings::m_parentalLevel
ParentalLevel::Level m_parentalLevel
Definition: videofilter.h:233
VideoFilterDialog::setTextFilter
void setTextFilter()
Definition: videofilter.cpp:816
VideoFilterSettings::m_prefix
QString m_prefix
Definition: videofilter.h:234
VideoFilterSettings::kFilterCountryChanged
@ kFilterCountryChanged
Definition: videofilter.h:81
VideoFilterSettings::kOrderByTitle
@ kOrderByTitle
Definition: videofilter.h:109
VideoFilterDialog::SetCategory
void SetCategory(MythUIButtonListItem *item)
Definition: videofilter.cpp:755
VideoFilterSettings::SetCast
void SetCast(int lcast)
Definition: videofilter.h:134
VideoFilterSettings::setGenre
void setGenre(int lgenre)
Definition: videofilter.h:127
VideoFilterDialog::m_genreList
MythUIButtonList * m_genreList
Definition: videofilter.h:316
BasicFilterSettingsProxy::BasicFilterSettingsProxy
BasicFilterSettingsProxy(T &type)
Definition: videofilter.h:256
VideoFilterSettings::getInteRef
int getInteRef() const
Definition: videofilter.h:199
VideoFilterDialog::setGenre
void setGenre(MythUIButtonListItem *item)
Definition: videofilter.cpp:767
VideoFilterSettings::kFilterUserRatingChanged
@ kFilterUserRatingChanged
Definition: videofilter.h:84
kInetRefFilterUnknown
@ kInetRefFilterUnknown
Definition: videofilter.h:64
VideoFilterDialog::m_watchedList
MythUIButtonList * m_watchedList
Definition: videofilter.h:310
VideoFilterSettings::m_year
int m_year
Definition: videofilter.h:225
VideoFilterSettings::kFilterCoverFileChanged
@ kFilterCoverFileChanged
Definition: videofilter.h:87
VideoFilterSettings::GetUserRating
int GetUserRating() const
Definition: videofilter.h:161
VideoFilterSettings::m_episode
int m_episode
Definition: videofilter.h:237
VideoFilterDialog::SetCast
void SetCast(MythUIButtonListItem *item)
Definition: videofilter.cpp:773
VideoFilterDialog::m_orderByList
MythUIButtonList * m_orderByList
Definition: videofilter.h:311
InetRefFilter
InetRefFilter
Definition: videofilter.h:62
parentalcontrols.h
VideoFilterSettings::m_runtime
int m_runtime
Definition: videofilter.h:226
VideoFilterSettings::kOrderByUserRatingDescending
@ kOrderByUserRatingDescending
Definition: videofilter.h:111
VideoFilterSettings::getRuntime
int getRuntime() const
Definition: videofilter.h:154
VideoFilterSettings::getGenre
int getGenre() const
Definition: videofilter.h:126
kCategoryFilterUnknown
@ kCategoryFilterUnknown
Definition: videofilter.h:37
kCategoryFilterAll
@ kCategoryFilterAll
Definition: videofilter.h:36
VideoFilterDialog::m_doneButton
MythUIButton * m_doneButton
Definition: videofilter.h:322
VideoFilterSettings::m_reSeason
const QRegExp m_reSeason
Definition: videofilter.h:239
VideoFilterSettings::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(VideoFilterSettings)
VideoFilterDialog::VideoFilterDialog
VideoFilterDialog(MythScreenStack *lparent, const QString &lname, VideoList *video_list)
Definition: videofilter.cpp:453
VideoFilterDialog::m_browseList
MythUIButtonList * m_browseList
Definition: videofilter.h:309
MythScreenStack
Definition: mythscreenstack.h:15
VideoFilterSettings::ordering
ordering
Definition: videofilter.h:105
VideoFilterSettings::kFilterGenreChanged
@ kFilterGenreChanged
Definition: videofilter.h:80
UserRatingFilter
UserRatingFilter
Definition: videofilter.h:50
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:32
VideoFilterSettings::kFilterBrowseChanged
@ kFilterBrowseChanged
Definition: videofilter.h:85
slots
unsigned int slots[4]
Definition: element.cpp:38
VideoFilterDialog::m_saveButton
MythUIButton * m_saveButton
Definition: videofilter.h:321
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
VideoFilterSettings::getParentalLevel
ParentalLevel::Level getParentalLevel() const
Definition: videofilter.h:192
kYearFilterUnknown
@ kYearFilterUnknown
Definition: videofilter.h:42
CategoryFilter
CategoryFilter
Definition: videofilter.h:35
VideoFilterSettings::setOrderby
void setOrderby(ordering lorderby)
Definition: videofilter.h:183
VideoFilterSettings::m_browse
int m_browse
Definition: videofilter.h:228
FilterSettingsProxy::~FilterSettingsProxy
virtual ~FilterSettingsProxy()=default
VideoFilterSettings::m_inetRef
int m_inetRef
Definition: videofilter.h:230
VideoFilterSettings::SetCoverFile
void SetCoverFile(int coverfile)
Definition: videofilter.h:207
VideoFilterSettings::getYear
int getYear() const
Definition: videofilter.h:147
VideoFilterSettings::saveAsDefault
void saveAsDefault()
Definition: videofilter.cpp:170
VideoFilterSettings::SetInetRef
void SetInetRef(int inetref)
Definition: videofilter.h:200
VideoFilterDialog::Create
bool Create() override
Definition: videofilter.cpp:466
VideoFilterDialog::m_textFilter
MythUITextEdit * m_textFilter
Definition: videofilter.h:324
VideoFilterSettings::kFilterRuntimeChanged
@ kFilterRuntimeChanged
Definition: videofilter.h:83
MythUIButtonListItem
Definition: mythuibuttonlist.h:27
BasicFilterSettingsProxy::setSettings
void setSettings(const VideoFilterSettings &settings) override
Definition: videofilter.h:263
VideoFilterDialog::SetYear
void SetYear(MythUIButtonListItem *item)
Definition: videofilter.cpp:742
VideoFilterDialog::m_countryList
MythUIButtonList * m_countryList
Definition: videofilter.h:315
VideoFilterSettings::m_userRating
int m_userRating
Definition: videofilter.h:227
VideoFilterSettings::kOrderByID
@ kOrderByID
Definition: videofilter.h:114
VideoFilterDialog::fillWidgets
void fillWidgets()
Definition: videofilter.cpp:550
VideoFilterDialog::m_runtimeList
MythUIButtonList * m_runtimeList
Definition: videofilter.h:318
VideoFilterSettings::SetYear
void SetYear(int lyear)
Definition: videofilter.h:148
VideoFilterDialog::setRunTime
void setRunTime(MythUIButtonListItem *item)
Definition: videofilter.cpp:779
VideoFilterDialog::saveAsDefault
void saveAsDefault()
Definition: videofilter.cpp:727
ParentalLevel::plNone
@ plNone
Definition: parentalcontrols.h:12
kYearFilterAll
@ kYearFilterAll
Definition: videofilter.h:41
FilterSettingsProxy
Definition: videofilter.h:245
VideoFilterSettings::kFilterParentalLevelChanged
@ kFilterParentalLevelChanged
Definition: videofilter.h:88
VideoFilterDialog::SetUserRating
void SetUserRating(MythUIButtonListItem *item)
Definition: videofilter.cpp:749
VideoFilterSettings::getOrderby
ordering getOrderby() const
Definition: videofilter.h:182
kRuntimeFilterAll
@ kRuntimeFilterAll
Definition: videofilter.h:46
VideoFilterSettings::m_genre
int m_genre
Definition: videofilter.h:222
kCastFilterAll
@ kCastFilterAll
Definition: videofilter.h:31
VideoFilterSettings::GetCoverFile
int GetCoverFile() const
Definition: videofilter.h:206
VideoFilterDialog::m_videoList
const VideoList & m_videoList
Definition: videofilter.h:326
ParentalLevel::Level
Level
Definition: parentalcontrols.h:12
VideoFilterDialog::m_inetRefList
MythUIButtonList * m_inetRefList
Definition: videofilter.h:319
VideoFilterSettings::kFilterWatchedChanged
@ kFilterWatchedChanged
Definition: videofilter.h:90
VideoFilterSettings::m_season
int m_season
Definition: videofilter.h:236
VideoFilterSettings::getTextFilter
QString getTextFilter() const
Definition: videofilter.h:189
VideoFilterSettings::operator=
VideoFilterSettings & operator=(const VideoFilterSettings &rhs)
Definition: videofilter.cpp:65
kCountryFilterUnknown
@ kCountryFilterUnknown
Definition: videofilter.h:27
GenreFilter
GenreFilter
Definition: videofilter.h:20
VideoFilterSettings::m_category
int m_category
Definition: videofilter.h:221
kCoverFileFilterNone
@ kCoverFileFilterNone
Definition: videofilter.h:69
kBrowseFilterAll
@ kBrowseFilterAll
Definition: videofilter.h:55
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
VideoFilterSettings::m_orderBy
ordering m_orderBy
Definition: videofilter.h:232
VideoFilterSettings::m_watched
int m_watched
Definition: videofilter.h:229
VideoFilterSettings::GetBrowse
int GetBrowse() const
Definition: videofilter.h:168
VideoFilterSettings::m_reDate
const QRegExp m_reDate
Definition: videofilter.h:240
VideoFilterDialog::SetBrowse
void SetBrowse(MythUIButtonListItem *item)
Definition: videofilter.cpp:785
kGenreFilterAll
@ kGenreFilterAll
Definition: videofilter.h:21
VideoFilterSettings::m_cast
int m_cast
Definition: videofilter.h:224
VideoFilterDialog::m_settings
VideoFilterSettings m_settings
Definition: videofilter.h:307
VideoFilterSettings::m_changedState
unsigned int m_changedState
Definition: videofilter.h:242
VideoFilterSettings::GetCategory
int GetCategory() const
Definition: videofilter.h:119
FilterSettingsProxy::setSettings
virtual void setSettings(const VideoFilterSettings &settings)=0
VideoFilterSettings::GetWatched
int GetWatched() const
Definition: videofilter.h:175
kUserRatingFilterAll
@ kUserRatingFilterAll
Definition: videofilter.h:51
VideoFilterDialog::saveAndExit
void saveAndExit()
Definition: videofilter.cpp:733
VideoFilterSettings::setParentalLevel
void setParentalLevel(ParentalLevel::Level parental_level)
Definition: videofilter.h:193
VideoFilterSettings::m_coverFile
int m_coverFile
Definition: videofilter.h:231
CastFilter
CastFilter
Definition: videofilter.h:30
VideoFilterSettings::kOrderByDateAddedDescending
@ kOrderByDateAddedDescending
Definition: videofilter.h:116
VideoFilterSettings::kOrderByYearDescending
@ kOrderByYearDescending
Definition: videofilter.h:110
VideoList
Definition: videolist.h:23
kInetRefFilterAll
@ kInetRefFilterAll
Definition: videofilter.h:63
YearFilter
YearFilter
Definition: videofilter.h:40
WatchedFilter
WatchedFilter
Definition: videofilter.h:58
FilterSettingsProxy::getSettings
virtual const VideoFilterSettings & getSettings()=0
CountryFilter
CountryFilter
Definition: videofilter.h:25
kRuntimeFilterUnknown
@ kRuntimeFilterUnknown
Definition: videofilter.h:47
VideoFilterSettings
Definition: videofilter.h:72
VideoFilterDialog::m_yearList
MythUIButtonList * m_yearList
Definition: videofilter.h:312
VideoFilterSettings::m_country
int m_country
Definition: videofilter.h:223
VideoFilterSettings::getCountry
int getCountry() const
Definition: videofilter.h:140
BasicFilterSettingsProxy
Definition: videofilter.h:253
VideoFilterSettings::kSortOrderChanged
@ kSortOrderChanged
Definition: videofilter.h:78
VideoFilterDialog
Definition: videofilter.h:272
kCoverFileFilterAll
@ kCoverFileFilterAll
Definition: videofilter.h:68
VideoFilterSettings::setTextFilter
void setTextFilter(const QString &val)
Definition: videofilter.cpp:399
VideoFilterSettings::m_textFilter
QString m_textFilter
Definition: videofilter.h:235
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
VideoFilterSettings::kFilterInetRefChanged
@ kFilterInetRefChanged
Definition: videofilter.h:86
VideoFilterSettings::SetBrowse
void SetBrowse(int lbrowse)
Definition: videofilter.h:169
CoverFileFilter
CoverFileFilter
Definition: videofilter.h:67
VideoFilterDialog::m_categoryList
MythUIButtonList * m_categoryList
Definition: videofilter.h:314
VideoFilterSettings::kFilterCastChanged
@ kFilterCastChanged
Definition: videofilter.h:89
VideoFilterSettings::kOrderByFilename
@ kOrderByFilename
Definition: videofilter.h:113
VideoFilterSettings::SetWatched
void SetWatched(int lwatched)
Definition: videofilter.h:176
kWatchedFilterAll
@ kWatchedFilterAll
Definition: videofilter.h:59
VideoFilterSettings::getChangedState
unsigned int getChangedState()
Definition: videofilter.h:213
VideoFilterDialog::m_fsp
FilterSettingsProxy * m_fsp
Definition: videofilter.h:327
VideoFilterSettings::SetUserRating
void SetUserRating(int luserrating)
Definition: videofilter.h:162
VideoFilterDialog::update_numvideo
void update_numvideo()
Definition: videofilter.cpp:535
VideoFilterSettings::kOrderByLength
@ kOrderByLength
Definition: videofilter.h:112
VideoFilterSettings::kFilterTextFilterChanged
@ kFilterTextFilterChanged
Definition: videofilter.h:91
VideoFilterDialog::SetInetRef
void SetInetRef(MythUIButtonListItem *item)
Definition: videofilter.cpp:797
VideoFilterSettings::GetCast
int GetCast() const
Definition: videofilter.h:133
VideoFilterDialog::m_coverFileList
MythUIButtonList * m_coverFileList
Definition: videofilter.h:320
VideoFilterSettings::SetCategory
void SetCategory(int lcategory)
Definition: videofilter.h:120
VideoFilterSettings::FilterChanges
FilterChanges
Definition: videofilter.h:77
VideoFilterSettings::kFilterYearChanged
@ kFilterYearChanged
Definition: videofilter.h:82
VideoFilterSettings::setRuntime
void setRuntime(int lruntime)
Definition: videofilter.h:155
VideoFilterDialog::filterChanged
void filterChanged()
kGenreFilterUnknown
@ kGenreFilterUnknown
Definition: videofilter.h:22
VideoFilterDialog::setOrderby
void setOrderby(MythUIButtonListItem *item)
Definition: videofilter.cpp:809
VideoFilterDialog::m_userRatingList
MythUIButtonList * m_userRatingList
Definition: videofilter.h:313
VideoFilterSettings::kFilterCategoryChanged
@ kFilterCategoryChanged
Definition: videofilter.h:79
VideoFilterDialog::m_numVideosText
MythUIText * m_numVideosText
Definition: videofilter.h:323
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:143
VideoFilterDialog::m_castList
MythUIButtonList * m_castList
Definition: videofilter.h:317
kCastFilterUnknown
@ kCastFilterUnknown
Definition: videofilter.h:32
VideoFilterSettings::matches_filter
bool matches_filter(const VideoMetadata &mdata) const
Definition: videofilter.cpp:187
VideoFilterSettings::m_insertDate
QDate m_insertDate
Definition: videofilter.h:238
VideoFilterDialog::~VideoFilterDialog
~VideoFilterDialog() override
Definition: videofilter.cpp:461
VideoFilterSettings::meta_less_than
bool meta_less_than(const VideoMetadata &lhs, const VideoMetadata &rhs) const
Compares two VideoMetadata instances.
Definition: videofilter.cpp:328
BasicFilterSettingsProxy::m_type
T & m_type
Definition: videofilter.h:269
kCountryFilterAll
@ kCountryFilterAll
Definition: videofilter.h:26
VideoFilterSettings::setCountry
void setCountry(int lcountry)
Definition: videofilter.h:141
VideoFilterSettings::kOrderBySeasonEp
@ kOrderBySeasonEp
Definition: videofilter.h:115
mythscreentype.h
VideoFilterDialog::SetCoverFile
void SetCoverFile(MythUIButtonListItem *item)
Definition: videofilter.cpp:803
VideoFilterDialog::setCountry
void setCountry(MythUIButtonListItem *item)
Definition: videofilter.cpp:761
BrowseFilter
BrowseFilter
Definition: videofilter.h:54
BasicFilterSettingsProxy::getSettings
const VideoFilterSettings & getSettings() override
Definition: videofilter.h:258