[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / listproviders / IListProvider.h
1 /*
2  *      Copyright (C) 2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #pragma once
22
23 #include <vector>
24 #include "boost/shared_ptr.hpp"
25
26 class TiXmlNode;
27 class CGUIListItem;
28 typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
29
30 /*!
31  \ingroup listproviders
32  \brief An interface for providing lists to UI containers.
33  */
34 class IListProvider
35 {
36 public:
37   IListProvider(int parentID) : m_parentID(parentID) {}
38   virtual ~IListProvider() {}
39
40   /*! \brief Factory to create list providers.
41    \param node a TiXmlNode to create.
42    \param parentID id of parent window for context.
43    \return the list provider, NULL if none.
44    */
45   static IListProvider *Create(const TiXmlNode *node, int parentID);
46
47   /*! \brief Update the list content
48    \return true if the content has changed, false otherwise.
49    */
50   virtual bool Update(bool refresh)=0;
51
52   /*! \brief Fetch the current list of items.
53    \param items [out] the list to be filled.
54    */
55   virtual void Fetch(std::vector<CGUIListItemPtr> &items) const=0;
56
57   /*! \brief Check whether the list provider is updating content.
58    \return true if in the processing of updating, false otherwise.
59    */
60   virtual bool IsUpdating() const { return false; }
61
62   /*! \brief Reset the current list of items.
63    Derived classes may choose to ignore this.
64    */
65   virtual void Reset() {};
66
67   /*! \brief Click event on an item.
68    \param item the item that was clicked.
69    \return true if the click was handled, false otherwise.
70    */
71   virtual bool OnClick(const CGUIListItemPtr &item)=0;
72
73   /*! \brief Set the default item to focus. For backwards compatibility.
74    \param item the item to focus.
75    \param always whether this item should always be used on first focus.
76    \sa GetDefaultItem, AlwaysFocusDefaultItem
77    */
78   virtual void SetDefaultItem(int item, bool always) {};
79
80   /*! \brief The default item to focus.
81    \return the item to focus by default. -1 for none.
82    \sa SetDefaultItem, AlwaysFocusDefaultItem
83    */
84   virtual int GetDefaultItem() const { return -1; }
85
86   /*! \brief Whether to always focus the default item.
87    \return true if the default item should always be the one to receive focus.
88    \sa GetDefaultItem, SetDefaultItem
89    */
90   virtual bool AlwaysFocusDefaultItem() const { return false; }
91 protected:
92   int m_parentID;
93 };