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
862#else
863 void setAvailableFanart(const std::vector<Properties>& images);
864#endif
865
866#ifdef DOXYGEN_SHOULD_USE_THIS
895#else
896 void addAvailableArtwork(const std::string& url,
897 const std::string& art_type = "",
898 const std::string& preview = "",
899 const std::string& referrer = "",
900 const std::string& cache = "",
901 bool post = false,
902 bool isgz = false,
903 int season = -1);
904#endif
905
906#ifdef DOXYGEN_SHOULD_USE_THIS
949#else
950 void addStreamInfo(const char* cType, const Properties& dictionary);
951#endif
952
953#ifdef DOXYGEN_SHOULD_USE_THIS
978#else
979 void addContextMenuItems(const std::vector<Tuple<String,String> >& items, bool replaceItems = false);
980#endif
981
982#ifdef DOXYGEN_SHOULD_USE_THIS
1030#else
1031 void setProperty(const char * key, const String& value);
1032#endif
1033
1034#ifdef DOXYGEN_SHOULD_USE_THIS
1054#else
1055 void setProperties(const Properties& dictionary);
1056#endif
1057
1058#ifdef DOXYGEN_SHOULD_USE_THIS
1082#else
1083 String getProperty(const char* key);
1084#endif
1085
1086#ifdef DOXYGEN_SHOULD_USE_THIS
1107#else
1108 void setPath(const String& path);
1109#endif
1110
1111#ifdef DOXYGEN_SHOULD_USE_THIS
1123#else
1124 void setMimeType(const String& mimetype);
1125#endif
1126
1127#ifdef DOXYGEN_SHOULD_USE_THIS
1142#else
1143 void setContentLookup(bool enable);
1144#endif
1145
1146#ifdef DOXYGEN_SHOULD_USE_THIS
1168#else
1169 void setSubtitles(const std::vector<String>& subtitleFiles);
1170#endif
1171
1172#ifdef DOXYGEN_SHOULD_USE_THIS
1186#else
1187 String getPath();
1188#endif
1189
1190#ifdef DOXYGEN_SHOULD_USE_THIS
1203#else
1205#endif
1206
1207#ifdef DOXYGEN_SHOULD_USE_THIS
1220#else
1222#endif
1223
1224#ifdef DOXYGEN_SHOULD_USE_THIS
1237#else
1239#endif
1240
1241#ifdef DOXYGEN_SHOULD_USE_THIS
1254#else
1256#endif
1257
1258private:
1259 std::vector<std::string> getStringArray(const InfoLabelValue& alt,
1260 const std::string& tag,
1261 std::string value,
1262 const std::string& separator);
1263 std::vector<std::string> getVideoStringArray(const InfoLabelValue& alt,
1264 const std::string& tag,
1265 std::string value = "");
1266 std::vector<std::string> getMusicStringArray(const InfoLabelValue& alt,
1267 const std::string& tag,
1268 std::string value = "");
1269
1270 CVideoInfoTag* GetVideoInfoTag();
1271 const CVideoInfoTag* GetVideoInfoTag() const;
1272
1273 MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag();
1274 const MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag() const;
1275
1276 void setTitleRaw(const std::string& title);
1277 void setPathRaw(const std::string& path);
1278 void setCountRaw(int count);
1279 void setSizeRaw(int64_t size);
1280 void setDateTimeRaw(const std::string& dateTime);
1281 void setIsFolderRaw(bool isFolder);
1282 void setStartOffsetRaw(double startOffset);
1283 void setMimeTypeRaw(const std::string& mimetype);
1284 void setSpecialSortRaw(std::string specialSort);
1285 void setContentLookupRaw(bool enable);
1286 void addArtRaw(std::string type, const std::string& url);
1287 void addPropertyRaw(std::string type, const CVariant& value);
1288 void addSubtitlesRaw(const std::vector<std::string>& subtitles);
1289 };
1290
1291#ifndef DOXYGEN_SHOULD_SKIP_THIS
1292 typedef std::vector<ListItem*> ListItemList;
1293#endif
1294 }
1295}
Definition InfoTagGame.h:49
Definition InfoTagMusic.h:48
Definition InfoTagPicture.h:44
Definition InfoTagVideo.h:860
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...