本文整理汇总了C++中DynamicIntegerSettingOptions类的典型用法代码示例。如果您正苦于以下问题:C++ DynamicIntegerSettingOptions类的具体用法?C++ DynamicIntegerSettingOptions怎么用?C++ DynamicIntegerSettingOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DynamicIntegerSettingOptions类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void CGUIControlSpinExSetting::FillIntegerSettingControl()
{
CSettingInt *pSettingInt = (CSettingInt *)m_pSetting;
switch (pSettingInt->GetOptionsType())
{
case SettingOptionsTypeStatic:
{
const StaticIntegerSettingOptions& options = pSettingInt->GetOptions();
for (StaticIntegerSettingOptions::const_iterator it = options.begin(); it != options.end(); ++it)
m_pSpin->AddLabel(g_localizeStrings.Get(it->first), it->second);
break;
}
case SettingOptionsTypeDynamic:
{
DynamicIntegerSettingOptions options = pSettingInt->UpdateDynamicOptions();
for (DynamicIntegerSettingOptions::const_iterator option = options.begin(); option != options.end(); ++option)
m_pSpin->AddLabel(option->first, option->second);
break;
}
case SettingOptionsTypeNone:
default:
{
std::string strLabel;
int i = pSettingInt->GetMinimum();
const CSettingControlSpinner *control = static_cast<const CSettingControlSpinner*>(pSettingInt->GetControl());
if (control->GetMinimumLabel() > -1)
{
strLabel = g_localizeStrings.Get(control->GetMinimumLabel());
m_pSpin->AddLabel(strLabel, pSettingInt->GetMinimum());
i += pSettingInt->GetStep();
}
for (; i <= pSettingInt->GetMaximum(); i += pSettingInt->GetStep())
{
if (control->GetFormatLabel() > -1)
strLabel = StringUtils::Format(g_localizeStrings.Get(control->GetFormatLabel()).c_str(), i);
else
strLabel = StringUtils::Format(control->GetFormatString().c_str(), i);
m_pSpin->AddLabel(strLabel, i);
}
break;
}
}
m_pSpin->SetValue(pSettingInt->GetValue());
}
示例2: switch
bool CSettingsOperations::SerializeSettingInt(const CSettingInt* setting, CVariant &obj)
{
if (setting == NULL)
return false;
obj["value"] = setting->GetValue();
obj["default"] = setting->GetDefault();
switch (setting->GetOptionsType())
{
case SettingOptionsTypeStatic:
{
obj["options"] = CVariant(CVariant::VariantTypeArray);
const StaticIntegerSettingOptions& options = setting->GetOptions();
for (StaticIntegerSettingOptions::const_iterator itOption = options.begin(); itOption != options.end(); ++itOption)
{
CVariant varOption(CVariant::VariantTypeObject);
varOption["label"] = g_localizeStrings.Get(itOption->first);
varOption["value"] = itOption->second;
obj["options"].push_back(varOption);
}
break;
}
case SettingOptionsTypeDynamic:
{
obj["options"] = CVariant(CVariant::VariantTypeArray);
DynamicIntegerSettingOptions options = const_cast<CSettingInt*>(setting)->UpdateDynamicOptions();
for (DynamicIntegerSettingOptions::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);
}
break;
}
case SettingOptionsTypeNone:
default:
obj["minimum"] = setting->GetMinimum();
obj["step"] = setting->GetStep();
obj["maximum"] = setting->GetMaximum();
break;
}
return true;
}
示例3: lock
DynamicIntegerSettingOptions CSettingInt::UpdateDynamicOptions()
{
CExclusiveLock lock(m_critical);
DynamicIntegerSettingOptions options;
if (m_optionsFiller == NULL &&
(m_optionsFillerName.empty() || m_settingsManager == NULL))
return options;
if (m_optionsFiller == NULL)
{
m_optionsFiller = (IntegerSettingOptionsFiller)m_settingsManager->GetSettingOptionsFiller(this);
if (m_optionsFiller == NULL)
return options;
}
int bestMatchingValue = m_value;
m_optionsFiller(this, options, bestMatchingValue, m_optionsFillerData);
if (bestMatchingValue != m_value)
SetValue(bestMatchingValue);
bool changed = m_dynamicOptions.size() != options.size();
if (!changed)
{
for (size_t index = 0; index < options.size(); index++)
{
if (options[index].first.compare(m_dynamicOptions[index].first) != 0 ||
options[index].second != m_dynamicOptions[index].second)
{
changed = true;
break;
}
}
}
if (changed)
{
m_dynamicOptions = options;
OnSettingPropertyChanged(this, "options");
}
return options;
}
示例4: switch
bool CGUIControlListSetting::GetIntegerItems(CSetting *setting, CFileItemList &items)
{
CSettingInt *pSettingInt = (CSettingInt *)setting;
switch (pSettingInt->GetOptionsType())
{
case SettingOptionsTypeStatic:
{
const StaticIntegerSettingOptions& options = pSettingInt->GetOptions();
for (StaticIntegerSettingOptions::const_iterator it = options.begin(); it != options.end(); ++it)
{
CFileItemPtr pItem = GetItem(g_localizeStrings.Get(it->first), it->second);
if (it->second == pSettingInt->GetValue())
pItem->Select(true);
items.Add(pItem);
}
break;
}
case SettingOptionsTypeDynamic:
{
DynamicIntegerSettingOptions options = pSettingInt->UpdateDynamicOptions();
for (DynamicIntegerSettingOptions::const_iterator option = options.begin(); option != options.end(); ++option)
{
CFileItemPtr pItem = GetItem(option->first, option->second);
if (option->second == pSettingInt->GetValue())
pItem->Select(true);
items.Add(pItem);
}
break;
}
case SettingOptionsTypeNone:
default:
return false;
}
return true;
}
示例5: if
bool CGUIControlListSetting::GetIntegerItems(const CSetting *setting, CFileItemList &items)
{
const CSettingInt *pSettingInt = NULL;
std::set<int> values;
if (setting->GetType() == SettingTypeInteger)
{
pSettingInt = static_cast<const CSettingInt*>(setting);
values.insert(pSettingInt->GetValue());
}
else if (setting->GetType() == SettingTypeList)
{
const CSettingList *settingList = static_cast<const CSettingList*>(setting);
if (settingList->GetElementType() != SettingTypeInteger)
return false;
pSettingInt = static_cast<const CSettingInt*>(settingList->GetDefinition());
std::vector<CVariant> list = CSettingUtils::GetList(settingList);
for (std::vector<CVariant>::const_iterator itValue = list.begin(); itValue != list.end(); ++itValue)
{
if (!itValue->isInteger())
return false;
values.insert((int)itValue->asInteger());
}
}
else
return false;
switch (pSettingInt->GetOptionsType())
{
case SettingOptionsTypeStatic:
{
const StaticIntegerSettingOptions& options = pSettingInt->GetOptions();
for (StaticIntegerSettingOptions::const_iterator it = options.begin(); it != options.end(); ++it)
{
CFileItemPtr pItem = GetItem(g_localizeStrings.Get(it->first), it->second);
if (values.find(it->second) != values.end())
pItem->Select(true);
items.Add(pItem);
}
break;
}
case SettingOptionsTypeDynamic:
{
DynamicIntegerSettingOptions options = const_cast<CSettingInt*>(pSettingInt)->UpdateDynamicOptions();
for (DynamicIntegerSettingOptions::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);
}
break;
}
case SettingOptionsTypeNone:
default:
return false;
}
return true;
}
示例6: GetIntegerOptions
static bool GetIntegerOptions(const CSetting* setting, DynamicIntegerSettingOptions& options, std::set<int>& selectedOptions)
{
const CSettingInt *pSettingInt = NULL;
if (setting->GetType() == SettingTypeInteger)
{
pSettingInt = static_cast<const CSettingInt*>(setting);
selectedOptions.insert(pSettingInt->GetValue());
}
else if (setting->GetType() == SettingTypeList)
{
const CSettingList *settingList = static_cast<const CSettingList*>(setting);
if (settingList->GetElementType() != SettingTypeInteger)
return false;
pSettingInt = static_cast<const CSettingInt*>(settingList->GetDefinition());
std::vector<CVariant> list = CSettingUtils::GetList(settingList);
for (const auto& itValue : list)
{
if (!itValue.isInteger())
return false;
selectedOptions.insert((int)itValue.asInteger());
}
}
else
return false;
switch (pSettingInt->GetOptionsType())
{
case SettingOptionsTypeStatic:
{
const StaticIntegerSettingOptions& settingOptions = pSettingInt->GetOptions();
for (const auto& option : settingOptions)
options.push_back(std::make_pair(g_localizeStrings.Get(option.first), option.second));
break;
}
case SettingOptionsTypeDynamic:
{
DynamicIntegerSettingOptions settingOptions = const_cast<CSettingInt*>(pSettingInt)->UpdateDynamicOptions();
for (const auto& option : settingOptions)
options.push_back(std::make_pair(option.first, option.second));
break;
}
case SettingOptionsTypeNone:
default:
{
const CSettingControlFormattedRange *control = static_cast<const CSettingControlFormattedRange*>(pSettingInt->GetControl());
for (int i = pSettingInt->GetMinimum(); i <= pSettingInt->GetMaximum(); i += pSettingInt->GetStep())
{
std::string strLabel;
if (i == pSettingInt->GetMinimum() && control->GetMinimumLabel() > -1)
strLabel = g_localizeStrings.Get(control->GetMinimumLabel());
else if (control->GetFormatLabel() > -1)
strLabel = StringUtils::Format(g_localizeStrings.Get(control->GetFormatLabel()).c_str(), i);
else
strLabel = StringUtils::Format(control->GetFormatString().c_str(), i);
options.push_back(std::make_pair(strLabel, i));
}
break;
}
}
return true;
}