Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
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 <memory>
26#include <utility>
27#include <vector>
28
29
30namespace XBMCAddon
31{
32 namespace xbmcgui
33 {
34 XBMCCOMMONS_STANDARD_EXCEPTION(ListItemException);
35
36 // This is a type that represents either a String or a String Tuple
37 typedef Alternative<StringOrInt,Tuple<String, StringOrInt> > InfoLabelStringOrTuple;
38
39 // This type is either a String or a list of InfoLabelStringOrTuple types
40 typedef Alternative<StringOrInt, std::vector<InfoLabelStringOrTuple> > InfoLabelValue;
41
42 // The type contains the dictionary values for the ListItem::setInfo call.
43 // The values in the dictionary can be either a String, or a list of items.
44 // If it's a list of items then the items can be either a String or a Tuple.
45 typedef Dictionary<InfoLabelValue> InfoLabelDict;
46
47 //
53 class ListItem : public AddonClass
54 {
55 public:
56#if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
57 CFileItemPtr item;
58 bool m_offscreen;
59#endif
60
61#ifdef DOXYGEN_SHOULD_USE_THIS
100 ListItem([label, label2, path, offscreen]);
101#else
102 ListItem(const String& label = emptyString,
103 const String& label2 = emptyString,
104 const String& path = emptyString,
105 bool offscreen = false);
106#endif
107
108#if !defined SWIG && !defined DOXYGEN_SHOULD_SKIP_THIS
109 inline explicit ListItem(CFileItemPtr pitem) : item(std::move(pitem)), m_offscreen(false) {}
110
111 static inline AddonClass::Ref<ListItem> fromString(const String& str)
112 {
113 AddonClass::Ref<ListItem> ret = AddonClass::Ref<ListItem>(new ListItem());
114 ret->item = std::make_shared<CFileItem>(str);
115 return ret;
116 }
117#endif
118
119#ifndef DOXYGEN_SHOULD_SKIP_THIS
120 ~ListItem() override;
121#endif
122
123#ifdef DOXYGEN_SHOULD_USE_THIS
143#else
144 String getLabel();
145#endif
146
147#ifdef DOXYGEN_SHOULD_USE_THIS
167#else
168 String getLabel2();
169#endif
170
171#ifdef DOXYGEN_SHOULD_USE_THIS
191#else
192 void setLabel(const String& label);
193#endif
194
195#ifdef DOXYGEN_SHOULD_USE_THIS
215#else
216 void setLabel2(const String& label);
217#endif
218
219#ifdef DOXYGEN_SHOULD_USE_THIS
240#else
241 String getDateTime();
242#endif
243
244#ifdef DOXYGEN_SHOULD_USE_THIS
275#else
276 void setDateTime(const String& dateTime);
277#endif
278
279#ifdef DOXYGEN_SHOULD_USE_THIS
312 setArt(...);
313#else
314 void setArt(const Properties& dictionary);
315#endif
316
317#ifdef DOXYGEN_SHOULD_USE_THIS
339#else
340 void setIsFolder(bool isFolder);
341#endif
342
343#ifdef DOXYGEN_SHOULD_USE_THIS
374#else
375 void setUniqueIDs(const Properties& dictionary, const String& defaultrating = "");
376#endif
377
378#ifdef DOXYGEN_SHOULD_USE_THIS
410#else
411 void setRating(const std::string& type, float rating, int votes = 0, bool defaultt = false);
412#endif
413
414#ifdef DOXYGEN_SHOULD_USE_THIS
438#else
439 void addSeason(int number, std::string name = "");
440#endif
441
442#ifdef DOXYGEN_SHOULD_USE_THIS
472 getArt(key);
473#else
474 String getArt(const char* key);
475#endif
476
477#ifdef DOXYGEN_SHOULD_USE_THIS
494#else
495 bool isFolder() const;
496#endif
497
498#ifdef DOXYGEN_SHOULD_USE_THIS
526#else
527 String getUniqueID(const char* key);
528#endif
529
530#ifdef DOXYGEN_SHOULD_USE_THIS
558#else
559 float getRating(const char* key);
560#endif
561
562#ifdef DOXYGEN_SHOULD_USE_THIS
590#else
591 int getVotes(const char* key);
592#endif
593
594#ifdef DOXYGEN_SHOULD_USE_THIS
614 select(...);
615#else
616 void select(bool selected);
617#endif
618
619#ifdef DOXYGEN_SHOULD_USE_THIS
640#else
641 bool isSelected();
642#endif
643
644#ifdef DOXYGEN_SHOULD_USE_THIS
795#else
796 void setInfo(const char* type, const InfoLabelDict& infoLabels);
797#endif
798
799#ifdef DOXYGEN_SHOULD_USE_THIS
829#else
830 void setCast(const std::vector<Properties>& actors);
831#endif
832
833#ifdef DOXYGEN_SHOULD_USE_THIS
861#else
862 void setAvailableFanart(const std::vector<Properties>& images);
863#endif
864
865#ifdef DOXYGEN_SHOULD_USE_THIS
894#else
895 void addAvailableArtwork(const std::string& url,
896 const std::string& art_type = "",
897 const std::string& preview = "",
898 const std::string& referrer = "",
899 const std::string& cache = "",
900 bool post = false,
901 bool isgz = false,
902 int season = -1);
903#endif
904
905#ifdef DOXYGEN_SHOULD_USE_THIS
948#else
949 void addStreamInfo(const char* cType, const Properties& dictionary);
950#endif
951
952#ifdef DOXYGEN_SHOULD_USE_THIS
977#else
978 void addContextMenuItems(const std::vector<Tuple<String,String> >& items, bool replaceItems = false);
979#endif
980
981#ifdef DOXYGEN_SHOULD_USE_THIS
1029#else
1030 void setProperty(const char * key, const String& value);
1031#endif
1032
1033#ifdef DOXYGEN_SHOULD_USE_THIS
1053#else
1054 void setProperties(const Properties& dictionary);
1055#endif
1056
1057#ifdef DOXYGEN_SHOULD_USE_THIS
1081#else
1082 String getProperty(const char* key);
1083#endif
1084
1085#ifdef DOXYGEN_SHOULD_USE_THIS
1106#else
1107 void setPath(const String& path);
1108#endif
1109
1110#ifdef DOXYGEN_SHOULD_USE_THIS
1122#else
1123 void setMimeType(const String& mimetype);
1124#endif
1125
1126#ifdef DOXYGEN_SHOULD_USE_THIS
1141#else
1142 void setContentLookup(bool enable);
1143#endif
1144
1145#ifdef DOXYGEN_SHOULD_USE_THIS
1167#else
1168 void setSubtitles(const std::vector<String>& subtitleFiles);
1169#endif
1170
1171#ifdef DOXYGEN_SHOULD_USE_THIS
1185#else
1186 String getPath();
1187#endif
1188
1189#ifdef DOXYGEN_SHOULD_USE_THIS
1202#else
1204#endif
1205
1206#ifdef DOXYGEN_SHOULD_USE_THIS
1219#else
1221#endif
1222
1223#ifdef DOXYGEN_SHOULD_USE_THIS
1236#else
1238#endif
1239
1240#ifdef DOXYGEN_SHOULD_USE_THIS
1253#else
1255#endif
1256
1257private:
1258 std::vector<std::string> getStringArray(const InfoLabelValue& alt,
1259 const std::string& tag,
1260 std::string value,
1261 const std::string& separator);
1262 std::vector<std::string> getVideoStringArray(const InfoLabelValue& alt,
1263 const std::string& tag,
1264 std::string value = "");
1265 std::vector<std::string> getMusicStringArray(const InfoLabelValue& alt,
1266 const std::string& tag,
1267 std::string value = "");
1268
1269 CVideoInfoTag* GetVideoInfoTag();
1270 const CVideoInfoTag* GetVideoInfoTag() const;
1271
1272 MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag();
1273 const MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag() const;
1274
1275 void setTitleRaw(std::string title);
1276 void setPathRaw(const std::string& path);
1277 void setCountRaw(int count);
1278 void setSizeRaw(int64_t size);
1279 void setDateTimeRaw(const std::string& dateTime);
1280 void setIsFolderRaw(bool isFolder);
1281 void setStartOffsetRaw(double startOffset);
1282 void setMimeTypeRaw(const std::string& mimetype);
1283 void setSpecialSortRaw(std::string specialSort);
1284 void setContentLookupRaw(bool enable);
1285 void addArtRaw(std::string type, const std::string& url);
1286 void addPropertyRaw(std::string type, const CVariant& value);
1287 void addSubtitlesRaw(const std::vector<std::string>& subtitles);
1288 };
1289
1290#ifndef DOXYGEN_SHOULD_SKIP_THIS
1291 typedef std::vector<ListItem*> ListItemList;
1292#endif
1293 }
1294}
Definition InfoTagGame.h:49
Definition InfoTagMusic.h:48
Definition InfoTagPicture.h:44
Definition InfoTagVideo.h:859
Definition ListItem.h:54
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...