Kodi Development  20.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 "InfoTagGame.h"
17 #include "InfoTagMusic.h"
18 #include "InfoTagPicture.h"
19 #include "InfoTagVideo.h"
20 #include "ListItem.h"
21 #include "Tuple.h"
22 #include "commons/Exception.h"
23 
24 #include <map>
25 #include <utility>
26 #include <vector>
27 
28 
29 namespace XBMCAddon
30 {
31  namespace xbmcgui
32  {
33  XBMCCOMMONS_STANDARD_EXCEPTION(ListItemException);
34 
35  // This is a type that represents either a String or a String Tuple
36  typedef Alternative<StringOrInt,Tuple<String, StringOrInt> > InfoLabelStringOrTuple;
37 
38  // This type is either a String or a list of InfoLabelStringOrTuple types
39  typedef Alternative<StringOrInt, std::vector<InfoLabelStringOrTuple> > InfoLabelValue;
40 
41  // The type contains the dictionary values for the ListItem::setInfo call.
42  // The values in the dictionary can be either a String, or a list of items.
43  // If it's a list of items then the items can be either a String or a Tuple.
44  typedef Dictionary<InfoLabelValue> InfoLabelDict;
45 
46  //
52  class ListItem : public AddonClass
53  {
54  public:
55 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
56  CFileItemPtr item;
57  bool m_offscreen;
58 #endif
59 
60 #ifdef DOXYGEN_SHOULD_USE_THIS
99  ListItem([label, label2, path, offscreen]);
100 #else
101  ListItem(const String& label = emptyString,
102  const String& label2 = emptyString,
103  const String& path = emptyString,
104  bool offscreen = false);
105 #endif
106 
107 #if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
108  inline explicit ListItem(CFileItemPtr pitem) : item(std::move(pitem)), m_offscreen(false) {}
109 
110  static inline AddonClass::Ref<ListItem> fromString(const String& str)
111  {
112  AddonClass::Ref<ListItem> ret = AddonClass::Ref<ListItem>(new ListItem());
113  ret->item.reset(new CFileItem(str));
114  return ret;
115  }
116 #endif
117 
118 #ifndef DOXYGEN_SHOULD_SKIP_THIS
119  ~ListItem() override;
120 #endif
121 
122 #ifdef DOXYGEN_SHOULD_USE_THIS
142 #else
143  String getLabel();
144 #endif
145 
146 #ifdef DOXYGEN_SHOULD_USE_THIS
166 #else
167  String getLabel2();
168 #endif
169 
170 #ifdef DOXYGEN_SHOULD_USE_THIS
189  setLabel(...);
190 #else
191  void setLabel(const String& label);
192 #endif
193 
194 #ifdef DOXYGEN_SHOULD_USE_THIS
213  setLabel2(...);
214 #else
215  void setLabel2(const String& label);
216 #endif
217 
218 #ifdef DOXYGEN_SHOULD_USE_THIS
239 #else
240  String getDateTime();
241 #endif
242 
243 #ifdef DOXYGEN_SHOULD_USE_THIS
274 #else
275  void setDateTime(const String& dateTime);
276 #endif
277 
278 #ifdef DOXYGEN_SHOULD_USE_THIS
311  setArt(...);
312 #else
313  void setArt(const Properties& dictionary);
314 #endif
315 
316 #ifdef DOXYGEN_SHOULD_USE_THIS
338 #else
339  void setIsFolder(bool isFolder);
340 #endif
341 
342 #ifdef DOXYGEN_SHOULD_USE_THIS
373 #else
374  void setUniqueIDs(const Properties& dictionary, const String& defaultrating = "");
375 #endif
376 
377 #ifdef DOXYGEN_SHOULD_USE_THIS
408  setRating(...);
409 #else
410  void setRating(const std::string& type, float rating, int votes = 0, bool defaultt = false);
411 #endif
412 
413 #ifdef DOXYGEN_SHOULD_USE_THIS
436  addSeason(...);
437 #else
438  void addSeason(int number, std::string name = "");
439 #endif
440 
441 #ifdef DOXYGEN_SHOULD_USE_THIS
471  getArt(key);
472 #else
473  String getArt(const char* key);
474 #endif
475 
476 #ifdef DOXYGEN_SHOULD_USE_THIS
493 #else
494  bool isFolder() const;
495 #endif
496 
497 #ifdef DOXYGEN_SHOULD_USE_THIS
525 #else
526  String getUniqueID(const char* key);
527 #endif
528 
529 #ifdef DOXYGEN_SHOULD_USE_THIS
556  getRating(key);
557 #else
558  float getRating(const char* key);
559 #endif
560 
561 #ifdef DOXYGEN_SHOULD_USE_THIS
588  getVotes(key);
589 #else
590  int getVotes(const char* key);
591 #endif
592 
593 #ifdef DOXYGEN_SHOULD_USE_THIS
613  select(...);
614 #else
615  void select(bool selected);
616 #endif
617 
618 #ifdef DOXYGEN_SHOULD_USE_THIS
639 #else
640  bool isSelected();
641 #endif
642 
643 #ifdef DOXYGEN_SHOULD_USE_THIS
791  setInfo(...);
792 #else
793  void setInfo(const char* type, const InfoLabelDict& infoLabels);
794 #endif
795 
796 #ifdef DOXYGEN_SHOULD_USE_THIS
825  setCast(...);
826 #else
827  void setCast(const std::vector<Properties>& actors);
828 #endif
829 
830 #ifdef DOXYGEN_SHOULD_USE_THIS
858 #else
859  void setAvailableFanart(const std::vector<Properties>& images);
860 #endif
861 
862 #ifdef DOXYGEN_SHOULD_USE_THIS
891 #else
892  void addAvailableArtwork(const std::string& url,
893  const std::string& art_type = "",
894  const std::string& preview = "",
895  const std::string& referrer = "",
896  const std::string& cache = "",
897  bool post = false,
898  bool isgz = false,
899  int season = -1);
900 #endif
901 
902 #ifdef DOXYGEN_SHOULD_USE_THIS
945 #else
946  void addStreamInfo(const char* cType, const Properties& dictionary);
947 #endif
948 
949 #ifdef DOXYGEN_SHOULD_USE_THIS
974 #else
975  void addContextMenuItems(const std::vector<Tuple<String,String> >& items, bool replaceItems = false);
976 #endif
977 
978 #ifdef DOXYGEN_SHOULD_USE_THIS
1024 #else
1025  void setProperty(const char * key, const String& value);
1026 #endif
1027 
1028 #ifdef DOXYGEN_SHOULD_USE_THIS
1048 #else
1049  void setProperties(const Properties& dictionary);
1050 #endif
1051 
1052 #ifdef DOXYGEN_SHOULD_USE_THIS
1076 #else
1077  String getProperty(const char* key);
1078 #endif
1079 
1080 #ifdef DOXYGEN_SHOULD_USE_THIS
1100  setPath(...);
1101 #else
1102  void setPath(const String& path);
1103 #endif
1104 
1105 #ifdef DOXYGEN_SHOULD_USE_THIS
1117 #else
1118  void setMimeType(const String& mimetype);
1119 #endif
1120 
1121 #ifdef DOXYGEN_SHOULD_USE_THIS
1136 #else
1137  void setContentLookup(bool enable);
1138 #endif
1139 
1140 #ifdef DOXYGEN_SHOULD_USE_THIS
1162 #else
1163  void setSubtitles(const std::vector<String>& subtitleFiles);
1164 #endif
1165 
1166 #ifdef DOXYGEN_SHOULD_USE_THIS
1180 #else
1181  String getPath();
1182 #endif
1183 
1184 #ifdef DOXYGEN_SHOULD_USE_THIS
1197 #else
1199 #endif
1200 
1201 #ifdef DOXYGEN_SHOULD_USE_THIS
1214 #else
1216 #endif
1217 
1218 #ifdef DOXYGEN_SHOULD_USE_THIS
1231 #else
1233 #endif
1234 
1235 #ifdef DOXYGEN_SHOULD_USE_THIS
1248 #else
1250 #endif
1251 
1252 private:
1253  std::vector<std::string> getStringArray(const InfoLabelValue& alt,
1254  const std::string& tag,
1255  std::string value,
1256  const std::string& separator);
1257  std::vector<std::string> getVideoStringArray(const InfoLabelValue& alt,
1258  const std::string& tag,
1259  std::string value = "");
1260  std::vector<std::string> getMusicStringArray(const InfoLabelValue& alt,
1261  const std::string& tag,
1262  std::string value = "");
1263 
1264  CVideoInfoTag* GetVideoInfoTag();
1265  const CVideoInfoTag* GetVideoInfoTag() const;
1266 
1267  MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag();
1268  const MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag() const;
1269 
1270  void setTitleRaw(std::string title);
1271  void setPathRaw(const std::string& path);
1272  void setCountRaw(int count);
1273  void setSizeRaw(int64_t size);
1274  void setDateTimeRaw(const std::string& dateTime);
1275  void setIsFolderRaw(bool isFolder);
1276  void setStartOffsetRaw(double startOffset);
1277  void setMimeTypeRaw(const std::string& mimetype);
1278  void setSpecialSortRaw(std::string specialSort);
1279  void setContentLookupRaw(bool enable);
1280  void addArtRaw(std::string type, const std::string& url);
1281  void addPropertyRaw(std::string type, const CVariant& value);
1282  void addSubtitlesRaw(const std::vector<std::string>& subtitles);
1283  };
1284 
1285 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1286  typedef std::vector<ListItem*> ListItemList;
1287 #endif
1288  }
1289 }
Definition: InfoTagGame.h:49
Definition: InfoTagMusic.h:48
Definition: InfoTagPicture.h:44
Definition: InfoTagVideo.h:815
Definition: ListItem.h:53
setLabel(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setRating(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getRating(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setInfo(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getUniqueID(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
addContextMenuItems(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getLabel()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getArt(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getVideoInfoTag()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setSubtitles(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getPictureInfoTag()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
isSelected()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setProperties(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setIsFolder(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setAvailableFanart(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getPath()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getMusicInfoTag()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
addSeason(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setDateTime(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setUniqueIDs(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getGameInfoTag()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
select(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getDateTime()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getLabel2()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getVotes(key)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setLabel2(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setArt(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
addStreamInfo(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
ListItem([label, label2, path, offscreen])
Selectable window list item.
setContentLookup(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
addAvailableArtwork(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setCast(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
isFolder()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setMimeType(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setPath(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...