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


C++ QDomNamedNodeMap::removeNamedItem方法代码示例

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


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

示例1: QDomNode

QDomNode QDomNamedNodeMapProto:: removeNamedItem(const QString& name)
{
  QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
  if (item)
    return item->removeNamedItem(name);
  return QDomNode();
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:7,代码来源:qdomnamednodemapproto.cpp

示例2: ApplyButtonPressed

void DialogEditNodeTable::ApplyButtonPressed()
{
    XmlEditCommandAggregator* commandAggregator = new XmlEditCommandAggregator(m_pXmlDocument);

    //Get all the attributes
    QDomNamedNodeMap attributes = m_node.attributes();

    //First remove the attributes the isn't present now
    for(int i=attributes.size()-1; i >= 0; i--)
    {
        bool attributePresent = false;
        QString attributeName = attributes.item(i).nodeName();

        //For each present attribute in the table
        for(int k=0; k < m_pTable->rowCount() && !attributePresent; ++k)
        {
            QString tableAttributeName = m_pTable->item(k, 0)->text();

            if(tableAttributeName != "" && attributeName == tableAttributeName)
            {
                attributePresent = true;
            }
        }

        //If the attribute is no longer present
        if(!attributePresent)
        {
            //Remove from the list
            attributes.removeNamedItem(attributeName);
            //Add an action to remove it
            commandAggregator->AddCommand(new XmlEditCommandRemoveAttribute(m_pXmlDocument, m_identifierNumber, attributeName));
        }
    }

    //Now the attributesList contains all the attribute that is present in the node
    //In the table it can be present more attribute (newly added ones)

    //Add the attributes that isn't present yet (new attribute) and modify the attributes already present
    for(int k=0; k < m_pTable->rowCount(); ++k)
    {
        bool attributeAlreadyPresent = false;
        QString tableAttributeName = m_pTable->item(k, 0)->text();
        QString tableAttributeValue = m_pTable->item(k, 1)->text();

        QString previousAttributeValue;

        //Not add the empty attribute name
        if(tableAttributeName != "")
        {
            //For each attribute already present
            for(int i=0;i < attributes.size() && !attributeAlreadyPresent; ++i)
            {
                if(attributes.item(i).nodeName() == tableAttributeName)
                {
                    attributeAlreadyPresent = true;
                    previousAttributeValue = attributes.item(i).nodeValue();
                }
            }

            //If the attribute is not present yet
            if(!attributeAlreadyPresent)
            {
                //Add an action to add it
                commandAggregator->AddCommand(new XmlEditCommandAddAttribute(m_pXmlDocument, m_identifierNumber, tableAttributeName,
                                                                             tableAttributeValue));
            }
            else //The attribute is yet present so maybe its value is changed
            {
                //If the value of the already present attribute is changed
                if(previousAttributeValue != tableAttributeValue)
                {
                    //Add an action to change its value
                    commandAggregator->AddCommand(new XmlEditCommandEditAttribute(m_pXmlDocument, m_identifierNumber, tableAttributeName,
                                                                                 tableAttributeValue));
                }
            }
        }
    }

    const QString& currentValue = m_pValueLine->text();

    //If the value is changed set the new
    if(m_node.toElement().text() != currentValue)
    {
        commandAggregator->AddCommand(new XmlEditCommandSetNodeValue(m_pXmlDocument, m_identifierNumber, currentValue));
    }

    if(commandAggregator->Size() > 0)
    {
        m_pXmlEditCommandInvoker->ExecuteACommand( commandAggregator );
    }
    QDialog::accept();
}
开发者ID:Mauxx91,项目名称:XML-Editor,代码行数:93,代码来源:DialogEditNodeTable.cpp


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