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++; } }
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 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(); } }
/** 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())); } } }
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(); } }
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(); }
//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; } }
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()); } }
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(); } }
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(); }
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()); } }
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); } }
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(); } }
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); } }
QDomNode QDomNamedNodeMapProto:: removeNamedItem(const QString& name) { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return item->removeNamedItem(name); return QDomNode(); }
QDomNode QDomNamedNodeMapProto:: setNamedItemNS(const QDomNode& newNode) { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return item->setNamedItemNS(newNode); return QDomNode(); }
bool DefinitionParser::createSingleFrameAsset (QDomNode& node, const Content::Class clazz, const QString& tag) { QDomNamedNodeMap attr = node.attributes(); const QString name = attr.namedItem(ATTR_CLASS).nodeValue(); const QString pathattr = attr.namedItem(ATTR_PATH).nodeValue(); if (pathattr.isEmpty()) { warnMissingAttr(ATTR_PATH, tag); return false; } const QString path = _targetDir.absoluteFilePath(pathattr); if (!checkPathExists(path)) { return false; } if (name.isEmpty()) { warnMissingAttr(ATTR_CLASS, tag); return false; } if (clazz == Content::SPRITE || clazz == Content::MOVIECLIP) { struct AssetBit asset; asset.path = _tempDir.relativeFilePath(path); copyAttributes(&asset, attr); struct SpriteAsset* sprite = new SpriteAsset(); sprite->assets.push_back(asset); sprite->clazz = clazz; sprite->name = name; _assets[name] = sprite; } else { struct Asset* common = new Asset(); common->path = path; common->name = name; _assets[name] = common; } return true; }
QString QDomNamedNodeMapProto::toString() const { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return QString("[QDomNamedNodeMap(size = %1)]").arg(item->size()); return QString("[QDomNamedNodeMap(unknown)]"); }
//copyright : (C) 2002-2004 InfoSiAL S.L. //email : [email protected] void MReportEngine::drawDetailHeader(MPageCollection *pages, int level) { MReportSection *header = findDetailHeader(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_); } header->setCalcFieldData(0, 0, &record, fillRecords_); int sectionHeight = header->getHeight(); header->draw(p, leftMargin, currY, sectionHeight); header->setLastPageIndex(pages->getCurrentIndex()); header->setOnPage((QPicture *) p->painter()->device()); currY += sectionHeight; } }
bool QDomNamedNodeMapProto:: contains(const QString& name) const { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return item->contains(name); return false; }
void XML::XMLToVariables(MOVector<Variable> & variables,QDomElement &element) { variables.clear(); QDomElement e; QDomNode n = element.firstChild(); QString fieldName; int iField; while( !n.isNull() ) { e = n.toElement(); if( !e.isNull() && (e.tagName()=="Variable")) { Variable* newVar = new Variable(); QDomNamedNodeMap attributes = e.attributes(); for(int i=0;i<attributes.count();i++) { iField = newVar->getFieldIndex(attributes.item(i).toAttr().name()); if(iField>-1) newVar->setFieldValue(iField,QVariant(attributes.item(i).toAttr().value())); } variables.addItem(newVar); } n = n.nextSibling(); } }
bool QDomNamedNodeMapProto:: isEmpty() const { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return item->isEmpty(); return false; }
bool Configurator::loadSectionItem( QDomNode sectionItem, QListWidget& listWidget ) { if( false == sectionItem.hasChildNodes() ) return false; if( sectionItem.nodeName() != c_sectionItemNodeName ) return false; QDomNamedNodeMap sectionItemAttributes = sectionItem.attributes(); if( false == sectionItemAttributes.contains(c_attributeName) ) return false; if( false == sectionItemAttributes.contains(c_attributeText) ) return false; // add the item to the section QString sectionItemName = sectionItemAttributes.namedItem(c_attributeName).nodeValue(); QString sectionItemText = sectionItemAttributes.namedItem(c_attributeText).nodeValue(); QListWidgetItem* listWidgetItem = new QListWidgetItem(); listWidgetItem->setText( sectionItemText ); listWidgetItem->setData( Qt::UserRole, sectionItemName ); listWidget.addItem( listWidgetItem ); return true; }
QDomNode QDomNamedNodeMapProto:: item(int index) const { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return item->item(index); return QDomNode(); }
QString Unpacker::getVarAppTitle(QString contents) const { QString manifest; QFile f(contents + "/AndroidManifest.xml"); if (f.open(QFile::ReadOnly | QFile::Text)) { manifest = f.readAll(); f.close(); } else { return QString(); } // Parse application title variable name: QDomDocument dom; dom.setContent(manifest); QDomNodeList nodes = dom.elementsByTagName("application"); if (!nodes.isEmpty()) { QDomNamedNodeMap attr = nodes.at(0).attributes(); const QString LABEL = attr.namedItem("android:label").nodeValue(); if (LABEL.startsWith("@string/")) { return LABEL.mid(8); } else { return QString(); } } else { return QString(); } }
uint QDomNamedNodeMapProto:: length() const { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return item->length(); return 0; }
void FileWriter::writeElementChilds(const QDomElement &AParent) { QDomNode node = AParent.firstChild(); while (!node.isNull()) { if (node.isElement()) { QDomElement elem = node.toElement(); if (elem.tagName() != "thread") { FXmlWriter->writeStartElement(elem.tagName()); QString elemNs = elem.namespaceURI(); if (!elemNs.isEmpty() && elem.parentNode().namespaceURI()!=elemNs) FXmlWriter->writeAttribute("xmlns",elem.namespaceURI()); QDomNamedNodeMap attrMap = elem.attributes(); for (uint i=0; i<attrMap.length(); i++) { QDomNode attrNode = attrMap.item(i); FXmlWriter->writeAttribute(attrNode.nodeName(), attrNode.nodeValue()); } writeElementChilds(elem); FXmlWriter->writeEndElement(); } } else if (node.isCharacterData()) { FXmlWriter->writeCharacters(node.toCharacterData().data()); } node = node.nextSibling(); } }
QDomNode QDomNamedNodeMapProto:: namedItemNS(const QString& nsURI, const QString& localName) const { QDomNamedNodeMap *item = qscriptvalue_cast<QDomNamedNodeMap*>(thisObject()); if (item) return item->namedItemNS(nsURI, localName); return QDomNode(); }
/** Returns wether the Report Section must be drawed or not depending on the DrawIf attribute and the current record values */ bool MReportSection::mustBeDrawed( QDomNode * record ) { QString value; QDomNamedNodeMap fields = record->attributes(); QString drawIfField = getDrawIf(); if ( !drawIfField.isEmpty() ) { QDomNode n = fields.namedItem( drawIfField ); if ( n.isNull() ) return false; value = n.toAttr().value(); if ( value.isEmpty() ) return false; bool b = true; float f = value.toFloat( &b ); if ( f == 0 && b ) return false; } return true; }
bool OsisData::ProcessAttributes(QDomElement& xmlElement) { // Parse and save attributes QDomNamedNodeMap attr = xmlElement.attributes(); int size = attr.size(); if (!size) { return false; // Error } for (int i = 0; i < size; i++) { QDomAttr at = attr.item(i).toAttr(); QString value(at.value()); int key = getEnumKey("OsisElementAttributes", at.name().toLocal8Bit().constData()); if (key != -1) { if (Attribute.contains(key)) { Attribute.remove(key); } Attribute[key] = value; } else { qCritical() << "<" << ElementName << ">: Unknown attribute: " << at.name() << "=" << value << endl; } } return true; }