4 * Copyright (C) 2005-2012 Team XBMC
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)
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.
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/>.
23 #include "utils/LabelFormatter.h"
24 #include "utils/SortUtils.h"
25 #include "MediaSource.h"
27 class CViewState; // forward
33 virtual ~CGUIViewState();
34 static CGUIViewState* GetViewState(int windowId, const CFileItemList& items);
36 void SetViewAsControl(int viewAsControl);
37 void SaveViewAsControl(int viewAsControl);
38 int GetViewAsControl() const;
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;
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();
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);
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
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);
77 void AddLiveTVSources();
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.
84 void AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks);
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;
91 static VECSOURCES m_sources;
93 int m_currentViewAsControl;
96 std::vector<SORT_METHOD_DETAILS> m_sortMethods;
97 int m_currentSortMethod;
99 SortOrder m_sortOrder;
101 static CStdString m_strPlaylistDirectory;
104 class CGUIViewStateGeneral : public CGUIViewState
107 CGUIViewStateGeneral(const CFileItemList& items);
110 virtual void SaveViewState() {};
113 class CGUIViewStateFromItems : public CGUIViewState
116 CGUIViewStateFromItems(const CFileItemList& items);
119 virtual void SaveViewState();
122 class CGUIViewStateLibrary : public CGUIViewState
125 CGUIViewStateLibrary(const CFileItemList& items);
128 virtual void SaveViewState();