| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "MediaSource.h" |
| 12 |
#include "utils/LabelFormatter.h" |
| 13 |
#include "utils/SortUtils.h" |
| 14 |
|
| 15 |
#include <vector> |
| 16 |
|
| 17 |
class CViewState; // forward |
| 18 |
class CFileItemList; |
| 19 |
|
| 20 |
namespace PLAYLIST |
| 21 |
{ |
| 22 |
using Id = int; |
| 23 |
} // namespace PLAYLIST |
| 24 |
|
| 25 |
class CGUIViewState |
| 26 |
{ |
| 27 |
public: |
| 28 |
virtual ~CGUIViewState(); |
| 29 |
static CGUIViewState* GetViewState(int windowId, const CFileItemList& items); |
| 30 |
|
| 31 |
void SetViewAsControl(int viewAsControl); |
| 32 |
void SaveViewAsControl(int viewAsControl); |
| 33 |
int GetViewAsControl() const; |
| 34 |
|
| 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; |
| 43 |
|
| 44 |
std::vector<SortDescription> GetSortDescriptions() const; |
| 45 |
|
| 46 |
SortOrder SetNextSortOrder(); |
| 47 |
SortOrder GetSortOrder() const; |
| 48 |
|
| 49 |
virtual bool HideExtensions(); |
| 50 |
virtual bool HideParentDirItems(); |
| 51 |
virtual bool DisableAddSourceButtons(); |
| 52 |
|
| 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(); |
| 58 |
|
| 59 |
virtual std::string GetLockType(); |
| 60 |
virtual std::string GetExtensions(); |
| 61 |
virtual VECSOURCES& GetSources(); |
| 62 |
|
| 63 |
protected: |
| 64 |
explicit CGUIViewState(const CFileItemList& items); // no direct object creation, use GetViewState() |
| 65 |
|
| 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); |
| 69 |
|
| 70 |
void AddLiveTVSources(); |
| 71 |
|
| 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. |
| 76 |
*/ |
| 77 |
void AddPlaylistOrder(const CFileItemList& items, const LABEL_MASKS& label_masks); |
| 78 |
|
| 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); |
| 85 |
|
| 86 |
bool AutoPlayNextVideoItem() const; |
| 87 |
|
| 88 |
const CFileItemList& m_items; |
| 89 |
|
| 90 |
int m_currentViewAsControl; |
| 91 |
PLAYLIST::Id m_playlist; |
| 92 |
|
| 93 |
std::vector<GUIViewSortDetails> m_sortMethods; |
| 94 |
int m_currentSortMethod; |
| 95 |
|
| 96 |
static VECSOURCES m_sources; |
| 97 |
static std::string m_strPlaylistDirectory; |
| 98 |
}; |
| 99 |
|
| 100 |
class CGUIViewStateGeneral : public CGUIViewState |
| 101 |
{ |
| 102 |
public: |
| 103 |
explicit CGUIViewStateGeneral(const CFileItemList& items); |
| 104 |
|
| 105 |
protected: |
| 106 |
void SaveViewState() override { } |
| 107 |
}; |
| 108 |
|
| 109 |
class CGUIViewStateFromItems : public CGUIViewState |
| 110 |
{ |
| 111 |
public: |
| 112 |
explicit CGUIViewStateFromItems(const CFileItemList& items); |
| 113 |
bool AutoPlayNextItem() override; |
| 114 |
|
| 115 |
protected: |
| 116 |
void SaveViewState() override; |
| 117 |
}; |
| 118 |
|
| 119 |
class CGUIViewStateLibrary : public CGUIViewState |
| 120 |
{ |
| 121 |
public: |
| 122 |
explicit CGUIViewStateLibrary(const CFileItemList& items); |
| 123 |
|
| 124 |
protected: |
| 125 |
void SaveViewState() override; |
| 126 |
}; |