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
void SetCategory(MythUIButtonListItem *item)
void SetCoverFile(MythUIButtonListItem *item)
void setOrderby(MythUIButtonListItem *item)
void SetInetRef(int inetref)
Definition: videofilter.h:200
int getRuntime() const
Definition: videofilter.h:154
unsigned int slots[4]
Definition: element.c:38
const QRegExp m_reSeason
Definition: videofilter.h:239
void SetUserRating(int luserrating)
Definition: videofilter.h:162
MythUIButton * m_saveButton
Definition: videofilter.h:321
void SetCast(MythUIButtonListItem *item)
RuntimeFilter
Definition: videofilter.h:45
virtual void setSettings(const VideoFilterSettings &settings)=0
void SetCategory(int lcategory)
Definition: videofilter.h:120
MythUIButton * m_doneButton
Definition: videofilter.h:322
int GetCoverFile() const
Definition: videofilter.h:206
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
CategoryFilter
Definition: videofilter.h:35
InetRefFilter
Definition: videofilter.h:62
void setGenre(MythUIButtonListItem *item)
VideoFilterSettings(bool loaddefaultsettings=true, const QString &_prefix="")
Definition: videofilter.cpp:19
ParentalLevel::Level m_parentalLevel
Definition: videofilter.h:233
void setSettings(const VideoFilterSettings &settings) override
Definition: videofilter.h:263
void setGenre(int lgenre)
Definition: videofilter.h:127
void SetBrowse(int lbrowse)
Definition: videofilter.h:169
int getYear() const
Definition: videofilter.h:147
MythUIButtonList * m_genreList
Definition: videofilter.h:316
virtual const VideoFilterSettings & getSettings()=0
void setCountry(int lcountry)
Definition: videofilter.h:141
MythUIButtonList * m_inetRefList
Definition: videofilter.h:319
const VideoList & m_videoList
Definition: videofilter.h:326
int GetCast() const
Definition: videofilter.h:133
VideoFilterDialog(MythScreenStack *lparent, const QString &lname, VideoList *video_list)
MythUIButtonList * m_browseList
Definition: videofilter.h:309
int getCountry() const
Definition: videofilter.h:140
int getInteRef() const
Definition: videofilter.h:199
void setTextFilter(const QString &val)
bool Create() override
int GetBrowse() const
Definition: videofilter.h:168
CountryFilter
Definition: videofilter.h:25
MythUIButtonList * m_runtimeList
Definition: videofilter.h:318
void SetCoverFile(int coverfile)
Definition: videofilter.h:207
unsigned int m_changedState
Definition: videofilter.h:242
void setRunTime(MythUIButtonListItem *item)
void SetWatched(int lwatched)
Definition: videofilter.h:176
const VideoFilterSettings & getSettings() override
Definition: videofilter.h:258
void SetBrowse(MythUIButtonListItem *item)
void SetUserRating(MythUIButtonListItem *item)
A text entry and edit widget.
MythUITextEdit * m_textFilter
Definition: videofilter.h:324
MythUIButtonList * m_yearList
Definition: videofilter.h:312
void SetYear(int lyear)
Definition: videofilter.h:148
MythUIButtonList * m_countryList
Definition: videofilter.h:315
void SetYear(MythUIButtonListItem *item)
void setRuntime(int lruntime)
Definition: videofilter.h:155
BasicFilterSettingsProxy(T &type)
Definition: videofilter.h:256
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
WatchedFilter
Definition: videofilter.h:58
bool matches_filter(const VideoMetadata &mdata) const
bool meta_less_than(const VideoMetadata &lhs, const VideoMetadata &rhs) const
Compares two VideoMetadata instances.
A single button widget.
Definition: mythuibutton.h:21
UserRatingFilter
Definition: videofilter.h:50
int getGenre() const
Definition: videofilter.h:126
MythUIButtonList * m_coverFileList
Definition: videofilter.h:320
int GetCategory() const
Definition: videofilter.h:119
CastFilter
Definition: videofilter.h:30
void setParentalLevel(ParentalLevel::Level parental_level)
Definition: videofilter.h:193
VideoFilterSettings m_settings
Definition: videofilter.h:307
MythUIButtonList * m_userRatingList
Definition: videofilter.h:313
MythUIText * m_numVideosText
Definition: videofilter.h:323
CoverFileFilter
Definition: videofilter.h:67
YearFilter
Definition: videofilter.h:40
MythUIButtonList * m_categoryList
Definition: videofilter.h:314
GenreFilter
Definition: videofilter.h:20
const QRegExp m_reDate
Definition: videofilter.h:240
FilterSettingsProxy * m_fsp
Definition: videofilter.h:327
void setCountry(MythUIButtonListItem *item)
int GetUserRating() const
Definition: videofilter.h:161
MythUIButtonList * m_castList
Definition: videofilter.h:317
virtual ~FilterSettingsProxy()=default
unsigned int getChangedState()
Definition: videofilter.h:213
Screen in which all other widgets are contained and rendered.
Q_DECLARE_TR_FUNCTIONS(VideoFilterSettings)
int GetWatched() const
Definition: videofilter.h:175
ordering getOrderby() const
Definition: videofilter.h:182
ParentalLevel::Level getParentalLevel() const
Definition: videofilter.h:192
void SetCast(int lcast)
Definition: videofilter.h:134
QString getTextFilter() const
Definition: videofilter.h:189
MythUIButtonList * m_watchedList
Definition: videofilter.h:310
VideoFilterSettings & operator=(const VideoFilterSettings &rhs)
Definition: videofilter.cpp:66
void SetWatched(MythUIButtonListItem *item)
BrowseFilter
Definition: videofilter.h:54
void SetInetRef(MythUIButtonListItem *item)
MythUIButtonList * m_orderByList
Definition: videofilter.h:311
void setOrderby(ordering lorderby)
Definition: videofilter.h:183
~VideoFilterDialog() override