[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / dialogs / GUIDialogMediaFilter.h
1 #pragma once
2 /*
3  *      Copyright (C) 2012-2013 Team XBMC
4  *      http://www.xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include <map>
23 #include <string>
24
25 #include "DbUrl.h"
26 #include "dbwrappers/Database.h"
27 #include "playlists/SmartPlayList.h"
28 #include "settings/GUIDialogSettings.h"
29 #include "threads/Timer.h"
30 #include "utils/DatabaseUtils.h"
31 #include "utils/StdString.h"
32
33 class CFileItemList;
34
35 class CGUIDialogMediaFilter : public CGUIDialogSettings, protected ITimerCallback
36 {
37 public:
38   CGUIDialogMediaFilter();
39   virtual ~CGUIDialogMediaFilter();
40
41   virtual bool OnMessage(CGUIMessage& message);
42
43   static void ShowAndEditMediaFilter(const std::string &path, CSmartPlaylist &filter);
44
45   typedef struct {
46     std::string mediaType;
47     Field field;
48     uint32_t label;
49     SettingInfo::SETTING_TYPE type;
50     CSmartPlaylistRule::SEARCH_OPERATOR ruleOperator;
51     void *data;
52     CSmartPlaylistRule *rule;
53     int controlIndex;
54   } Filter;
55
56 protected:
57   virtual void OnWindowLoaded();
58
59   virtual void CreateSettings();
60   virtual void SetupPage();
61   virtual void OnSettingChanged(SettingInfo &setting);
62
63   virtual void OnTimeout();
64
65   void Reset();
66   bool SetPath(const std::string &path);
67   void UpdateControls();
68   void TriggerFilter() const;
69
70   void OnBrowse(const Filter &filter, CFileItemList &items, bool countOnly = false);
71   CSmartPlaylistRule* AddRule(Field field, CSmartPlaylistRule::SEARCH_OPERATOR ruleOperator = CSmartPlaylistRule::OPERATOR_CONTAINS);
72   void DeleteRule(Field field);
73   void GetRange(const Filter &filter, float &min, float &interval, float &max, RANGEFORMATFUNCTION &formatFunction);
74   bool GetMinMax(const CStdString &table, const CStdString &field, float &min, float &max, const CDatabase::Filter &filter = CDatabase::Filter());
75
76   static CStdString RangeAsFloat(float valueLower, float valueUpper, float minimum);
77   static CStdString RangeAsInt(float valueLower, float valueUpper, float minimum);
78   static CStdString RangeAsDate(float valueLower, float valueUpper, float minimum);
79   static CStdString RangeAsTime(float valueLower, float valueUpper, float minimum);
80
81   CDbUrl* m_dbUrl;
82   std::string m_mediaType;
83   CSmartPlaylist *m_filter;
84   std::map<uint32_t, Filter> m_filters;
85   CTimer *m_delayTimer;
86 };