2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "MediaSource.h"
12 #include "utils/LabelFormatter.h"
13 #include "utils/SortUtils.h"
17 class CViewState
; // forward
23 } // namespace PLAYLIST
28 virtual ~CGUIViewState();
29 static CGUIViewState
* GetViewState(int windowId
, const CFileItemList
& items
);
31 void SetViewAsControl(int viewAsControl
);
32 void SaveViewAsControl(int viewAsControl
);
33 int GetViewAsControl() const;
35 bool ChooseSortMethod();
36 SortDescription
SetNextSortMethod(int direction
= 1);
37 void SetCurrentSortMethod(int method
);
38 SortDescription
GetSortMethod() const;
39 bool HasMultipleSortMethods() const;
40 int GetSortMethodLabel() const;
41 int GetSortOrderLabel() const;
42 void GetSortMethodLabelMasks(LABEL_MASKS
& masks
) const;
44 std::vector
<SortDescription
> GetSortDescriptions() const;
46 SortOrder
SetNextSortOrder();
47 SortOrder
GetSortOrder() const;
49 virtual bool HideExtensions();
50 virtual bool HideParentDirItems();
51 virtual bool DisableAddSourceButtons();
53 virtual PLAYLIST::Id
GetPlaylist() const;
54 const std::string
& GetPlaylistDirectory();
55 void SetPlaylistDirectory(const std::string
& strDirectory
);
56 bool IsCurrentPlaylistDirectory(const std::string
& strDirectory
);
57 virtual bool AutoPlayNextItem();
59 virtual std::string
GetLockType();
60 virtual std::string
GetExtensions();
61 virtual VECSOURCES
& GetSources();
64 explicit CGUIViewState(const CFileItemList
& items
); // no direct object creation, use GetViewState()
66 virtual void SaveViewState() = 0;
67 virtual void SaveViewToDb(const std::string
&path
, int windowID
, CViewState
*viewState
= NULL
);
68 void LoadViewState(const std::string
&path
, int windowID
);
70 void AddLiveTVSources();
72 /*! \brief Add the sort order defined in a smartplaylist
73 Defaults to SORT_METHOD_PLAYLIST_ORDER if no order is defined.
74 \param items the list of items for the view state.
75 \param label_mask the label masks for formatting items.
77 void AddPlaylistOrder(const CFileItemList
& items
, const LABEL_MASKS
& label_masks
);
79 void AddSortMethod(SortBy sortBy
, int buttonLabel
, const LABEL_MASKS
&labelMasks
, SortAttribute sortAttributes
= SortAttributeNone
, SortOrder sortOrder
= SortOrderNone
);
80 void AddSortMethod(SortBy sortBy
, SortAttribute sortAttributes
, int buttonLabel
, const LABEL_MASKS
&labelMasks
, SortOrder sortOrder
= SortOrderNone
);
81 void AddSortMethod(SortDescription sortDescription
, int buttonLabel
, const LABEL_MASKS
&labelMasks
);
82 void SetSortMethod(SortBy sortBy
, SortOrder sortOrder
= SortOrderNone
);
83 void SetSortMethod(SortDescription sortDescription
);
84 void SetSortOrder(SortOrder sortOrder
);
86 bool AutoPlayNextVideoItem() const;
88 const CFileItemList
& m_items
;
90 int m_currentViewAsControl
;
91 PLAYLIST::Id m_playlist
;
93 std::vector
<GUIViewSortDetails
> m_sortMethods
;
94 int m_currentSortMethod
;
96 static VECSOURCES m_sources
;
97 static std::string m_strPlaylistDirectory
;
100 class CGUIViewStateGeneral
: public CGUIViewState
103 explicit CGUIViewStateGeneral(const CFileItemList
& items
);
106 void SaveViewState() override
{ }
109 class CGUIViewStateFromItems
: public CGUIViewState
112 explicit CGUIViewStateFromItems(const CFileItemList
& items
);
113 bool AutoPlayNextItem() override
;
116 void SaveViewState() override
;
119 class CGUIViewStateLibrary
: public CGUIViewState
122 explicit CGUIViewStateLibrary(const CFileItemList
& items
);
125 void SaveViewState() override
;