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