6 #ifndef GUILIB_GUILISTITEM_H
7 #define GUILIB_GUILISTITEM_H
12 * Copyright (C) 2005-2013 Team XBMC
15 * This Program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * This Program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with XBMC; see the file COPYING. If not, see
27 * <http://www.gnu.org/licenses/>.
31 #include "utils/StdString.h"
37 class CGUIListItemLayout;
48 typedef std::map<std::string, std::string> ArtMap;
50 enum GUIIconOverlay { ICON_OVERLAY_NONE = 0,
54 ICON_OVERLAY_HAS_TRAINER,
56 ICON_OVERLAY_UNWATCHED,
61 CGUIListItem(const CGUIListItem& item);
62 CGUIListItem(const CStdString& strLabel);
63 virtual ~CGUIListItem(void);
64 virtual CGUIListItem *Clone() const { return new CGUIListItem(*this); };
66 const CGUIListItem& operator =(const CGUIListItem& item);
68 virtual void SetLabel(const CStdString& strLabel);
69 const CStdString& GetLabel() const;
71 void SetLabel2(const CStdString& strLabel);
72 const CStdString& GetLabel2() const;
74 void SetIconImage(const CStdString& strIcon);
75 const CStdString& GetIconImage() const;
77 void SetOverlayImage(GUIIconOverlay icon, bool bOnOff=false);
78 CStdString GetOverlayImage() const;
80 /*! \brief Set a particular art type for an item
81 \param type type of art to set.
82 \param url the url of the art.
84 void SetArt(const std::string &type, const std::string &url);
86 /*! \brief set artwork for an item
87 \param art a type:url map for artwork
90 void SetArt(const ArtMap &art);
92 /*! \brief append artwork to an item
93 \param art a type:url map for artwork
94 \param prefix a prefix for the art, if applicable.
97 void AppendArt(const ArtMap &art, const std::string &prefix = "");
99 /*! \brief set a fallback image for art
100 \param from the type to fallback from
101 \param to the type to fallback to
104 void SetArtFallback(const std::string &from, const std::string &to);
106 /*! \brief clear art on an item
111 /*! \brief Get a particular art type for an item
112 \param type type of art to fetch.
113 \return the art URL, if available, else empty.
115 std::string GetArt(const std::string &type) const;
117 /*! \brief get artwork for an item
118 Retrieves artwork in a type:url map
119 \return a type:url map for artwork
122 const ArtMap &GetArt() const;
124 /*! \brief Check whether an item has a particular piece of art
125 Equivalent to !GetArt(type).empty()
126 \param type type of art to set.
127 \return true if the item has that art set, false otherwise.
129 bool HasArt(const std::string &type) const;
131 void SetSortLabel(const CStdString &label);
132 void SetSortLabel(const CStdStringW &label);
133 const CStdStringW &GetSortLabel() const;
135 void Select(bool bOnOff);
136 bool IsSelected() const;
138 bool HasIcon() const;
139 bool HasOverlay() const;
140 virtual bool IsFileItem() const { return false; };
142 void SetLayout(CGUIListItemLayout *layout);
143 CGUIListItemLayout *GetLayout();
145 void SetFocusedLayout(CGUIListItemLayout *layout);
146 CGUIListItemLayout *GetFocusedLayout();
149 void FreeMemory(bool immediately = false);
152 bool m_bIsFolder; ///< is item a folder or a file
154 void SetProperty(const CStdString &strKey, const CVariant &value);
156 void IncrementProperty(const CStdString &strKey, int nVal);
157 void IncrementProperty(const CStdString &strKey, double dVal);
159 void ClearProperties();
161 /*! \brief Append the properties of one CGUIListItem to another.
162 Any existing properties in the current item will be overridden if they
163 are set in the passed in item.
164 \param item the item containing the properties to append.
166 void AppendProperties(const CGUIListItem &item);
168 void Archive(CArchive& ar);
169 void Serialize(CVariant& value);
171 bool HasProperty(const CStdString &strKey) const;
172 bool HasProperties() const { return m_mapProperties.size() > 0; };
173 void ClearProperty(const CStdString &strKey);
175 CVariant GetProperty(const CStdString &strKey) const;
178 CStdString m_strLabel2; // text of column2
179 CStdString m_strIcon; // filename of icon
180 GUIIconOverlay m_overlayIcon; // type of overlay icon
182 CGUIListItemLayout *m_layout;
183 CGUIListItemLayout *m_focusedLayout;
184 bool m_bSelected; // item is selected or not
188 bool operator()(const CStdString &s1, const CStdString &s2) const
190 return s1.CompareNoCase(s2) < 0;
194 typedef std::map<CStdString, CVariant, icompare> PropertyMap;
195 PropertyMap m_mapProperties;
197 CStdStringW m_sortLabel; // text for sorting. Need to be UTF16 for proper sorting
198 CStdString m_strLabel; // text of column1
201 ArtMap m_artFallbacks;