00001 #ifndef VIDEOFILTER_H_
00002 #define VIDEOFILTER_H_
00003
00004 #include "mythscreentype.h"
00005 #include "parentalcontrols.h"
00006
00007 class MythUIButtonList;
00008 class MythUIButtonListItem;
00009 class MythUIButton;
00010 class MythUIText;
00011
00012 class VideoMetadata;
00013 class VideoList;
00014
00015 class VideoFilterSettings
00016 {
00017 public:
00018 static const unsigned int FILTER_MASK = 0xFFFE;
00019 static const unsigned int SORT_MASK = 0x1;
00020 enum FilterChanges {
00021 kSortOrderChanged = (1 << 0),
00022 kFilterCategoryChanged = (1 << 1),
00023 kFilterGenreChanged = (1 << 2),
00024 kFilterCountryChanged = (1 << 3),
00025 kFilterYearChanged = (1 << 4),
00026 kFilterRuntimeChanged = (1 << 5),
00027 kFilterUserRatingChanged = (1 << 6),
00028 kFilterBrowseChanged = (1 << 7),
00029 kFilterInetRefChanged = (1 << 8),
00030 kFilterCoverFileChanged = (1 << 9),
00031 kFilterParentalLevelChanged = (1 << 10),
00032 kFilterCastChanged = (1 << 11),
00033 kFilterWatchedChanged = (1 << 12),
00034 kFilterTextFilterChanged = (1 << 13)
00035 };
00036
00037 public:
00038 VideoFilterSettings(bool loaddefaultsettings = true,
00039 const QString &_prefix = "");
00040 VideoFilterSettings(const VideoFilterSettings &rhs);
00041 VideoFilterSettings &operator=(const VideoFilterSettings &rhs);
00042
00043 bool matches_filter(const VideoMetadata &mdata) const;
00044 bool meta_less_than(const VideoMetadata &lhs, const VideoMetadata &rhs,
00045 bool sort_ignores_case) const;
00046
00047 void saveAsDefault();
00048
00049 enum ordering
00050 {
00051
00052
00053 kOrderByTitle = 0,
00054 kOrderByYearDescending = 1,
00055 kOrderByUserRatingDescending = 2,
00056 kOrderByLength = 3,
00057 kOrderByFilename = 4,
00058 kOrderByID = 5,
00059 kOrderBySeasonEp = 6,
00060 kOrderByDateAddedDescending = 7
00061 };
00062
00063 int GetCategory() const { return category; }
00064 void SetCategory(int lcategory)
00065 {
00066 m_changed_state |= kFilterCategoryChanged;
00067 category = lcategory;
00068 }
00069
00070 int getGenre() const { return genre; }
00071 void setGenre(int lgenre)
00072 {
00073 m_changed_state |= kFilterGenreChanged;
00074 genre = lgenre;
00075 }
00076
00077 int GetCast() const { return cast; }
00078 void SetCast(int lcast)
00079 {
00080 m_changed_state |= kFilterCastChanged;
00081 cast = lcast;
00082 }
00083
00084 int getCountry() const { return country; }
00085 void setCountry(int lcountry)
00086 {
00087 m_changed_state |= kFilterCountryChanged;
00088 country = lcountry;
00089 }
00090
00091 int getYear() const { return year; }
00092 void SetYear(int lyear)
00093 {
00094 m_changed_state |= kFilterYearChanged;
00095 year = lyear;
00096 }
00097
00098 int getRuntime() const { return runtime; }
00099 void setRuntime(int lruntime)
00100 {
00101 m_changed_state |= kFilterRuntimeChanged;
00102 runtime = lruntime;
00103 }
00104
00105 int GetUserRating() const { return userrating; }
00106 void SetUserRating(int luserrating)
00107 {
00108 m_changed_state |= kFilterUserRatingChanged;
00109 userrating = luserrating;
00110 }
00111
00112 int GetBrowse() const {return browse; }
00113 void SetBrowse(int lbrowse)
00114 {
00115 m_changed_state |= kFilterBrowseChanged;
00116 browse = lbrowse;
00117 }
00118
00119 int GetWatched() const {return watched; }
00120 void SetWatched(int lwatched)
00121 {
00122 m_changed_state |= kFilterWatchedChanged;
00123 watched = lwatched;
00124 }
00125
00126 ordering getOrderby() const { return orderby; }
00127 void setOrderby(ordering lorderby)
00128 {
00129 m_changed_state |= kSortOrderChanged;
00130 orderby = lorderby;
00131 }
00132
00133 QString getTextFilter() const { return textfilter; }
00134 void setTextFilter(QString val);
00135
00136 ParentalLevel::Level getParentalLevel() const { return m_parental_level; }
00137 void setParentalLevel(ParentalLevel::Level parental_level)
00138 {
00139 m_changed_state |= kFilterParentalLevelChanged;
00140 m_parental_level = parental_level;
00141 }
00142
00143 int getInteRef() const { return m_inetref; }
00144 void SetInetRef(int inetref)
00145 {
00146 m_inetref = inetref;
00147 m_changed_state |= kFilterInetRefChanged;
00148 }
00149
00150 int GetCoverFile() const { return m_coverfile; }
00151 void SetCoverFile(int coverfile)
00152 {
00153 m_coverfile = coverfile;
00154 m_changed_state |= kFilterCoverFileChanged;
00155 }
00156
00157 unsigned int getChangedState()
00158 {
00159 unsigned int ret = m_changed_state;
00160 m_changed_state = 0;
00161 return ret;
00162 }
00163
00164 private:
00165 int category;
00166 int genre;
00167 int country;
00168 int cast;
00169 int year;
00170 int runtime;
00171 int userrating;
00172 int browse;
00173 int watched;
00174 int m_inetref;
00175 int m_coverfile;
00176 ordering orderby;
00177 ParentalLevel::Level m_parental_level;
00178 QString prefix;
00179 QString textfilter;
00180 int season;
00181 int episode;
00182 QDate insertdate;
00183 const QRegExp re_season;
00184 const QRegExp re_date;
00185
00186
00187 unsigned int m_changed_state;
00188 };
00189
00190 struct FilterSettingsProxy
00191 {
00192 virtual ~FilterSettingsProxy() {}
00193 virtual const VideoFilterSettings &getSettings() = 0;
00194 virtual void setSettings(const VideoFilterSettings &settings) = 0;
00195 };
00196
00197 template <typename T>
00198 class BasicFilterSettingsProxy : public FilterSettingsProxy
00199 {
00200 public:
00201 BasicFilterSettingsProxy(T &type) : m_type(type) {}
00202
00203 const VideoFilterSettings &getSettings()
00204 {
00205 return m_type.getCurrentVideoFilter();
00206 }
00207
00208 void setSettings(const VideoFilterSettings &settings)
00209 {
00210 m_type.setCurrentVideoFilter(settings);
00211 }
00212
00213 private:
00214 T &m_type;
00215 };
00216
00217 class VideoFilterDialog : public MythScreenType
00218 {
00219
00220 Q_OBJECT
00221
00222 public:
00223 VideoFilterDialog( MythScreenStack *lparent, QString lname,
00224 VideoList *video_list);
00225 ~VideoFilterDialog();
00226
00227 bool Create();
00228
00229 signals:
00230 void filterChanged();
00231
00232 public slots:
00233 void saveAndExit();
00234 void saveAsDefault();
00235 void SetYear(MythUIButtonListItem *item);
00236 void SetUserRating(MythUIButtonListItem *item);
00237 void SetCategory(MythUIButtonListItem *item);
00238 void setCountry(MythUIButtonListItem *item);
00239 void setGenre(MythUIButtonListItem *item);
00240 void SetCast(MythUIButtonListItem *item);
00241 void setRunTime(MythUIButtonListItem *item);
00242 void SetBrowse(MythUIButtonListItem *item);
00243 void SetWatched(MythUIButtonListItem *item);
00244 void SetInetRef(MythUIButtonListItem *item);
00245 void SetCoverFile(MythUIButtonListItem *item);
00246 void setOrderby(MythUIButtonListItem *item);
00247 void setTextFilter();
00248
00249 private:
00250 void fillWidgets();
00251 void update_numvideo();
00252 VideoFilterSettings m_settings;
00253
00254 MythUIButtonList *m_browseList;
00255 MythUIButtonList *m_watchedList;
00256 MythUIButtonList *m_orderbyList;
00257 MythUIButtonList *m_yearList;
00258 MythUIButtonList *m_userratingList;
00259 MythUIButtonList *m_categoryList;
00260 MythUIButtonList *m_countryList;
00261 MythUIButtonList *m_genreList;
00262 MythUIButtonList *m_castList;
00263 MythUIButtonList *m_runtimeList;
00264 MythUIButtonList *m_inetrefList;
00265 MythUIButtonList *m_coverfileList;
00266 MythUIButton *m_saveButton;
00267 MythUIButton *m_doneButton;
00268 MythUIText *m_numvideosText;
00269 MythUITextEdit *m_textfilter;
00270
00271 const VideoList &m_videoList;
00272 FilterSettingsProxy *m_fsp;
00273 };
00274
00275 #endif