[settings] Moving label and help into ISetting
authorAlwinEsch <alwin.esch@web.de>
Sat, 14 Feb 2015 09:19:15 +0000 (10:19 +0100)
committerAlwinEsch <alwin.esch@web.de>
Sun, 15 Feb 2015 19:28:09 +0000 (20:28 +0100)
xbmc/settings/lib/ISetting.cpp
xbmc/settings/lib/ISetting.h
xbmc/settings/lib/SettingSection.cpp
xbmc/settings/lib/SettingSection.h

index 755b1bf..921889a 100644 (file)
@@ -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)
 { }
@@ -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;
index 4bfe65c..b2df2b4 100644 (file)
@@ -73,7 +73,30 @@ public:
    \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.
 
@@ -107,6 +130,8 @@ protected:
 
 private:
   bool m_visible;
+  int m_label;
+  int m_help;
   bool m_meetsRequirements;
   CSettingRequirement m_requirementCondition;
 };
index 9d0c45c..c970bff 100644 (file)
@@ -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)
 { }
 
@@ -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))
@@ -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()
@@ -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)
   {
index fd43743..1be382d 100644 (file)
@@ -96,30 +96,6 @@ public:
   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.
 
@@ -147,8 +123,6 @@ public:
   void AddGroups(const SettingGroupList &groups);
 
 private:
-  int m_label;
-  int m_help;
   SettingGroupList m_groups;
   CSettingCategoryAccess m_accessCondition;
 };
@@ -177,30 +151,6 @@ public:
   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.
 
@@ -221,7 +171,5 @@ public:
   void AddCategories(const SettingCategoryList &categories);
 
 private:
-  int m_label;
-  int m_help;
   SettingCategoryList m_categories;
 };