summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h345
1 files changed, 345 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h
new file mode 100644
index 0000000..3a4d50b
--- /dev/null
+++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/ListItem.h
@@ -0,0 +1,345 @@
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 "../AddonBase.h"
12#include "../c-api/gui/list_item.h"
13
14#ifdef __cplusplus
15
16#include <memory>
17
18namespace kodi
19{
20namespace gui
21{
22
23class CWindow;
24
25class ATTRIBUTE_HIDDEN CAddonGUIControlBase
26{
27public:
28 KODI_GUI_LISTITEM_HANDLE GetControlHandle() const { return m_controlHandle; }
29
30protected:
31 explicit CAddonGUIControlBase(CAddonGUIControlBase* window)
32 : m_controlHandle(nullptr),
33 m_interface(::kodi::addon::CAddonBase::m_interface->toKodi),
34 m_Window(window)
35 {
36 }
37
38 virtual ~CAddonGUIControlBase() = default;
39
40 friend class CWindow;
41
42 KODI_GUI_LISTITEM_HANDLE m_controlHandle;
43 AddonToKodiFuncTable_Addon* m_interface;
44 CAddonGUIControlBase* m_Window;
45
46private:
47 CAddonGUIControlBase() = delete;
48 CAddonGUIControlBase(const CAddonGUIControlBase&) = delete;
49 CAddonGUIControlBase& operator=(const CAddonGUIControlBase&) = delete;
50};
51
52class CListItem;
53
54//==============================================================================
55/// @addtogroup cpp_kodi_gui_windows_listitem
56/// @brief @cpp_class{ kodi::gui::CListItem }
57/// **Selectable window list item**\n
58/// The list item control is used for creating item lists in Kodi.
59///
60/// The with @ref ListItem.h "#include <kodi/gui/ListItem.h>" given
61/// class is used to create a item entry for a list on window and to support it's
62/// control.
63///
64class ATTRIBUTE_HIDDEN CListItem : public CAddonGUIControlBase
65{
66public:
67 //============================================================================
68 /// @ingroup cpp_kodi_gui_windows_listitem
69 /// @brief Class constructor with parameters.
70 ///
71 /// @param[in] label [opt] Item label
72 /// @param[in] label2 [opt] Second Item label (if needed)
73 /// @param[in] path [opt] Path to where item is defined
74 ///
75 CListItem(const std::string& label = "",
76 const std::string& label2 = "",
77 const std::string& path = "")
78 : CAddonGUIControlBase(nullptr)
79 {
80 m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(),
81 label2.c_str(), path.c_str());
82 }
83
84 /*
85 * Constructor used for parts given by list items from addon window
86 *
87 * Related to call of "std::shared_ptr<CListItem> kodi::gui::CWindow::GetListItem(int listPos)"
88 * Not needed for addon development itself
89 */
90 explicit CListItem(KODI_GUI_LISTITEM_HANDLE listItemHandle) : CAddonGUIControlBase(nullptr)
91 {
92 m_controlHandle = listItemHandle;
93 }
94
95 //============================================================================
96 /// @ingroup cpp_kodi_gui_windows_listitem
97 /// @brief Class destructor
98 ///
99 ~CListItem() override
100 {
101 m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle);
102 }
103 //----------------------------------------------------------------------------
104
105 //============================================================================
106 /// @ingroup cpp_kodi_gui_windows_listitem
107 /// @brief Returns the listitem label.
108 ///
109 /// @return Label of item
110 ///
111 std::string GetLabel()
112 {
113 std::string label;
114 char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle);
115 if (ret != nullptr)
116 {
117 if (std::strlen(ret))
118 label = ret;
119 m_interface->free_string(m_interface->kodiBase, ret);
120 }
121 return label;
122 }
123 //----------------------------------------------------------------------------
124
125 //============================================================================
126 /// @ingroup cpp_kodi_gui_windows_listitem
127 /// @brief Sets the listitem label.
128 ///
129 /// @param[in] label string or unicode - text string.
130 ///
131 void SetLabel(const std::string& label)
132 {
133 m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle,
134 label.c_str());
135 }
136 //----------------------------------------------------------------------------
137
138 //============================================================================
139 /// @ingroup cpp_kodi_gui_windows_listitem
140 /// @brief Returns the second listitem label.
141 ///
142 /// @return Second label of item
143 ///
144 std::string GetLabel2()
145 {
146 std::string label;
147 char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle);
148 if (ret != nullptr)
149 {
150 if (std::strlen(ret))
151 label = ret;
152 m_interface->free_string(m_interface->kodiBase, ret);
153 }
154 return label;
155 }
156 //----------------------------------------------------------------------------
157
158 //============================================================================
159 /// @ingroup cpp_kodi_gui_windows_listitem
160 /// @brief Sets the listitem's label2.
161 ///
162 /// @param[in] label string or unicode - text string.
163 ///
164 void SetLabel2(const std::string& label)
165 {
166 m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle,
167 label.c_str());
168 }
169 //----------------------------------------------------------------------------
170
171 //============================================================================
172 /// @ingroup cpp_kodi_gui_windows_listitem
173 /// @brief Sets the listitem's art
174 ///
175 /// @param[in] type Type of Art to set
176 /// - Some default art values (any string possible):
177 /// | value (type) | Type |
178 /// |:-------------:|:--------------------------------------------------|
179 /// | thumb | string - image filename
180 /// | poster | string - image filename
181 /// | banner | string - image filename
182 /// | fanart | string - image filename
183 /// | clearart | string - image filename
184 /// | clearlogo | string - image filename
185 /// | landscape | string - image filename
186 /// | icon | string - image filename
187 /// @return The url to use for Art
188 ///
189 std::string GetArt(const std::string& type)
190 {
191 std::string strReturn;
192 char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle,
193 type.c_str());
194 if (ret != nullptr)
195 {
196 if (std::strlen(ret))
197 strReturn = ret;
198 m_interface->free_string(m_interface->kodiBase, ret);
199 }
200 return strReturn;
201 }
202 //----------------------------------------------------------------------------
203
204 //============================================================================
205 /// @ingroup cpp_kodi_gui_windows_listitem
206 /// @brief Sets the listitem's art
207 ///
208 /// @param[in] type Type of Art to set
209 /// @param[in] url The url to use for Art
210 /// - Some default art values (any string possible):
211 /// | value (type) | Type |
212 /// |:-------------:|:--------------------------------------------------|
213 /// | thumb | string - image filename
214 /// | poster | string - image filename
215 /// | banner | string - image filename
216 /// | fanart | string - image filename
217 /// | clearart | string - image filename
218 /// | clearlogo | string - image filename
219 /// | landscape | string - image filename
220 /// | icon | string - image filename
221 ///
222 void SetArt(const std::string& type, const std::string& url)
223 {
224 m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(),
225 url.c_str());
226 }
227 //----------------------------------------------------------------------------
228
229 //============================================================================
230 /// @ingroup cpp_kodi_gui_windows_listitem
231 /// @brief Returns the path / filename of this listitem.
232 ///
233 /// @return Path string
234 ///
235 std::string GetPath()
236 {
237 std::string strReturn;
238 char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle);
239 if (ret != nullptr)
240 {
241 if (std::strlen(ret))
242 strReturn = ret;
243 m_interface->free_string(m_interface->kodiBase, ret);
244 }
245 return strReturn;
246 }
247 //----------------------------------------------------------------------------
248
249 //============================================================================
250 /// @ingroup cpp_kodi_gui_windows_listitem
251 /// @brief Sets the listitem's path.
252 ///
253 /// @param[in] path string or unicode - path, activated when item is clicked.
254 ///
255 /// @note You can use the above as keywords for arguments.
256 ///
257 void SetPath(const std::string& path)
258 {
259 m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str());
260 }
261 //----------------------------------------------------------------------------
262
263 //============================================================================
264 /// @ingroup cpp_kodi_gui_windows_listitem
265 /// @brief Sets a listitem property, similar to an infolabel.
266 ///
267 /// @param[in] key string - property name.
268 /// @param[in] value string or unicode - value of property.
269 ///
270 /// @note Key is NOT case sensitive.
271 /// You can use the above as keywords for arguments and skip certain@n
272 /// optional arguments.\n
273 /// Once you use a keyword, all following arguments require the
274 /// keyword.
275 ///
276 /// Some of these are treated internally by Kodi, such as the
277 /// <b>'StartOffset'</b> property, which is the offset in seconds at which to
278 /// start playback of an item. Others may be used in the skin to add
279 /// extra information, such as <b>'WatchedCount'</b> for tvshow items
280 ///
281 void SetProperty(const std::string& key, const std::string& value)
282 {
283 m_interface->kodi_gui->listItem->set_property(m_interface->kodiBase, m_controlHandle,
284 key.c_str(), value.c_str());
285 }
286 //----------------------------------------------------------------------------
287
288 //============================================================================
289 /// @ingroup cpp_kodi_gui_windows_listitem
290 /// @brief Returns a listitem property as a string, similar to an infolabel.
291 ///
292 /// @param[in] key string - property name.
293 /// @return string - List item property
294 ///
295 /// @note Key is NOT case sensitive.\n
296 /// You can use the above as keywords for arguments and skip certain
297 /// optional arguments.\n
298 /// Once you use a keyword, all following arguments require the
299 /// keyword.
300 ///
301 std::string GetProperty(const std::string& key)
302 {
303 std::string label;
304 char* ret = m_interface->kodi_gui->listItem->get_property(m_interface->kodiBase,
305 m_controlHandle, key.c_str());
306 if (ret != nullptr)
307 {
308 if (std::strlen(ret))
309 label = ret;
310 m_interface->free_string(m_interface->kodiBase, ret);
311 }
312 return label;
313 }
314 //----------------------------------------------------------------------------
315
316 //============================================================================
317 /// @ingroup cpp_kodi_gui_windows_listitem
318 /// @brief To control selection of item in list (also multiple selection,
319 /// in list on serveral items possible).
320 ///
321 /// @param[in] selected if true becomes set as selected
322 ///
323 void Select(bool selected)
324 {
325 m_interface->kodi_gui->listItem->select(m_interface->kodiBase, m_controlHandle, selected);
326 }
327 //----------------------------------------------------------------------------
328
329 //============================================================================
330 /// @ingroup cpp_kodi_gui_windows_listitem
331 /// @brief Returns the listitem's selected status.
332 ///
333 /// @return true if selected, otherwise false
334 ///
335 bool IsSelected()
336 {
337 return m_interface->kodi_gui->listItem->is_selected(m_interface->kodiBase, m_controlHandle);
338 }
339 //----------------------------------------------------------------------------
340};
341
342} /* namespace gui */
343} /* namespace kodi */
344
345#endif /* __cplusplus */