当前位置: 首页>>代码示例>>C++>>正文


C++ QDomElement::hasChildNodes方法代码示例

本文整理汇总了C++中QDomElement::hasChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::hasChildNodes方法的具体用法?C++ QDomElement::hasChildNodes怎么用?C++ QDomElement::hasChildNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDomElement的用法示例。


在下文中一共展示了QDomElement::hasChildNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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 );
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:56,代码来源:wpxmlparser.cpp

示例2: recurseCreateTOC

static void recurseCreateTOC( QDomDocument &maindoc, const QDomNode &parent, QDomNode &parentDestination, KDjVu *djvu )
{
    QDomNode n = parent.firstChild();
    while( !n.isNull() )
    {
        QDomElement el = n.toElement();

        QDomElement newel = maindoc.createElement( el.attribute( "title" ) );
        parentDestination.appendChild( newel );

        QString dest;
        if ( !( dest = el.attribute( "PageNumber" ) ).isEmpty() )
        {
            Okular::DocumentViewport vp;
            vp.pageNumber = dest.toInt() - 1;
            newel.setAttribute( "Viewport", vp.toString() );
        }
        else if ( !( dest = el.attribute( "PageName" ) ).isEmpty() )
        {
            Okular::DocumentViewport vp;
            vp.pageNumber = djvu->pageNumber( dest );
            newel.setAttribute( "Viewport", vp.toString() );
        }
        else if ( !( dest = el.attribute( "URL" ) ).isEmpty() )
        {
            newel.setAttribute( "URL", dest );
        }

        if ( el.hasChildNodes() )
        {
            recurseCreateTOC( maindoc, n, newel, djvu );
        }
        n = n.nextSibling();
    }
}
开发者ID:azat-archive,项目名称:okular,代码行数:35,代码来源:generator_djvu.cpp

示例3: addChildren

void TOC::addChildren( const QDomNode & parentNode, KListViewItem * parentItem )
{
    // keep track of the current listViewItem
    TOCItem * currentItem = 0;
    QDomNode n = parentNode.firstChild();
    while( !n.isNull() )
    {
        // convert the node to an element (sure it is)
        QDomElement e = n.toElement();

        // insert the entry as top level (listview parented) or 2nd+ level
        if ( !parentItem )
            currentItem = new TOCItem( this, currentItem, e );
        else
            currentItem = new TOCItem( parentItem, currentItem, e );

        // descend recursively and advance to the next node
        if ( e.hasChildNodes() )
            addChildren( n, currentItem );

        // open/keep close the item
        bool isOpen = false;
        if ( e.hasAttribute( "Open" ) )
            isOpen = QVariant( e.attribute( "Open" ) ).toBool();
        currentItem->setOpen( isOpen );

        n = n.nextSibling();
    }
}
开发者ID:serghei,项目名称:kde3-kdegraphics,代码行数:29,代码来源:toc.cpp

示例4: fillToc

static void fillToc(Poppler::Document *doc, const QDomNode &parent, QTreeWidget *tree, QTreeWidgetItem *parentItem)
{
    QTreeWidgetItem *newitem = 0;
    for (QDomNode node = parent.firstChild(); !node.isNull(); node = node.nextSibling()) {
        QDomElement e = node.toElement();

		// for some unknown reason e.attribute("Destination") does not exist while Okular successfully uses it; so we cannot use Poppler::LinkDestination(e.attribute(QString::fromLatin1("Destination"))).pageNumber() and must use the following
//		const int pageNumber = doc->linkDestination(e.attribute(QString::fromLatin1("DestinationName")))->pageNumber();
		Poppler::LinkDestination *dest = doc->linkDestination(e.attribute(QString::fromLatin1("DestinationName")));
		const double pageNumber = dest->pageNumber() + dest->top();
		delete dest;

        if (!parentItem) {
            newitem = new QTreeWidgetItem(tree, newitem);
        } else {
            newitem = new QTreeWidgetItem(parentItem, newitem);
        }
        newitem->setText(0, e.tagName());
		newitem->setData(0, Qt::UserRole, pageNumber);

        bool isOpen = false;
        if (e.hasAttribute(QString::fromLatin1("Open"))) {
            isOpen = QVariant(e.attribute(QString::fromLatin1("Open"))).toBool();
        }
        if (isOpen) {
            tree->expandItem(newitem);
        }

        if (e.hasChildNodes()) {
            fillToc(doc, node, tree, newitem);
        }
    }
}
开发者ID:amkhlv,项目名称:pdfviewer,代码行数:33,代码来源:tocdock.cpp

示例5: fillToc

static void fillToc(const QDomNode &parent, QTreeWidget *tree, QTreeWidgetItem *parentItem)
{
	QTreeWidgetItem *newitem = 0;
	for (QDomNode node = parent.firstChild(); !node.isNull(); node = node.nextSibling()) {
		QDomElement e = node.toElement();

		if (!parentItem)
			newitem = new QTreeWidgetItem(tree, newitem);
		else
			newitem = new QTreeWidgetItem(parentItem, newitem);
		newitem->setText(0, e.tagName());

		bool isOpen = false;
		if (e.hasAttribute("Open"))
			isOpen = QVariant(e.attribute("Open")).toBool();
		if (isOpen)
			tree->expandItem(newitem);

		if (e.hasAttribute("DestinationName"))
			newitem->setText(1, e.attribute("DestinationName"));

		if (e.hasChildNodes())
			fillToc(node, tree, newitem);
	}
}
开发者ID:bngabonziza,项目名称:miktex,代码行数:25,代码来源:PDFDocks.cpp

示例6: 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;
}
开发者ID:KyryloBR,项目名称:PictureSubmarine,代码行数:33,代码来源:parseralbum.cpp

示例7: if

void PackagesInfo::Private::addPackageFrom(const QDomElement& packageE)
{
    if( !packageE.hasChildNodes() )
        return;

    PackageInfo info;
    for( QDomNode childNode = packageE.firstChild(); !childNode.isNull(); childNode = childNode.nextSibling() )
    {
        const QDomElement childNodeE = childNode.toElement();
        if( childNodeE.isNull() )
            continue;

        if( childNodeE.tagName() == QLatin1String( "Name" ) )
            info.name = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Pixmap" ) )
            info.pixmap = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Title" ) )
            info.title = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Description" ) )
            info.description = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Version" ) )
            info.version = childNodeE.text();
        else if( childNodeE.tagName() == QLatin1String( "Size" ) )
            info.uncompressedSize = childNodeE.text().toULongLong();
        else if( childNodeE.tagName() == QLatin1String( "Dependencies" ) )
            info.dependencies = childNodeE.text().split( QLatin1String( "," ), QString::SkipEmptyParts );
        else if( childNodeE.tagName() == QLatin1String( "LastUpdateDate" ) )
            info.lastUpdateDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
        else if( childNodeE.tagName() == QLatin1String( "InstallDate" ) )
            info.installDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
    }

    this->packageInfoList.append( info );
}
开发者ID:jun-zhang,项目名称:KDUpdater,代码行数:34,代码来源:kdupdaterpackagesinfo.cpp

示例8: unRotateChild

void SvgFlattener::unRotateChild(QDomElement & element, QMatrix transform) {

	// TODO: missing ellipse element

    if(!element.hasChildNodes()) {

		QString sw = element.attribute("stroke-width");
		if (!sw.isEmpty()) {
			bool ok;
			double strokeWidth = sw.toDouble(&ok);
			if (ok) {
                QLineF line(0, 0, strokeWidth, 0);
                QLineF newLine = transform.map(line);
				element.setAttribute("stroke-width", newLine.length());
			}
		}

		// I'm a leaf node.
		QString tag = element.nodeName().toLower();
		if(tag == "path"){
            QString data = element.attribute("d").trimmed();
            if (!data.isEmpty()) {
                const char * slot = SLOT(rotateCommandSlot(QChar, bool, QList<double> &, void *));
                PathUserData pathUserData;
                pathUserData.transform = transform;
                if (parsePath(data, slot, pathUserData, this, true)) {
                    element.setAttribute("d", pathUserData.string);
                }
            }
        }
开发者ID:himanshuchoudhary,项目名称:cscope,代码行数:30,代码来源:svgflattener.cpp

示例9: parseChildNodes

void FeedList::parseChildNodes(QDomNode &node, Folder* parent)
{
    QDomElement e = node.toElement(); // try to convert the node to an element.

    if( !e.isNull() )
    {
        QString title = e.hasAttribute("text") ? e.attribute("text") : e.attribute("title");

        if (e.hasAttribute("xmlUrl") || e.hasAttribute("xmlurl") || e.hasAttribute("xmlURL") )
        {
            Feed* feed = Feed::fromOPML(e, d->storage);
            if (feed)
            {
                if (!d->urlMap[feed->xmlUrl()].contains(feed))
                    d->urlMap[feed->xmlUrl()].append(feed);
                parent->appendChild(feed);
            }
        }
        else
        {
            Folder* fg = Folder::fromOPML(e);
            parent->appendChild(fg);

            if (e.hasChildNodes())
            {
                QDomNode child = e.firstChild();
                while(!child.isNull())
                {
                    parseChildNodes(child, fg);
                    child = child.nextSibling();
                }
            }
        }
    }
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:35,代码来源:feedlist.cpp

示例10: unRotateChild

void SvgFlattener::unRotateChild(QDomElement & element, QMatrix transform) {

	// TODO: missing ellipse element

    if(!element.hasChildNodes()) {

		double scale = qMin(qAbs(transform.m11()), qAbs(transform.m22()));
		if (scale != 1 && transform.m21() == 0 && transform.m12() == 0) {
			QString sw = element.attribute("stroke-width");
			if (!sw.isEmpty()) {
				bool ok;
				double strokeWidth = sw.toDouble(&ok);
				if (ok) {
					element.setAttribute("stroke-width", QString::number(strokeWidth * scale));
				}
			}
		}

		// I'm a leaf node.
		QString tag = element.nodeName().toLower();
		if(tag == "path"){
            QString data = element.attribute("d").trimmed();
            if (!data.isEmpty()) {
                const char * slot = SLOT(rotateCommandSlot(QChar, bool, QList<double> &, void *));
                PathUserData pathUserData;
                pathUserData.transform = transform;
                if (parsePath(data, slot, pathUserData, this, true)) {
                    element.setAttribute("d", pathUserData.string);
                }
            }
        }
开发者ID:Ipallis,项目名称:Fritzing,代码行数:31,代码来源:svgflattener.cpp

示例11: addChildren

void TOCModelPrivate::addChildren( const QDomNode & parentNode, TOCItem * parentItem )
{
    TOCItem * currentItem = 0;
    QDomNode n = parentNode.firstChild();
    while( !n.isNull() )
    {
        // convert the node to an element (sure it is)
        QDomElement e = n.toElement();

        // insert the entry as top level (listview parented) or 2nd+ level
        currentItem = new TOCItem( parentItem, e );

        // descend recursively and advance to the next node
        if ( e.hasChildNodes() )
            addChildren( n, currentItem );

        // open/keep close the item
        bool isOpen = false;
        if ( e.hasAttribute( "Open" ) )
            isOpen = QVariant( e.attribute( "Open" ) ).toBool();
        if ( isOpen )
            itemsToOpen.append( currentItem );

        n = n.nextSibling();
    }
}
开发者ID:Saljack,项目名称:osp-okular,代码行数:26,代码来源:tocmodel.cpp

示例12: if

QList<QDomElement> Exporter::searchForCheckedItems(QDomElement element)
{
    QList<QDomElement> list;

    if(element.tagName() == "plume-tree"){
        for(int i = 0 ; i < element.childNodes().size() ; ++i)
            list.append(searchForCheckedItems(element.childNodes().at(i).toElement()));

    }
    else if(element.attribute("exporterCheckState", "2").toInt() != 0){



        if(element.tagName() == "trash")
            return list;




        list.append(element);

        if(!element.hasChildNodes())
            return list;


        for(int i = 0 ; i < element.childNodes().size() ; ++i)
            list.append(searchForCheckedItems(element.childNodes().at(i).toElement()));



    }
    return list;
}
开发者ID:jacquetc,项目名称:plume-creator-legacy,代码行数:33,代码来源:exporter.cpp

示例13: writeXml

// 将销售记录写入文档
void Widget::writeXml()
{
    // 先从文件读取
    if (docRead()) {
            QString currentDate = getDateTime(Date);
            QDomElement root = doc.documentElement();
            // 根据是否有日期节点进行处理
            if (!root.hasChildNodes()) {
                    QDomElement date = doc.createElement(QString("日期"));
                    QDomAttr curDate = doc.createAttribute("date");
                    curDate.setValue(currentDate);
                    date.setAttributeNode(curDate);
                    root.appendChild(date);
                    createNodes(date);
            } else {
                    QDomElement date = root.lastChild().toElement();
                    // 根据是否已经有今天的日期节点进行处理
                    if (date.attribute("date") == currentDate) {
                            createNodes(date);
                    } else {
                            QDomElement date = doc.createElement(QString("日期"));
                            QDomAttr curDate = doc.createAttribute("date");
                            curDate.setValue(currentDate);
                            date.setAttributeNode(curDate);
                            root.appendChild(date);
                            createNodes(date);
                    }
            }
            // 写入到文件
            docWrite();
    }
}
开发者ID:github-jxm,项目名称:QtCrearor_fast_learn,代码行数:33,代码来源:widget.cpp

示例14: loadStereotype

/**
 * Analyzes the given QDomElement for a reference to a stereotype.
 *
 * @param element   QDomElement to analyze.
 * @return          True if a stereotype reference was found, else false.
 */
bool UMLObject::loadStereotype(QDomElement & element)
{
    QString tag = element.tagName();
    if (!UMLDoc::tagEq(tag, QLatin1String("stereotype")))
        return false;
    QString stereo = element.attribute(QLatin1String("xmi.value"));
    if (stereo.isEmpty() && element.hasChildNodes()) {
        /* like so:
         <UML:ModelElement.stereotype>
           <UML:Stereotype xmi.idref = '07CD'/>
         </UML:ModelElement.stereotype>
         */
        QDomNode stereoNode = element.firstChild();
        QDomElement stereoElem = stereoNode.toElement();
        tag = stereoElem.tagName();
        if (UMLDoc::tagEq(tag, QLatin1String("Stereotype"))) {
            stereo = stereoElem.attribute(QLatin1String("xmi.idref"));
        }
    }
    if (stereo.isEmpty())
        return false;
    Uml::ID::Type stereoID = Uml::ID::fromString(stereo);
    UMLDoc *pDoc = UMLApp::app()->document();
    m_pStereotype = pDoc->findStereotypeById(stereoID);
    if (m_pStereotype)
        m_pStereotype->incrRefCount();
    else
        m_SecondaryId = stereo;  // leave it to resolveRef()
    return true;
}
开发者ID:evaldobarbosa,项目名称:umbrello,代码行数:36,代码来源:umlobject.cpp

示例15: createFromXml

// static
EffectPointer Effect::createFromXml(EffectsManager* pEffectsManager,
                              const QDomElement& element) {
    // Empty <Effect/> elements are used to preserve chain order
    // when there are empty slots at the beginning of the chain.
    if (!element.hasChildNodes()) {
        return EffectPointer();
    }
    QString effectId = XmlParse::selectNodeQString(element, EffectXml::EffectId);
    EffectPointer pEffect = pEffectsManager->instantiateEffect(effectId);
    return pEffect;
}
开发者ID:Drakeo,项目名称:mixxx,代码行数:12,代码来源:effect.cpp


注:本文中的QDomElement::hasChildNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。