本文整理汇总了C++中CSetting::SetOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ CSetting::SetOrder方法的具体用法?C++ CSetting::SetOrder怎么用?C++ CSetting::SetOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSetting
的用法示例。
在下文中一共展示了CSetting::SetOrder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSettingsFromMappingsFile
void CPeripherals::GetSettingsFromMappingsFile(TiXmlElement *xmlNode, map<CStdString, CSetting *> &m_settings)
{
TiXmlElement *currentNode = xmlNode->FirstChildElement("setting");
int iMaxOrder(0);
while (currentNode)
{
CSetting *setting = NULL;
CStdString strKey(currentNode->Attribute("key"));
if (strKey.IsEmpty())
continue;
CStdString strSettingsType(currentNode->Attribute("type"));
int iLabelId = currentNode->Attribute("label") ? atoi(currentNode->Attribute("label")) : -1;
bool bConfigurable = (!currentNode->Attribute("configurable") ||
strcmp(currentNode->Attribute("configurable"), "") == 0 ||
(strcmp(currentNode->Attribute("configurable"), "no") != 0 &&
strcmp(currentNode->Attribute("configurable"), "false") != 0 &&
strcmp(currentNode->Attribute("configurable"), "0") != 0));
if (strSettingsType.Equals("bool"))
{
bool bValue = (strcmp(currentNode->Attribute("value"), "no") != 0 &&
strcmp(currentNode->Attribute("value"), "false") != 0 &&
strcmp(currentNode->Attribute("value"), "0") != 0);
setting = new CSettingBool(0, strKey, iLabelId, bValue, CHECKMARK_CONTROL);
}
else if (strSettingsType.Equals("int"))
{
int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0;
int iMin = currentNode->Attribute("min") ? atoi(currentNode->Attribute("min")) : 0;
int iStep = currentNode->Attribute("step") ? atoi(currentNode->Attribute("step")) : 1;
int iMax = currentNode->Attribute("max") ? atoi(currentNode->Attribute("max")) : 255;
CStdString strFormat(currentNode->Attribute("format"));
setting = new CSettingInt(0, strKey, iLabelId, iValue, iMin, iStep, iMax, SPIN_CONTROL_INT, strFormat);
}
else if (strSettingsType.Equals("float"))
{
float fValue = currentNode->Attribute("value") ? (float) atof(currentNode->Attribute("value")) : 0;
float fMin = currentNode->Attribute("min") ? (float) atof(currentNode->Attribute("min")) : 0;
float fStep = currentNode->Attribute("step") ? (float) atof(currentNode->Attribute("step")) : 0;
float fMax = currentNode->Attribute("max") ? (float) atof(currentNode->Attribute("max")) : 0;
setting = new CSettingFloat(0, strKey, iLabelId, fValue, fMin, fStep, fMax, SPIN_CONTROL_FLOAT);
}
else if (strSettingsType.Equals("enum"))
{
CStdString strEnums(currentNode->Attribute("lvalues"));
if (!strEnums.IsEmpty())
{
map<int,int> enums;
vector<CStdString> valuesVec;
CUtil::Tokenize(strEnums, valuesVec, "|");
for (unsigned int i = 0; i < valuesVec.size(); i++)
enums.insert(make_pair(atoi(valuesVec[i]), atoi(valuesVec[i])));
int iValue = currentNode->Attribute("value") ? atoi(currentNode->Attribute("value")) : 0;
setting = new CSettingInt(0, strKey, iLabelId, iValue, enums, SPIN_CONTROL_TEXT);
}
}
else
{
CStdString strValue(currentNode->Attribute("value"));
setting = new CSettingString(0, strKey, iLabelId, strValue, EDIT_CONTROL_INPUT, !bConfigurable, -1);
}
if (setting)
{
//TODO add more types if needed
/* set the visibility */
setting->SetVisible(bConfigurable);
/* set the order */
int iOrder(0);
currentNode->Attribute("order", &iOrder);
/* if the order attribute is invalid or 0, then the setting will be added at the end */
if (iOrder < 0)
iOrder = 0;
setting->SetOrder(iOrder);
if (iOrder > iMaxOrder)
iMaxOrder = iOrder;
/* and add this new setting */
m_settings[strKey] = setting;
}
currentNode = currentNode->NextSiblingElement("setting");
}
/* add the settings without an order attribute or an invalid order attribute set at the end */
for (map<CStdString, CSetting *>::iterator it = m_settings.begin(); it != m_settings.end(); it++)
{
if (it->second->GetOrder() == 0)
it->second->SetOrder(++iMaxOrder);
}
}