Kodi Development 23.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
893#else
894 void addAvailableArtwork(const std::string& url,
895 const std::string& art_type = "",
896 const std::string& preview = "",
897 const std::string& referrer = "",
898 int season = -1);
899#endif
900
901#ifdef DOXYGEN_SHOULD_USE_THIS
944#else
945 void addStreamInfo(const char* cType, const Properties& dictionary);
946#endif
947
948#ifdef DOXYGEN_SHOULD_USE_THIS
973#else
974 void addContextMenuItems(const std::vector<Tuple<String,String> >& items, bool replaceItems = false);
975#endif
976
977#ifdef DOXYGEN_SHOULD_USE_THIS
1027#else
1028 void setProperty(const char * key, const String& value);
1029#endif
1030
1031#ifdef DOXYGEN_SHOULD_USE_THIS
1051#else
1052 void setProperties(const Properties& dictionary);
1053#endif
1054
1055#ifdef DOXYGEN_SHOULD_USE_THIS
1079#else
1080 String getProperty(const char* key);
1081#endif
1082
1083#ifdef DOXYGEN_SHOULD_USE_THIS
1104#else
1105 void setPath(const String& path);
1106#endif
1107
1108#ifdef DOXYGEN_SHOULD_USE_THIS
1120#else
1121 void setMimeType(const String& mimetype);
1122#endif
1123
1124#ifdef DOXYGEN_SHOULD_USE_THIS
1139#else
1140 void setContentLookup(bool enable);
1141#endif
1142
1143#ifdef DOXYGEN_SHOULD_USE_THIS
1157#else
1158 void setFileTitle(const String& title);
1159#endif
1160
1161#ifdef DOXYGEN_SHOULD_USE_THIS
1175#else
1176 void setCount(int count);
1177#endif
1178
1179#ifdef DOXYGEN_SHOULD_USE_THIS
1192#else
1193 void setSize(int64_t size);
1194#endif
1195
1196#ifdef DOXYGEN_SHOULD_USE_THIS
1212#else
1213 void setOverlay(int overlay);
1214#endif
1215
1216#ifdef DOXYGEN_SHOULD_USE_THIS
1238#else
1239 void setSubtitles(const std::vector<String>& subtitleFiles);
1240#endif
1241
1242#ifdef DOXYGEN_SHOULD_USE_THIS
1256#else
1257 String getPath();
1258#endif
1259
1260#ifdef DOXYGEN_SHOULD_USE_THIS
1273#else
1275#endif
1276
1277#ifdef DOXYGEN_SHOULD_USE_THIS
1290#else
1292#endif
1293
1294#ifdef DOXYGEN_SHOULD_USE_THIS
1307#else
1309#endif
1310
1311#ifdef DOXYGEN_SHOULD_USE_THIS
1324#else
1326#endif
1327
1328private:
1329 std::vector<std::string> getStringArray(const InfoLabelValue& alt,
1330 const std::string& tag,
1331 std::string value,
1332 const std::string& separator);
1333 std::vector<std::string> getVideoStringArray(const InfoLabelValue& alt,
1334 const std::string& tag,
1335 std::string value = "");
1336 std::vector<std::string> getMusicStringArray(const InfoLabelValue& alt,
1337 const std::string& tag,
1338 std::string value = "");
1339
1340 CVideoInfoTag* GetVideoInfoTag();
1341 const CVideoInfoTag* GetVideoInfoTag() const;
1342
1343 MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag();
1344 const MUSIC_INFO::CMusicInfoTag* GetMusicInfoTag() const;
1345
1346 void setTitleRaw(const std::string& title);
1347 void setPathRaw(const std::string& path);
1348 void setCountRaw(int count);
1349 void setSizeRaw(int64_t size);
1350 void setDateTimeRaw(const std::string& dateTime);
1351 void setIsFolderRaw(bool isFolder);
1352 void setStartOffsetRaw(double startOffset);
1353 void setMimeTypeRaw(const std::string& mimetype);
1354 void setSpecialSortRaw(std::string specialSort);
1355 void setContentLookupRaw(bool enable);
1356 void addArtRaw(std::string type, const std::string& url);
1357 void addPropertyRaw(std::string type, const CVariant& value);
1358 void addSubtitlesRaw(const std::vector<std::string>& subtitles);
1359 };
1360
1361#ifndef DOXYGEN_SHOULD_SKIP_THIS
1362 typedef std::vector<ListItem*> ListItemList;
1363#endif
1364 }
1365}
Definition InfoTagGame.h:49
Definition InfoTagMusic.h:48
Definition InfoTagPicture.h:44
Definition InfoTagVideo.h:1423
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...
setCount(...)
<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...
setFileTitle(...)
<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...
setOverlay(...)
<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...
setSize(...)
<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...