void vleSmDT::setInitialValue(const QString& varName, const vle::value::Value& val) { QDomNode var = nodeVariable(varName); if (var.isNull()) { return; } undoStackSm->snapshot(var); QDomNodeList initList = var.toElement().elementsByTagName("initial_value"); if (initList.length() == 0) { //TODO see vpz management of vle values QDomElement dble = mDocSm->createElement("double"); dble.appendChild(mDocSm->createTextNode( val.writeToString().c_str())); QDomElement el = mDocSm->createElement("initial_value"); el.appendChild(dble); var.appendChild(el); } else { QDomNode init_value = initList.at(0); init_value = var.toElement().elementsByTagName("double").at(0); if (init_value.nodeName() == "double") { QDomText dbleval = init_value.childNodes().item(0).toText(); dbleval.setData(val.writeToString().c_str()); } } }
static QString parseInstrName(const QString& name) { QString sName; QDomDocument dom; int line, column; QString err; if (!dom.setContent(name, false, &err, &line, &column)) { QString col, ln; col.setNum(column); ln.setNum(line); QString error = err + "\n at line " + ln + " column " + col; qDebug("error: %s\n", qPrintable(error)); qDebug(" data:<%s>\n", qPrintable(name)); return QString(); } for (QDomNode e = dom.documentElement(); !e.isNull(); e = e.nextSiblingElement()) { for (QDomNode ee = e.firstChild(); !ee.isNull(); ee = ee.nextSibling()) { QDomElement el = ee.toElement(); const QString& tag(el.tagName()); if (tag == "symbol") { QString name = el.attribute(QString("name")); if (name == "flat") sName += "b"; else if (name == "sharp") sName += "#"; } QDomText t = ee.toText(); if (!t.isNull()) sName += t.data(); } } return sName; }
void Format::parseBlock( QTextCursor &cursor, const QDomElement &element ) { // dbg() << "Format::parseBlock()" << endl; QDomNode n; for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) { QDomElement e = n.toElement(); if ( e.tagName() == "fragment" ) { QTextCharFormat format; if ( e.hasAttribute( "link" ) ) { format.setAnchor( true ); QString href = e.attribute( "link" ); format.setAnchorHref( href ); format.setFontUnderline( true ); if ( href.startsWith( "todoodle:" ) ) { format = TextFormats::topicLinkCharFormat( href ); } else { format = TextFormats::hyperLinkCharFormat( href ); } } if ( e.attribute( "bold" ) == "true" ) { format.setFontWeight( QFont::Bold ); } if ( e.attribute( "italic" ) == "true" ) { format.setFontItalic( true ); } int fontSize = 0; if ( e.hasAttribute( "fontsize" ) ) { fontSize = e.attribute( "fontsize" ).toInt(); } else { fontSize = 10; } if ( fontSize > 0 ) format.setFontPointSize( fontSize ); QDomNode n2; for( n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling() ) { // dbg() << "TICK" << endl; QDomText t = n2.toText(); if ( !t.isNull() ) { // dbg() << "TEXT: '" << t.data() << "'" << endl; cursor.insertText( t.data(), format ); // dbg() << "done" << endl; } else { QDomElement e2 = n2.toElement(); if ( !e2.isNull() ) { if ( e2.tagName() == "todo" ) { QTextImageFormat f; if ( e2.attribute( "status" ) == "todo" ) { f.setName( ":/images/todo.png" ); } else { f.setName( ":/images/tododone.png" ); } cursor.insertImage( f ); } } } } } } }
void operator <<= (ScanDescriptionIDL& description, const QDomNode& node) { description.group.length(0); if (!node.isNull()) { QDomNode n1 = node.firstChild(); while(!n1.isNull() ) { if (n1.nodeName() == "sensorgroup") { description.group.length(description.group.length() + 1); description.group[description.group.length() - 1].sensor.length(0); description.group[description.group.length() - 1] <<= n1; } else if (n1.nodeName() == "scantype") { QDomNode n2 = n1.firstChild(); if (!n2.isNull()) { QDomText t = n2.toText(); // try to convert the node to a text description.scanType = t.data().toInt(); } } else if (n1.nodeName() == "eventname") { QDomNode n2 = n1.firstChild(); if (!n2.isNull()) { QDomText t = n2.toText(); // try to convert the node to a text description.eventName = CORBA::string_dup(t.data()); } } n1 = n1.nextSibling(); } } }
/* Esta funcion busca en el xmlDocumento hasta que encuentra el tag y retorna el valor del string contenido por el @param tag: Es la etiqueta que contiene el texto buscado. */ QString SbXmlInterprete::xmlObtenerTexto(QString tag) { xmlElemento = xmlDocumento.documentElement(); // retorna la raiz del documento QDomNode nodo = xmlElemento.firstChild(); // se obtiene el primer Hijo // std::cout << "tagName: " << xmlElemento.tagName() << std::endl; while( ! nodo.isNull()) { QDomElement elemento = nodo.toElement(); QDomNode hijo = elemento.firstChild(); while (! hijo.isNull()) { QDomElement elemento2 = hijo.toElement(); if ( !elemento2.isNull() ) { QString tmpTagName = elemento2.tagName(); // std::cout << tmpTagName; QDomText textChild = hijo.firstChild().toText(); QString tmpTextData = textChild.nodeValue(); // std::cout << ": " << tmpTextData << std::endl; if (elemento2.tagName() == tag) { return tmpTextData; } } hijo = hijo.nextSibling(); } nodo = nodo.nextSibling(); } return ""; }
void operator <<= (SensorDescriptionIDL& sensor, const QDomNode& node) { if (!node.isNull()) { QDomNode n1 = node.firstChild(); while(!n1.isNull() ) { QDomNode n2 = n1.firstChild(); if (!n2.isNull()) { QDomText t = n2.toText(); // try to convert the node to a text if(!t.isNull() ) { // the node was really a text element. if (n1.nodeName() == "minrange") { sensor.minRange = t.data().toInt(); } else if (n1.nodeName() == "maxrange") { sensor.maxRange = t.data().toInt(); } else if (n1.nodeName() == "focus") { sensor.focus = deg2Rad(t.data().toDouble()); } } } n1 = n1.nextSibling(); } } }
void UrlResolverTest::checkVerifyResponse(){ QDomDocument doc("foo"); QDomElement root = doc.createElement("foo"); doc.appendChild(root); QDomElement action = doc.createElement("action"); root.appendChild(action); action.appendChild(doc.createTextNode("register")); QDomElement deviceId = doc.createElement("deviceId"); root.appendChild(deviceId); deviceId.appendChild(doc.createTextNode("deadbeef-dead-beef-dead")); QDomElement protocolVersion = doc.createElement("protocolVersion"); root.appendChild(protocolVersion); QDomText protocolVersionText = doc.createTextNode(SSU_PROTOCOL_VERSION); protocolVersion.appendChild(protocolVersionText); QVERIFY(ssu.verifyResponse(&doc)); protocolVersionText.setData(SSU_PROTOCOL_VERSION ".invalid"); QVERIFY2(!ssu.verifyResponse(&doc), "Ssu::verifyResponse() should fail when protocolVersion does not match SSU_PROTOCOL_VERSION"); }
/** Get the project title XML in file has this form: \verbatim <qgis projectname="default project"> <title>a project title</title> \endverbatim @todo XXX we should go with the attribute xor title, not both. */ static void _getTitle( QDomDocument const &doc, QString & title ) { QDomNodeList nl = doc.elementsByTagName( "title" ); title = ""; // by default the title will be empty if ( !nl.count() ) { QgsDebugMsg( "unable to find title element" ); return; } QDomNode titleNode = nl.item( 0 ); // there should only be one, so zeroth element ok if ( !titleNode.hasChildNodes() ) // if not, then there's no actual text { QgsDebugMsg( "unable to find title element" ); return; } QDomNode titleTextNode = titleNode.firstChild(); // should only have one child if ( !titleTextNode.isText() ) { QgsDebugMsg( "unable to find title element" ); return; } QDomText titleText = titleTextNode.toText(); title = titleText.data(); } // _getTitle
void Ersky9xInterface::appendTextElement(QDomDocument * qdoc, QDomElement * pe, QString name, QString value) { QDomElement e = qdoc->createElement(name); QDomText t = qdoc->createTextNode(name); t.setNodeValue(value); e.appendChild(t); pe->appendChild(e); }
QString KWDWriter::getText(const QDomElement ¶graph) { QDomNode temp = paragraph.elementsByTagName("TEXT").item(0).firstChild(); QDomText currentText = temp.toText(); if (temp.isNull()) { kWarning(30503) << "no text"; } return currentText.data(); }
void UPnpDeviceDesc::SetNumValue( const QDomNode &n, int &nValue ) { if (!n.isNull()) { QDomText oText = n.firstChild().toText(); if (!oText.isNull()) nValue = oText.nodeValue().toInt(); } }
void Ersky9xInterface::appendNumberElement(QDomDocument * qdoc, QDomElement * pe,QString name, int value, bool forceZeroWrite) { if(value || forceZeroWrite) { QDomElement e = qdoc->createElement(name); QDomText t = qdoc->createTextNode(name); t.setNodeValue(QString("%1").arg(value)); e.appendChild(t); pe->appendChild(e); } }
void UPnpDeviceDesc::SetStrValue( const QDomNode &n, QString &sValue ) { if (!n.isNull()) { QDomText oText = n.firstChild().toText(); if (!oText.isNull()) sValue = oText.nodeValue(); } }
static QString getFirstText(QDomElement element) { for (QDomNode dname = element.firstChild(); !dname.isNull(); dname = dname.nextSibling()) { QDomText t = dname.toText(); if (!t.isNull()) return t.data(); } return QString(); }
void QgsProjectBadLayerHandler::setDataSource( QDomNode &layerNode, const QString &dataSource ) { QDomNode dataSourceNode = layerNode.namedItem( QStringLiteral( "datasource" ) ); QDomElement dataSourceElement = dataSourceNode.toElement(); QDomText dataSourceText = dataSourceElement.firstChild().toText(); QgsDebugMsg( "datasource changed from " + dataSourceText.data() ); dataSourceText.setData( dataSource ); QgsDebugMsg( "to " + dataSourceText.data() ); }
/** * Loads the <UML:CheckConstraint> XMI element. */ bool UMLCheckConstraint::load( QDomElement & element ) { QDomNode node = element.firstChild(); QDomText checkConstraintText = node.toText(); if ( checkConstraintText.isNull() ) return false; m_CheckCondition = checkConstraintText.data(); return true; }
QString tagContent(const QDomElement &e) { // look for some tag content for(QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { QDomText i = n.toText(); if(i.isNull()) continue; return i.data(); } return ""; }
void UPnpDeviceDesc::SetBoolValue( const QDomNode &n, bool &nValue ) { if (!n.isNull()) { QDomText oText = n.firstChild().toText(); if (!oText.isNull()) { QString s = oText.nodeValue(); nValue = (s == "yes" || s == "true" || s.toInt()); } } }
/*! *\en * Sets text for current node. * \param text (in) - new text value. * \return void. *\_en \ru * Устанавливает текст текущего узла. * \param text (in) - Значение нового текста. * \return ничего. *\_ru */ bool AExtXML::setText( const QString &text ) { QDomText t; if (current.isNull()) return false; while (!current.firstChild().isNull()) { current.removeChild( current.firstChild() ); } t = xml.createTextNode( text ); if ( t.isNull() ) return false; current.appendChild( t ); return true; }
void operator <<= (SensorPositionIDL& position, const QDomNode& node) { if (!node.isNull()) { QDomNode n1 = node.firstChild(); while(!n1.isNull() ) { QDomNode n2 = n1.firstChild(); if (!n2.isNull()) { QDomText t = n2.toText(); // try to convert the node to a text if(!t.isNull() ) { // the node was really a text element. if (n1.nodeName() == "height") { position.height = t.data().toInt(); } else if (n1.nodeName() == "distance") { position.distance = t.data().toInt(); } else if (n1.nodeName() == "alpha") { position.alpha = deg2Rad(t.data().toDouble()); } else if (n1.nodeName() == "beta") { position.beta = deg2Rad(t.data().toDouble()); } else if (n1.nodeName() == "gamma") { position.gamma = deg2Rad(t.data().toDouble()); } else if (n1.nodeName() == "masked") { position.masked = (t.data() == "true"); } } } n1 = n1.nextSibling(); } } }
QString XmlConfiguration::GetValue( const QString &sSetting, QString sDefault ) { QDomNode node = FindNode( sSetting ); if (!node.isNull()) { // -=>TODO: This Always assumes firstChild is a Text Node... should change QDomText oText = node.firstChild().toText(); if (!oText.isNull()) return oText.nodeValue(); } return sDefault; }
void DifferentialMotionParameters::operator <<= (const QDomNode& _node) { Super::operator<<=(_node); QDomNode n = _node.firstChild(); while( !n.isNull() ) { QDomElement e = n.toElement(); // try to convert the node to an element. if( !e.isNull() ) { // the node was really an element. if (e.tagName()=="parameter") { QDomAttr parameterName = e.attributeNode("name"); QString name; QString value; if (!parameterName.isNull()) { name = parameterName.value(); } else { throw Exception("Parameter tag without name."); } QDomNode n2 = n.firstChild(); while (!n2.isNull()) { QDomText t = n2.toText(); // try to convert the node to a text if(!t.isNull() ) { // the node was really a text element. value = t.data(); break; } n2 = n2.nextSibling(); } if (n2.isNull()) throw Exception("Parameter " + std::string(name) + "without value."); if (name == "MinLTranslation") minLTranslation = value.toInt(); else if (name == "MaxLTranslation") maxLTranslation = value.toInt(); else if (name == "MinRTranslation") minRTranslation = value.toInt(); else if (name == "MaxRTranslation") maxRTranslation = value.toInt(); else if (name == "WheelBase") wheelBase = value.toInt(); } } n = n.nextSibling(); } }
QDomElement ConditionVariable::save(QDomElement* root, QDomDocument* document) { QDomElement condition = Condition::save(root, document); QDomElement type = document->createElement("type"); QDomText typeText = document->createTextNode("variable"); type.appendChild(typeText); condition.appendChild(type); // save name QDomElement name = document->createElement("name"); QDomText nameText = document->createTextNode( QString::fromStdString(m_varName) ); name.appendChild(nameText); condition.appendChild(name); QDomElement value = document->createElement("value"); QDomText valueText = document->createTextNode( QString::number(m_triggerValue) ); value.appendChild(valueText); condition.appendChild(value); // save trigger QDomElement trigger = document->createElement("trigger"); QDomText triggerValue = document->createTextNode(""); switch(m_trigger) { case Equal: triggerValue.setNodeValue("Equal"); break; case NoLongerEqual: triggerValue.setNodeValue("NoLongerEqual"); break; case GreaterThan: triggerValue.setNodeValue("GreaterThan"); break; case LessThan: triggerValue.setNodeValue("LessThan"); break; } trigger.appendChild(triggerValue); condition.appendChild(trigger); return condition; }
QDomText EmoticonExpander::insertEmoticon(QDomText textNode, const Emoticon &emoticon, int index) const { int emoticonLength = emoticon.triggerText().length(); QDomText afterEmoticon = textNode.splitText(index + emoticonLength); textNode.setNodeValue(textNode.nodeValue().mid(0, index)); QDomElement emoticonElement = textNode.ownerDocument().createElement("img"); emoticonElement.setAttribute("emoticon", emoticon.triggerText()); emoticonElement.setAttribute("title", emoticon.triggerText()); emoticonElement.setAttribute("alt", emoticon.triggerText()); emoticonElement.setAttribute("src", "file:///" + m_pathProvider->emoticonPath(emoticon)); textNode.parentNode().insertBefore(emoticonElement, afterEmoticon); return afterEmoticon; }
void Select1::saveData() { kDebug() <<"Select1::saveData()"; kDebug() << ref().toString(); kDebug() <<"Context:" << context().nodeName(); Reference::Segment s; if( ref().segments().size() > 0 ) s = ref().segments().last(); QString txt; if( mProperties->appearance == Full ) { for( int i = 0; i < mRadioButtons.size() && i < mValues.size(); ++i ) { if( mRadioButtons[i]->isChecked() ) { txt = mValues[ i ]; break; } } } else if( mProperties->appearance == Compact ) { if( mListWidget->currentRow() < mValues.size() ) txt = mValues[ mListWidget->currentRow() ]; } else { if( mComboBox->currentIndex() < mValues.size() ) txt = mValues[ mComboBox->currentIndex() ]; } if ( s.isAttribute() ) { context().setAttribute( s.name(), txt ); } else { QDomElement e = ref().applyElement( context() ); if ( e.isNull() ) { e = createElement( ref() ); } QDomNode n = e.firstChild(); if( n.isNull() ) { n = mManager->document().createElement( txt ); e.appendChild( n ); } else { if( n.isText() ) { QDomText t = n.toText(); t.setData( txt ); } else if( n.isElement() ){ n.toElement().setTagName( txt ); } } } }
void makeTextNodeMod(KBookmark bk, const QString &m_nodename, const QString &m_newText) { QDomNode subnode = bk.internalElement().namedItem(m_nodename); if (subnode.isNull()) { subnode = bk.internalElement().ownerDocument().createElement(m_nodename); bk.internalElement().appendChild(subnode); } if (subnode.firstChild().isNull()) { QDomText domtext = subnode.ownerDocument().createTextNode(""); subnode.appendChild(domtext); } QDomText domtext = subnode.firstChild().toText(); QString m_oldText = domtext.data(); domtext.setData(m_newText); }
void DevParameters::operator <<= (const QDomNode& node) { if (!node.isNull()) { QDomNode n1 = node.firstChild(); while(!n1.isNull() ) { if (n1.nodeName() == "device") { QDomNode n2 = n1.firstChild(); QDomText t = n2.toText(); // try to convert the node to a text if(!t.isNull() ) { // the node was really an element. device = t.data(); } } n1 = n1.nextSibling(); } } }
// Author & Date: Ehsan Azar 15 June 2010 // Purpose: Get current node value // Inputs: // val - the default value QVariant XmlFile::value(const QVariant & val) { QVariant res = val; if (!m_nodes.isEmpty()) { // Get the current node QDomElement node = m_nodes.last(); if (!node.isNull()) { // Array Type is how we distinguish lists if (node.attribute("Type").compare("Array", Qt::CaseInsensitive) == 0) { QVariantList varlist; QStringList keys = childKeys(); for (int i = 0; i < keys.count(); ++i) { QString key = keys[i]; if (i > 0 && key == keys[i - 1]) key = QString(key + "<%1>").arg(i); // Recursively return the list beginGroup(key); QVariant nodevalue = value(QString()); endGroup(); // Make sure value is meaningful if (nodevalue.isValid()) varlist += nodevalue; // add new value } if (!keys.isEmpty()) res = varlist; } else { QDomNode child = node.firstChild(); if (!child.isNull()) { QDomText domText = child.toText(); if (!domText.isNull()) res = domText.data(); else return toString(); } } } } return res; }
bool TextRegExp::load( QDomElement top, const QString& /*version*/) { Q_ASSERT( top.tagName() == QString::fromLocal8Bit( "Text" ) ); if ( top.hasChildNodes() ) { QDomNode child = top.firstChild(); if ( ! child.isText() ) { KMessageBox::sorry( 0, i18n("<p>Element <b>Text</b> did not contain any textual data.</p>"), i18n("Error While Loading From XML File") ) ; return false; } QDomText txtNode = child.toText(); _text = txtNode.data(); } else { _text = QString::fromLatin1( "" ); } return true; }
void OutlineTree::getHeaderInformation( const QDomElement &header ) { // visit all children of the header element and look if you can make // something with it QDomNode node = header.firstChild(); while ( !node.isNull() ) { if ( node.isElement() ) { // case for the different header entries if ( node.nodeName() == "title" ) { QDomText textChild = node.firstChild().toText(); if ( !textChild.isNull() ) { setColumnText( 0, textChild.nodeValue() ); } } } node = node.nextSibling(); } }