本文整理汇总了C++中QDomElement::nodeName方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::nodeName方法的具体用法?C++ QDomElement::nodeName怎么用?C++ QDomElement::nodeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::nodeName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool ProItemInfoManager::load(const QString &filename)
{
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
return false;
QDomDocument doc;
if (!doc.setContent(&file))
return false;
QDomElement root = doc.documentElement();
if (root.nodeName() != QLatin1String("proiteminfo"))
return false;
QDomElement child = root.firstChildElement();
for (; !child.isNull(); child = child.nextSiblingElement()) {
if (child.nodeName() == QLatin1String("scope"))
readScope(child);
else if (child.nodeName() == QLatin1String("variable"))
readVariable(child);
}
file.close();
return true;
}
示例2: file
/*!
...
*/
QMap<QString, QKeySequence> CommandsFile::importCommands() const
{
QMap<QString, QKeySequence> result;
QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly))
return result;
QDomDocument doc("KeyboardMappingScheme");
if (!doc.setContent(&file))
return result;
QDomElement root = doc.documentElement();
if (root.nodeName() != QLatin1String("mapping"))
return result;
QDomElement ks = root.firstChildElement();
for (; !ks.isNull(); ks = ks.nextSiblingElement()) {
if (ks.nodeName() == QLatin1String("shortcut")) {
QString id = ks.attribute(QLatin1String("id"));
QKeySequence shortcutkey;
QDomElement keyelem = ks.firstChildElement("key");
if (!keyelem.isNull())
shortcutkey = QKeySequence(keyelem.attribute("value"));
result.insert(id, shortcutkey);
}
}
file.close();
return result;
}
示例3: fromXml
void RuleSet::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() == "book")
m_book = current.text().simplified();
else if(current.nodeName() == "version")
m_version = current.text().simplified();
else if(current.nodeName() == "edition")
m_edition = current.text().simplified();
else if(current.nodeName() == "rules")
RuleList::fromXml(current);
else
throw XmlParseException("invalid node" , current);
}
}
if(m_book.isEmpty())
throw XmlParseException("missing ruleset book node", ele);
if(m_edition.isEmpty())
throw XmlParseException("missing ruleset edition node", ele);
if(m_version.isEmpty())
throw XmlParseException("missing ruleset version node", ele);
}
示例4: processDefinitionElement
void cHorizontalScrollbar::processDefinitionElement(QDomElement element) {
if (element.nodeName() == "leftbutton") {
ushort unpressed = Utilities::stringToUInt(element.attribute("unpressed"));
ushort pressed = Utilities::stringToUInt(element.attribute("pressed", QString::number(unpressed)));
ushort hover = Utilities::stringToUInt(element.attribute("hover", QString::number(pressed)));
setLeftButtonIds(unpressed, pressed, hover);
} else if (element.nodeName() == "rightbutton" && element.hasAttribute("unpressed")) {
ushort unpressed = Utilities::stringToUInt(element.attribute("unpressed"));
ushort pressed = Utilities::stringToUInt(element.attribute("pressed", QString::number(unpressed)));
ushort hover = Utilities::stringToUInt(element.attribute("hover", QString::number(pressed)));
setRightButtonIds(unpressed, pressed, hover);
} else if (element.nodeName() == "range" && element.hasAttribute("min") && element.hasAttribute("max")) {
int min = Utilities::stringToInt(element.attribute("min"));
int max = Utilities::stringToInt(element.attribute("max"));
setRange(min, max);
} else if (element.nodeName() == "background" && element.hasAttribute("id1")) {
ushort id1 = Utilities::stringToUInt(element.attribute("id1"));
ushort id2 = Utilities::stringToUInt(element.attribute("id2", QString::number(id1)));
ushort id3 = Utilities::stringToUInt(element.attribute("id3", QString::number(id1)));
ushort id4 = Utilities::stringToUInt(element.attribute("id4", QString::number(id1)));
ushort id5 = Utilities::stringToUInt(element.attribute("id5", QString::number(id1)));
ushort id6 = Utilities::stringToUInt(element.attribute("id6", QString::number(id1)));
ushort id7 = Utilities::stringToUInt(element.attribute("id7", QString::number(id1)));
ushort id8 = Utilities::stringToUInt(element.attribute("id8", QString::number(id1)));
ushort id9 = Utilities::stringToUInt(element.attribute("id9", QString::number(id1)));
background->setIds(id1, id2, id3, id4, id5, id6, id7, id8, id9);
} else {
cContainer::processDefinitionElement(element);
}
}
示例5: stripAnswers
QString XmlUtil::stripAnswers(const QString &input) {
QDomDocument doc;
doc.setContent(input);
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while ( !n.isNull() ) {
QDomElement e = n.toElement();
if ( !e.isNull() && (e.namespaceURI().isEmpty() || e.namespaceURI() == XML_NS) ) {
if ( e.nodeName() == "choose" ) {
QDomElement c = e.firstChildElement("choice");
while ( !c.isNull() ) {
c.removeAttribute("answer");
c = c.nextSiblingElement("choice");
}
} else if ( e.nodeName() == "identification" ) {
QDomElement a = e.firstChildElement("a");
while ( !a.isNull() ) {
e.removeChild(a);
a = e.firstChildElement("a");
}
}
}
n = n.nextSibling();
}
return doc.toString(2);
}
示例6: Loadable
LoadMetasql::LoadMetasql(const QDomElement &elem, const bool system,
QStringList &msg, QList<bool> &fatal)
: Loadable(elem, system, msg, fatal)
{
if (DEBUG)
qDebug("LoadMetasql::LoadMetasql(QDomElement) entered");
_pkgitemtype = "M";
if (elem.nodeName() != "loadmetasql")
{
msg.append(TR("Creating a LoadMetasql element from a %1 node.")
.arg(elem.nodeName()));
fatal.append(false);
}
if (elem.hasAttribute("group"))
_group = elem.attribute("group");
if (elem.hasAttribute("enabled"))
{
msg.append(TR("Node %1 '%2' has an 'enabled' "
"attribute which is ignored for MetaSQL statements.")
.arg(elem.nodeName()).arg(elem.attribute("name")));
fatal.append(false);
}
}
示例7: getAlbumFromFile
Album ParserAlbum::getAlbumFromFile(const QString &_name)
{
m_pFile->close();
if(!m_pFile->open(QIODevice::ReadOnly))
{
qDebug() << "Can`t open file : " << m_pFile->fileName();
}
Album newAlbum;
newAlbum.setName(_name);
QDomElement element = m_pDoc->documentElement();
QDomNode node = element.firstChild();
while(!node.isNull())
{
if(node.isElement())
{
QDomElement domElement = node.toElement();
if(domElement.nodeName() == "images")
{
if(domElement.hasChildNodes())
{
getImages(newAlbum,domElement.childNodes());
}
}
if(domElement.nodeName() == "current")
{
newAlbum.setCurrentIndex(domElement.text().toInt());
}
node = node.nextSibling().toElement();
}
}
m_pFile->close();
return newAlbum;
}
示例8: open
bool FilterScript::open(QString filename)
{
QDomDocument doc;
filtparlist.clear();
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
{
qDebug("Failure in opening Script %s", qUtf8Printable(filename));
qDebug("Current dir is %s", qUtf8Printable(QDir::currentPath()));
return false;
}
QString errorMsg; int errorLine,errorColumn;
if(!doc.setContent(&file,false,&errorMsg,&errorLine,&errorColumn))
{
qDebug("Failure in setting Content line %i column %i \nError'%s'",errorLine,errorColumn, qUtf8Printable(errorMsg));
return false;
}
file.close();
QDomElement root = doc.documentElement();
if(root.nodeName() != "FilterScript")
{
qDebug("Failure in parsing script %s\nNo root node with name FilterScript\n", qUtf8Printable(filename));
qDebug("Current rootname is %s", qUtf8Printable(root.nodeName()));
return false;
}
qDebug("FilterScript");
for(QDomElement nf = root.firstChildElement(); !nf.isNull(); nf = nf.nextSiblingElement())
{
if (nf.tagName() == QString("filter"))
{
RichParameterSet par;
QString name=nf.attribute("name");
qDebug("Reading filter with name %s", qUtf8Printable(name));
for(QDomElement np = nf.firstChildElement("Param"); !np.isNull(); np = np.nextSiblingElement("Param"))
{
RichParameter* rp = NULL;
RichParameterAdapter::create(np,&rp);
//FilterParameter::addQDomElement(par,np);
par.paramList.push_back(rp);
}
OldFilterNameParameterValuesPair* tmp = new OldFilterNameParameterValuesPair();
tmp->pair = qMakePair(name,par);
filtparlist.append(tmp);
}
else
{
QString name=nf.attribute("name");
qDebug("Reading filter with name %s", qUtf8Printable(name));
QMap<QString,QString> map;
for(QDomElement np = nf.firstChildElement("xmlparam"); !np.isNull(); np = np.nextSiblingElement("xmlparam"))
map[np.attribute("name")] = np.attribute("value");
XMLFilterNameParameterValuesPair* tmp = new XMLFilterNameParameterValuesPair();
tmp->pair = qMakePair(name,map);
filtparlist.append(tmp);
}
}
return true;
}
示例9: On_DiffTick
void ReportUser::On_DiffTick()
{
if (this->qDiff == NULL)
{
return;
}
if (!this->qDiff->IsProcessed())
{
return;
}
if (this->qDiff->Result->Failed)
{
ui->webView->setHtml(_l("browser-fail", this->qDiff->Result->ErrorMessage));
this->tPageDiff->stop();
return;
}
QString Summary;
QString Diff;
QDomDocument d;
d.setContent(this->qDiff->Result->Data);
QDomNodeList l = d.elementsByTagName("rev");
QDomNodeList diff = d.elementsByTagName("diff");
if (diff.count() > 0)
{
QDomElement e = diff.at(0).toElement();
if (e.nodeName() == "diff")
{
Diff = e.text();
}
} else
{
Huggle::Syslog::HuggleLogs->DebugLog(this->qDiff->Result->Data);
this->ui->webView->setHtml("Unable to retrieve diff because api returned no data for it, debug information:<br><hr>" +
HuggleWeb::Encode(this->qDiff->Result->Data));
this->tPageDiff->stop();
return;
}
// get last id
if (l.count() > 0)
{
QDomElement e = l.at(0).toElement();
if (e.nodeName() == "rev")
{
if (e.attributes().contains("comment"))
{
Summary = e.attribute("comment");
}
}
}
if (!Summary.size())
Summary = "<font color=red>" + _l("browser-miss-summ") + "</font>";
else
Summary = HuggleWeb::Encode(Summary);
this->ui->webView->setHtml(Resources::GetHtmlHeader() + Resources::DiffHeader + "<tr></td colspan=2><b>" + _l("summary")
+ ":</b> " + Summary + "</td></tr>" + Diff + Resources::DiffFooter + Resources::HtmlFooter);
this->tPageDiff->stop();
}
示例10: processScriptItemNode
void IDefReader::processScriptItemNode( P_ITEM madeItem, QDomElement &Node )
{
for( UI16 k = 0; k < Node.childNodes().count(); k++ )
{
QDomElement currChild = Node.childNodes().item( k ).toElement();
if( currChild.nodeName() == "amount" )
{
QString Value = QString();
UI16 i = 0;
if( currChild.hasChildNodes() ) // <random> i.e.
for( i = 0; i < currChild.childNodes().count(); i++ )
{
if( currChild.childNodes().item( i ).isText() )
Value += currChild.childNodes().item( i ).toText().data();
else if( currChild.childNodes().item( i ).isElement() )
Value += processNode( currChild.childNodes().item( i ).toElement() );
}
else
Value = currChild.nodeValue();
if( Value.toInt() < 1 )
Value = QString("1");
if( madeItem->isPileable() )
madeItem->setAmount( Value.toInt() );
else
for( i = 1; i < Value.toInt(); i++ ) //dupe it n-1 times
Commands->DupeItem(-1, madeItem, 1);
}
else if( currChild.nodeName() == "color" ) //process <color> tags
{
QString Value = QString();
if( currChild.hasChildNodes() ) // colorlist or random i.e.
for( UI16 i = 0; i < currChild.childNodes().count(); i++ )
{
if( currChild.childNodes().item( i ).isText() )
Value += currChild.childNodes().item( i ).toText().data();
else if( currChild.childNodes().item( i ).isElement() )
Value += processNode( currChild.childNodes().item( i ).toElement() );
}
else
Value = currChild.nodeValue();
if( Value.toInt() < 0 )
Value = QString("0");
madeItem->setColor( Value.toInt() );
}
else if( currChild.nodeName() == "inherit" && currChild.attributes().contains("id") )
{
QDomElement* derivalSection = DefManager->getSection( WPDT_ITEM, currChild.attribute("id") );
if( !derivalSection->isNull() )
this->applyNodes( madeItem, derivalSection );
}
}
}
示例11: if
LoadAppScript::LoadAppScript(const QDomElement &elem, const bool system,
QStringList &msg, QList<bool> &fatal)
: Loadable(elem, system, msg, fatal)
{
_pkgitemtype = "C";
if (_name.isEmpty())
{
msg.append(TR("The script in %1 does not have a name.")
.arg(_filename));
fatal.append(true);
}
if (elem.nodeName() != "loadappscript")
{
msg.append(TR("Creating a LoadAppScript element from a %1 node.")
.arg(elem.nodeName()));
fatal.append(false);
}
if (elem.hasAttribute("grade"))
{
msg.append(TR("Node %1 '%2' has a 'grade' attribute but should use "
"'order' instead.")
.arg(elem.nodeName()).arg(elem.attribute("name")));
fatal.append(false);
}
if (elem.hasAttribute("order"))
{
if (elem.attribute("order").contains("highest", Qt::CaseInsensitive))
_grade = INT_MAX;
else if (elem.attribute("order").contains("lowest", Qt::CaseInsensitive))
_grade = INT_MIN;
else
_grade = elem.attribute("order").toInt();
}
_enabled = true;
if (elem.hasAttribute("enabled"))
{
if (elem.attribute("enabled").contains(trueRegExp))
_enabled = true;
else if (elem.attribute("enabled").contains(falseRegExp))
_enabled = false;
else
{
msg.append(TR("Node %1 '%2' has an 'enabled' attribute that is "
"neither 'true' nor 'false'. Using '%3'.")
.arg(elem.nodeName()).arg(elem.attribute("name"))
.arg(_enabled ? "true" : "false"));
fatal.append(false);
}
}
}
示例12: readItem
void ProItemInfoManager::readItem(ProItemInfo *item, const QDomElement &data)
{
QDomElement child = data.firstChildElement();
for (; !child.isNull(); child = child.nextSiblingElement()) {
if (child.nodeName() == QLatin1String("id"))
item->setId(child.text());
else if (child.nodeName() == QLatin1String("name"))
item->setName(child.text());
else if (child.nodeName() == QLatin1String("description"))
item->setDescription(child.text());
}
}
示例13: CreateDBObj
CreateTrigger::CreateTrigger(const QDomElement &elem, QStringList &msg, QList<bool> &fatal)
: CreateDBObj(elem, msg, fatal)
{
_pkgitemtype = "G";
if (elem.nodeName() != "createtrigger")
{
msg.append(QObject::tr("Creating a CreateTrigger element from a %1 node.")
.arg(elem.nodeName()));
fatal.append(false);
}
}
示例14: CreateDBObj
CreateFunction::CreateFunction(const QDomElement &elem, QStringList &msg, QList<bool> &fatal)
: CreateDBObj(elem, msg, fatal)
{
_pkgitemtype = "F";
if (elem.nodeName() != "createfunction")
{
msg.append(TR("Creating a CreateFunction element from a %1 node.")
.arg(elem.nodeName()));
fatal.append(false);
}
}
示例15: Loadable
LoadReport::LoadReport(const QDomElement & elem, const bool system,
QStringList &msg, QList<bool> &fatal)
: Loadable(elem, system, msg, fatal)
{
_pkgitemtype = "R";
if (elem.nodeName() != "loadreport")
{
msg.append(TR("Creating a LoadAppReport element from a %1 node.")
.arg(elem.nodeName()));
fatal.append(false);
}
}