[droid] Do not show any ui if pre-checks are OK
[vuplus_xbmc] / xbmc / GUIViewState.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2012 Team XBMC
5  *      http://www.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   SORT_METHOD SetNextSortMethod(int direction = 1);
41   void SetCurrentSortMethod(int method);
42   SORT_METHOD GetSortMethod() const;
43   int GetSortMethodLabel() const;
44   void GetSortMethodLabelMasks(LABEL_MASKS& masks) const;
45   void GetSortMethods(std::vector< std::pair<int,int> > &sortMethods) 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(SORT_METHOD sortMethod, int buttonLabel, LABEL_MASKS labelmasks);
87   void SetSortMethod(SORT_METHOD sortMethod);
88   void SetSortOrder(SortOrder sortOrder);
89   const CFileItemList& m_items;
90
91   static VECSOURCES m_sources;
92
93   int m_currentViewAsControl;
94   int m_playlist;
95
96   std::vector<SORT_METHOD_DETAILS> m_sortMethods;
97   int m_currentSortMethod;
98
99   SortOrder m_sortOrder;
100
101   static CStdString m_strPlaylistDirectory;
102 };
103
104 class CGUIViewStateGeneral : public CGUIViewState
105 {
106 public:
107   CGUIViewStateGeneral(const CFileItemList& items);
108
109 protected:
110   virtual void SaveViewState() {};
111 };
112
113 class CGUIViewStateFromItems : public CGUIViewState
114 {
115 public:
116   CGUIViewStateFromItems(const CFileItemList& items);
117
118 protected:
119   virtual void SaveViewState();
120 };
121
122 class CGUIViewStateLibrary : public CGUIViewState
123 {
124 public:
125   CGUIViewStateLibrary(const CFileItemList& items);
126
127 protected:
128   virtual void SaveViewState();
129 };