bool CGUIControlListSetting::GetStringItems(const CSetting *setting, CFileItemList &items) { const CSettingString *pSettingString = NULL; std::set<std::string> values; if (setting->GetType() == SettingTypeString) { pSettingString = static_cast<const CSettingString*>(setting); values.insert(pSettingString->GetValue()); } else if (setting->GetType() == SettingTypeList) { const CSettingList *settingList = static_cast<const CSettingList*>(setting); if (settingList->GetElementType() != SettingTypeString) return false; pSettingString = static_cast<const CSettingString*>(settingList->GetDefinition()); std::vector<CVariant> list = CSettingUtils::GetList(settingList); for (std::vector<CVariant>::const_iterator itValue = list.begin(); itValue != list.end(); ++itValue) { if (!itValue->isString()) return false; values.insert(itValue->asString()); } } else return false; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions options = const_cast<CSettingString*>(pSettingString)->UpdateDynamicOptions(); for (DynamicStringSettingOptions::const_iterator option = options.begin(); option != options.end(); ++option) { CFileItemPtr pItem = GetItem(option->first, option->second); if (values.find(option->second) != values.end()) pItem->Select(true); items.Add(pItem); } } else return false; return true; }
bool CGUIControlListSetting::GetItems(CSetting *setting, CFileItemList &items) { switch (setting->GetControl().GetFormat()) { case SettingControlFormatInteger: return GetIntegerItems(setting, items); case SettingControlFormatString: { if (setting->GetType() == SettingTypeInteger) return GetIntegerItems(setting, items); else if (setting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)setting; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions options = pSettingString->UpdateDynamicOptions(); for (DynamicStringSettingOptions::const_iterator option = options.begin(); option != options.end(); ++option) { CFileItemPtr pItem = GetItem(option->first, option->second); if (StringUtils::EqualsNoCase(option->second, pSettingString->GetValue())) pItem->Select(true); items.Add(pItem); } } } break; } default: return false; } return true; }
bool CSettingsOperations::SerializeSettingString(const CSettingString* setting, CVariant &obj) { if (setting == NULL) return false; obj["value"] = setting->GetValue(); obj["default"] = setting->GetDefault(); obj["allowempty"] = setting->AllowEmpty(); if (setting->GetOptionsType() == SettingOptionsTypeDynamic) { obj["options"] = CVariant(CVariant::VariantTypeArray); DynamicStringSettingOptions options = const_cast<CSettingString*>(setting)->UpdateDynamicOptions(); for (DynamicStringSettingOptions::const_iterator itOption = options.begin(); itOption != options.end(); ++itOption) { CVariant varOption(CVariant::VariantTypeObject); varOption["label"] = itOption->first; varOption["value"] = itOption->second; obj["options"].push_back(varOption); } } const ISettingControl* control = setting->GetControl(); if (control->GetFormat() == "path") { if (!SerializeSettingPath(static_cast<const CSettingPath*>(setting), obj)) return false; } if (control->GetFormat() == "addon") { if (!SerializeSettingAddon(static_cast<const CSettingAddon*>(setting), obj)) return false; } return true; }
static bool GetStringOptions(const CSetting* setting, DynamicStringSettingOptions& options, std::set<std::string>& selectedOptions) { const CSettingString *pSettingString = NULL; if (setting->GetType() == SettingTypeString) { pSettingString = static_cast<const CSettingString*>(setting); selectedOptions.insert(pSettingString->GetValue()); } else if (setting->GetType() == SettingTypeList) { const CSettingList *settingList = static_cast<const CSettingList*>(setting); if (settingList->GetElementType() != SettingTypeString) return false; pSettingString = static_cast<const CSettingString*>(settingList->GetDefinition()); std::vector<CVariant> list = CSettingUtils::GetList(settingList); for (const auto& itValue : list) { if (!itValue.isString()) return false; selectedOptions.insert(itValue.asString()); } } else return false; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions settingOptions = const_cast<CSettingString*>(pSettingString)->UpdateDynamicOptions(); options.insert(options.end(), settingOptions.begin(), settingOptions.end()); } else return false; return true; }
void CGUIControlSpinExSetting::FillControl() { m_pSpin->Clear(); switch (m_pSetting->GetControl().GetFormat()) { case SettingControlFormatNumber: { CSettingNumber *pSettingNumber = (CSettingNumber *)m_pSetting; m_pSpin->SetType(SPIN_CONTROL_TYPE_FLOAT); m_pSpin->SetFloatRange((float)pSettingNumber->GetMinimum(), (float)pSettingNumber->GetMaximum()); m_pSpin->SetFloatInterval((float)pSettingNumber->GetStep()); m_pSpin->SetFloatValue((float)pSettingNumber->GetValue()); break; } case SettingControlFormatInteger: { m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); FillIntegerSettingControl(); break; } case SettingControlFormatString: { m_pSpin->SetType(SPIN_CONTROL_TYPE_TEXT); if (m_pSetting->GetType() == SettingTypeInteger) FillIntegerSettingControl(); else if (m_pSetting->GetType() == SettingTypeString) { CSettingString *pSettingString = (CSettingString *)m_pSetting; if (pSettingString->GetOptionsType() == SettingOptionsTypeDynamic) { DynamicStringSettingOptions options = pSettingString->UpdateDynamicOptions(); for (std::vector< std::pair<std::string, std::string> >::const_iterator option = options.begin(); option != options.end(); ++option) m_pSpin->AddLabel(option->first, option->second); m_pSpin->SetStringValue(pSettingString->GetValue()); } } break; } default: break; } }