int main(int argc, char* argv[]) { QString filename("config.xml"); QFile f(filename); QDomDocument doc; doc.setContent(dynamic_cast<QIODevice*>(&f), false); QDomNodeList nodes = doc.elementsByTagName(QString("pythonpath")); for (unsigned int i = 0; i < nodes.length(); ++i) { QString s; s = nodes.at(i).toElement().text(); s.replace(QString("$PYTHONHOME"), QString("/usr/bin/python27")); s.replace(QString("$PROJECT_PATH"), QString("~/mysample")); s.replace(QString("$PYTHON_VERSION"), QString("27")); printf("%s\n", s.toAscii().data()); } return 0; }
QDomElement KWDWriter::formatAttribute(const QDomElement ¶graph, const QString& name, const QString& attrName, const QString& attr) { QDomElement lastformat = currentFormat(paragraph, true); QDomNodeList qdnl = lastformat.elementsByTagName(name); if (qdnl.length()) { QDomElement el; el = qdnl.item(0).toElement(); el.setAttribute(attrName, attr); return el; } else { QDomElement al = _doc->createElement(name); lastformat.appendChild(al); al.setAttribute(attrName, attr); return al; } }
bool QgsAttributeAction::readXML( const QDomNode& layer_node ) { mActions.clear(); QDomNode aaNode = layer_node.namedItem( "attributeactions" ); if ( !aaNode.isNull() ) { QDomNodeList actionsettings = aaNode.childNodes(); for ( unsigned int i = 0; i < actionsettings.length(); ++i ) { QDomElement setting = actionsettings.item( i ).toElement(); addAction(( QgsAction::ActionType ) setting.attributeNode( "type" ).value().toInt(), setting.attributeNode( "name" ).value(), setting.attributeNode( "action" ).value(), setting.attributeNode( "capture" ).value().toInt() != 0 ); } } return true; }
void ConfigLoader::loadIncludes(QDomDocument const &config, QFileInfo const ¤tFile) { QDomNodeList includes = config.elementsByTagName("include"); for (unsigned i = 0; i < includes.length(); i++) { QDomElement includeElement = includes.at(i).toElement(); QString includeName = includeElement.attribute("name"); QFileInfo included = QFileInfo(currentFile.dir(), includeName); if (included.exists()) { load(included.canonicalFilePath()); } else { fprintf(stderr, "Error 13 (%s:%d,%d) : Include '%s' is unknown.\n", currentFile.fileName().toLatin1().constData(), includeElement.lineNumber(), includeElement.columnNumber(), includeName.toLatin1().constData() ); } } }
QString vleVpm::getCondGUIplugin(const QString& condName) const { QStringList res; if (mDocVpm) { QDomElement docElem = mDocVpm->documentElement(); QDomNode condsPlugins = mDocVpm->elementsByTagName("condPlugins").item(0); QDomNodeList plugins = condsPlugins.toElement().elementsByTagName("condPlugin"); for (int i =0; i< plugins.length(); i++) { QDomNode plug = plugins.item(i); if (plug.attributes().contains("cond") and (plug.attributes().namedItem("cond").nodeValue() == condName)) { return plug.attributes().namedItem("plugin").nodeValue(); } } } return ""; }
void vleSmDT::setComputeToDoc(const QString& computeBody) { QDomElement docElem = mDocSm->documentElement(); QDomNode computeNode = mDocSm->elementsByTagName("compute").item(0); undoStackSm->snapshot(computeNode); QDomNodeList childs = computeNode.childNodes(); if (childs.length() == 0) { QDomCDATASection cdataCompute = mDocSm->createCDATASection(computeBody); computeNode.appendChild(cdataCompute); } else { QDomCDATASection cdataCompute = childs.at(0).toCDATASection(); cdataCompute.setData(computeBody); } emit modified(); }
void Uic::registerDatabases( const QDomElement& e ) { QDomElement n; QDomNodeList nl; int i; nl = e.parentNode().toElement().elementsByTagName( "widget" ); for ( i = 0; i < ( int ) nl.length(); ++i ) { n = nl.item( i ).toElement(); QString conn = getDatabaseInfo( n, "connection" ); QString tab = getDatabaseInfo( n, "table" ); QString fld = getDatabaseInfo( n, "field" ); if ( !conn.isNull() ) { dbConnections += conn; if ( !tab.isNull() ) { dbCursors[conn] += tab; if ( !fld.isNull() ) dbForms[conn] += tab; } } } }
QDomElement BookmarkWidget::findElementbyUUID(QDomDocument& doc, QString uuid, int type, const QString xmlPath) { QString path; if (xmlPath == QString()) path = getBookmarkFilepath(); else path = xmlPath; QFile file(path); if(!file.open(QIODevice::ReadWrite | QIODevice::Text)) { qDebug()<<"File cannot be opened."; showFileOpenError(); file.close(); return doc.createElement(QString()); } doc.setContent(&file); QDomNodeList list = doc.elementsByTagName(BOOKMARK_XML_ROOT); if(list.isEmpty()) { showInvalidFileError(); file.close(); return doc.createElement(QString()); } QDomElement root = list.at(0).toElement(); QDomNodeList nodes; if(type == BOOKMARK) nodes = root.elementsByTagName(BOOKMARK_NAME); else if(type == FOLDER) nodes = root.elementsByTagName(FOLDER_NAME); QDomElement elt; QString value; for(int i = 0; i < nodes.length(); i++) { elt = nodes.at(i).toElement(); value = elt.attribute(UUID_NAME); if(value == uuid) break; value.clear(); } file.close(); if(!value.isEmpty()) return elt; else return doc.createElement(QString()); }
bool PodcastRSSParser::isValidPodcastFeed(QByteArray xmlReply) { qDebug() << "Checking is podcast feed is valid."; if (xmlReply.size() < 10) { qDebug() << "Not valid!"; return false; } QDomDocument xmlDocument; if (xmlDocument.setContent(xmlReply) == false) { // Construct the XML document and parse it. return false; } QDomElement docElement = xmlDocument.documentElement(); QDomNodeList itemNodes = docElement.elementsByTagName("item"); // Find all the "item nodes from the feed XML. for (uint i=0; i<itemNodes.length(); i++) { QDomNode node = itemNodes.at(i); if (isEmptyItem(node)) { qWarning() << "Empty podcast item. Ignoring..."; continue; } QDateTime pubDate = parsePubDate(node); if (!pubDate.isValid()) { qDebug() << "INVALID FEED: Pubdate not valid!"; return false; } if (!containsEnclosure(itemNodes)) { qDebug() << "INVALID FEED: Does not contain media."; return false; } } qDebug() << "Is valid."; return true; }
void WargearList::fromXml(const QDomElement& ele) throw(XmlParseException) { QDomNodeList list = ele.childNodes(); int len = list.length(); QDomElement current; for(int i = 0; i < len; i++) { current = list.item(i).toElement(); if(!current.isNull()) { if(current.nodeName() == "wargear") { Wargear wg(current, race()); m_wargears.insert(wg.id(), wg); } else throw XmlParseException("invalid wargear list node", current); } } }
QDomElement findPackageElement( const QDomDocument &list, QString packageType, QString packageName, QString mapName ) { QDomNodeList packageNodeList = list.elementsByTagName( packageType ); for( unsigned int i=0; i < packageNodeList.length(); i++ ) { QDomElement package = packageNodeList.at( i ).toElement(); if( packageType == "map" && package.attribute( "name" ) == packageName ) return package; if( packageType == "module" && package.attribute( "name" ) == packageName ) { if( package.parentNode().parentNode().toElement().attribute( "name" ) == mapName ) return package; } } return QDomElement(); }
void XmlLoader::readStylus(QDomElement const &stylus) { QDomNodeList stylusAttributes = stylus.childNodes(); Stylus* stylusItem = new Stylus(0, 0, NULL); for (unsigned i = 0; i < stylusAttributes.length(); ++i) { QDomElement type = stylusAttributes.at(i).toElement(); if (type.tagName() == "line") { QRectF rect = readRectOfXandY(type); Line* item = new Line(rect.left(), rect.top(), rect.right(), rect.bottom(), NULL); item->readPenBrush(type); stylusItem->mListLine.push_back(item); stylusItem->setPen(item->pen()); stylusItem->setBrush(item->brush()); } else qDebug() << "Incorrect stylus tag"; } mScene->addItem(stylusItem); mScene->setZValue(stylusItem); }
vle::value::Value* vleSmDT::getInitialValue(const QString& varName) { QStringList res; QDomNode var = nodeVariable(varName); if (var.isNull()) { return 0; } QDomNodeList initList = var.toElement().elementsByTagName("initial_value"); if (initList.length() == 0) { return 0; } QDomNode init_value = initList.at(0); init_value = var.toElement().elementsByTagName("double").at(0); if (init_value.nodeName() == "double") { QVariant qv = init_value.childNodes().item(0).toText().nodeValue();; return new vle::value::Double(qv.toDouble()); } return 0; }
QString TextFormatter::getFormattedVacancy(QDomNode vacancyNode) { QDomNodeList itemChildNodes = vacancyNode.childNodes(); QString formattedVacancy = ""; for(int i = 0; i < itemChildNodes.length(); i++) { QDomNode currentNode = itemChildNodes.at(i); QString nodeName = currentNode.nodeName(); if(nodeName.compare("title") == 0) { formattedVacancy += getFormattedTitle(currentNode); } else if(nodeName.compare("section") == 0) { formattedVacancy += getFormattedSection(currentNode); } } return formattedVacancy; }
QString TextFormatter::getFormattedItem(QDomNode itemNode) { QDomNodeList itemChildNodes = itemNode.childNodes(); QString formattedItem = ""; for(int i = 0; i < itemChildNodes.length(); i++) { QDomNode currentNode = itemChildNodes.at(i); QString nodeName = currentNode.nodeName(); if(nodeName.compare("title") == 0) { formattedItem += getFormattedTitle(currentNode); } else if(nodeName.compare("description") == 0) { formattedItem += getFormattedDescription(currentNode); } } return formattedItem; }
QString TextFormatter::getFormattedChannel(QDomNode channelNode) { QDomNodeList itemChildNodes = channelNode.childNodes(); QString formattedChannel = ""; for(int i = 0; i < itemChildNodes.length(); i++) { QDomNode currentNode = itemChildNodes.at(i); QString nodeName = currentNode.nodeName(); if(nodeName.compare("item") == 0) { formattedChannel += getFormattedItem(currentNode); } } formattedChannel.append("<br/>"); formattedChannel.append("<br/>"); return formattedChannel; }
void WidgetVpzPropertyObservables::refresh() { bool oldBlock = QComboBox::blockSignals(true); QComboBox::clear(); QString dyn = mVpz->modelDynFromDoc(mModQuery); QDomNodeList obss = mVpz->obssListFromObss(mVpz->obsFromDoc()); QComboBox::addItem("<none>"); int selectIndex = 0; for (int i = 0; i < obss.length(); i++) { QDomNode obs = obss.at(i); QString obsName = DomFunctions::attributeValue(obs, "name"); QComboBox::addItem(obsName); if (mVpz->modelObsFromDoc(mModQuery) == obsName) { selectIndex = i + 1; } } QComboBox::setCurrentIndex(selectIndex); QComboBox::blockSignals(oldBlock); }
// Index any resources void IndexRunner::indexRecognition(qint32 lid, Resource &r) { if (!keepRunning || pauseIndexing) { indexTimer->start(); return; } // Make sure we have something to look through. Data recognition; if (r.recognition.isSet()) recognition = r.recognition; if (!recognition.body.isSet()) return; QDomDocument doc; QString emsg; doc.setContent(recognition.body, &emsg); // look for text tags QDomNodeList anchors = doc.documentElement().elementsByTagName("t"); for (unsigned int i=0; keepRunning && !pauseIndexing && i<anchors.length(); i++) { QApplication::processEvents(); QDomElement enmedia = anchors.at(i).toElement(); QString weight = enmedia.attribute("w"); QString text = enmedia.text(); if (text != "") { IndexRecord *rec = new IndexRecord(); rec->weight = weight.toInt(); rec->lid = lid; rec->content = text; rec->source = "recognition"; if (indexHash->contains(lid)) { delete indexHash->value(lid); indexHash->remove(lid); } indexHash->insert(lid, rec); } } }
//NOTE: This task watch for pre-JEP session. bool JingleWatchSessionTask::take(const QDomElement &element) { if(element.tagName() != "iq") return false; QString sessionType, initiator; QDomElement first = element.firstChild().toElement(); if( !first.isNull() && first.attribute("xmlns") == JINGLE_NS && first.tagName() == "session" ) { kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Checking for incoming sesssion." << endl; initiator = first.attribute("initiator"); // Only proceed initiate type Jingle XMPP call. if( first.attribute("type") != QString::fromUtf8("initiate") ) return false; int nodeIndex; QDomNodeList nodeList = first.childNodes(); // Do not check first child for(nodeIndex = 0; nodeIndex < nodeList.length(); nodeIndex++) { QDomElement nodeElement = nodeList.item(nodeIndex).toElement(); if(nodeElement.tagName() == "description") { sessionType = nodeElement.attribute("xmlns"); } } if( !initiator.isEmpty() && !sessionType.isEmpty() ) { kdDebug(JABBER_DEBUG_GLOBAL) << k_funcinfo << "Emmiting incoming sesssion." << endl; emit watchSession(sessionType, initiator); return true; } } return false; }
void JobManager::setRegionsFile(const QString &filename) { QFile file(filename); file.open(QFile::ReadOnly); QDomDocument xml; if ( !xml.setContent( &file ) ) { qDebug() << "Cannot parse xml file with regions."; return; } QDomElement root = xml.documentElement(); QDomNodeList regions = root.elementsByTagName( "region" ); for ( unsigned int i = 0; i < regions.length(); ++i ) { Region region; QDomNode node = regions.item( i ); if (!node.namedItem("continent").isNull()) { region.setContinent(node.namedItem("continent").toElement().text()); } if (!node.namedItem("country").isNull()) { region.setCountry(node.namedItem("country").toElement().text()); } if (!node.namedItem("name").isNull()) { region.setName(node.namedItem("name").toElement().text()); } if (!node.namedItem("id").isNull()) { region.setId(node.namedItem("id").toElement().text()); } if (!node.namedItem("path").isNull()) { region.setPath(node.namedItem("path").toElement().text()); } if (!node.namedItem("pbf").isNull()) { region.setPbfFile(node.namedItem("pbf").toElement().text()); } if (!region.continent().isEmpty() && !region.name().isEmpty()) { m_regions << region; } } }
Model ModelMaker::createFromXML(const QDomDocument& doc) { Model model; if (doc.isNull()) return model; QDomElement rdfNode = doc.documentElement(); QDomNodeList list = rdfNode.childNodes(); for (uint i = 0; i < list.length(); ++i) { if (list.item(i).isElement()) { QDomElement el = list.item(i).toElement(); readResource(model, el); } } return model; }
void RuleRefList::fromXml(const QDomElement& ele) throw(XmlParseException) { QDomNodeList list = ele.childNodes(); int len = list.length(); QDomElement node; for(int i = 0; i < len; i++) { node = list.item(i).toElement(); if(!node.isNull()) { if(node.nodeName() == "rule_ref") { UnresolvedReference ref(node); m_unresolvedRules.append(ref); } else throw XmlParseException("invalid rule ref list node", node); } } }
bool ConfigListWidget::fromDomElement(QDomElement domElement) { QDomNodeList children = domElement.childNodes(); int length = children.length(); for (int i = 0; i < length; i++) { QDomNode node = children.item(i); if (node.isElement()) { QDomElement element = node.toElement(); if (element.tagName() != "item") continue; itemValues.append(element.attribute("value")); itemCaptions.append(element.attribute("caption")); addItem(qApp->translate("@default", element.attribute("caption").toAscii().data())); } } return ConfigWidget::fromDomElement(domElement); }
QString TextFormatter::getNewsWidgetFormat(QDomNodeList items) { QString newsLayOut_text; newsLayOut_text.append("<font size=5>"); for(int i = 0; i < items.length(); i++) { QDomNode item = items.at(i); if (m_sMode.compare("rss") == 0) { newsLayOut_text += getFormattedChannel(item); } else if (m_sMode.compare("files") == 0) { newsLayOut_text += getFormattedVacancy(item); } } newsLayOut_text.append("</font>"); return newsLayOut_text; }
/* public slots */ void SmartCardDevice_Edit::setDataDescription(QString &xmlDesc) { //qDebug()<<xmlDesc; QDomDocument doc, channelDoc; doc.setContent(xmlDesc); QDomElement _device, _addr, _channel, _channelDev; _device = doc.firstChildElement("device") .firstChildElement("smartcard"); QString _mode, _type, _channelXMLDesc; _mode = _device.attribute("mode", "host"); int idx = mode->findText(_mode, Qt::MatchContains); mode->setCurrentIndex( (idx<0)? 0:idx ); _channelDev = channelDoc.createElement("device"); channelDoc.appendChild(_channelDev); _channel = channelDoc.createElement("channel"); _channelDev.appendChild(_channel); _type = _device.attribute("type", "spicevmc"); _channel.setAttribute("type", _type); QDomNodeList list = _device.childNodes(); uint j = 0; uint count = list.length(); for (int i=0; i<count;i++) { //qDebug()<<list.item(j).nodeName()<<i; if (!list.item(j).isNull() && list.item(j).toElement().tagName()!="address") _channel.appendChild(list.item(j)); else ++j; }; _channelXMLDesc = channelDoc.toString(); channel->setDataDescription(_channelXMLDesc); idx = addr->type->findText("ccid", Qt::MatchContains); addr->type->setCurrentIndex( (idx<0)? 0:idx ); _addr = _device.firstChildElement("address"); addr->use->setChecked(!_addr.isNull()); if ( !_addr.isNull() ) { CCIDAddr *wdg = static_cast<CCIDAddr*>( addr->getCurrentAddrWidget() ); wdg->bus->setText( _addr.attribute("bus") ); wdg->slot->setText( _addr.attribute("slot") ); }; }
QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeWidgetItem* parent) { qDebug() << "BtBookmarkLoader::handleXmlElement"; QTreeWidgetItem* newItem = 0; if (element.tagName() == "Folder") { qDebug() << "BtBookmarkLoader::handleXmlElement: found folder"; BtBookmarkFolder* newFolder = new BtBookmarkFolder(parent, QString()); if (element.hasAttribute("caption")) { newFolder->setText(0, element.attribute("caption")); } QDomNodeList childList = element.childNodes(); for (unsigned int i = 0; i < childList.length(); i++) { qDebug() << "BtBookmarkLoader::handleXmlElement: go through child list of folder"; QDomElement newElement = childList.at(i).toElement(); QTreeWidgetItem* newChildItem = handleXmlElement(newElement, newFolder); newFolder->addChild(newChildItem); } newFolder->update(); newItem = newFolder; } else if (element.tagName() == "Bookmark") { qDebug() << "BtBookmarkLoader::handleXmlElement: found bookmark"; BtBookmarkItem* newBookmarkItem = new BtBookmarkItem(parent); if (element.hasAttribute("modulename")) { //we use the name in all cases, even if the module isn't installed anymore newBookmarkItem->m_moduleName = element.attribute("modulename"); } if (element.hasAttribute("key")) { newBookmarkItem->m_key = element.attribute("key"); } if (element.hasAttribute("description")) { newBookmarkItem->m_description = element.attribute("description"); } newBookmarkItem->update(); newItem = newBookmarkItem; } qDebug() << "BtBookmarkLoader::handleXmlElement: return new item"; return newItem; }
void TShuffle::parse(QDomElement metadata) { QDomNodeList childs = metadata.childNodes(); QDomElement element; int length = childs.length(); for (int i = 0; i < length; i++) { element = childs.item(i).toElement(); if (element.tagName() == "meta" && element.hasAttribute("name") && element.hasAttribute("content")) { if (element.attribute("name") == "adapi:pickingAlgorithm") pickingAlgorithm = element.attribute("content"); else if (element.attribute("name") == "adapi:pickingBehavior") pickingBehavior = element.attribute("content"); else if (element.attribute("name") == "adapi:pickNumber") pickNumber = element.attribute("content").toInt(); internal_pick = pickNumber; randomizePlaylist(); } } return; }
void SvgFlattener::flattenChildren(QDomElement &element){ // recurse the children QDomNodeList childList = element.childNodes(); for(uint i = 0; i < childList.length(); i++){ QDomElement child = childList.item(i).toElement(); flattenChildren(child); } //do translate if(hasTranslate(element)){ QList<double> params = TextUtils::getTransformFloats(element); if (params.size() == 2) { shiftChild(element, params.at(0), params.at(1), false); //DebugDialog::debug(QString("translating %1 %2").arg(params.at(0)).arg(params.at(1))); } else if (params.size() == 6) { shiftChild(element, params.at(4), params.at(5), false); } else if (params.size() == 1) { shiftChild(element, params.at(0), 0, false); //DebugDialog::debug(QString("translating %1").arg(params.at(0))); } else { DebugDialog::debug("weird transform found"); } } else if(hasOtherTransform(element)) { QMatrix transform = TextUtils::transformStringToMatrix(element.attribute("transform")); //DebugDialog::debug(QString("rotating %1 %2 %3 %4 %5 %6").arg(params.at(0)).arg(params.at(1)).arg(params.at(2)).arg(params.at(3)).arg(params.at(4)).arg(params.at(5))); unRotateChild(element, transform); } // remove transform element.removeAttribute("transform"); }
void TMedia::setBaseParameters() { cache_control = filename = log_content_id = ""; if (root_element.hasChildNodes()) { QDomNodeList childs = root_element.childNodes(); QDomElement param; for (int i = 0; i < childs.length(); i++) { param = childs.item(i).toElement(); if (param.tagName() == "param") { if (param.hasAttribute("cacheControl") && param.hasAttribute("value")) cache_control = param.attribute("value"); else if (param.hasAttribute("filename") && param.hasAttribute("value")) filename = param.attribute("value"); else if (param.hasAttribute("logContentId") && param.hasAttribute("value")) log_content_id = param.attribute("value"); } } } }
void vleVpm::renameCondGUIplugin(const QString& oldCond, const QString& newCond) { xCreateDom(); QDomElement docElem = mDocVpm->documentElement(); QDomNode condsPlugins = mDocVpm->elementsByTagName("condPlugins").item(0); undoStackVpm->snapshot(condsPlugins); QDomNodeList plugins = condsPlugins.toElement().elementsByTagName("condPlugin"); for (int i =0; i< plugins.length(); i++) { QDomNode plug = plugins.at(i); for (int j=0; j< plug.attributes().size(); j++) { if ((plug.attributes().item(j).nodeName() == "cond") and (plug.attributes().item(j).nodeValue() == oldCond)) { plug.toElement().setAttribute("cond", newCond); return; } } } }