1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* Copyright (C) 2013-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include <memory>
#include <vector>
class TiXmlNode;
class CGUIListItem;
typedef std::shared_ptr<CGUIListItem> CGUIListItemPtr;
/*!
\ingroup listproviders
\brief An interface for providing lists to UI containers.
*/
class IListProvider
{
public:
explicit IListProvider(int parentID) : m_parentID(parentID) {}
explicit IListProvider(const IListProvider& other) = default;
virtual ~IListProvider() = default;
/*! \brief Factory to create list providers.
\param parent a parent TiXmlNode for the container.
\param parentID id of parent window for context.
\return the list provider, empty pointer if none.
*/
static std::unique_ptr<IListProvider> Create(const TiXmlNode* parent, int parentID);
/*! \brief Factory to create list providers. Cannot create a multi-provider.
\param content the TiXmlNode for the content to create.
\param parentID id of parent window for context.
\return the list provider, empty pointer if none.
*/
static std::unique_ptr<IListProvider> CreateSingle(const TiXmlNode* content, int parentID);
/*! \brief Create an instance of the derived class. Allows for polymorphic copies.
*/
virtual std::unique_ptr<IListProvider> Clone() = 0;
/*! \brief Update the list content
\return true if the content has changed, false otherwise.
*/
virtual bool Update(bool forceRefresh)=0;
/*! \brief Fetch the current list of items.
\param items [out] the list to be filled.
*/
virtual void Fetch(std::vector<CGUIListItemPtr> &items)=0;
/*! \brief Check whether the list provider is updating content.
\return true if in the processing of updating, false otherwise.
*/
virtual bool IsUpdating() const { return false; }
/*! \brief Reset the current list of items.
Derived classes may choose to ignore this.
*/
virtual void Reset() {}
/*! \brief Free all GUI resources allocated by the items.
\param immediately true to free resources immediately, free resources async later otherwise.
*/
virtual void FreeResources(bool immediately) {}
/*! \brief Click event on an item.
\param item the item that was clicked.
\return true if the click was handled, false otherwise.
*/
virtual bool OnClick(const CGUIListItemPtr &item)=0;
/*! \brief Play event on an item.
\param item the item to play.
\return true if the event was handled, false otherwise.
*/
virtual bool OnPlay(const CGUIListItemPtr& item) { return false; }
/*! \brief Open the info dialog for an item provided by this IListProvider.
\param item the item that was clicked.
\return true if the dialog was shown, false otherwise.
*/
virtual bool OnInfo(const CGUIListItemPtr &item)=0;
/*! \brief Open the context menu for an item provided by this IListProvider.
\param item the item that was clicked.
\return true if the click was handled, false otherwise.
*/
virtual bool OnContextMenu(const CGUIListItemPtr &item)=0;
/*! \brief Set the default item to focus. For backwards compatibility.
\param item the item to focus.
\param always whether this item should always be used on first focus.
\sa GetDefaultItem, AlwaysFocusDefaultItem
*/
virtual void SetDefaultItem(int item, bool always) {}
/*! \brief The default item to focus.
\return the item to focus by default. -1 for none.
\sa SetDefaultItem, AlwaysFocusDefaultItem
*/
virtual int GetDefaultItem() const { return -1; }
/*! \brief Whether to always focus the default item.
\return true if the default item should always be the one to receive focus.
\sa GetDefaultItem, SetDefaultItem
*/
virtual bool AlwaysFocusDefaultItem() const { return false; }
protected:
int m_parentID;
};
|