本文整理汇总了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();
}
示例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();
}