4 * Copyright (C) 2005-2013 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 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;
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(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;
94 static VECSOURCES m_sources;
96 int m_currentViewAsControl;
99 std::vector<SORT_METHOD_DETAILS> m_sortMethods;
100 int m_currentSortMethod;
102 SortOrder m_sortOrder;
104 static CStdString m_strPlaylistDirectory;
107 class CGUIViewStateGeneral : public CGUIViewState
110 CGUIViewStateGeneral(const CFileItemList& items);
113 virtual void SaveViewState() {};
116 class CGUIViewStateFromItems : public CGUIViewState
119 CGUIViewStateFromItems(const CFileItemList& items);
122 virtual void SaveViewState();
125 class CGUIViewStateLibrary : public CGUIViewState
128 CGUIViewStateLibrary(const CFileItemList& items);
131 virtual void SaveViewState();