本文整理汇总了C++中QDomElement::attributes方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::attributes方法的具体用法?C++ QDomElement::attributes怎么用?C++ QDomElement::attributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::attributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
void HuggleFeedProviderWiki::Process(QString data)
{
//QStringList lines = data.split("\n");
QDomDocument d;
d.setContent(data);
QDomNodeList l = d.elementsByTagName("rc");
int CurrentNode = l.count();
if (l.count() == 0)
{
Huggle::Syslog::HuggleLogs->Log("Error, wiki provider returned: " + data);
return;
}
// recursively scan all RC changes
QDateTime t = this->LatestTime;
bool Changed = false;
while (CurrentNode > 0)
{
CurrentNode--;
// get a time of rc change
QDomElement item = l.at(CurrentNode).toElement();
if (!item.attributes().contains("timestamp"))
{
Huggle::Syslog::HuggleLogs->Log(_l("rc-timestamp-missing", item.toElement().nodeName()));
continue;
}
QDateTime time = MediaWiki::FromMWTimestamp(item.attribute("timestamp"));
if (time < t)
{
// this record is older than latest parsed record, so we don't want to parse it
continue;
} else
{
Changed = true;
t = time;
}
if (!item.attributes().contains("type"))
{
Huggle::Syslog::HuggleLogs->Log(_l("rc-type-missing", item.text()));
continue;
}
if (!item.attributes().contains("title"))
{
Huggle::Syslog::HuggleLogs->Log(_l("rc-title-missing", item.text()));
continue;
}
QString type = item.attribute("type");
if (type == "edit" || type == "new")
{
ProcessEdit(item);
}
else if (type == "log")
{
ProcessLog(item);
}
}
if (Changed)
{
this->LatestTime = t.addSecs(1);
}
}
示例2: getNodeValue
QString cDefinable::getNodeValue( const QDomElement &Tag )
{
QString Value = QString();
if( !Tag.hasChildNodes() )
return "";
else
{
QDomNode childNode = Tag.firstChild();
while( !childNode.isNull() )
{
if( !childNode.isElement() )
{
if( childNode.isText() )
Value += childNode.toText().data();
childNode = childNode.nextSibling();
continue;
}
QDomElement childTag = childNode.toElement();
if( childTag.nodeName() == "random" )
{
if( childTag.attributes().contains("min") && childTag.attributes().contains("max") )
Value += QString("%1").arg( RandomNum( childTag.attributeNode("min").nodeValue().toInt(), childTag.attributeNode("max").nodeValue().toInt() ) );
else if( childTag.attributes().contains("valuelist") )
{
QStringList RandValues = QStringList::split(",", childTag.attributeNode("list").nodeValue());
Value += RandValues[ RandomNum(0,RandValues.size()-1) ];
}
else if( childTag.attributes().contains( "list" ) )
{
Value += DefManager->getRandomListEntry( childTag.attribute( "list" ) );
}
else if( childTag.attributes().contains("dice") )
Value += QString("%1").arg(rollDice(childTag.attributeNode("dice").nodeValue()));
else
Value += QString("0");
}
// Process the childnodes
QDomNodeList childNodes = childTag.childNodes();
for( int i = 0; i < childNodes.count(); i++ )
{
if( !childNodes.item( i ).isElement() )
continue;
Value += this->getNodeValue( childNodes.item( i ).toElement() );
}
childNode = childNode.nextSibling();
}
}
return hex2dec( Value );
}
示例3: ProcessNode
// Method for processing one node
void WPDefManager::ProcessNode( QDomElement Node )
{
if( Node.isNull() )
return;
QString NodeName = Node.nodeName();
if( NodeName == "include" )
{
// Try to get the filename
// <include file="data\npcs.xml" \>
if( !Node.attributes().contains( "file" ) )
return;
// Get the filename and import it
ImportSections( Node.attribute("file") );
return;
}
// Get the Node ID
if( !Node.attributes().contains( "id" ) )
return;
QString NodeID = Node.attribute("id");
// IF's for all kind of nodes
// <item id="xx">
// <script id="xx">
// <npc id="xx">
if( NodeName == "item" )
Items[ NodeID ] = Node;
else if( NodeName == "script" )
Scripts[ NodeID ] = Node;
else if( NodeName == "npc" )
NPCs[ NodeID ] = Node;
else if( NodeName == "menu" )
Menus[ NodeID ] = Node;
else if( NodeName == "spell" )
Spells[ NodeID ] = Node;
else if( NodeName == "list" )
StringLists[ NodeID ] = Node;
else if( NodeName == "privlevel" )
PrivLevels[ NodeID ] = Node;
else if( NodeName == "spawnregion" )
SpawnRegions[ NodeID ] = Node;
else if( NodeName == "region" )
Regions[ NodeID ] = Node;
else if( NodeName == "multi" )
Multis[ NodeID ] = Node;
else if( NodeName == "text" )
Texts[ NodeID ] = Node;
}
示例4: appendChilds
void XdgMenuPrivate::appendChilds(QDomElement& srcElement, QDomElement& destElement)
{
MutableDomElementIterator it(srcElement);
while(it.hasNext())
destElement.appendChild(it.next());
if (srcElement.attributes().contains("deleted"))
destElement.setAttribute("deleted", srcElement.attribute("deleted"));
if (srcElement.attributes().contains("onlyUnallocated"))
destElement.setAttribute("onlyUnallocated", srcElement.attribute("onlyUnallocated"));
}
示例5: ProcessEdit
void HuggleFeedProviderWiki::ProcessEdit(QDomElement item)
{
WikiEdit *edit = new WikiEdit();
edit->Page = new WikiPage(item.attribute("title"));
QString type = item.attribute("type");
if (type == "new")
edit->NewPage = true;
if (item.attributes().contains("newlen") && item.attributes().contains("oldlen"))
edit->Size = item.attribute("newlen").toInt() - item.attribute("oldlen").toInt();
if (item.attributes().contains("user"))
edit->User = new WikiUser(item.attribute("user"));
if (item.attributes().contains("comment"))
edit->Summary = item.attribute("comment");
if (item.attributes().contains("bot"))
edit->Bot = true;
if (item.attributes().contains("anon"))
edit->User->ForceIP();
if (item.attributes().contains("revid"))
{
edit->RevID = QString(item.attribute("revid")).toInt();
if (edit->RevID == 0)
{
edit->RevID = WIKI_UNKNOWN_REVID;
}
}
if (item.attributes().contains("minor"))
edit->Minor = true;
edit->IncRef();
this->InsertEdit(edit);
}
示例6: loadWinProperties
void MainWindow::loadWinProperties(QWidget *window, QDomElement *docElement)
{
QDomElement node = docElement->firstChildElement(window->objectName());
if(!node.isNull())
{
window->setGeometry(node.attributes().namedItem("x").nodeValue().toInt(),
node.attributes().namedItem("y").nodeValue().toInt(),
node.attributes().namedItem("w").nodeValue().toInt(),
node.attributes().namedItem("h").nodeValue().toInt());
if(window != this)
((SoSSubWindow*)window)->setAllowShow(node.attributes().namedItem("visible").nodeValue().toInt());
}
}
示例7: LoadDefs
void Core::LoadDefs()
{
QFile defs(Configuration::GetConfigurationPath() + "users.xml");
if (QFile(Configuration::GetConfigurationPath() + "users.xml~").exists())
{
Huggle::Syslog::HuggleLogs->Log("WARNING: recovering definitions from last session");
QFile(Configuration::GetConfigurationPath() + "users.xml").remove();
if (QFile(Configuration::GetConfigurationPath() + "users.xml~").copy(Configuration::GetConfigurationPath() + "users.xml"))
{
QFile().remove(Configuration::GetConfigurationPath() + "users.xml~");
} else
{
Huggle::Syslog::HuggleLogs->Log("WARNING: Unable to recover the definitions");
}
}
if (!defs.exists())
{
return;
}
defs.open(QIODevice::ReadOnly);
QString Contents(defs.readAll());
QDomDocument list;
list.setContent(Contents);
QDomNodeList l = list.elementsByTagName("user");
if (l.count() > 0)
{
int i=0;
while (i<l.count())
{
WikiUser *user;
QDomElement e = l.at(i).toElement();
if (!e.attributes().contains("name"))
{
i++;
continue;
}
user = new WikiUser();
user->Username = e.attribute("name");
if (e.attributes().contains("badness"))
{
// do not resync this user while we init the db, this is first time it's written to it so there is no point in that
user->SetBadnessScore(e.attribute("badness").toInt(), false, false);
}
WikiUser::ProblematicUsers.append(user);
i++;
}
}
HUGGLE_DEBUG1("Loaded " + QString::number(WikiUser::ProblematicUsers.count()) + " records from last session");
defs.close();
}
示例8: 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();
}
示例9: 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);
}
}
示例10: writeElementChilds
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();
}
}
示例11: QDate
/** 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()));
}
}
}
示例12: 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);
}
示例13: findTypeElement
// function that scans the DOM for all 'attribute' elements
void
findAttributeElements(QDomElement e) {
// in the mathml spec, e never has children
if (!e.firstChild().isNull()) {
err << "Hmm, I did not expect childeren." << endl;
}
// check that there are only two attributes: name and type
if (e.attributes().length() != 2 || !e.hasAttribute("type")) {
err << "Hmm, I expected two children for element elements."
<< endl;
}
QString type = e.attribute("type");
// find the element with the name type
QDomElement typee;
findTypeElement(type, e.ownerDocument().documentElement(),
typee);
if (typee.isNull()) {
err << "Hmm, no element with name=\""<<type<<"\" was found."
<< endl;
}
elements[e.attribute("name")].type = typee;
collectAttributes(typee.firstChild(),
elements[e.attribute("name")].atts);
//pmrintAttributes(e, 10);
}
示例14: ProcessAttributes
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;
}
示例15: XMLToVariables
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();
}
}