2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "GUIStaticItem.h"
22 #include "utils/XMLUtils.h"
23 #include "GUIControlFactory.h"
24 #include "GUIInfoManager.h"
25 #include "utils/Variant.h"
29 CGUIStaticItem::CGUIStaticItem(const TiXmlElement *item, int parentID) : CFileItem()
36 // check whether we're using the more verbose method...
37 const TiXmlNode *click = item->FirstChild("onclick");
38 if (click && click->FirstChild())
40 CGUIInfoLabel label, label2, thumb, icon;
41 CGUIControlFactory::GetInfoLabel(item, "label", label, parentID);
42 CGUIControlFactory::GetInfoLabel(item, "label2", label2, parentID);
43 CGUIControlFactory::GetInfoLabel(item, "thumb", thumb, parentID);
44 CGUIControlFactory::GetInfoLabel(item, "icon", icon, parentID);
45 const char *id = item->Attribute("id");
47 CGUIControlFactory::GetConditionalVisibility(item, condition);
48 m_visCondition = g_infoManager.Register(condition, parentID);
49 CGUIControlFactory::GetActions(item, "onclick", m_clickActions);
50 SetLabel(label.GetLabel(parentID));
51 SetLabel2(label2.GetLabel(parentID));
52 SetArt("thumb", thumb.GetLabel(parentID, true));
53 SetIconImage(icon.GetLabel(parentID, true));
54 if (!label.IsConstant()) m_info.push_back(make_pair(label, "label"));
55 if (!label2.IsConstant()) m_info.push_back(make_pair(label2, "label2"));
56 if (!thumb.IsConstant()) m_info.push_back(make_pair(thumb, "thumb"));
57 if (!icon.IsConstant()) m_info.push_back(make_pair(icon, "icon"));
58 m_iprogramCount = id ? atoi(id) : 0;
60 const TiXmlElement *property = item->FirstChildElement("property");
63 CStdString name = property->Attribute("name");
65 if (!name.IsEmpty() && CGUIControlFactory::GetInfoLabelFromElement(property, prop, parentID))
67 SetProperty(name, prop.GetLabel(parentID, true).c_str());
68 if (!prop.IsConstant())
69 m_info.push_back(make_pair(prop, name));
71 property = property->NextSiblingElement("property");
76 CStdString label, label2, thumb, icon;
77 label = item->Attribute("label"); label = CGUIControlFactory::FilterLabel(label);
78 label2 = item->Attribute("label2"); label2 = CGUIControlFactory::FilterLabel(label2);
79 thumb = item->Attribute("thumb"); thumb = CGUIControlFactory::FilterLabel(thumb);
80 icon = item->Attribute("icon"); icon = CGUIControlFactory::FilterLabel(icon);
81 const char *id = item->Attribute("id");
82 SetLabel(CGUIInfoLabel::GetLabel(label, parentID));
83 SetPath(item->FirstChild()->Value());
84 SetLabel2(CGUIInfoLabel::GetLabel(label2, parentID));
85 SetArt("thumb", CGUIInfoLabel::GetLabel(thumb, parentID, true));
86 SetIconImage(CGUIInfoLabel::GetLabel(icon, parentID, true));
87 m_iprogramCount = id ? atoi(id) : 0;
91 void CGUIStaticItem::UpdateProperties(int contextWindow)
93 for (InfoVector::const_iterator i = m_info.begin(); i != m_info.end(); i++)
95 const CGUIInfoLabel &info = i->first;
96 const CStdString &name = i->second;
97 bool preferTexture = strnicmp("label", name.c_str(), 5) != 0;
98 CStdString value(info.GetLabel(contextWindow, preferTexture));
99 if (name.Equals("label"))
101 else if (name.Equals("label2"))
103 else if (name.Equals("thumb"))
104 SetArt("thumb", value);
105 else if (name.Equals("icon"))
108 SetProperty(name, value.c_str());
112 bool CGUIStaticItem::UpdateVisibility(int contextWindow)
116 bool state = g_infoManager.GetBoolValue(m_visCondition);
117 if (state != m_visState)
125 bool CGUIStaticItem::IsVisible() const