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


C++ CSetting类代码示例

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


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

示例1: GetSettingControl

void CGUIWindowSettingsCategory::UpdateControl(const std::string &dependingSetting, const CSettingDependency &dependency)
{
  if (dependingSetting.empty())
    return;

  BaseSettingControlPtr pControl = GetSettingControl(dependingSetting);
  if (pControl == NULL)
    return;

  CSetting *pSetting = pControl->GetSetting();
  if (pSetting == NULL)
    return;

  CheckDependency(pControl, dependency);

  const SettingDependencyMap& deps = m_settings.GetDependencies(pSetting->GetId());
  for (SettingDependencyMap::const_iterator depsIt = deps.begin(); depsIt != deps.end(); depsIt++)
  {
    for (SettingDependencies::const_iterator depIt = depsIt->second.begin(); depIt != depsIt->second.end(); depIt++)
      UpdateControl(depsIt->first, *depIt);
  }

  // update GUI of the changed setting as the change could have been triggered by something else
  pControl->Update();
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: ResetSettingValue

JSONRPC_STATUS CSettingsOperations::ResetSettingValue(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  string settingId = parameterObject["setting"].asString();

  CSetting* setting = CSettings::Get().GetSetting(settingId);
  if (setting == NULL ||
      !setting->IsVisible())
    return InvalidParams;

  switch (setting->GetType())
  {
  case SettingTypeBool:
  case SettingTypeInteger:
  case SettingTypeNumber:
  case SettingTypeString:
  case SettingTypeList:
    setting->Reset();
    break;

  case SettingTypeNone:
  case SettingTypeAction:
  default:
    return InvalidParams;
  }

  return ACK;
}
开发者ID:CEikermann,项目名称:xbmc,代码行数:27,代码来源:SettingsOperations.cpp

示例3: UpdateSettings

void CGUIWindowSettingsCategory::UpdateSettings()
{
  for (vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); it++)
  {
    BaseSettingControlPtr pSettingControl = *it;
    CSetting *pSetting = pSettingControl->GetSetting();
    CGUIControl *pControl = pSettingControl->GetControl();
    if (pSetting == NULL || pControl == NULL)
      continue;

    // update the setting's control's state (enabled/disabled etc)
    const SettingDependencies &deps = pSetting->GetDependencies();
    for (SettingDependencies::const_iterator dep = deps.begin(); dep != deps.end(); dep++)
    {
      // don't check "update" dependencies here as all the controls are already
      // setup properly based on the existing values
      if (dep->GetType() == SettingDependencyTypeUpdate)
        continue;

      CheckDependency(pSettingControl, *dep);
    }

    pSettingControl->Update();
  }
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: IsEnabled

bool CSetting::IsEnabled() const
{
    if (m_dependencies.empty() && m_parentSetting.empty())
        return m_enabled;

    // if the setting has a parent setting and that parent setting is disabled
    // the setting should automatically also be disabled
    if (!m_parentSetting.empty())
    {
        CSetting *parentSetting = m_settingsManager->GetSetting(m_parentSetting);
        if (parentSetting != NULL && !parentSetting->IsEnabled())
            return false;
    }

    bool enabled = true;
    for (SettingDependencies::const_iterator depIt = m_dependencies.begin(); depIt != m_dependencies.end(); ++depIt)
    {
        if (depIt->GetType() != SettingDependencyTypeEnable)
            continue;

        if (!depIt->Check())
        {
            enabled = false;
            break;
        }
    }

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

示例5: fromValues

bool CSettingList::fromValues(const std::vector<std::string> &strValues, SettingPtrList &values) const
{
    if ((int)strValues.size() < m_minimumItems ||
            (m_maximumItems > 0 && (int)strValues.size() > m_maximumItems))
        return false;

    bool ret = true;
    int index = 0;
    for (std::vector<std::string>::const_iterator itValue = strValues.begin(); itValue != strValues.end(); ++itValue)
    {
        CSetting *settingValue = m_definition->Clone(StringUtils::Format("%s.%d", m_id.c_str(), index++));
        if (settingValue == NULL ||
                !settingValue->FromString(*itValue))
        {
            delete settingValue;
            ret = false;
            break;
        }

        values.push_back(SettingPtr(settingValue));
    }

    if (!ret)
        values.clear();

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

示例6: _ttoi

BOOL CRFIDprototypeApp::CheckGSM()
{
	int nRate;
	nRate = _ttoi(m_strRate);

	while (!::OpenComm(m_strPort, nRate))
	{
		CString strError;
		strError.Format(L"无法打开端口%s! 现在设置吗?", m_strPort);
		if (AfxMessageBox(strError, MB_YESNO) == IDNO) return FALSE;

		CSetting dlg;
		dlg.m_strPort = m_strPort;
		dlg.m_strRate = m_strRate;
		dlg.m_strSmsc = m_strSmsc;
		if (dlg.DoModal() == IDOK)
		{
			m_strPort = dlg.m_strPort;
			m_strRate = dlg.m_strRate;
			m_strSmsc = dlg.m_strSmsc;
		
		}
		else
		{
			return FALSE;
		}
	}

	if (!gsmInit())
	{
		CString strError;
		strError.Format(L"端口%s上没有发现MODEM!", m_strPort);
		AfxMessageBox(strError, MB_OK);
		CloseComm();
		return FALSE;
	}

	if (m_strSmsc.IsEmpty())
	{
		AfxMessageBox(L"请设置SMSC!");
		 
 		CSetting dlg;
 		dlg.m_strPort = m_strPort;
 		dlg.m_strRate = m_strRate;
 		dlg.m_strSmsc = m_strSmsc;
 		if (dlg.DoModal() == IDOK)
 		{
 			m_strPort = dlg.m_strPort;
 			m_strRate = dlg.m_strRate;
 			m_strSmsc = dlg.m_strSmsc;
 		}
 		else
 		{
			CloseComm();
 			return FALSE;
 		}
	}

	return TRUE;
}
开发者ID:yourgods,项目名称:RFID,代码行数:60,代码来源:RFID+prototype.cpp

示例7: switch

bool CGUIWindowSettingsCategory::OnAction(const CAction &action)
{
  switch (action.GetID())
  {
    case ACTION_SETTINGS_RESET:
    {
      if (CGUIDialogYesNo::ShowAndGetInput(10041, 0, 10042, 0))
      {
        for(vector<BaseSettingControlPtr>::iterator it = m_settingControls.begin(); it != m_settingControls.end(); ++it)
        {
          CSetting *setting = (*it)->GetSetting();
          if (setting != NULL)
            setting->Reset();
        }
      }
      return true;
    }

    case ACTION_SETTINGS_LEVEL_CHANGE:
    {
      //Test if we can access the new level
      if (!g_passwordManager.CheckSettingLevelLock(CViewStateSettings::Get().GetNextSettingLevel(), true))
        return false;
      
      CViewStateSettings::Get().CycleSettingLevel();
      CSettings::Get().Save();

      // try to keep the current position
      std::string oldCategory;
      if (m_iCategory >= 0 && m_iCategory < (int)m_categories.size())
        oldCategory = m_categories[m_iCategory]->GetId();

      SET_CONTROL_LABEL(CONTRL_BTN_LEVELS, 10036 + (int)CViewStateSettings::Get().GetSettingLevel());
      // only re-create the categories, the settings will be created later
      SetupControls(false);

      m_iCategory = 0;
      // try to find the category that was previously selected
      if (!oldCategory.empty())
      {
        for (int i = 0; i < (int)m_categories.size(); i++)
        {
          if (m_categories[i]->GetId() == oldCategory)
          {
            m_iCategory = i;
            break;
          }
        }
      }

      CreateSettings();
      return true;
    }

    default:
      break;
  }

  return CGUIWindow::OnAction(action);
}
开发者ID:alltech,项目名称:xbmc,代码行数:60,代码来源:GUIWindowSettingsCategory.cpp

示例8: FreeSettingsControls

std::set<std::string> CGUIDialogSettingsBase::CreateSettings()
{
  FreeSettingsControls();

  std::set<std::string> settingMap;

  if (m_categories.size() <= 0)
    return settingMap;

  if (m_iCategory < 0 || m_iCategory >= (int)m_categories.size())
    m_iCategory = 0;

  CGUIControlGroupList *group = dynamic_cast<CGUIControlGroupList *>(GetControl(SETTINGS_GROUP_ID));
  if (group == NULL)
    return settingMap;

  const CSettingCategory* category = m_categories.at(m_iCategory);
  if (category == NULL)
    return settingMap;

  // set the description of the current category
  SetDescription(category->GetHelp());

  const SettingGroupList& groups = category->GetGroups((SettingLevel)GetSettingLevel());
  int iControlID = CONTROL_SETTINGS_START_CONTROL;
  bool first = true;
  for (SettingGroupList::const_iterator groupIt = groups.begin(); groupIt != groups.end(); groupIt++)
  {
    if (*groupIt == NULL)
      continue;

    const SettingList& settings = (*groupIt)->GetSettings((SettingLevel)GetSettingLevel());
    if (settings.size() <= 0)
      continue;

    if (first)
      first = false;
    else
      AddSeparator(group->GetWidth(), iControlID);

    for (SettingList::const_iterator settingIt = settings.begin(); settingIt != settings.end(); settingIt++)
    {
      CSetting *pSetting = *settingIt;
      settingMap.insert(pSetting->GetId());
      AddSetting(pSetting, group->GetWidth(), iControlID);
    }
  }

  if (AllowResettingSettings() && !settingMap.empty())
  {
    // add "Reset" control
    AddSeparator(group->GetWidth(), iControlID);
    AddSetting(m_resetSetting, group->GetWidth(), iControlID);
  }
  
  // update our settings (turns controls on/off as appropriate)
  UpdateSettings();

  return settingMap;
}
开发者ID:Antimoni,项目名称:xbmc,代码行数:60,代码来源:GUIDialogSettingsBase.cpp

示例9: sort

// get all the settings beginning with the term "strGroup"
void CGUISettings::GetSettingsGroup(const char *strGroup, vecSettings &settings)
{
  vecSettings unorderedSettings;
  for (mapIter it = settingsMap.begin(); it != settingsMap.end(); it++)
  {
    if ((*it).first.Left(strlen(strGroup)).Equals(strGroup) && (*it).second->GetOrder() > 0 && !(*it).second->IsAdvanced())
      unorderedSettings.push_back((*it).second);
  }
  // now order them...
  sort(unorderedSettings.begin(), unorderedSettings.end(), sortsettings());

  // remove any instances of 2 separators in a row
  bool lastWasSeparator(false);
  for (vecSettings::iterator it = unorderedSettings.begin(); it != unorderedSettings.end(); it++)
  {
    CSetting *setting = *it;
    // only add separators if we don't have 2 in a row
    if (setting->GetType() == SETTINGS_TYPE_SEPARATOR)
    {
      if (!lastWasSeparator)
        settings.push_back(setting);
      lastWasSeparator = true;
    }
    else
    {
      lastWasSeparator = false;
      settings.push_back(setting);
    }
  }
}
开发者ID:Rocky5,项目名称:XBMC4Kids,代码行数:31,代码来源:GUISettings.cpp

示例10: SetList

bool CSettings::SetList(const std::string &id, const std::vector<CVariant> &value)
{
  CSetting *setting = m_settingsManager->GetSetting(id);
  if (setting == NULL || setting->GetType() != SettingTypeList)
    return false;

  return CSettingUtils::SetList(static_cast<CSettingList*>(setting), value);
}
开发者ID:CEikermann,项目名称:xbmc,代码行数:8,代码来源:Settings.cpp

示例11: GetList

std::vector<CVariant> CSettings::GetList(const std::string &id) const
{
  CSetting *setting = m_settingsManager->GetSetting(id);
  if (setting == NULL || setting->GetType() != SettingTypeList)
    return std::vector<CVariant>();

  return CSettingUtils::GetList(static_cast<CSettingList*>(setting));
}
开发者ID:CEikermann,项目名称:xbmc,代码行数:8,代码来源:Settings.cpp

示例12: switch

bool CSettings::SetList(const std::string &id, const std::vector<CVariant> &value)
{
  CSetting *setting = m_settingsManager->GetSetting(id);
  if (setting == NULL || setting->GetType() != SettingTypeList)
    return false;

  CSettingList *listSetting = static_cast<CSettingList*>(setting);
  SettingPtrList newValues;
  bool ret = true;
  int index = 0;
  for (std::vector<CVariant>::const_iterator itValue = value.begin(); itValue != value.end(); ++itValue)
  {
    CSetting *settingValue = listSetting->GetDefinition()->Clone(StringUtils::Format("%s.%d", listSetting->GetId().c_str(), index++));
    if (settingValue == NULL)
      return false;

    switch (listSetting->GetElementType())
    {
      case SettingTypeBool:
        if (!itValue->isBoolean())
          return false;
        ret = static_cast<CSettingBool*>(settingValue)->SetValue(itValue->asBoolean());
        break;

      case SettingTypeInteger:
        if (!itValue->isInteger())
          return false;
        ret = static_cast<CSettingInt*>(settingValue)->SetValue((int)itValue->asInteger());
        break;

      case SettingTypeNumber:
        if (!itValue->isDouble())
          return false;
        ret = static_cast<CSettingNumber*>(settingValue)->SetValue(itValue->asDouble());
        break;

      case SettingTypeString:
        if (!itValue->isString())
          return false;
        ret = static_cast<CSettingString*>(settingValue)->SetValue(itValue->asString());
        break;

      default:
        ret = false;
        break;
    }

    if (!ret)
    {
      delete settingValue;
      return false;
    }

    newValues.push_back(SettingPtr(settingValue));
  }

  return listSetting->SetValue(newValues);
}
开发者ID:Anankin,项目名称:xbmc,代码行数:58,代码来源:Settings.cpp

示例13: lock

std::string CSettingsManager::GetString(const std::string &id) const
{
  CSharedLock lock(m_settingsCritical);
  CSetting *setting = GetSetting(id);
  if (setting == NULL || setting->GetType() != SettingTypeString)
    return "";

  return ((CSettingString*)setting)->GetValue();
}
开发者ID:Anankin,项目名称:xbmc,代码行数:9,代码来源:SettingsManager.cpp

示例14: lock

bool CSettingsManager::SetInt(const std::string &id, int value)
{
  CSingleLock lock(m_critical);
  CSetting *setting = GetSetting(id);
  if (setting == NULL || setting->GetType() != SettingTypeInteger)
    return false;

  return ((CSettingInt*)setting)->SetValue(value);
}
开发者ID:NHellFire,项目名称:xbmc,代码行数:9,代码来源:SettingsManager.cpp

示例15: ListToValues

std::vector<CVariant> CSettings::GetList(const std::string &id) const
{
  CSetting *setting = m_settingsManager->GetSetting(id);
  if (setting == NULL || setting->GetType() != SettingTypeList)
    return std::vector<CVariant>();

  CSettingList *listSetting = static_cast<CSettingList*>(setting);
  return ListToValues(listSetting, listSetting->GetValue());
}
开发者ID:Anankin,项目名称:xbmc,代码行数:9,代码来源:Settings.cpp


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