kodi
StaticProvider.h
1 /*
2  * Copyright (C) 2013-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 "IListProvider.h"
12 #include "guilib/GUIStaticItem.h"
13 
14 #include <vector>
15 
17 {
18 public:
19  CStaticListProvider(const TiXmlElement *element, int parentID);
20  explicit CStaticListProvider(const std::vector<CGUIStaticItemPtr> &items); // for python
21  explicit CStaticListProvider(const CStaticListProvider& other);
22  ~CStaticListProvider() override;
23 
24  // Implementation of IListProvider
25  std::unique_ptr<IListProvider> Clone() override;
26  bool Update(bool forceRefresh) override;
27  void Fetch(std::vector<std::shared_ptr<CGUIListItem>>& items) override;
28  bool OnClick(const std::shared_ptr<CGUIListItem>& item) override;
29  bool OnInfo(const std::shared_ptr<CGUIListItem>& item) override { return false; }
30  bool OnContextMenu(const std::shared_ptr<CGUIListItem>& item) override { return false; }
31  void SetDefaultItem(int item, bool always) override;
32  int GetDefaultItem() const override;
33  bool AlwaysFocusDefaultItem() const override;
34 private:
35  int m_defaultItem;
36  bool m_defaultAlways;
37  unsigned int m_updateTime;
38  std::vector<CGUIStaticItemPtr> m_items;
39 };
An interface for providing lists to UI containers.
Definition: IListProvider.h:21
bool OnClick(const std::shared_ptr< CGUIListItem > &item) override
Click event on an item.
Definition: StaticProvider.cpp:133
bool OnInfo(const std::shared_ptr< CGUIListItem > &item) override
Open the info dialog for an item provided by this IListProvider.
Definition: StaticProvider.h:29
void Fetch(std::vector< std::shared_ptr< CGUIListItem >> &items) override
Fetch the current list of items.
Definition: StaticProvider.cpp:94
bool Update(bool forceRefresh) override
Update the list content.
Definition: StaticProvider.cpp:78
bool OnContextMenu(const std::shared_ptr< CGUIListItem > &item) override
Open the context menu for an item provided by this IListProvider.
Definition: StaticProvider.h:30
Definition: StaticProvider.h:16
int GetDefaultItem() const override
The default item to focus.
Definition: StaticProvider.cpp:110
bool AlwaysFocusDefaultItem() const override
Whether to always focus the default item.
Definition: StaticProvider.cpp:128
std::unique_ptr< IListProvider > Clone() override
Create an instance of the derived class. Allows for polymorphic copies.
Definition: StaticProvider.cpp:73
void SetDefaultItem(int item, bool always) override
Set the default item to focus. For backwards compatibility.
Definition: StaticProvider.cpp:104