本文整理汇总了C++中QDomNamedNodeMap类的典型用法代码示例。如果您正苦于以下问题:C++ QDomNamedNodeMap类的具体用法?C++ QDomNamedNodeMap怎么用?C++ QDomNamedNodeMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDomNamedNodeMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadContent
void DialogEditNodeTable::LoadContent()
{
//Load the element value
m_pValueLine->setText(m_node.toElement().text());
//Get all the attributes
QDomNamedNodeMap attributes = m_node.attributes();
m_pTable->setRowCount(attributes.size());
QTableWidgetItem* item = 0;
//Add each attribute in to the table
for(int indexRow=0; indexRow < attributes.size(); ++indexRow)
{
int columnIndex = 0;
QDomAttr attributeNode = attributes.item(indexRow).toAttr();
item = new QTableWidgetItem(attributeNode.nodeName());// << attribute name
item->setToolTip(attributeNode.nodeName());
m_pTable->setItem(indexRow, columnIndex, item);
columnIndex++;
item = new QTableWidgetItem(attributeNode.nodeValue());// << value
item->setToolTip(attributeNode.nodeValue());
m_pTable->setItem(indexRow, columnIndex, item);
columnIndex++;
}
}
示例2: setArgs
void GTest_RunCMDLine::setArgs(const QDomElement & el) {
QString commandLine;
QDomNamedNodeMap map = el.attributes();
int mapSz = map.length();
for( int i = 0; i < mapSz; ++i ) {
QDomNode node = map.item(i);
if(node.nodeName() == "message"){
expectedMessage = node.nodeValue();
continue;
}
if(node.nodeName() == "nomessage"){
unexpectedMessage = node.nodeValue();
continue;
}
if(node.nodeName() == WORKINK_DIR_ATTR){
continue;
}
QString argument = "--" + node.nodeName() + "=" + getVal(node.nodeValue());
if( argument.startsWith("--task") ) {
args.prepend(argument);
commandLine.prepend(argument + " ");
} else {
args.append(argument);
commandLine.append(argument + " ");
}
}
args.append("--log-level-details");
args.append("--lang=en");
args.append("--log-no-task-progress");
commandLine.append(QString(" --log-level-details --lang=en --log-no-task-progress"));
cmdLog.info(commandLine);
}
示例3: QVariant
//! [3]
QVariant DomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNode node = item->node();
//! [3] //! [4]
QStringList attributes;
QDomNamedNodeMap attributeMap = node.attributes();
switch (index.column()) {
case 0:
return node.nodeName();
case 1:
for (int i = 0; i < attributeMap.count(); ++i) {
QDomNode attribute = attributeMap.item(i);
attributes << attribute.nodeName() + "=\""
+attribute.nodeValue() + "\"";
}
return attributes.join(" ");
case 2:
return node.nodeValue().split("\n").join(" ");
default:
return QVariant();
}
}
示例4: LOG_ERROR_FOR
/** Construct an DrugDrugInteraction object using the XML QDomElement. */
DrugDrugInteraction::DrugDrugInteraction(const QDomElement &element)
{
if (element.tagName()!="DDI") {
LOG_ERROR_FOR("DrugDrugInteraction", "Wrong XML Element");
} else {
m_Data.insert(FirstInteractorName, Constants::correctedUid(Utils::removeAccents(element.attribute("i1"))));
m_Data.insert(SecondInteractorName, Constants::correctedUid(Utils::removeAccents(element.attribute("i2"))));
m_Data.insert(FirstInteractorRouteOfAdministrationIds, element.attribute("i1ra").split(";"));
m_Data.insert(SecondInteractorRouteOfAdministrationIds, element.attribute("i2ra").split(";"));
m_Data.insert(LevelCode, element.attribute("l"));
m_Data.insert(LevelName, ::levelName(element.attribute("l")));
m_Data.insert(DateCreation, QDate::fromString(element.attribute("a", QDate(2010,01,01).toString(Qt::ISODate)), Qt::ISODate));
m_Data.insert(DateLastUpdate, QDate::fromString(element.attribute("lu", QDate(2010,01,01).toString(Qt::ISODate)), Qt::ISODate));
m_Data.insert(IsValid, element.attribute("v", "1").toInt());
m_Data.insert(IsReviewed, element.attribute("rv", "0").toInt());
if (!element.attribute("p").isEmpty())
m_Data.insert(PMIDsStringList, element.attribute("p").split(";"));
m_Data.insert(IsDuplicated, false);
// Read Risk
QDomElement risk = element.firstChildElement("R");
while (!risk.isNull()) {
setRisk(risk.attribute("t"), risk.attribute("l"));
risk = risk.nextSiblingElement("R");
}
// Read Management
QDomElement management = element.firstChildElement("M");
while (!management.isNull()) {
setManagement(management.attribute("t"), management.attribute("l"));
management = management.nextSiblingElement("M");
}
// Read Dose related interactions
QDomElement dose = element.firstChildElement("D");
while (!dose.isNull()) {
DrugDrugInteractionDose *ddidose = 0;
if (dose.attribute("i") == "1") {
ddidose = &m_FirstDose;
} else {
ddidose = &m_SecondDose;
}
if (dose.attribute("uf").toInt()==1) {
ddidose->setData(DrugDrugInteractionDose::UsesFrom, true);
ddidose->setData(DrugDrugInteractionDose::FromValue , dose.attribute("fv"));
ddidose->setData(DrugDrugInteractionDose::FromUnits, dose.attribute("fu"));
ddidose->setData(DrugDrugInteractionDose::FromRepartition , dose.attribute("fr"));
} else if (dose.attribute("ut").toInt()==1) {
ddidose->setData(DrugDrugInteractionDose::UsesTo, true);
ddidose->setData(DrugDrugInteractionDose::ToValue , dose.attribute("tv"));
ddidose->setData(DrugDrugInteractionDose::ToUnits, dose.attribute("tu"));
ddidose->setData(DrugDrugInteractionDose::ToRepartition , dose.attribute("tr"));
}
dose = dose.nextSiblingElement("D");
}
// Read formalized risk
QDomElement form = element.firstChildElement("F");
QDomNamedNodeMap attributeMap = form.attributes();
for(int i=0; i < attributeMap.size(); ++i) {
addFormalized(attributeMap.item(i).nodeName(), form.attribute(attributeMap.item(i).nodeName()));
}
}
}
示例5: initPins
void ComponentItem::initPins()
{
QDomNode pinsNode;
QDomNodeList list = m_svgDocument.elementsByTagName("g");
for (int i=0;i<list.count();i++){
QDomNamedNodeMap attrs = list.item(i).attributes();
if (attrs.contains("id") &&
attrs.namedItem("id").toAttr().value() == QString("pins")){
pinsNode = list.item(i);
break;
}
}
if (pinsNode.isNull() || !pinsNode.hasChildNodes()){
kWarning() << "No pins definition found for this component";
return;
}
QDomElement pin = pinsNode.firstChildElement();
while (!pin.isNull()) {
QRectF pinRect;
double r = pin.attribute("r").toDouble();
pinRect.setLeft(pin.attribute("cx").toDouble());
pinRect.setTop(pin.attribute("cy").toDouble());
pinRect.setWidth(r*2);
pinRect.setHeight(r*2);
PinItem* p = new PinItem(pinRect, this, qobject_cast< IDocumentScene* >(scene()));
p->setId(pin.attribute("id"));
pin = pin.nextSiblingElement();
}
}
示例6: copyAttributes
void DefinitionParser::copyAttributes (AssetBit* asset, const QDomNamedNodeMap& attributes) const
{
asset->x = attributes.namedItem(ATTR_X).nodeValue();
asset->y = attributes.namedItem(ATTR_Y).nodeValue();
asset->alpha = attributes.namedItem(ATTR_ALPHA).nodeValue();
asset->visible = attributes.namedItem(ATTR_VISIBLE).nodeValue();
}
示例7: findAddOnHeader
//copyright : (C) 2002-2004 InfoSiAL S.L.
//email : [email protected]
void MReportEngine::drawAddOnHeader(MPageCollection *pages, int level,
QPtrList<QMemArray<double> > *gDT,
QValueVector<QString> *gDTS)
{
MReportSection *header = findAddOnHeader(level);
if (header) {
QDomNode record = records.item(currRecord_);
if (!header->mustBeDrawed(&record))
return;
header->setPageNumber(currPage);
header->setReportDate(currDate);
if ((currY + header->getHeight()) > currHeight)
newPage(pages);
QString value;
QDomNamedNodeMap fields = record.attributes();
for (int i = 0; i < header->getFieldCount(); i++) {
value = fields.namedItem(header->getFieldName(i)).nodeValue();
header->setFieldData(i, value, &record, fillRecords_);
}
if (gDT && level > -1)
header->setCalcFieldData(gDT, gDTS, &record, fillRecords_);
header->setCalcFieldDataGT(grandTotal);
int sectionHeight = header->getHeight();
header->draw(p, leftMargin, currY, sectionHeight);
currY += sectionHeight;
}
}
示例8: setName
void ViElement::fromDom(QDomNode &dom)
{
setName(dom.toElement().tagName());
QDomNamedNodeMap attributes = dom.attributes();
for(int i = 0; i < attributes.size(); ++i)
{
addAttribute(ViAttribute(attributes.item(i).nodeName(), attributes.item(i).nodeValue()));
}
QDomNodeList children = dom.childNodes();
if(children.size() > 0)
{
for(int i = 0; i < children.size(); ++i)
{
if(children.item(i).isText())
{
setValue(children.item(i).nodeValue());
}
else
{
ViElement child;
QDomNode node = children.item(i);
child.fromDom(node);
addChild(child);
}
}
}
else
{
setValue(dom.nodeValue());
}
}
示例9: modify
void SvgImage::modify(const QString &tag, const QString &id, const QString &attribute,
const QString &value)
{
bool modified = false;
QDomNodeList nodeList = m_svgDocument.elementsByTagName( tag );
for ( int i = 0; i < nodeList.count(); ++i )
{
QDomNode node = nodeList.at( i );
QDomNamedNodeMap attributes = node.attributes();
if ( checkIDAttribute( attributes, id ) )
{
QDomNode attrElement = attributes.namedItem( attribute );
if ( attrElement.isAttr() )
{
QDomAttr attr = attrElement.toAttr();
attr.setValue( value );
modified = true;
}
}
}
if ( modified )
{
m_updateNeeded = true;
update();
}
}
示例10: helperToXmlAddDomElement
static void helperToXmlAddDomElement(QXmlStreamWriter* stream, const QDomElement& element, const QStringList &omitNamespaces)
{
stream->writeStartElement(element.tagName());
/* attributes */
QString xmlns = element.namespaceURI();
if (!xmlns.isEmpty() && !omitNamespaces.contains(xmlns))
stream->writeAttribute("xmlns", xmlns);
QDomNamedNodeMap attrs = element.attributes();
for (int i = 0; i < attrs.size(); i++)
{
QDomAttr attr = attrs.item(i).toAttr();
stream->writeAttribute(attr.name(), attr.value());
}
/* children */
QDomNode childNode = element.firstChild();
while (!childNode.isNull())
{
if (childNode.isElement())
{
helperToXmlAddDomElement(stream, childNode.toElement(), QStringList() << xmlns);
} else if (childNode.isText()) {
stream->writeCharacters(childNode.toText().data());
}
childNode = childNode.nextSibling();
}
stream->writeEndElement();
}
示例11: QLatin1Char
void WAccount::fillStrings(QString &text, QString &html, const QDomElement &element, const QString &prefix)
{
QString key = prefix + QLatin1Char('%');
if (key != QLatin1String("%%")) {
text.replace(key, element.text());
html.replace(key, element.text().toHtmlEscaped());
qDebug() << key;
}
key.chop(1);
QDomNamedNodeMap attributes = element.attributes();
for (int i = 0; i < attributes.count(); ++i) {
QDomNode attribute = attributes.item(i);
QString attributeKey = key
% QLatin1Char('/')
% attribute.nodeName()
% QLatin1Char('%');
qDebug() << attributeKey;
text.replace(attributeKey, attribute.nodeValue());
html.replace(attributeKey, attribute.nodeValue().toHtmlEscaped());
}
if (!key.endsWith(QLatin1Char('%')))
key += QLatin1Char('/');
QDomNodeList elementChildren = element.childNodes();
for (int i = 0; i < elementChildren.count(); ++i) {
QDomNode node = elementChildren.at(i);
if (node.isElement())
fillStrings(text, html, node.toElement(), key + node.nodeName());
}
}
示例12: searchFinished
void WSettings::searchFinished(QNetworkReply *reply)
{
reply->deleteLater();
ui.addButton->setEnabled(true);
ui.searchEdit->clear();
QDomDocument doc;
if (!doc.setContent(reply->readAll()))
return;
QDomElement rootElement = doc.documentElement();
QDomNodeList locations = rootElement.elementsByTagName(QLatin1String("location"));
if (locations.isEmpty())
ui.searchEdit->addItem(tr("Not found"));
for (int i = 0; i < locations.count(); i++) {
QDomNamedNodeMap attributes = locations.at(i).attributes();
QString cityId = attributes.namedItem(QLatin1String("location")).nodeValue();
QString cityName = attributes.namedItem(QLatin1String("city")).nodeValue();
QString stateName = attributes.namedItem(QLatin1String("state")).nodeValue();
QString cityFullName = cityName + ", " + stateName;
int index = ui.searchEdit->count();
ui.searchEdit->addItem(cityFullName);
ui.searchEdit->setItemData(index, cityId, CodeRole);
ui.searchEdit->setItemData(index, cityName, CityRole);
ui.searchEdit->setItemData(index, stateName, StateRole);
}
}
示例13: QVariant
QVariant MetricDomModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNode node = item->node();
QStringList attributes;
QDomNamedNodeMap attributeMap = node.attributes();
switch (index.column()) {
case 0:
return node.nodeName();
case 1:
if( !attributeMap.contains("Type") ) {
return QVariant();
}
return attributeMap.namedItem("Type").nodeValue();
case 2:
if( !attributeMap.contains("Format") ) {
return QVariant();
}
return attributeMap.namedItem("Format").nodeValue();
default:
return QVariant();
}
}
示例14: cleanMathml
void cleanMathml(QDomElement pElement)
{
// Clean up the current element
// Note: the idea is to remove all the attributes that are not in the
// MathML namespace. Indeed, if we were to leave them in then the XSL
// transformation would either do nothing or, worst, crash OpenCOR...
static const QString MathmlNamespace = "http://www.w3.org/1998/Math/MathML";
QDomNamedNodeMap attributes = pElement.attributes();
QList<QDomNode> nonMathmlAttributes = QList<QDomNode>();
for (int i = 0, iMax = attributes.count(); i < iMax; ++i) {
QDomNode attribute = attributes.item(i);
if (attribute.namespaceURI().compare(MathmlNamespace))
nonMathmlAttributes << attribute;
}
foreach (QDomNode nonMathmlAttribute, nonMathmlAttributes)
pElement.removeAttributeNode(nonMathmlAttribute.toAttr());
// Go through the element's child elements, if any, and clean them up
for (QDomElement childElement = pElement.firstChildElement();
!childElement.isNull(); childElement = childElement.nextSiblingElement()) {
cleanMathml(childElement);
}
}
示例15: removeNamedItem
QDomNode QDomNamedNodeMapProto:: removeNamedItem(const QString& name)
{
QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject());
if (item)
return item->removeNamedItem(name);
return QDomNode();
}