本文整理汇总了C++中QDomNode::nodeType方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::nodeType方法的具体用法?C++ QDomNode::nodeType怎么用?C++ QDomNode::nodeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::nodeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isDeepEqual
bool TestBaseLine::isDeepEqual(const QDomNode &n1, const QDomNode &n2)
{
if(n1.nodeType() != n2.nodeType())
return false;
switch(n1.nodeType())
{
case QDomNode::CommentNode:
/* Fallthrough. */
case QDomNode::TextNode:
{
return static_cast<const QDomCharacterData &>(n1).data() ==
static_cast<const QDomCharacterData &>(n2).data();
}
case QDomNode::ProcessingInstructionNode:
{
return n1.nodeName() == n2.nodeName() &&
n1.nodeValue() == n2.nodeValue();
}
case QDomNode::DocumentNode:
return isChildrenDeepEqual(n1.childNodes(), n2.childNodes());
case QDomNode::ElementNode:
{
return n1.localName() == n2.localName() &&
n1.namespaceURI() == n2.namespaceURI() &&
n1.nodeName() == n2.nodeName() && /* Yes, this one is needed in addition to localName(). */
isAttributesEqual(n1.attributes(), n2.attributes()) &&
isChildrenDeepEqual(n1.childNodes(), n2.childNodes());
}
/* Fallthrough all these. */
case QDomNode::EntityReferenceNode:
case QDomNode::CDATASectionNode:
case QDomNode::EntityNode:
case QDomNode::DocumentTypeNode:
case QDomNode::DocumentFragmentNode:
case QDomNode::NotationNode:
case QDomNode::BaseNode:
case QDomNode::CharacterDataNode:
{
Q_ASSERT_X(false, Q_FUNC_INFO,
"An unsupported node type was encountered.");
return false;
}
case QDomNode::AttributeNode:
{
Q_ASSERT_X(false, Q_FUNC_INFO,
"This should never happen. QDom doesn't allow us to compare DOM attributes "
"properly.");
return false;
}
default:
{
Q_ASSERT_X(false, Q_FUNC_INFO, "Unhandled QDom::NodeType value.");
return false;
}
}
}
示例2: createInternalFromXML
void KScoringManager::createInternalFromXML( QDomNode n )
{
static KScoringRule *cR = 0; // the currentRule
// the XML file was parsed and now we simply traverse the resulting tree
if ( !n.isNull() ) {
kDebug(5100) <<"inspecting node of type" << n.nodeType()
<< "named" << n.toElement().tagName();
switch ( n.nodeType() ) {
case QDomNode::DocumentNode:
{
// the document itself
break;
}
case QDomNode::ElementNode:
{
// Server, Newsgroup, Rule, Expression, Action
QDomElement e = n.toElement();
QString s = e.tagName();
if ( s == "Rule" ) {
cR = new KScoringRule( e.attribute( "name" ) );
cR->setLinkMode( e.attribute( "linkmode" ) );
cR->setExpire( e.attribute( "expires" ) );
addRuleInternal( cR );
} else if ( s == "Group" ) {
Q_CHECK_PTR( cR );
cR->addGroup( e.attribute( "name" ) );
} else if ( s == "Expression" ) {
cR->addExpression( new KScoringExpression( e.attribute( "header" ),
e.attribute( "type" ),
e.attribute( "expr" ),
e.attribute( "neg" ) ) );
} else if ( s == "Action" ) {
Q_CHECK_PTR( cR );
cR->addAction( ActionBase::getTypeForName( e.attribute( "type" ) ),
e.attribute( "value" ) );
}
break;
}
default:
;
}
QDomNodeList nodelist = n.childNodes();
int cnt = nodelist.count();
for ( int i=0; i<cnt; ++i ) {
createInternalFromXML( nodelist.item( i ) );
}
}
}
示例3: fromXML
PackageMetainfo PackageMetainfo::fromXML(const QByteArray& data){
QDomDocument dom;
dom.setContent(data);
QDomElement eleInfo = dom.documentElement();
QDomNodeList nodeList = eleInfo.childNodes();
PackageMetainfo info;
for(int i=0;i<nodeList.count();++i){
QDomNode node = nodeList.at(i);
qDebug()<<"name : "<<node.nodeName()
<<" type: "<<node.nodeType()
<<" text: "<<node.toElement().text();
if(node.nodeName() == "gameid"){
info.setGameId(node.toElement().text().toInt());
}else if(node.nodeName() == "name"){
info.setName(node.toElement().text());
}else if(node.nodeName() == "version"){
info.setVersion(node.toElement().text());
}else if(node.nodeName() == "author"){
info.setAuthor(node.toElement().text());
}else if(node.nodeName() == "organization"){
info.setOrganization(node.toElement().text());
}else if(node.nodeName() == "introduction"){
info.setIntroduction(node.toElement().text());
}else if(node.nodeName() == "os"){
info.setOsStr(node.toElement().text());
}else if(node.nodeName() == "runfilepath"){
info.setRunFilePath(node.toElement().text());
}
}
return info;
}
示例4: readVariables
void InternetServerPlatform::readVariables( QDomNode node )
{
Logging::logInfo( this, "readVariables()" );
if( node.isNull() )
return;
QDomNode variable = node.firstChild();
while( false == variable.isNull() )
{
if( QDomNode::CommentNode != variable.nodeType() )
{
QString variableName = variable.nodeName();
if( _variableList.contains(variableName) )
continue;
QString variableValue = variable.attributes().namedItem("value").nodeValue();
replaceVariables( variableValue );
_variableList.insert( variableName, variableValue );
Logging::logInfo( this, QString("%1 = %2").arg(variableName).arg(variableValue) );
variable = variable.nextSibling();
}
}
}
示例5: nodeType
int QDomNodeProto::nodeType() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->nodeType();
return 0;
}
示例6: createContextMenuEntry
CContextMenuConfig* CConfiguration::createContextMenuEntry(const QString& nodeName,
const QDomElement& element)
{
QString itemName;
QString commandLine;
QDomNode currentNode = element.firstChild();
while(!currentNode.isNull()) {
if(QDomNode::ElementNode == currentNode.nodeType()) {
if(currentNode.toElement().tagName() == QString(g_CMDTag)) {
commandLine = currentNode.toElement().text();
}
else if(currentNode.toElement().tagName() == QString(g_NameTag)) {
itemName = currentNode.toElement().text();
}
else {
QMessageBox::critical(0, "Error!", "Found unknown tag in config file: " +
currentNode.toElement().tagName());
}
}
currentNode = currentNode.nextSibling();
}
CContextMenuConfig* node = new CContextMenuConfig(m_CanvasWidget, nodeName, itemName, commandLine);
return node;
}
示例7: getTextFromNode
QString getTextFromNode(QDomNode* nodePtr) {
QDomNode childNode = nodePtr->firstChild();
while (!childNode.isNull()) {
if (childNode.nodeType() == QDomNode::TextNode) {
return childNode.toText().data().trimmed();
}
childNode = childNode.nextSibling();
}
return "";
}
示例8: _parseEntry
void DomParser::_parseEntry(const QDomElement &element, int &l)
{
if(ready2Parse==FALSE)
return;
QDomNode node = element.firstChild();
// Block: only save *complete* o-t pairs
// Drawback: o must be the first element of e. Is that a problem? We'll see.
if (node.toElement().tagName() == "o") {
QDomNode c = node.firstChild();
if (c.nodeType() == QDomNode::TextNode)
{
l++;
}
}
while (!node.isNull()) {
if (node.toElement().tagName() == "e") {
_parseEntry(node.toElement(), l);
} else if (node.toElement().tagName() == "o") {
QDomNode childNode = node.firstChild();
while (!childNode.isNull()) {
if (childNode.nodeType() == QDomNode::TextNode) {
iTitles[l] = QString(childNode.toText().data());
break;
}
childNode = childNode.nextSibling();
}
} else if (node.toElement().tagName() == "t") {
QDomNode childNode = node.firstChild();
while (!childNode.isNull())
{
if (childNode.nodeType() == QDomNode::TextNode && !iTitles[l].isEmpty()) {
iTexts[l] = QString(childNode.toText().data());
break;
}
childNode = childNode.nextSibling();
}
}
node = node.nextSibling();
}
}
示例9: findDomNodeScan
/**
* @brief XmlEditWidgetPrivate::findDomNodeScan find the nearest match to a position
* @param node
* @param nodeTarget
* @param lineSearched
* @param columnSearched
* @param lastKnownNode: last known "good" position
* @return
*/
bool XmlEditWidgetPrivate::findDomNodeScan(QDomNode node, QDomNode nodeTarget, const int lineSearched, const int columnSearched, FindNodeWithLocationInfo &info)
{
int row = node.lineNumber();
int col = node.columnNumber();
if(!node.isDocument()) {
if((lineSearched == row) && (columnSearched == col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched == row) && (columnSearched == col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched == row) && (columnSearched < col)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched < row)) {
info.matchedNode = nodeTarget ;
return true ;
}
if((lineSearched <= row)) {
info.lastKnownNode = nodeTarget ;
}
if(node.nodeType() == QDomNode::ElementNode) {
QDomElement element = node.toElement();
QDomNamedNodeMap attributes = element.attributes();
int numAttrs = attributes.length();
for(int i = 0 ; i < numAttrs ; i++) {
QDomNode node = attributes.item(i);
QDomAttr attr = node.toAttr();
if(findDomNodeScan(attr, nodeTarget, lineSearched, columnSearched, info)) {
return true;
}
} // for
}
}
int nodes = node.childNodes().count();
for(int i = 0 ; i < nodes ; i ++) {
QDomNode childNode = node.childNodes().item(i) ;
if(childNode.isText() || childNode.isCDATASection()) {
if(findDomNodeScan(childNode, nodeTarget, lineSearched, columnSearched, info)) {
return true;
}
} else {
if(findDomNodeScan(childNode, childNode, lineSearched, columnSearched, info)) {
return true ;
}
}
}
return false ;
}
示例10: recursiveRead
void TreeModel::recursiveRead(QDomNode dNode, TreeItem *item)
{
do
{
int totalOfChilds = dNode.childNodes().size();
if (dNode.nodeType() != QDomNode::CommentNode)
{
if (totalOfChilds == 0)
{
if (dNode.nodeType() == QDomNode::TextNode)
item->setValue(dNode.nodeValue());
else
{
TreeItem *subItem = new TreeItem(dNode.nodeName());
for (int i = 0; i < dNode.attributes().size(); i++)
subItem->addAttribute(dNode.attributes().item(i).nodeName(), dNode.attributes().item(i).nodeValue());
item->appendRow(subItem);
}
}
else
{
TreeItem *item2 = new TreeItem(dNode.nodeName());
for (int i = 0; i < dNode.attributes().size(); i++)
item->addAttribute(dNode.attributes().item(i).nodeName(), dNode.attributes().item(i).nodeValue());
for (int i = 0; i < totalOfChilds; i++)
if (dNode.childNodes().size() > 0 and i == 0)
recursiveRead(dNode.childNodes().at(i), item2);
item->appendRow(item2);
}
}
dNode = dNode.nextSibling();
}
while (!dNode.isNull());
}
示例11: htmlToString
void Xml::htmlToString(QDomElement e, int level, QString* s)
{
*s += QString("<%1").arg(e.tagName());
QDomNamedNodeMap map = e.attributes();
int n = map.size();
for (int i = 0; i < n; ++i) {
QDomAttr a = map.item(i).toAttr();
*s += QString(" %1=\"%2\"").arg(a.name()).arg(a.value());
}
*s += ">";
++level;
for (QDomNode ee = e.firstChild(); !ee.isNull(); ee = ee.nextSibling()) {
if (ee.nodeType() == QDomNode::ElementNode)
htmlToString(ee.toElement(), level, s);
else if (ee.nodeType() == QDomNode::TextNode)
*s += Qt::escape(ee.toText().data());
}
*s += QString("</%1>").arg(e.tagName());
--level;
}
示例12: processNode
void Platform::processNode(const QDomNode &node)
{
if (node.isNull())
return;
// vc_dbg << "Node Name: " << node.nodeName();
// vc_dbg << "Node type: " << node.nodeType();
if (node.nodeType() == QDomNode::ElementNode)
processNodeAttributes(node.toElement());
}
示例13: toString
QString QDomNodeProto::toString() const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return QString("[QDomNode(%1=%2, %3, %4)]")
.arg(item->nodeName())
.arg(item->nodeValue())
.arg(item->nodeType())
.arg(item->hasChildNodes() ? "has children" : "leaf node");
return QString("[QDomNode(unknown)]");
}
示例14: getparstr
void QtXmlWrapper::getparstr(const std::string &name, char *par, int maxstrlen) const
{
ZERO(par, maxstrlen);
QDomNode tmp = findElement( d->m_node, "string", "name", name.c_str() );
if( tmp.isNull() || !tmp.hasChildNodes() )
{
return;
}
tmp = tmp.firstChild();
if( tmp.nodeType() == QDomNode::ElementNode )
{
snprintf(par, maxstrlen, "%s", tmp.toElement().tagName().toUtf8().constData() );
return;
}
if( tmp.nodeType() == QDomNode::TextNode )
{
snprintf(par, maxstrlen, "%s", tmp.toText().data().toUtf8().constData() );
return;
}
}
示例15: updateField
void SvgView::updateField(QDomNode &e, QString tag, QString value)
{
if ( e.nodeType() == QDomNode::TextNode)
{
if (e.nodeValue() == tag)
e.setNodeValue(value);
}
else
{
for(QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling())
updateField(n, tag, value);
}
}