Fix keymap.
[vuplus_xbmc] / xbmc / view / GUIViewState.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "utils/LabelFormatter.h"
24 #include "utils/SortUtils.h"
25 #include "MediaSource.h"
26
27 class CViewState; // forward
28 class CFileItemList;
29
30 class CGUIViewState
31 {
32 public:
33   virtual ~CGUIViewState();
34   static CGUIViewState* GetViewState(int windowId, const CFileItemList& items);
35
36   void SetViewAsControl(int viewAsControl);
37   void SaveViewAsControl(int viewAsControl);
38   int GetViewAsControl() const;
39
40   SortDescription SetNextSortMethod(int direction = 1);
41   void SetCurrentSortMethod(int method);
42   SortDescription GetSortMethod() const;
43   bool HasMultipleSortMethods() const;
44   int GetSortMethodLabel() const;
45   void GetSortMethodLabelMasks(LABEL_MASKS& masks) const;
46
47   SortOrder SetNextSortOrder();
48   SortOrder GetSortOrder() const { return m_sortOrder; };
49   SortOrder GetDisplaySortOrder() const;
50   virtual bool HideExtensions();
51   virtual bool HideParentDirItems();
52   virtual bool DisableAddSourceButtons();
53   virtual int GetPlaylist();
54   const CStdString& GetPlaylistDirectory();
55   void SetPlaylistDirectory(const CStdString& strDirectory);
56   bool IsCurrentPlaylistDirectory(const CStdString& strDirectory);
57   virtual bool AutoPlayNextItem();
58   virtual CStdString GetLockType();
59   virtual CStdString GetExtensions();
60   virtual VECSOURCES& GetSources();
61
62 protected:
63   CGUIViewState(const CFileItemList& items);  // no direct object creation, use GetViewState()
64   virtual void SaveViewState()=0;
65   virtual void SaveViewToDb(const CStdString &path, int windowID, CViewState *viewState = NULL);
66   void LoadViewState(const CStdString &path, int windowID);
67   
68   /*! \brief Add the addons source for the given content type, if the user has suitable addons
69    \param content the type of addon content desired
70    \param label the name of the addons source
71    \param thumb the skin image to use as the icon
72    */
73   void AddAddonsSource(const CStdString &content, const CStdString &label, const CStdString& thumb);
74 #if defined(TARGET_ANDROID)
75   void AddAndroidSource(const CStdString &content, const CStdString &label, const CStdString& thumb);
76 #endif
77   void AddLiveTVSources();
78
79   /*! \brief Add the sort order defined in a smartplaylist
80    Defaults to SORT_METHOD_PLAYLIST_ORDER if no order is defined.
81    \param items the list of items for the view state.
82    \param label_mask the label masks for formatting items.
83    */
84   void AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks);
85
86   void AddSortMethod(SortBy sortBy, int buttonLabel, const LABEL_MASKS &labelMasks, SortAttribute sortAttributes = SortAttributeNone);
87   void AddSortMethod(SortBy sortBy, SortAttribute sortAttributes, int buttonLabel, const LABEL_MASKS &labelMasks);
88   void AddSortMethod(SortDescription sortDescription, int buttonLabel, const LABEL_MASKS &labelMasks);
89   void SetSortMethod(SortBy sortBy, SortAttribute sortAttributes = SortAttributeNone);
90   void SetSortMethod(SortDescription sortDescription);
91   void SetSortOrder(SortOrder sortOrder);
92   const CFileItemList& m_items;
93
94   static VECSOURCES m_sources;
95
96   int m_currentViewAsControl;
97   int m_playlist;
98
99   std::vector<SORT_METHOD_DETAILS> m_sortMethods;
100   int m_currentSortMethod;
101
102   SortOrder m_sortOrder;
103
104   static CStdString m_strPlaylistDirectory;
105 };
106
107 class CGUIViewStateGeneral : public CGUIViewState
108 {
109 public:
110   CGUIViewStateGeneral(const CFileItemList& items);
111
112 protected:
113   virtual void SaveViewState() {};
114 };
115
116 class CGUIViewStateFromItems : public CGUIViewState
117 {
118 public:
119   CGUIViewStateFromItems(const CFileItemList& items);
120
121 protected:
122   virtual void SaveViewState();
123 };
124
125 class CGUIViewStateLibrary : public CGUIViewState
126 {
127 public:
128   CGUIViewStateLibrary(const CFileItemList& items);
129
130 protected:
131   virtual void SaveViewState();
132 };