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


C++ QDomDocument::replaceChild方法代码示例

本文整理汇总了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();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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);
}
开发者ID:cephdon,项目名称:OMOptim,代码行数:48,代码来源:OpenModelica.cpp

示例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);
}
开发者ID:cephdon,项目名称:OMOptim,代码行数:64,代码来源:ModPlusExeCtrl.cpp


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