本文整理汇总了C++中QDomDocument::replaceChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::replaceChild方法的具体用法?C++ QDomDocument::replaceChild怎么用?C++ QDomDocument::replaceChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::replaceChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replaceChild
QDomNode QDomDocumentProto::replaceChild(const QDomNode& newChild, const QDomNode& oldChild)
{
QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
if (item)
return item->replaceChild(newChild, oldChild);
return QDomNode();
}
示例2: setInputParametersXml
void OpenModelica::setInputParametersXml(QDomDocument &doc,MOParameters *parameters)
{
QDomElement xfmi = doc.firstChildElement("fmiModelDescription");
QDomElement oldxfmi = xfmi;
QDomElement xExp = xfmi.firstChildElement("DefaultExperiment");
QDomElement oldxExp = xExp;
double starttime = parameters->value(OpenModelicaParameters::str(OpenModelicaParameters::STARTTIME),0).toDouble();
double stoptime = parameters->value(OpenModelicaParameters::str(OpenModelicaParameters::STOPTIME),1).toDouble();
int nbIntervals = parameters->value(OpenModelicaParameters::str(OpenModelicaParameters::NBINTERVALS),2).toInt();
double stepSize = (stoptime-starttime)/nbIntervals;
MOParameter * curParam;
MOParameterListed* curParamListed;
for(int i=0;i<parameters->size();i++)
{
curParam = parameters->at(i);
if(!curParam->name().contains(" ")) // remove old parameters, temporary
{
if(curParam->name()==OpenModelicaParameters::str(OpenModelicaParameters::SOLVER))
{
curParamListed = dynamic_cast<MOParameterListed*>(curParam);
xExp.setAttribute(curParamListed->name(),curParamListed->strValue());
}
else if(curParam->name()==OpenModelicaParameters::str(OpenModelicaParameters::OUTPUT))
{
curParamListed = dynamic_cast<MOParameterListed*>(curParam);
xExp.setAttribute(curParamListed->name(),curParamListed->strValue());
}
else if (curParam->name()==OpenModelicaParameters::str(OpenModelicaParameters::NBINTERVALS))
{
xExp.setAttribute("stepSize",QString::number(stepSize));
}
else
{
xExp.setAttribute(curParam->name(),curParam->value().toString());
}
}
}
// update xfmi with new vars
xfmi.replaceChild(xExp,oldxExp);
doc.replaceChild(xfmi,oldxfmi);
}
示例3: setInputVariablesXml
void ModPlusExeCtrl::setInputVariablesXml(QDomDocument & doc, QString modelName, MOVector<Variable> *variables)
{
QDomElement xfmi = doc.firstChildElement("fmiModelDescription");
QDomElement oldxfmi = xfmi;
QDomElement xModelVars = xfmi.firstChildElement("ModelVariables");
QDomElement oldxModelVars = xModelVars;
QDomNodeList listScalarVars = xModelVars.elementsByTagName("ScalarVariable");
// filling map
QMap<QString,int> mapScalarVars; //<name,index in listScalarVars>
QMap<QDomElement,QDomElement> mapNewScalarVars; // <old node,new node>
QDomElement curVar;
QDomElement oldVar;
QDomElement newVar;
int index;
QDomElement oldType;
QDomElement newType;
QString localVarName;
// create map for index looking
for(int i=0;i<listScalarVars.size();i++)
{
curVar = listScalarVars.at(i).toElement();
mapScalarVars.insert(curVar.attribute("name"),i);
}
// change variables values
for(int i=0;i<variables->size();i++)
{
// getting local var name (name in init file does not contain model name)
localVarName = variables->at(i)->name(Variable::SHORT);
if(localVarName.contains(modelName))
localVarName = localVarName.remove(modelName+".");
index = mapScalarVars.value(localVarName,-1);
if(index>-1)
{
oldVar = listScalarVars.at(index).toElement();
newVar = oldVar;
oldType = newVar.firstChildElement("Real");
if(oldType.isNull())
oldType = newVar.firstChildElement("Integer");
if(oldType.isNull())
oldType = newVar.firstChildElement("Boolean");
if(!oldType.isNull())
{
newType = oldType;
newType.setAttribute("start",variables->at(i)->value().toString());
newVar.replaceChild(newType,oldType);
xModelVars.replaceChild(newVar,oldVar);
}
xModelVars.replaceChild(newVar,oldVar);
}
}
// update xfmi with new vars
xfmi.replaceChild(xModelVars,oldxModelVars);
doc.replaceChild(xfmi,oldxfmi);
}