Skip to content

Commit

Permalink
[settings] Moving label and help into ISetting
Browse files Browse the repository at this point in the history
  • Loading branch information
AlwinEsch committed Feb 15, 2015
1 parent ecb47ab commit 84883f7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 75 deletions.
11 changes: 11 additions & 0 deletions xbmc/settings/lib/ISetting.cpp
Expand Up @@ -30,6 +30,7 @@ ISetting::ISetting(const std::string &id, CSettingsManager *settingsManager /* =
: m_id(id),
m_settingsManager(settingsManager),
m_visible(true),
m_label(-1), m_help(-1),
m_meetsRequirements(true),
m_requirementCondition(settingsManager)
{ }
Expand All @@ -43,6 +44,16 @@ bool ISetting::Deserialize(const TiXmlNode *node, bool update /* = false */)
if (XMLUtils::GetBoolean(node, SETTING_XML_ELM_VISIBLE, value))
m_visible = value;

const TiXmlElement *element = node->ToElement();
if (element == NULL)
return false;

int iValue = -1;
if (element->QueryIntAttribute(SETTING_XML_ATTR_LABEL, &iValue) == TIXML_SUCCESS && iValue > 0)
m_label = iValue;
if (element->QueryIntAttribute(SETTING_XML_ATTR_HELP, &iValue) == TIXML_SUCCESS && iValue > 0)
m_help = iValue;

const TiXmlNode *requirementNode = node->FirstChild(SETTING_XML_ELM_REQUIREMENT);
if (requirementNode == NULL)
return true;
Expand Down
25 changes: 25 additions & 0 deletions xbmc/settings/lib/ISetting.h
Expand Up @@ -73,7 +73,30 @@ class ISetting
\param visible Whether the setting object shall be visible or not
*/
virtual void SetVisible(bool visible) { m_visible = visible; }
/*!
\brief Gets the localizeable label ID of the setting group.
\return Localizeable label ID of the setting group
*/
const int GetLabel() const { return m_label; }
/*!
\brief Sets the localizeable label ID of the setting group.
\param label Localizeable label ID of the setting group
*/
void SetLabel(int label) { m_label = label; }
/*!
\brief Gets the localizeable help ID of the setting group.
\return Localizeable help ID of the setting group
*/
const int GetHelp() const { return m_help; }
/*!
\brief Sets the localizeable help ID of the setting group.
\param label Localizeable help ID of the setting group
*/
void SetHelp(int help) { m_help = help; }
/*!
\brief Whether the setting object meets all necessary requirements.
Expand Down Expand Up @@ -107,6 +130,8 @@ class ISetting

private:
bool m_visible;
int m_label;
int m_help;
bool m_meetsRequirements;
CSettingRequirement m_requirementCondition;
};
24 changes: 1 addition & 23 deletions xbmc/settings/lib/SettingSection.cpp
Expand Up @@ -153,7 +153,6 @@ void CSettingGroup::AddSettings(const SettingList &settings)

CSettingCategory::CSettingCategory(const std::string &id, CSettingsManager *settingsManager /* = NULL */)
: ISetting(id, settingsManager),
m_label(-1), m_help(-1),
m_accessCondition(settingsManager)
{ }

Expand All @@ -170,16 +169,6 @@ bool CSettingCategory::Deserialize(const TiXmlNode *node, bool update /* = false
// handle <visible> conditions
if (!ISetting::Deserialize(node, update))
return false;

const TiXmlElement *element = node->ToElement();
if (element == NULL)
return false;

int tmp = -1;
if (element->QueryIntAttribute(SETTING_XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0)
m_label = tmp;
if (element->QueryIntAttribute(SETTING_XML_ATTR_HELP, &tmp) == TIXML_SUCCESS && tmp > 0)
m_help = tmp;

const TiXmlNode *accessNode = node->FirstChild(SETTING_XML_ELM_ACCESS);
if (accessNode != NULL && !m_accessCondition.Deserialize(accessNode))
Expand Down Expand Up @@ -254,8 +243,7 @@ void CSettingCategory::AddGroups(const SettingGroupList &groups)
}

CSettingSection::CSettingSection(const std::string &id, CSettingsManager *settingsManager /* = NULL */)
: ISetting(id, settingsManager),
m_label(-1), m_help(-1)
: ISetting(id, settingsManager)
{ }

CSettingSection::~CSettingSection()
Expand All @@ -272,16 +260,6 @@ bool CSettingSection::Deserialize(const TiXmlNode *node, bool update /* = false
if (!ISetting::Deserialize(node, update))
return false;

const TiXmlElement *element = node->ToElement();
if (element == NULL)
return false;

int tmp = -1;
if (element->QueryIntAttribute(SETTING_XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0)
m_label = tmp;
if (element->QueryIntAttribute(SETTING_XML_ATTR_HELP, &tmp) == TIXML_SUCCESS && tmp > 0)
m_help = tmp;

const TiXmlNode *categoryNode = node->FirstChild(SETTING_XML_ELM_CATEGORY);
while (categoryNode != NULL)
{
Expand Down
52 changes: 0 additions & 52 deletions xbmc/settings/lib/SettingSection.h
Expand Up @@ -95,30 +95,6 @@ class CSettingCategory : public ISetting
// implementation of ISetting
virtual bool Deserialize(const TiXmlNode *node, bool update = false);

/*!
\brief Gets the localizeable label ID of the setting category.
\return Localizeable label ID of the setting category
*/
const int GetLabel() const { return m_label; }
/*!
\brief Sets the localizeable label ID of the setting category.
\param label Localizeable label ID of the setting category
*/
void SetLabel(int label) { m_label = label; }
/*!
\brief Gets the localizeable help ID of the setting category.
\return Localizeable help ID of the setting category
*/
const int GetHelp() const { return m_help; }
/*!
\brief Sets the localizeable help ID of the setting category.
\param label Localizeable help ID of the setting category
*/
void SetHelp(int help) { m_help = help; }
/*!
\brief Gets the full list of setting groups belonging to the setting
category.
Expand Down Expand Up @@ -147,8 +123,6 @@ class CSettingCategory : public ISetting
void AddGroups(const SettingGroupList &groups);

private:
int m_label;
int m_help;
SettingGroupList m_groups;
CSettingCategoryAccess m_accessCondition;
};
Expand Down Expand Up @@ -176,30 +150,6 @@ class CSettingSection : public ISetting
// implementation of ISetting
virtual bool Deserialize(const TiXmlNode *node, bool update = false);

/*!
\brief Gets the localizeable label ID of the setting section.
\return Localizeable label ID of the setting section
*/
const int GetLabel() const { return m_label; }
/*!
\brief Sets the localizeable label ID of the setting section.
\param label Localizeable label ID of the setting section
*/
void SetLabel(int label) { m_label = label; }
/*!
\brief Gets the localizeable help ID of the setting section.
\return Localizeable help ID of the setting section
*/
const int GetHelp() const { return m_help; }
/*!
\brief Sets the localizeable help ID of the setting section.
\param label Localizeable help ID of the setting section
*/
void SetHelp(int help) { m_help = help; }
/*!
\brief Gets the full list of setting categories belonging to the setting
section.
Expand All @@ -221,7 +171,5 @@ class CSettingSection : public ISetting
void AddCategories(const SettingCategoryList &categories);

private:
int m_label;
int m_help;
SettingCategoryList m_categories;
};

0 comments on commit 84883f7

Please sign in to comment.