예제 #1
0
CSettingList* CGUIDialogSettingsManualBase::AddRange(CSettingGroup *group, const std::string &id, int label, int level, float valueLower, float valueUpper, float minimum,
                                                     float step, float maximum, const std::string &format, int formatLabel, int valueFormatLabel,
                                                     const std::string &valueFormatString, bool delayed, bool visible, int help)
{
  if (group == NULL || id.empty() || label < 0 ||
      GetSetting(id) != NULL)
    return NULL;

  CSettingNumber *settingDefinition = new CSettingNumber(id, m_settingsManager);
  if (settingDefinition == NULL)
    return NULL;
  
  settingDefinition->SetMinimum(minimum);
  settingDefinition->SetStep(step);
  settingDefinition->SetMaximum(maximum);

  CSettingList *setting = new CSettingList(id, settingDefinition, label, m_settingsManager);
  if (setting == NULL)
  {
    delete settingDefinition;
    return NULL;
  }

  std::vector<CVariant> valueList;
  valueList.push_back(valueLower);
  valueList.push_back(valueUpper);
  SettingPtrList settingValues;
  if (!CSettingUtils::ValuesToList(setting, valueList, settingValues))
  {
    delete settingDefinition;
    delete setting;
    return NULL;
  }
  // setting the default will also set the actual value on an unchanged setting
  setting->SetDefault(settingValues);
  
  setting->SetControl(GetRangeControl(format, delayed, formatLabel, valueFormatLabel, valueFormatString));
  setting->SetMinimumItems(2);
  setting->SetMaximumItems(2);

  setSettingDetails(setting, level, visible, help);

  group->AddSetting(setting);
  return setting;
}
예제 #2
0
CSettingList* CGUIDialogSettingsManualBase::AddList(CSettingGroup *group, const std::string &id, int label, int level, std::vector<int> values,
                                                    IntegerSettingOptionsFiller filler, int heading, int minimumItems /* = 0 */, int maximumItems /* = -1 */,
                                                    bool visible /* = true */, int help /* = -1 */)
{
  if (group == NULL || id.empty() || label < 0 || filler == NULL ||
      GetSetting(id) != NULL)
    return NULL;

  CSettingInt *settingDefinition = new CSettingInt(id, m_settingsManager);
  if (settingDefinition == NULL)
    return NULL;
  
  settingDefinition->SetOptionsFiller(filler, this);

  CSettingList *setting = new CSettingList(id, settingDefinition, label, m_settingsManager);
  if (setting == NULL)
  {
    delete settingDefinition;
    return NULL;
  }

  std::vector<CVariant> valueList;
  for (std::vector<int>::const_iterator itValue = values.begin(); itValue != values.end(); ++itValue)
    valueList.push_back(CVariant(*itValue));
  SettingPtrList settingValues;
  if (!CSettingUtils::ValuesToList(setting, valueList, settingValues))
  {
    delete settingDefinition;
    delete setting;
    return NULL;
  }
  // setting the default will also set the actual value on an unchanged setting
  setting->SetDefault(settingValues);

  setting->SetControl(GetListControl("integer", false, heading, true));
  setting->SetMinimumItems(minimumItems);
  setting->SetMaximumItems(maximumItems);
  setSettingDetails(setting, level, visible, help);

  group->AddSetting(setting);
  return setting;
}