Kodi Development  19.0
for Binary and Script based Add-Ons
ListItem.h
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 "AddonClass.h"
12 #include "AddonString.h"
13 #include "Alternative.h"
14 #include "Dictionary.h"
15 #include "FileItem.h"
16 #include "InfoTagMusic.h"
17 #include "InfoTagVideo.h"
18 #include "ListItem.h"
19 #include "Tuple.h"
20 #include "commons/Exception.h"
21 
22 #include <map>
23 #include <vector>
24 
25 
26 namespace XBMCAddon
27 {
28  namespace xbmcgui
29  {
30  XBMCCOMMONS_STANDARD_EXCEPTION(ListItemException);
31 
32  // This is a type that represents either a String or a String Tuple
33  typedef Alternative<StringOrInt,Tuple<String, StringOrInt> > InfoLabelStringOrTuple;
34 
35  // This type is either a String or a list of InfoLabelStringOrTuple types
36  typedef Alternative<StringOrInt, std::vector<InfoLabelStringOrTuple> > InfoLabelValue;
37 
38  // The type contains the dictionary values for the ListItem::setInfo call.
39  // The values in the dictionary can be either a String, or a list of items.
40  // If it's a list of items then the items can be either a String or a Tuple.
41  typedef Dictionary<InfoLabelValue> InfoLabelDict;
42 
43  //
68  class ListItem : public AddonClass
69  {
70  public:
71 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
72  CFileItemPtr item;
73  bool m_offscreen;
74 #endif
75 
76  ListItem(const String& label = emptyString,
77  const String& label2 = emptyString,
78  const String& path = emptyString,
79  bool offscreen = false);
80 
81 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
82  inline explicit ListItem(CFileItemPtr pitem) :
83  item(pitem), m_offscreen(false)
84  {}
85 
86  static inline AddonClass::Ref<ListItem> fromString(const String& str)
87  {
88  AddonClass::Ref<ListItem> ret = AddonClass::Ref<ListItem>(new ListItem());
89  ret->item.reset(new CFileItem(str));
90  return ret;
91  }
92 #endif
93 
94  ~ListItem() override;
95 
96 #ifdef DOXYGEN_SHOULD_USE_THIS
97  getLabel();
116 #else
117  String getLabel();
118 #endif
119 
120 #ifdef DOXYGEN_SHOULD_USE_THIS
121  getLabel2();
140 #else
141  String getLabel2();
142 #endif
143 
144 #ifdef DOXYGEN_SHOULD_USE_THIS
145  setLabel(...);
164 #else
165  void setLabel(const String& label);
166 #endif
167 
168 #ifdef DOXYGEN_SHOULD_USE_THIS
169  setLabel2(...);
188 #else
189  void setLabel2(const String& label);
190 #endif
191 
192 #ifdef DOXYGEN_SHOULD_USE_THIS
193  setArt(...);
226 #else
227  void setArt(const Properties& dictionary);
228 #endif
229 
230 #ifdef DOXYGEN_SHOULD_USE_THIS
231  setIsFolder(...);
252 #else
253  void setIsFolder(bool isFolder);
254 #endif
255 
256 #ifdef DOXYGEN_SHOULD_USE_THIS
257  setUniqueIDs(...);
286 #else
287  void setUniqueIDs(const Properties& dictionary, const String& defaultrating = "");
288 #endif
289 
290 #ifdef DOXYGEN_SHOULD_USE_THIS
291  setRating(...);
321 #else
322  void setRating(std::string type, float rating, int votes = 0, bool defaultt = false);
323 #endif
324 
325 #ifdef DOXYGEN_SHOULD_USE_THIS
326  addSeason(...);
348 #else
349  void addSeason(int number, std::string name = "");
350 #endif
351 
352 #ifdef DOXYGEN_SHOULD_USE_THIS
353  getArt(key);
383 #else
384  String getArt(const char* key);
385 #endif
386 
387 #ifdef DOXYGEN_SHOULD_USE_THIS
388  getUniqueID(key);
414 #else
415  String getUniqueID(const char* key);
416 #endif
417 
418 #ifdef DOXYGEN_SHOULD_USE_THIS
419  getRating(key);
445 #else
446  float getRating(const char* key);
447 #endif
448 
449 #ifdef DOXYGEN_SHOULD_USE_THIS
450  getVotes(key);
476 #else
477  int getVotes(const char* key);
478 #endif
479 
480 #ifdef DOXYGEN_SHOULD_USE_THIS
481  select(...);
501 #else
502  void select(bool selected);
503 #endif
504 
505 #ifdef DOXYGEN_SHOULD_USE_THIS
506  isSelected();
526 #else
527  bool isSelected();
528 #endif
529 
530 #ifdef DOXYGEN_SHOULD_USE_THIS
531  setInfo(...);
678 #else
679  void setInfo(const char* type, const InfoLabelDict& infoLabels);
680 #endif
681 
682 #ifdef DOXYGEN_SHOULD_USE_THIS
683  setCast(...);
711 #else
712  void setCast(const std::vector<Properties>& actors);
713 #endif
714 
715 #ifdef DOXYGEN_SHOULD_USE_THIS
716  setAvailableFanart(...);
743 #else
744  void setAvailableFanart(const std::vector<Properties>& images);
745 #endif
746 
747 #ifdef DOXYGEN_SHOULD_USE_THIS
748  addAvailableArtwork(...);
775 #else
776  void addAvailableArtwork(std::string url, std::string art_type = "", std::string preview = "", std::string referrer = "", std::string cache = "", bool post = false, bool isgz = false, int season = -1);
777 #endif
778 
779 #ifdef DOXYGEN_SHOULD_USE_THIS
780  addStreamInfo(...);
821 #else
822  void addStreamInfo(const char* cType, const Properties& dictionary);
823 #endif
824 
825 #ifdef DOXYGEN_SHOULD_USE_THIS
826  addContextMenuItems(...);
850 #else
851  void addContextMenuItems(const std::vector<Tuple<String,String> >& items, bool replaceItems = false);
852 #endif
853 
854 #ifdef DOXYGEN_SHOULD_USE_THIS
855  setProperty(...);
895 #else
896  void setProperty(const char * key, const String& value);
897 #endif
898 
899 #ifdef DOXYGEN_SHOULD_USE_THIS
900  setProperties(...);
919 #else
920  void setProperties(const Properties& dictionary);
921 #endif
922 
923 #ifdef DOXYGEN_SHOULD_USE_THIS
924  getProperty(...);
946 #else
947  String getProperty(const char* key);
948 #endif
949 
950 #ifdef DOXYGEN_SHOULD_USE_THIS
951  setPath(...);
971 #else
972  void setPath(const String& path);
973 #endif
974 
975 #ifdef DOXYGEN_SHOULD_USE_THIS
976  setMimeType(...);
987 #else
988  void setMimeType(const String& mimetype);
989 #endif
990 
991 #ifdef DOXYGEN_SHOULD_USE_THIS
992  setContentLookup(...);
1006 #else
1007  void setContentLookup(bool enable);
1008 #endif
1009 
1010 #ifdef DOXYGEN_SHOULD_USE_THIS
1011  setSubtitles(...);
1032 #else
1033  void setSubtitles(const std::vector<String>& subtitleFiles);
1034 #endif
1035 
1036 #ifdef DOXYGEN_SHOULD_USE_THIS
1037  getPath();
1050 #else
1051  String getPath();
1052 #endif
1053 
1054 #ifdef DOXYGEN_SHOULD_USE_THIS
1055  getVideoInfoTag();
1067 #else
1069 #endif
1070 
1071 #ifdef DOXYGEN_SHOULD_USE_THIS
1072  getMusicInfoTag();
1084 #else
1086 #endif
1087 
1088 private:
1089  std::vector<std::string> getStringArray(const InfoLabelValue& alt, const std::string& tag, std::string value = "");
1090 
1091  CVideoInfoTag* GetVideoInfoTag();
1092  const CVideoInfoTag* GetVideoInfoTag() const;
1093  };
1094 
1095 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1096  typedef std::vector<ListItem*> ListItemList;
1097 #endif
1098  }
1099 }
1100 
1101 
XBMCAddon::xbmcgui::ListItem::getArt
getArt(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setMimeType
setMimeType(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setAvailableFanart
setAvailableFanart(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getLabel
getLabel()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::addAvailableArtwork
addAvailableArtwork(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getRating
getRating(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getVotes
getVotes(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getProperty
getProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::addContextMenuItems
addContextMenuItems(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setCast
setCast(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setPath
setPath(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setSubtitles
setSubtitles(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setLabel
setLabel(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::addStreamInfo
addStreamInfo(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmc::InfoTagMusic
Definition: InfoTagMusic.h:44
XBMCAddon::xbmcgui::ListItem::setLabel2
setLabel2(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setContentLookup
setContentLookup(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem
Definition: ListItem.h:69
XBMCAddon::xbmcgui::ListItem::setProperty
setProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setUniqueIDs
setUniqueIDs(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setRating
setRating(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::select
select(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getUniqueID
getUniqueID(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setIsFolder
setIsFolder(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setArt
setArt(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getMusicInfoTag
getMusicInfoTag()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setInfo
setInfo(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getVideoInfoTag
getVideoInfoTag()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::isSelected
isSelected()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::setProperties
setProperties(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::getPath
getPath()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::ListItem::addSeason
addSeason(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmc::InfoTagVideo
Definition: InfoTagVideo.h:45
XBMCAddon::xbmcgui::ListItem::getLabel2
getLabel2()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...