summaryrefslogtreecommitdiffstats
path: root/xbmc/listproviders/IListProvider.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/listproviders/IListProvider.h
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/listproviders/IListProvider.h')
-rw-r--r--xbmc/listproviders/IListProvider.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/xbmc/listproviders/IListProvider.h b/xbmc/listproviders/IListProvider.h
new file mode 100644
index 0000000..fea2860
--- /dev/null
+++ b/xbmc/listproviders/IListProvider.h
@@ -0,0 +1,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;
+};