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:
77  static const unsigned int FILTER_MASK = 0xFFFE;
78  static const unsigned int SORT_MASK = 0x1;
80  kSortOrderChanged = (1 << 0),
82  kFilterGenreChanged = (1 << 2),
84  kFilterYearChanged = (1 << 4),
91  kFilterCastChanged = (1 << 11),
92  kFilterWatchedChanged = (1 << 12),
94  };
95 
96  public:
97  VideoFilterSettings(bool loaddefaultsettings = true,
98  const QString &_prefix = "");
101 
102  bool matches_filter(const VideoMetadata &mdata) const;
103  bool meta_less_than(const VideoMetadata &lhs, const VideoMetadata &rhs) const;
104 
105  void saveAsDefault();
106 
107  enum ordering
108  {
109  // These values must be explicitly assigned; they represent
110  // database values
119  };
120 
121  int GetCategory() const { return m_category; }
122  void SetCategory(int lcategory)
123  {
125  m_category = lcategory;
126  }
127 
128  int getGenre() const { return m_genre; }
129  void setGenre(int lgenre)
130  {
132  m_genre = lgenre;
133  }
134 
135  int GetCast() const { return m_cast; }
136  void SetCast(int lcast)
137  {
139  m_cast = lcast;
140  }
141 
142  int getCountry() const { return m_country; }
143  void setCountry(int lcountry)
144  {
146  m_country = lcountry;
147  }
148 
149  int getYear() const { return m_year; }
150  void SetYear(int lyear)
151  {
153  m_year = lyear;
154  }
155 
156  int getRuntime() const { return m_runtime; }
157  void setRuntime(int lruntime)
158  {
160  m_runtime = lruntime;
161  }
162 
163  int GetUserRating() const { return m_userrating; }
164  void SetUserRating(int luserrating)
165  {
167  m_userrating = luserrating;
168  }
169 
170  int GetBrowse() const {return m_browse; }
171  void SetBrowse(int lbrowse)
172  {
174  m_browse = lbrowse;
175  }
176 
177  int GetWatched() const {return m_watched; }
178  void SetWatched(int lwatched)
179  {
181  m_watched = lwatched;
182  }
183 
184  ordering getOrderby() const { return m_orderby; }
185  void setOrderby(ordering lorderby)
186  {
188  m_orderby = lorderby;
189  }
190 
191  QString getTextFilter() const { return m_textfilter; }
192  void setTextFilter(const QString& val);
193 
196  {
198  m_parental_level = parental_level;
199  }
200 
201  int getInteRef() const { return m_inetref; }
202  void SetInetRef(int inetref)
203  {
204  m_inetref = inetref;
206  }
207 
208  int GetCoverFile() const { return m_coverfile; }
209  void SetCoverFile(int coverfile)
210  {
211  m_coverfile = coverfile;
213  }
214 
215  unsigned int getChangedState()
216  {
217  unsigned int ret = m_changed_state;
218  m_changed_state = 0;
219  return ret;
220  }
221 
222  private:
236  QString m_prefix;
237  QString m_textfilter;
238  int m_season {-1};
239  int m_episode {-1};
241  const QRegExp m_re_season {"(\\d+)[xX](\\d*)"};
242  const QRegExp m_re_date {"-(\\d+)([dmw])"};
243 
244  unsigned int m_changed_state {0};
245 };
246 
248 {
249  virtual ~FilterSettingsProxy() = default;
250  virtual const VideoFilterSettings &getSettings() = 0;
251  virtual void setSettings(const VideoFilterSettings &settings) = 0;
252 };
253 
254 template <typename T>
256 {
257  public:
259 
260  const VideoFilterSettings &getSettings() override // FilterSettingsProxy
261  {
262  return m_type.getCurrentVideoFilter();
263  }
264 
265  void setSettings(const VideoFilterSettings &settings) override // FilterSettingsProxy
266  {
267  m_type.setCurrentVideoFilter(settings);
268  }
269 
270  private:
271  T &m_type;
272 };
273 
275 {
276 
277  Q_OBJECT
278 
279  public:
280  VideoFilterDialog( MythScreenStack *lparent, const QString& lname,
281  VideoList *video_list);
283 
284  bool Create() override; // MythScreenType
285 
286  signals:
287  void filterChanged();
288 
289  public slots:
290  void saveAndExit();
291  void saveAsDefault();
292  void SetYear(MythUIButtonListItem *item);
294  void SetCategory(MythUIButtonListItem *item);
295  void setCountry(MythUIButtonListItem *item);
296  void setGenre(MythUIButtonListItem *item);
297  void SetCast(MythUIButtonListItem *item);
298  void setRunTime(MythUIButtonListItem *item);
299  void SetBrowse(MythUIButtonListItem *item);
300  void SetWatched(MythUIButtonListItem *item);
301  void SetInetRef(MythUIButtonListItem *item);
303  void setOrderby(MythUIButtonListItem *item);
304  void setTextFilter();
305 
306  private:
307  void fillWidgets();
308  void update_numvideo();
310 
327 
330 };
331 
332 #endif
void SetCategory(MythUIButtonListItem *item)
void SetCoverFile(MythUIButtonListItem *item)
void setOrderby(MythUIButtonListItem *item)
void SetInetRef(int inetref)
Definition: videofilter.h:202
int getRuntime() const
Definition: videofilter.h:156
unsigned int slots[4]
Definition: element.c:38
void SetUserRating(int luserrating)
Definition: videofilter.h:164
MythUIButton * m_saveButton
Definition: videofilter.h:323
void SetCast(MythUIButtonListItem *item)
RuntimeFilter
Definition: videofilter.h:45
virtual void setSettings(const VideoFilterSettings &settings)=0
MythUIText * m_numvideosText
Definition: videofilter.h:325
void SetCategory(int lcategory)
Definition: videofilter.h:122
MythUIButton * m_doneButton
Definition: videofilter.h:324
int GetCoverFile() const
Definition: videofilter.h:208
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
MythUIButtonList * m_coverfileList
Definition: videofilter.h:322
void setSettings(const VideoFilterSettings &settings) override
Definition: videofilter.h:265
void setGenre(int lgenre)
Definition: videofilter.h:129
void SetBrowse(int lbrowse)
Definition: videofilter.h:171
static const unsigned int SORT_MASK
Definition: videofilter.h:78
int getYear() const
Definition: videofilter.h:149
MythUIButtonList * m_orderbyList
Definition: videofilter.h:313
MythUIButtonList * m_genreList
Definition: videofilter.h:318
virtual const VideoFilterSettings & getSettings()=0
void setCountry(int lcountry)
Definition: videofilter.h:143
static const unsigned int FILTER_MASK
Definition: videofilter.h:77
const VideoList & m_videoList
Definition: videofilter.h:328
const QRegExp m_re_season
Definition: videofilter.h:241
MythUITextEdit * m_textfilter
Definition: videofilter.h:326
int GetCast() const
Definition: videofilter.h:135
unsigned int m_changed_state
Definition: videofilter.h:244
VideoFilterDialog(MythScreenStack *lparent, const QString &lname, VideoList *video_list)
MythUIButtonList * m_browseList
Definition: videofilter.h:311
int getCountry() const
Definition: videofilter.h:142
int getInteRef() const
Definition: videofilter.h:201
void setTextFilter(const QString &val)
MythUIButtonList * m_userratingList
Definition: videofilter.h:315
bool Create() override
int GetBrowse() const
Definition: videofilter.h:170
CountryFilter
Definition: videofilter.h:25
MythUIButtonList * m_runtimeList
Definition: videofilter.h:320
void SetCoverFile(int coverfile)
Definition: videofilter.h:209
void setRunTime(MythUIButtonListItem *item)
const QRegExp m_re_date
Definition: videofilter.h:242
void SetWatched(int lwatched)
Definition: videofilter.h:178
const VideoFilterSettings & getSettings() override
Definition: videofilter.h:260
void SetBrowse(MythUIButtonListItem *item)
void SetUserRating(MythUIButtonListItem *item)
A text entry and edit widget.
MythUIButtonList * m_yearList
Definition: videofilter.h:314
void SetYear(int lyear)
Definition: videofilter.h:150
MythUIButtonList * m_countryList
Definition: videofilter.h:317
void SetYear(MythUIButtonListItem *item)
void setRuntime(int lruntime)
Definition: videofilter.h:157
BasicFilterSettingsProxy(T &type)
Definition: videofilter.h:258
MythUIButtonList * m_inetrefList
Definition: videofilter.h:321
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:128
int GetCategory() const
Definition: videofilter.h:121
CastFilter
Definition: videofilter.h:30
void setParentalLevel(ParentalLevel::Level parental_level)
Definition: videofilter.h:195
VideoFilterSettings m_settings
Definition: videofilter.h:309
CoverFileFilter
Definition: videofilter.h:67
YearFilter
Definition: videofilter.h:40
MythUIButtonList * m_categoryList
Definition: videofilter.h:316
GenreFilter
Definition: videofilter.h:20
FilterSettingsProxy * m_fsp
Definition: videofilter.h:329
void setCountry(MythUIButtonListItem *item)
int GetUserRating() const
Definition: videofilter.h:163
MythUIButtonList * m_castList
Definition: videofilter.h:319
virtual ~FilterSettingsProxy()=default
unsigned int getChangedState()
Definition: videofilter.h:215
Screen in which all other widgets are contained and rendered.
Q_DECLARE_TR_FUNCTIONS(VideoFilterSettings)
int GetWatched() const
Definition: videofilter.h:177
ordering getOrderby() const
Definition: videofilter.h:184
ParentalLevel::Level m_parental_level
Definition: videofilter.h:235
ParentalLevel::Level getParentalLevel() const
Definition: videofilter.h:194
void SetCast(int lcast)
Definition: videofilter.h:136
QString getTextFilter() const
Definition: videofilter.h:191
MythUIButtonList * m_watchedList
Definition: videofilter.h:312
VideoFilterSettings & operator=(const VideoFilterSettings &rhs)
Definition: videofilter.cpp:66
void SetWatched(MythUIButtonListItem *item)
BrowseFilter
Definition: videofilter.h:54
void SetInetRef(MythUIButtonListItem *item)
void setOrderby(ordering lorderby)
Definition: videofilter.h:185