本文整理汇总了C++中QDomNode::childNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::childNodes方法的具体用法?C++ QDomNode::childNodes怎么用?C++ QDomNode::childNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::childNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scanDataSingleStyle
bool StylePersistence::scanDataSingleStyle(VStyle* style, QDomNode &rootNode)
{
bool isOk = true ;
mapTokens.clear();
int nodi = rootNode.childNodes().count();
//D(printf("sono in assegna con %d nodi\n", nodi));
for(int i = 0 ; i < nodi ; i ++) {
QDomNode childNode = rootNode.childNodes().item(i) ;
if(childNode.isElement()) {
QDomElement element = childNode.toElement();
//QString name = element.attribute("name", "");
//QString description = element.attribute("description", "");
QString nameSpace = element.attribute("namespace", "");
if(!nameSpace.isEmpty()) {
style->setNamespace(nameSpace);
}
if(STYLE_ROOT_ELEMENT == element.tagName()) {
if(!scanStyleData(style, element)) {
isOk = false;
}
}
if(isOk) {
completeStyle(style);
}
}
}//for
return isOk ;
}//scanData()
示例2: scanStyleData
bool StylePersistence::scanStyleData(VStyle *style, QDomNode &rootNode)
{
bool isOk = true ;
int nodi = rootNode.childNodes().count();
for(int i = 0 ; i < nodi ; i ++) {
QDomNode childNode = rootNode.childNodes().item(i) ;
if(childNode.isElement()) {
QDomElement element = childNode.toElement();
QDomNodeList childs = element.childNodes();
if(STYLESETENTRY_TAGNAME == element.tagName()) {
if(!collectStyles(style, childs)) {
isOk = false;
}
} else if(KEYWORDSETENTRY_TAGNAME == element.tagName()) {
if(!collectKeywords(style, childs)) {
isOk = false;
}
} else if(IDS_TAGNAME == element.tagName()) {
if(!collectIds(style, childs)) {
isOk = false;
}
}
}//if
}//for
return isOk ;
}//scanStyleData()
示例3: if
//-----------------------------------------------------------------------------
// Function: ApiInterface::ApiInterface()
//-----------------------------------------------------------------------------
ApiInterface::ApiInterface(QDomNode& node)
: nameGroup_(node),
apiType_(),
dependencyDir_(DEPENDENCY_PROVIDER),
defaultPos_()
{
for (int i = 0; i < node.childNodes().count(); ++i)
{
QDomNode childNode = node.childNodes().at(i);
if (childNode.isComment())
{
continue;
}
if (childNode.nodeName() == "kactus2:apiType")
{
apiType_ = VLNV::createVLNV(childNode, VLNV::APIDEFINITION);
}
else if (childNode.nodeName() == "kactus2:dependencyDirection")
{
dependencyDir_ = str2DependencyDirection(childNode.childNodes().at(0).nodeValue(), DEPENDENCY_PROVIDER);
}
else if (childNode.nodeName() == "kactus2:position")
{
defaultPos_.setX(childNode.attributes().namedItem("x").nodeValue().toInt());
defaultPos_.setY(childNode.attributes().namedItem("y").nodeValue().toInt());
}
}
}
示例4: Generator
// the constructor
ComponentGenerator::ComponentGenerator(QDomNode &generatorNode):
Generator(generatorNode),
scope_(ComponentGenerator::INSTANCE),
groups_() {
QDomNamedNodeMap attributeMap = generatorNode.attributes();
// get the spirit scope attribute
QString scope = attributeMap.namedItem(QString("spirit:scope")).nodeValue();
if (scope == QString("entity")) {
scope_ = ComponentGenerator::ENTITY;
}
else {
scope_ = ComponentGenerator::INSTANCE;
}
// go through all the child nodes of the component generator
for (int i = 0; i < generatorNode.childNodes().count(); ++i) {
QDomNode tempNode = generatorNode.childNodes().at(i);
if (tempNode.nodeName() == QString("spirit:group")) {
QString groupName = tempNode.childNodes().at(0).nodeValue();
groupName = XmlUtils::removeWhiteSpace(groupName);
groups_.append(groupName);
}
}
}
示例5: heightXML
void MainWindow::heightXML(QDomNode doc, int *height)
{
if(!doc.isNull())
{
int heightCurrentNode = 0;
QDomNode docParent = doc;
while(!docParent.parentNode().isNull())
{
docParent = docParent.parentNode();
heightCurrentNode++;
}
if(heightCurrentNode > *height)
{
*height = heightCurrentNode;
}
if(!doc.childNodes().isEmpty() && (doc.firstChild().toElement().tagName() != "" || doc.firstChild().isComment()))
{
QDomNodeList nodeList = doc.childNodes();
for(int i = 0; i < nodeList.length(); i++)
{
heightXML(nodeList.at(i), height);
}
}
}
}
示例6: removeDefaultNode
void QQMlDom::removeDefaultNode(QDomElement nDocument, QString element)
{
QDomNodeList removeList = nDocument.elementsByTagName(element);
QDomNode rUrl = removeList.at(0);
qDebug() << "is there a child node ?" << rUrl.hasChildNodes() <<" " << rUrl.childNodes().at(0).nodeName() ;
rUrl.removeChild(rUrl.childNodes().at(0));
}
示例7: dataDownloadComplete
void GoogleCalendar::dataDownloadComplete(QNetworkReply *rep)
{
if ((rep->error() != 0) && (rep->error() != QNetworkReply::UnknownContentError))
{
fprintf(stderr, QString("HTTP error %1\n").arg(rep->error()).toStdString().c_str());
return;
}
QString content = rep->readAll();
QDomDocument *xml = new QDomDocument("feed");
if (!xml->setContent(content))
{
fprintf(stderr, ("Unable to open gcal XML from:\n"+webpath.toString()+"\n").toStdString().c_str());
qDebug() << content;
return;
}
events.clear();
qDebug() << QString("Loading %1 entries").arg(xml->documentElement().elementsByTagName("entry").count());
for (int i = 0; i < xml->documentElement().elementsByTagName("entry").count(); ++i) {
QDomNode event = xml->documentElement().elementsByTagName("entry").at(i);
QString title = event.firstChildElement("title").text();
QString content = event.firstChildElement("content").text();
for (int x = 0; x < event.childNodes().count(); ++x) {
if (event.childNodes().at(x).nodeName() == "gd:when") {
QDateTime start = RFC3339::fromString(event.childNodes().at(x).attributes().namedItem("startTime").nodeValue());
QDateTime end = RFC3339::fromString(event.childNodes().at(x).attributes().namedItem("endTime").nodeValue());
events.append(new CalendarEvent(title, start, end, content));
}
}
}
qSort(events.begin(), events.end(), CalendarEventComparator());
purgePast();
emit refreshComplete();
delete xml;
}
示例8: if
bool Lvk::Clue::ScriptParser::parseHeader(QDomElement &header, Clue::Script &script)
{
bool hasCharacter = false;
for (int i = 0; i < header.childNodes().size(); ++i) {
QDomNode node = header.childNodes().item(i);
if (node.childNodes().isEmpty()) {
continue;
}
QString name = node.nodeName().toLower();
QString value = node.childNodes().at(0).nodeValue().trimmed();
if (name == "character") {
script.character = value;
hasCharacter = true;
} else if (name == "scriptnumber") {
script.number = value.toInt();
} else {
m_errMsg = QObject::tr("Unknown tag '%1'").arg(name);
return false;
}
}
return hasCharacter;
}
示例9: getTagAttributes
void MainWindow::getTagAttributes(QList<QStandardItem*> *list, QDomNode doc)
{
//add the tag's name in the list
QStandardItem *newItem = new QStandardItem(doc.toElement().tagName());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
//if the node doesn't have any children, it means there is a value inside the node, we add this value in the list here
if((!doc.childNodes().item(0).isElement() && doc.hasChildNodes()) && !doc.childNodes().item(0).isComment())
{
newItem = new QStandardItem(doc.toElement().text());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
}
//if the node have at least one child, there is no value inside the node so we just had an empty string to the list
else
{
newItem = new QStandardItem("");
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
}
//add all the attributes to the list
for(int i = 0; i < doc.attributes().length(); i++)
{
newItem = new QStandardItem(doc.attributes().item(i).toAttr().name() + " : " + doc.attributes().item(i).toAttr().value());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
list->append(newItem);
}
}
示例10: 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;
}
}
}
示例11: RecursiveFetch
static void RecursiveFetch(QDomNode node, QList<QDomElement> *list)
{
list->append(node.toElement());
int index = 0;
while (index < node.childNodes().count())
{
QDomNode nx = node.childNodes().at(index++);
RecursiveFetch(nx, list);
}
}
示例12: 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 ;
}
示例13: print_dom
void treubug::print_dom(QDomNode in, int ind){
QString a="";
for(int i=0; i<ind; i++)
a+="--------";
qDebug("%s%s(%s)", a.ascii(), in.toElement().tagName().ascii(), in.toElement().text().ascii());
if(in.childNodes().length()==1)
return;
for(unsigned int i=0 ; i<in.childNodes().length(); i++){
print_dom(in.childNodes().item(i), ind+1);
}
}
示例14: initNodeType
void btFactory::initNodeType(QDomNode xmlNode)
{
QDomNamedNodeMap nodeTypeAttributes = xmlNode.attributes();
btNode* nodeType = btFactory::instance()->getRegisteredNodeType(nodeTypeAttributes.namedItem("className").nodeValue());
if(!nodeType)
{
nodeType = new btNode();
nodeType->setType(btNode::UnusableNodeType);
btFactory::instance()->registerNodeType(nodeType, nodeTypeAttributes.namedItem("className").nodeValue());
}
else
{
QString typeCategory = nodeTypeAttributes.namedItem("category").nodeValue();
if(typeCategory == "action")
{
nodeType->setType(btNode::ActionNodeType);
}
else if(typeCategory == "condition")
{
nodeType->setType(btNode::ConditionNodeType);
}
else if(typeCategory == "composite")
{
nodeType->setType(btNode::CompositeNodeType);
}
else if(typeCategory == "decorator")
{
nodeType->setType(btNode::DecoratorNodeType);
}
else if(typeCategory == "reference")
{
nodeType->setType(btNode::ReferenceNodeType);
}
else
{
nodeType->setType(btNode::UnusableNodeType);
}
}
nodeType->setName(nodeTypeAttributes.namedItem("name").nodeValue());
nodeType->setDescription(nodeTypeAttributes.namedItem("description").nodeValue());
nodeType->setClassName(nodeTypeAttributes.namedItem("className").nodeValue());
for(int j = 0; j < xmlNode.childNodes().count(); j++)
{
QDomNode currentProperty = xmlNode.childNodes().at(j);
QDomNamedNodeMap propertyAttributes = currentProperty.attributes();
nodeType->setProperty(propertyAttributes.namedItem("name").nodeValue().toUtf8(), propertyAttributes.namedItem("datatype").nodeValue());
}
}
示例15: DomItem
DomItem *DomItem::child(int i)
{
if (childItems.contains(i))
return childItems[i];
if (i >= 0 && i < domNode.childNodes().count()) {
QDomNode childNode = domNode.childNodes().item(i);
DomItem *childItem = new DomItem(childNode, i, this);
childItems[i] = childItem;
return childItem;
}
return 0;
}