当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicStringSettingOptions类代码示例

本文整理汇总了C++中DynamicStringSettingOptions的典型用法代码示例。如果您正苦于以下问题:C++ DynamicStringSettingOptions类的具体用法?C++ DynamicStringSettingOptions怎么用?C++ DynamicStringSettingOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DynamicStringSettingOptions类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

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;
}
开发者ID:gellis12,项目名称:xbmc,代码行数:45,代码来源:GUIControlSettings.cpp

示例2: lock

DynamicStringSettingOptions CSettingString::UpdateDynamicOptions()
{
    CExclusiveLock lock(m_critical);
    DynamicStringSettingOptions options;
    if (m_optionsFiller == NULL &&
            (m_optionsFillerName.empty() || m_settingsManager == NULL))
        return options;

    if (m_optionsFiller == NULL)
    {
        m_optionsFiller = (StringSettingOptionsFiller)m_settingsManager->GetSettingOptionsFiller(this);
        if (m_optionsFiller == NULL)
            return options;
    }

    std::string bestMatchingValue = m_value;
    m_optionsFiller(this, options, bestMatchingValue, m_optionsFillerData);

    if (bestMatchingValue != m_value)
        SetValue(bestMatchingValue);

    // check if the list of items has changed
    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.compare(m_dynamicOptions[index].second) != 0)
            {
                changed = true;
                break;
            }
        }
    }

    if (changed)
    {
        m_dynamicOptions = options;
        OnSettingPropertyChanged(this, "options");
    }

    return options;
}
开发者ID:B0k0,项目名称:xbmc,代码行数:44,代码来源:Setting.cpp

示例3: switch

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;
}
开发者ID:Micromax-56,项目名称:xbmc,代码行数:37,代码来源:GUIControlSettings.cpp

示例4: CVariant

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;
}
开发者ID:CEikermann,项目名称:xbmc,代码行数:37,代码来源:SettingsOperations.cpp

示例5: GetStringOptions

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;
}
开发者ID:,项目名称:,代码行数:36,代码来源:


注:本文中的DynamicStringSettingOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。