aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlwinEsch <alwin.esch@web.de>2015-04-05 07:25:12 +0200
committerAlwinEsch <alwin.esch@web.de>2015-04-06 15:33:28 +0200
commit9a40348ab0dacf7977bd2e31dc6debde70d28f6c (patch)
treea0e4d50f66be33da018bbf5d2c73985a32a64afa
parentd99ca917893706a01d08125ccb7a6dea4f4cae26 (diff)
[settings] Add single control type to CSettingGroup
-rw-r--r--xbmc/settings/lib/SettingSection.cpp31
-rw-r--r--xbmc/settings/lib/SettingSection.h5
2 files changed, 36 insertions, 0 deletions
diff --git a/xbmc/settings/lib/SettingSection.cpp b/xbmc/settings/lib/SettingSection.cpp
index c970bffe8b..7f010e2d20 100644
--- a/xbmc/settings/lib/SettingSection.cpp
+++ b/xbmc/settings/lib/SettingSection.cpp
@@ -63,6 +63,7 @@ template<class T> void addISetting(const TiXmlNode *node, const T &item, std::ve
CSettingGroup::CSettingGroup(const std::string &id, CSettingsManager *settingsManager /* = NULL */)
: ISetting(id, settingsManager)
+ , m_control(NULL)
{ }
CSettingGroup::~CSettingGroup()
@@ -70,6 +71,8 @@ CSettingGroup::~CSettingGroup()
for (SettingList::const_iterator setting = m_settings.begin(); setting != m_settings.end(); ++setting)
delete *setting;
m_settings.clear();
+ if (m_control)
+ delete m_control;
}
bool CSettingGroup::Deserialize(const TiXmlNode *node, bool update /* = false */)
@@ -78,6 +81,34 @@ bool CSettingGroup::Deserialize(const TiXmlNode *node, bool update /* = false */
if (!ISetting::Deserialize(node, update))
return false;
+ const TiXmlElement *controlElement = node->FirstChildElement(SETTING_XML_ELM_CONTROL);
+ if (controlElement != NULL)
+ {
+ const char* controlType = controlElement->Attribute(SETTING_XML_ATTR_TYPE);
+ if (controlType == NULL || strlen(controlType) <= 0)
+ {
+ CLog::Log(LOGERROR, "CSettingGroup: unable to read control type");
+ return false;
+ }
+
+ if (m_control != NULL)
+ delete m_control;
+
+ m_control = m_settingsManager->CreateControl(controlType);
+ if (m_control == NULL)
+ {
+ CLog::Log(LOGERROR, "CSettingGroup: unable to create new control \"%s\"", controlType);
+ return false;
+ }
+
+ if (!m_control->Deserialize(controlElement))
+ {
+ CLog::Log(LOGWARNING, "CSettingGroup: unable to read control \"%s\"", controlType);
+ delete m_control;
+ m_control = NULL;
+ }
+ }
+
const TiXmlElement *settingElement = node->FirstChildElement(SETTING_XML_ELM_SETTING);
while (settingElement != NULL)
{
diff --git a/xbmc/settings/lib/SettingSection.h b/xbmc/settings/lib/SettingSection.h
index 1be382d3d8..2603e20f3a 100644
--- a/xbmc/settings/lib/SettingSection.h
+++ b/xbmc/settings/lib/SettingSection.h
@@ -68,8 +68,13 @@ public:
void AddSetting(CSetting *setting);
void AddSettings(const SettingList &settings);
+ const ISettingControl *GetControl() const { return m_control; }
+ ISettingControl *GetControl() { return m_control; }
+ void SetControl(ISettingControl *control) { m_control = control; }
+
private:
SettingList m_settings;
+ ISettingControl *m_control;
};
typedef std::vector<CSettingGroup *> SettingGroupList;