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


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

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


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

示例1: saveToXMI

void UMLArtifact::saveToXMI(QDomDocument& qDoc, QDomElement& qElement) {
    QDomElement artifactElement = UMLObject::save("UML:Artifact", qDoc);
    artifactElement.setAttribute("drawas", m_drawAsType);
    qElement.appendChild(artifactElement);
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:5,代码来源:artifact.cpp

示例2: setVCard

bool StoreVCard::setVCard( const QString &bareJid, vCardData &vCard ) {
    QDomDocument vCardXMLDoc("vCard");

    if( pathCache.isEmpty() )
        return false;

    QDomElement rootVCard = vCardXMLDoc.createElement("vCard");
    vCardXMLDoc.appendChild( rootVCard );

    QDomElement nodeNickname = vCardXMLDoc.createElement( "nickName" );
    rootVCard.appendChild(nodeNickname);
    QDomText txtNickname = vCardXMLDoc.createTextNode( vCard.nickName.toUtf8() );
    nodeNickname.appendChild( txtNickname );

    //setElementStore( "firstName", vCard.firstName );
    nodeNickname = vCardXMLDoc.createElement( "firstName" );
    rootVCard.appendChild(nodeNickname);
    txtNickname = vCardXMLDoc.createTextNode( vCard.firstName.toUtf8() );
    nodeNickname.appendChild( txtNickname );

    //setElementStore( "middleName", vCard.middleName );
    nodeNickname = vCardXMLDoc.createElement( "middleName" );
    rootVCard.appendChild(nodeNickname);
    txtNickname = vCardXMLDoc.createTextNode( vCard.middleName.toUtf8() );
    nodeNickname.appendChild( txtNickname );

    //setElementStore( "lastName", vCard.lastName );
    nodeNickname = vCardXMLDoc.createElement( "lastName" );
    rootVCard.appendChild(nodeNickname);
    txtNickname = vCardXMLDoc.createTextNode( vCard.lastName.toUtf8() );
    nodeNickname.appendChild( txtNickname );

    //setElementStore( "url", vCard.url );
    nodeNickname = vCardXMLDoc.createElement( "url" );
    rootVCard.appendChild(nodeNickname);
    txtNickname = vCardXMLDoc.createTextNode( vCard.url.toUtf8() );
    nodeNickname.appendChild( txtNickname );

    //setElementStore( "eMail", vCard.eMail );
    nodeNickname = vCardXMLDoc.createElement( "eMail" );
    rootVCard.appendChild(nodeNickname);
    txtNickname = vCardXMLDoc.createTextNode( vCard.eMail.toUtf8() );
    nodeNickname.appendChild( txtNickname );

    //setElementStore( "fullName", vCard.fullName );
    nodeNickname = vCardXMLDoc.createElement( "fullName" );
    rootVCard.appendChild(nodeNickname);
    txtNickname = vCardXMLDoc.createTextNode( vCard.fullName.toUtf8() );
    nodeNickname.appendChild( txtNickname );

    #ifdef QT_DEBUG
    //qDebug() << "doc=" << vCardXMLDoc.toString();
    #endif

    QString fileVCard = pathCache + QDir::separator() + bareJid + QDir::separator() +"vCard.xml";
    QFile xmlVCardFile(fileVCard);
    if( !xmlVCardFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) {
        qCritical()  << "commitVCard: Failed to open file for writing: " <<  fileVCard;
        return false;
    }
    QTextStream stream( &xmlVCardFile );
    stream << vCardXMLDoc.toString();
    xmlVCardFile.close();

    return true;
}
开发者ID:ksiazkowicz,项目名称:lightbulb,代码行数:66,代码来源:storevcard.cpp

示例3: toXml

QDomElement VCard::toXml(QDomDocument *doc) const
{
	QDomElement v = doc->createElement("vCard");
	v.setAttribute("version", "2.0");
	v.setAttribute("prodid", "-//HandGen//NONSGML vGen v1.0//EN");
	v.setAttribute("xmlns", "vcard-temp");

	if ( !d->version.isEmpty() )
		v.appendChild( textTag(doc, "VERSION",	d->version) );
	if ( !d->fullName.isEmpty() )
		v.appendChild( textTag(doc, "FN",	d->fullName) );

	if ( !d->familyName.isEmpty() || !d->givenName.isEmpty() || !d->middleName.isEmpty() ||
	     !d->prefixName.isEmpty() || !d->suffixName.isEmpty() ) {
		QDomElement w = doc->createElement("N");

		if ( !d->familyName.isEmpty() )
			w.appendChild( textTag(doc, "FAMILY",	d->familyName) );
		if ( !d->givenName.isEmpty() )
			w.appendChild( textTag(doc, "GIVEN",	d->givenName) );
		if ( !d->middleName.isEmpty() )
			w.appendChild( textTag(doc, "MIDDLE",	d->middleName) );
		if ( !d->prefixName.isEmpty() )
			w.appendChild( textTag(doc, "PREFIX",	d->prefixName) );
		if ( !d->suffixName.isEmpty() )
			w.appendChild( textTag(doc, "SUFFIX",	d->suffixName) );

		v.appendChild(w);
	}

	if ( !d->nickName.isEmpty() )
		v.appendChild( textTag(doc, "NICKNAME",	d->nickName) );

	if ( !d->photo.isEmpty() || !d->photoURI.isEmpty() ) {
		QDomElement w = doc->createElement("PHOTO");

		if ( !d->photo.isEmpty() ) {
			w.appendChild( textTag(doc, "TYPE",	image2type(d->photo)) );
			w.appendChild( textTag(doc, "BINVAL",	foldString( QCA::Base64().arrayToString(d->photo)) ) );
		}
		else if ( !d->photoURI.isEmpty() )
			w.appendChild( textTag(doc, "EXTVAL",	d->photoURI) );

		v.appendChild(w);
	}

	if ( !d->bday.isEmpty() )
		v.appendChild( textTag(doc, "BDAY",	d->bday) );

	if ( !d->addressList.isEmpty() ) {
		AddressList::Iterator it = d->addressList.begin();
		for ( ; it != d->addressList.end(); ++it ) {
			QDomElement w = doc->createElement("ADR");
			Address a = *it;

			if ( a.home )
				w.appendChild( emptyTag(doc, "HOME") );
			if ( a.work )
				w.appendChild( emptyTag(doc, "WORK") );
			if ( a.postal )
				w.appendChild( emptyTag(doc, "POSTAL") );
			if ( a.parcel )
				w.appendChild( emptyTag(doc, "PARCEL") );
			if ( a.dom )
				w.appendChild( emptyTag(doc, "DOM") );
			if ( a.intl )
				w.appendChild( emptyTag(doc, "INTL") );
			if ( a.pref )
				w.appendChild( emptyTag(doc, "PREF") );

			if ( !a.pobox.isEmpty() )
				w.appendChild( textTag(doc, "POBOX",	a.pobox) );
			if ( !a.extaddr.isEmpty() )
				w.appendChild( textTag(doc, "EXTADR",	a.extaddr) );
			if ( !a.street.isEmpty() )
				w.appendChild( textTag(doc, "STREET",	a.street) );
			if ( !a.locality.isEmpty() )
				w.appendChild( textTag(doc, "LOCALITY",	a.locality) );
			if ( !a.region.isEmpty() )
				w.appendChild( textTag(doc, "REGION",	a.region) );
			if ( !a.pcode.isEmpty() )
				w.appendChild( textTag(doc, "PCODE",	a.pcode) );
			if ( !a.country.isEmpty() )
				w.appendChild( textTag(doc, "CTRY",	a.country) );

			v.appendChild(w);
		}
	}

	if ( !d->labelList.isEmpty() ) {
		LabelList::Iterator it = d->labelList.begin();
		for ( ; it != d->labelList.end(); ++it ) {
			QDomElement w = doc->createElement("LABEL");
			Label l = *it;

			if ( l.home )
				w.appendChild( emptyTag(doc, "HOME") );
			if ( l.work )
				w.appendChild( emptyTag(doc, "WORK") );
			if ( l.postal )
//.........这里部分代码省略.........
开发者ID:mblsha,项目名称:yapsi-psi-snapshot,代码行数:101,代码来源:xmpp_vcard.cpp

示例4: serializeList

QDomElement PListSerializer::serializeList(QDomDocument &doc, const QVariantList &list) {
	QDomElement element = doc.createElement(QStringLiteral("array"));
	foreach(QVariant item, list) {
		element.appendChild(serializeElement(doc, item));
	}
开发者ID:WezSieTato,项目名称:qtplist,代码行数:5,代码来源:PListSerializer.cpp

示例5: serialize

QString PipelineLoader::serialize( Pipeline* pl )
    throw(std::runtime_error) /*TODO checked exceptions*/
{
    //RefPtr<Pipeline> pl = pipeline;

    QDomDocument doc;

    QDomElement xmlPipeline = doc.createElement( "pipeline" );
    doc.appendChild( xmlPipeline );

    QDomElement xmlElements = doc.createElement( "elements" );
    xmlPipeline.appendChild( xmlElements );

    const Pipeline::PipelineElementMap& ples = pl->getChildren();
    QMapIterator<int, RefPtr<PipelineElement> > itr( ples );
    while( itr.hasNext() )
    {
        itr.next();
        RefPtr<PipelineElement> ple = itr.value();

        QString className = ple->metaObject()->className();
        int id = ple->getId();

        QDomElement xmlElement = doc.createElement( "element" );
        xmlElement.setAttribute( "id", id );
        xmlElement.setAttribute( "name", className );
        xmlElements.appendChild( xmlElement );

        QDomElement xmlProperties = doc.createElement( "properties" );
        xmlElement.appendChild( xmlProperties );

        // first do static properties
        const QMetaObject* metaObject = ple->metaObject();
        for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i)
        {
            QMetaProperty property = metaObject->property(i);
            QString propertyName = QString::fromLatin1( property.name() );

            QString propertyValue;
            QVariant::Type propertyType = property.type();

            // custom types are saved here
            if( propertyType == QVariant::UserType )
            {
                // TODO: pass control here to pipeline element
                // to parse custom types?

                QVariant value = property.read( ple );
                if( value.canConvert<plv::Enum>() )
                {
                    plv::Enum e = value.value<plv::Enum>();
                    propertyValue = e.getSelectedItemName();
                }
            }
            // all other QVariant can easily be converted to string
            else
            {
                propertyValue = property.read( ple ).toString();
            }
            QDomElement xmlProperty = doc.createElement( propertyName );
            QDomText text = doc.createTextNode( propertyValue );
            xmlProperty.appendChild( text );
            xmlProperties.appendChild( xmlProperty );
        }

        // now dynamic properties
        // these are not used by processor definitions
        {
            QVariant xVal = ple->property("sceneCoordX");
            QVariant yVal = ple->property("sceneCoordY");
            if( xVal.isValid() && yVal.isValid() )
            {
                QDomElement xmlXValProperty = doc.createElement( "sceneCoordX" );
                QDomText xValText = doc.createTextNode( xVal.toString() );
                xmlXValProperty.appendChild( xValText );
                xmlProperties.appendChild( xmlXValProperty );

                QDomElement xmlYValProperty = doc.createElement( "sceneCoordY" );
                QDomText yValText = doc.createTextNode( yVal.toString() );
                xmlYValProperty.appendChild( yValText );
                xmlProperties.appendChild( xmlYValProperty );
            }
        }
    }

    QDomElement xmlConnections = doc.createElement( "connections" );
    xmlPipeline.appendChild( xmlConnections );

    const Pipeline::PipelineConnectionsList& connections = pl->getConnections();
    foreach( RefPtr<PinConnection> connection, connections )
    {
        QDomElement xmlConnection = doc.createElement( "connection" );
        xmlConnections.appendChild( xmlConnection );

        QDomElement xmlSink = doc.createElement("sink");
        xmlConnection.appendChild( xmlSink );

        QDomElement xmlSinkPinName = doc.createElement( "pinName" );
        QDomElement xmlSinkId = doc.createElement( "processorId" );

//.........这里部分代码省略.........
开发者ID:NiekHoeijmakers,项目名称:parlevision,代码行数:101,代码来源:PipelineLoader.cpp

示例6: insertDownloadingNode

void XMLOperations::insertDownloadingNode(SDownloading tmpStruct)
{
    QDomDocument domDocument;
    QFile downloadingFile(DOWNLOADINGFILE_PATH);
    if (downloadingFile.open(QIODevice::ReadOnly))
    {
        // 此处需做错误判断
        if (!domDocument.setContent(&downloadingFile))
        {
             return;
        }
    }
    else
        return;

    downloadingFile.close();

    QDomElement fileElement = domDocument.createElement("File");

    fileElement.appendChild(createChildElement("Name", tmpStruct.name));
    fileElement.appendChild(createChildElement("JobMaxSpeed", tmpStruct.jobMaxSpeed));
    fileElement.appendChild(createChildElement("SavePath", tmpStruct.savePath));
    fileElement.appendChild(createChildElement("EnableUpload", tmpStruct.enableUpload));
    fileElement.appendChild(createChildElement("URL", tmpStruct.URL));
    fileElement.appendChild(createChildElement("RedirectURL", tmpStruct.redirectRUL));
    fileElement.appendChild(createChildElement("DLToolsType", tmpStruct.dlToolsType));
    fileElement.appendChild(createChildElement("BlockCount", tmpStruct.blockCount));
    fileElement.appendChild(createChildElement("BlockSize", tmpStruct.blockSize));
    fileElement.appendChild(createChildElement("TotalSize", tmpStruct.totalSize));
    fileElement.appendChild(createChildElement("ReadySize", tmpStruct.readySize));
    fileElement.appendChild(createChildElement("State", tmpStruct.state));//2014.4.7add
    fileElement.appendChild(createChildElement("AverageSpeed", tmpStruct.averageSpeed));//2014.4.7add
    fileElement.appendChild(createChildElement("LastModifyTime", tmpStruct.lastModifyTime));//2014.4.7add
    fileElement.appendChild(createChildElement("AutoOpenFolder", tmpStruct.autoOpenFolder));
    fileElement.appendChild(createChildElement("IconPath",tmpStruct.iconPath));
    fileElement.appendChild(createThreadElement(tmpStruct.threadList));

    QDomElement rootElement = domDocument.documentElement();
    rootElement.appendChild(fileElement);

    //写xml文件
    if (!downloadingFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
        return;
    QTextStream textStream(&downloadingFile);

    domDocument.save(textStream,4);

    downloadingFile.close();
}
开发者ID:Augus-Wang,项目名称:PointDownload,代码行数:49,代码来源:xmloperations.cpp

示例7: CreateMetadataXMLItem

void CreateMetadataXMLItem(MetadataLookup *lookup,
                           QDomElement placetoadd,
                           QDomDocument docroot)
{
    if (!lookup)
        return;

    QDomElement item = docroot.createElement("item");
    placetoadd.appendChild(item);
    QString RFC822("ddd, d MMMM yyyy hh:mm:ss");

    // Language
    if (!lookup->GetLanguage().isEmpty())
    {
        QDomElement language = docroot.createElement("language");
        item.appendChild(language);
        language.appendChild(docroot.createTextNode(lookup->GetLanguage()));
    }
    // Title
    if (!lookup->GetTitle().isEmpty())
    {
        QDomElement title = docroot.createElement("title");
        item.appendChild(title);
        title.appendChild(docroot.createTextNode(lookup->GetTitle()));
    }
    // Subtitle
    if (!lookup->GetSubtitle().isEmpty())
    {
        QDomElement subtitle = docroot.createElement("subtitle");
        item.appendChild(subtitle);
        subtitle.appendChild(docroot.createTextNode(lookup->GetSubtitle()));
    }
    // Network
    if (!lookup->GetNetwork().isEmpty())
    {
        QDomElement network = docroot.createElement("network");
        item.appendChild(network);
        network.appendChild(docroot.createTextNode(lookup->GetNetwork()));
    }
    // Status
    if (!lookup->GetStatus().isEmpty())
    {
        QDomElement status = docroot.createElement("status");
        item.appendChild(status);
        status.appendChild(docroot.createTextNode(lookup->GetStatus()));
    }
    // Season
    if (lookup->GetSeason() > 0 || lookup->GetEpisode() > 0)
    {
        QDomElement season = docroot.createElement("season");
        item.appendChild(season);
        season.appendChild(docroot.createTextNode(
                           QString::number(lookup->GetSeason())));
    }
    // Episode
    if (lookup->GetSeason() > 0 || lookup->GetEpisode() > 0)
    {
        QDomElement episode = docroot.createElement("episode");
        item.appendChild(episode);
        episode.appendChild(docroot.createTextNode(
                           QString::number(lookup->GetEpisode())));
    }
    // Tagline
    if (!lookup->GetTagline().isEmpty())
    {
        QDomElement tagline = docroot.createElement("tagline");
        item.appendChild(tagline);
        tagline.appendChild(docroot.createTextNode(lookup->GetTagline()));
    }
    // Plot
    if (!lookup->GetDescription().isEmpty())
    {
        QDomElement desc = docroot.createElement("description");
        item.appendChild(desc);
        desc.appendChild(docroot.createTextNode(lookup->GetDescription()));
    }
    // Album Name
    if (!lookup->GetAlbumTitle().isEmpty())
    {
        QDomElement albumname = docroot.createElement("albumname");
        item.appendChild(albumname);
        albumname.appendChild(docroot.createTextNode(lookup->GetAlbumTitle()));
    }
    // Inetref
    if (!lookup->GetInetref().isEmpty())
    {
        QDomElement inetref = docroot.createElement("inetref");
        item.appendChild(inetref);
        inetref.appendChild(docroot.createTextNode(lookup->GetInetref()));
    }
    // Collectionref
    if (!lookup->GetCollectionref().isEmpty())
    {
        QDomElement collectionref = docroot.createElement("collectionref");
        item.appendChild(collectionref);
        collectionref.appendChild(docroot.createTextNode(lookup->GetCollectionref()));
    }
    // TMSref/SeriesID
    if (!lookup->GetTMSref().isEmpty())
    {
//.........这里部分代码省略.........
开发者ID:drescherjm,项目名称:mythtv,代码行数:101,代码来源:metadatacommon.cpp

示例8: loadSuccessLegacy

void Chaser_Test::loadSuccessLegacy()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Function");
    root.setAttribute("Type", "Chaser");

    QDomElement bus = doc.createElement("Bus");
    bus.setAttribute("Role", "Hold");
    QDomText busText = doc.createTextNode("16");
    bus.appendChild(busText);
    root.appendChild(bus);

    QDomElement dir = doc.createElement("Direction");
    QDomText dirText = doc.createTextNode("Backward");
    dir.appendChild(dirText);
    root.appendChild(dir);

    QDomElement run = doc.createElement("RunOrder");
    QDomText runText = doc.createTextNode("SingleShot");
    run.appendChild(runText);
    root.appendChild(run);

    QDomElement s1 = doc.createElement("Step");
    s1.setAttribute("Number", 1);
    QDomText s1Text = doc.createTextNode("50");
    s1.appendChild(s1Text);
    root.appendChild(s1);

    QDomElement s2 = doc.createElement("Step");
    s2.setAttribute("Number", 2);
    QDomText s2Text = doc.createTextNode("12");
    s2.appendChild(s2Text);
    root.appendChild(s2);

    QDomElement s3 = doc.createElement("Step");
    s3.setAttribute("Number", 0);
    QDomText s3Text = doc.createTextNode("87");
    s3.appendChild(s3Text);
    root.appendChild(s3);

    // Unknown tag
    QDomElement foo = doc.createElement("Foo");
    foo.setAttribute("Number", 3);
    QDomText fooText = doc.createTextNode("1");
    foo.appendChild(fooText);
    root.appendChild(foo);

    Bus::instance()->setValue(16, MasterTimer::frequency());

    Chaser c(m_doc);
    QVERIFY(c.loadXML(root) == true);
    QVERIFY(c.direction() == Chaser::Backward);
    QVERIFY(c.runOrder() == Chaser::SingleShot);
    QCOMPARE(c.steps().size(), 3);
    QVERIFY(c.steps().at(0) == ChaserStep(87));
    QVERIFY(c.steps().at(1) == ChaserStep(50));
    QVERIFY(c.steps().at(2) == ChaserStep(12));

    // postLoad() removes nonexistent functions so let's check this here
    c.postLoad();
    QCOMPARE(c.duration(), MasterTimer::frequency() * MasterTimer::tick());
}
开发者ID:CCLinck21,项目名称:qlcplus,代码行数:63,代码来源:chaser_test.cpp

示例9: loadSuccess

void Chaser_Test::loadSuccess()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Function");
    root.setAttribute("Type", "Chaser");

    QDomElement speed = doc.createElement("Speed");
    speed.setAttribute("FadeIn", "42");
    speed.setAttribute("FadeOut", "69");
    speed.setAttribute("Duration", "1337");
    root.appendChild(speed);

    QDomElement dir = doc.createElement("Direction");
    QDomText dirText = doc.createTextNode("Backward");
    dir.appendChild(dirText);
    root.appendChild(dir);

    QDomElement run = doc.createElement("RunOrder");
    QDomText runText = doc.createTextNode("SingleShot");
    run.appendChild(runText);
    root.appendChild(run);

    QDomElement s1 = doc.createElement("Step");
    s1.setAttribute("Number", 1);
    s1.setAttribute("FadeIn", 600);
    s1.setAttribute("FadeOut", 700);
    s1.setAttribute("Duration", 800);
    QDomText s1Text = doc.createTextNode("50");
    s1.appendChild(s1Text);
    root.appendChild(s1);

    QDomElement s2 = doc.createElement("Step");
    s2.setAttribute("Number", 2);
    s2.setAttribute("FadeIn", 1600);
    s2.setAttribute("FadeOut", 1700);
    s2.setAttribute("Duration", 1800);
    QDomText s2Text = doc.createTextNode("12");
    s2.appendChild(s2Text);
    root.appendChild(s2);

    QDomElement s3 = doc.createElement("Step");
    s3.setAttribute("Number", 0);
    // Let's leave these out from this step just for test's sake
    //s3.setAttribute("FadeIn", 2600);
    //s3.setAttribute("FadeOut", 2700);
    //s3.setAttribute("Duration", 2800);
    QDomText s3Text = doc.createTextNode("87");
    s3.appendChild(s3Text);
    root.appendChild(s3);

    QDomElement spd = doc.createElement("SpeedModes");
    spd.setAttribute("FadeIn", "Common");
    spd.setAttribute("FadeOut", "Default");
    spd.setAttribute("Duration", "PerStep");
    root.appendChild(spd);

    // Unknown tag
    QDomElement foo = doc.createElement("Foo");
    foo.setAttribute("Number", 3);
    QDomText fooText = doc.createTextNode("1");
    foo.appendChild(fooText);
    root.appendChild(foo);

    Chaser c(m_doc);
    QVERIFY(c.loadXML(root) == true);
    QVERIFY(c.fadeInSpeed() == 42);
    QVERIFY(c.fadeOutSpeed() == 69);
    QVERIFY(c.duration() == 1337);
    QCOMPARE(c.fadeInMode(), Chaser::Common);
    QCOMPARE(c.fadeOutMode(), Chaser::Default);
    QCOMPARE(c.durationMode(), Chaser::PerStep);
    QVERIFY(c.direction() == Chaser::Backward);
    QVERIFY(c.runOrder() == Chaser::SingleShot);
    QVERIFY(c.steps().size() == 3);

    QVERIFY(c.steps().at(0) == ChaserStep(87));
    QCOMPARE(c.steps().at(0).fadeIn, uint(0));
    QCOMPARE(c.steps().at(0).fadeOut, uint(0));
    QCOMPARE(c.steps().at(0).duration, uint(0));

    QVERIFY(c.steps().at(1) == ChaserStep(50));
    QCOMPARE(c.steps().at(1).fadeIn, uint(600));
    QCOMPARE(c.steps().at(1).fadeOut, uint(700));
    QCOMPARE(c.steps().at(1).duration, uint(800));

    QVERIFY(c.steps().at(2) == ChaserStep(12));
    QCOMPARE(c.steps().at(2).fadeIn, uint(1600));
    QCOMPARE(c.steps().at(2).fadeOut, uint(1700));
    QCOMPARE(c.steps().at(2).duration, uint(1800));
}
开发者ID:CCLinck21,项目名称:qlcplus,代码行数:91,代码来源:chaser_test.cpp

示例10:

QDomElement QgsCategorizedSymbolRendererV2::save( QDomDocument& doc )
{
  QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
  rendererElem.setAttribute( "type", "categorizedSymbol" );
  rendererElem.setAttribute( "symbollevels", ( mUsingSymbolLevels ? "1" : "0" ) );
  rendererElem.setAttribute( "attr", mAttrName );

  // categories
  int i = 0;
  QgsSymbolV2Map symbols;
  QDomElement catsElem = doc.createElement( "categories" );
  QgsCategoryList::const_iterator it = mCategories.constBegin();
  for ( ; it != mCategories.end(); ++it )
  {
    const QgsRendererCategoryV2& cat = *it;
    QString symbolName = QString::number( i );
    symbols.insert( symbolName, cat.symbol() );

    QDomElement catElem = doc.createElement( "category" );
    catElem.setAttribute( "value", cat.value().toString() );
    catElem.setAttribute( "symbol", symbolName );
    catElem.setAttribute( "label", cat.label() );
    catElem.setAttribute( "render", cat.renderState() ? "true" : "false" );
    catsElem.appendChild( catElem );
    i++;
  }

  rendererElem.appendChild( catsElem );

  // save symbols
  QDomElement symbolsElem = QgsSymbolLayerV2Utils::saveSymbols( symbols, "symbols", doc );
  rendererElem.appendChild( symbolsElem );

  // save source symbol
  if ( mSourceSymbol.data() )
  {
    QgsSymbolV2Map sourceSymbols;
    sourceSymbols.insert( "0", mSourceSymbol.data() );
    QDomElement sourceSymbolElem = QgsSymbolLayerV2Utils::saveSymbols( sourceSymbols, "source-symbol", doc );
    rendererElem.appendChild( sourceSymbolElem );
  }

  // save source color ramp
  if ( mSourceColorRamp.data() )
  {
    QDomElement colorRampElem = QgsSymbolLayerV2Utils::saveColorRamp( "[source]", mSourceColorRamp.data(), doc );
    rendererElem.appendChild( colorRampElem );
    QDomElement invertedElem = doc.createElement( "invertedcolorramp" );
    invertedElem.setAttribute( "value", mInvertedColorRamp );
    rendererElem.appendChild( invertedElem );
  }

  QDomElement rotationElem = doc.createElement( "rotation" );
  if ( mRotation.data() )
    rotationElem.setAttribute( "field", QgsSymbolLayerV2Utils::fieldOrExpressionFromExpression( mRotation.data() ) );
  rendererElem.appendChild( rotationElem );

  QDomElement sizeScaleElem = doc.createElement( "sizescale" );
  if ( mSizeScale.data() )
    sizeScaleElem.setAttribute( "field", QgsSymbolLayerV2Utils::fieldOrExpressionFromExpression( mSizeScale.data() ) );
  sizeScaleElem.setAttribute( "scalemethod", QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod ) );
  rendererElem.appendChild( sizeScaleElem );

  return rendererElem;
}
开发者ID:lusekelok,项目名称:QGIS,代码行数:65,代码来源:qgscategorizedsymbolrendererv2.cpp

示例11: writeMetadataXml

bool QgsLayerMetadata::writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const
{
  // identifier
  QDomElement identifier = document.createElement( QStringLiteral( "identifier" ) );
  QDomText identifierText = document.createTextNode( mIdentifier );
  identifier.appendChild( identifierText );
  metadataElement.appendChild( identifier );

  // parent identifier
  QDomElement parentIdentifier = document.createElement( QStringLiteral( "parentidentifier" ) );
  QDomText parentIdentifierText = document.createTextNode( mParentIdentifier );
  parentIdentifier.appendChild( parentIdentifierText );
  metadataElement.appendChild( parentIdentifier );

  // language
  QDomElement language = document.createElement( QStringLiteral( "language" ) );
  QDomText languageText = document.createTextNode( mLanguage );
  language.appendChild( languageText );
  metadataElement.appendChild( language );

  // type
  QDomElement type = document.createElement( QStringLiteral( "type" ) );
  QDomText typeText = document.createTextNode( mType );
  type.appendChild( typeText );
  metadataElement.appendChild( type );

  // title
  QDomElement title = document.createElement( QStringLiteral( "title" ) );
  QDomText titleText = document.createTextNode( mTitle );
  title.appendChild( titleText );
  metadataElement.appendChild( title );

  // abstract
  QDomElement abstract = document.createElement( QStringLiteral( "abstract" ) );
  QDomText abstractText = document.createTextNode( mAbstract );
  abstract.appendChild( abstractText );
  metadataElement.appendChild( abstract );

  // keywords
  QMapIterator<QString, QStringList> i( mKeywords );
  while ( i.hasNext() )
  {
    i.next();
    QDomElement keywordsElement = document.createElement( QStringLiteral( "keywords" ) );
    keywordsElement.setAttribute( QStringLiteral( "vocabulary" ), i.key() );
    const QStringList values = i.value();
    for ( const QString &kw : values )
    {
      QDomElement keyword = document.createElement( QStringLiteral( "keyword" ) );
      QDomText keywordText = document.createTextNode( kw );
      keyword.appendChild( keywordText );
      keywordsElement.appendChild( keyword );
    }
    metadataElement.appendChild( keywordsElement );
  }

  // fees
  QDomElement fees = document.createElement( QStringLiteral( "fees" ) );
  QDomText feesText = document.createTextNode( mFees );
  fees.appendChild( feesText );
  metadataElement.appendChild( fees );

  // constraints
  for ( const QgsLayerMetadata::Constraint &constraint : mConstraints )
  {
    QDomElement constraintElement = document.createElement( QStringLiteral( "constraints" ) );
    constraintElement.setAttribute( QStringLiteral( "type" ), constraint.type );
    QDomText constraintText = document.createTextNode( constraint.constraint );
    constraintElement.appendChild( constraintText );
    metadataElement.appendChild( constraintElement );
  }

  // rights
  for ( const QString &right : mRights )
  {
    QDomElement rightElement = document.createElement( QStringLiteral( "rights" ) );
    QDomText rightText = document.createTextNode( right );
    rightElement.appendChild( rightText );
    metadataElement.appendChild( rightElement );
  }

  // license
  for ( const QString &license : mLicenses )
  {
    QDomElement licenseElement = document.createElement( QStringLiteral( "license" ) );
    QDomText licenseText = document.createTextNode( license );
    licenseElement.appendChild( licenseText );
    metadataElement.appendChild( licenseElement );
  }

  // encoding
  QDomElement encoding = document.createElement( QStringLiteral( "encoding" ) );
  QDomText encodingText = document.createTextNode( mEncoding );
  encoding.appendChild( encodingText );
  metadataElement.appendChild( encoding );

  // crs
  QDomElement crsElement = document.createElement( QStringLiteral( "crs" ) );
  mCrs.writeXml( crsElement, document );
  metadataElement.appendChild( crsElement );
//.........这里部分代码省略.........
开发者ID:Cracert,项目名称:Quantum-GIS,代码行数:101,代码来源:qgslayermetadata.cpp

示例12: save

bool SyncDocument::save(const QString &fileName)
{
	QDomDocument doc;
	QDomElement rootNode = doc.createElement("sync");
	rootNode.setAttribute("rows", int(getRows()));
	doc.appendChild(rootNode);

	rootNode.appendChild(doc.createTextNode("\n\t"));
	QDomElement tracksNode =
	    doc.createElement("tracks");
	for (size_t i = 0; i < getTrackCount(); ++i) {
		const SyncTrack *t = getTrack(trackOrder[i]);

		QDomElement trackElem =
		    doc.createElement("track");
		trackElem.setAttribute("name", t->name);

		QMap<int, SyncTrack::TrackKey> keyMap = t->getKeyMap();
		QMap<int, SyncTrack::TrackKey>::const_iterator it;
		for (it = keyMap.constBegin(); it != keyMap.constEnd(); ++it) {
			int row = it.key();
			float value = it->value;
			char interpolationType = char(it->type);

			QDomElement keyElem =
			    doc.createElement("key");
				
			keyElem.setAttribute("row", row);
			keyElem.setAttribute("value", value);
			keyElem.setAttribute("interpolation",
			    (int)interpolationType);

			trackElem.appendChild(
			    doc.createTextNode("\n\t\t\t"));
			trackElem.appendChild(keyElem);
		}
		if (keyMap.size())
			trackElem.appendChild(
			    doc.createTextNode("\n\t\t"));

		tracksNode.appendChild(doc.createTextNode("\n\t\t"));
		tracksNode.appendChild(trackElem);
	}
	if (getTrackCount())
		tracksNode.appendChild(doc.createTextNode("\n\t"));
	rootNode.appendChild(tracksNode);
	rootNode.appendChild(doc.createTextNode("\n\t"));

	QDomElement bookmarksNode =
	    doc.createElement("bookmarks");
	QList<int>::const_iterator it;
	for (it = rowBookmarks.begin(); it != rowBookmarks.end(); ++it) {
		QDomElement bookmarkElem =
		    doc.createElement("bookmark");
		bookmarkElem.setAttribute("row", *it);

		bookmarksNode.appendChild(
		    doc.createTextNode("\n\t\t"));
		bookmarksNode.appendChild(bookmarkElem);
	}
	if (0 != rowBookmarks.size())
		bookmarksNode.appendChild(
		    doc.createTextNode("\n\t"));
	rootNode.appendChild(bookmarksNode);
	rootNode.appendChild(doc.createTextNode("\n"));

	QFile file(fileName);
	if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
		QMessageBox::critical(NULL, "Error", file.errorString());
		return false;
	}
	QTextStream streamFileOut(&file);
	streamFileOut.setCodec("UTF-8");
	streamFileOut << doc.toString();
	streamFileOut.flush();
	file.close();

	undoStack.setClean();
	return true;
}
开发者ID:yonglehou,项目名称:rocket-1,代码行数:80,代码来源:syncdocument.cpp

示例13: createDescribeFeatureTypeDocument

  QDomDocument createDescribeFeatureTypeDocument( QgsServerInterface *serverIface, const QgsProject *project, const QString &version,
      const QgsServerRequest &request )
  {
    Q_UNUSED( version );

    QDomDocument doc;

    QgsServerRequest::Parameters parameters = request.parameters();
    QgsWfsParameters wfsParameters( parameters );
    QgsWfsParameters::Format oFormat = wfsParameters.outputFormat();

    // test oFormat
    if ( oFormat == QgsWfsParameters::Format::NONE )
      throw QgsBadRequestException( QStringLiteral( "Invalid WFS Parameter" ),
                                    "OUTPUTFORMAT " + wfsParameters.outputFormatAsString() + "is not supported" );

    QgsAccessControl *accessControl = serverIface->accessControls();

    //xsd:schema
    QDomElement schemaElement = doc.createElement( QStringLiteral( "schema" )/*xsd:schema*/ );
    schemaElement.setAttribute( QStringLiteral( "xmlns" ), QStringLiteral( "http://www.w3.org/2001/XMLSchema" ) );
    schemaElement.setAttribute( QStringLiteral( "xmlns:xsd" ), QStringLiteral( "http://www.w3.org/2001/XMLSchema" ) );
    schemaElement.setAttribute( QStringLiteral( "xmlns:ogc" ), OGC_NAMESPACE );
    schemaElement.setAttribute( QStringLiteral( "xmlns:gml" ), GML_NAMESPACE );
    schemaElement.setAttribute( QStringLiteral( "xmlns:qgs" ), QGS_NAMESPACE );
    schemaElement.setAttribute( QStringLiteral( "targetNamespace" ), QGS_NAMESPACE );
    schemaElement.setAttribute( QStringLiteral( "elementFormDefault" ), QStringLiteral( "qualified" ) );
    schemaElement.setAttribute( QStringLiteral( "version" ), QStringLiteral( "1.0" ) );
    doc.appendChild( schemaElement );

    //xsd:import
    QDomElement importElement = doc.createElement( QStringLiteral( "import" )/*xsd:import*/ );
    importElement.setAttribute( QStringLiteral( "namespace" ),  GML_NAMESPACE );
    if ( oFormat == QgsWfsParameters::Format::GML2 )
      importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/2.1.2/feature.xsd" ) );
    else if ( oFormat == QgsWfsParameters::Format::GML3 )
      importElement.setAttribute( QStringLiteral( "schemaLocation" ), QStringLiteral( "http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" ) );
    schemaElement.appendChild( importElement );

    QStringList typeNameList;
    QDomDocument queryDoc;
    QString errorMsg;
    if ( queryDoc.setContent( parameters.value( QStringLiteral( "REQUEST_BODY" ) ), true, &errorMsg ) )
    {
      //read doc
      QDomElement queryDocElem = queryDoc.documentElement();
      QDomNodeList docChildNodes = queryDocElem.childNodes();
      if ( docChildNodes.size() )
      {
        for ( int i = 0; i < docChildNodes.size(); i++ )
        {
          QDomElement docChildElem = docChildNodes.at( i ).toElement();
          if ( docChildElem.tagName() == QLatin1String( "TypeName" ) )
          {
            QString typeName = docChildElem.text().trimmed();
            if ( typeName.contains( ':' ) )
              typeNameList << typeName.section( ':', 1, 1 );
            else
              typeNameList << typeName;
          }
        }
      }
    }
    else
    {
      QString typeNames = request.parameter( QStringLiteral( "TYPENAME" ) );
      if ( !typeNames.isEmpty() )
      {
        QStringList typeNameSplit = typeNames.split( ',' );
        for ( int i = 0; i < typeNameSplit.size(); ++i )
        {
          QString typeName = typeNameSplit.at( i ).trimmed();
          if ( typeName.contains( ':' ) )
            typeNameList << typeName.section( ':', 1, 1 );
          else
            typeNameList << typeName;
        }
      }
    }

    QStringList wfsLayerIds = QgsServerProjectUtils::wfsLayerIds( *project );
    for ( int i = 0; i < wfsLayerIds.size(); ++i )
    {
      QgsMapLayer *layer = project->mapLayer( wfsLayerIds.at( i ) );
      if ( layer->type() != QgsMapLayer::LayerType::VectorLayer )
      {
        continue;
      }

      QString name = layer->name();
      if ( !layer->shortName().isEmpty() )
        name = layer->shortName();
      name = name.replace( ' ', '_' );

      if ( !typeNameList.isEmpty() && !typeNameList.contains( name ) )
      {
        continue;
      }

      if ( accessControl && !accessControl->layerReadPermission( layer ) )
//.........这里部分代码省略.........
开发者ID:cz172638,项目名称:QGIS,代码行数:101,代码来源:qgswfsdescribefeaturetype.cpp

示例14: postLoad

void Chaser_Test::postLoad()
{
    Scene* sc1 = new Scene(m_doc);
    m_doc->addFunction(sc1);

    Scene* sc2 = new Scene(m_doc);
    m_doc->addFunction(sc2);

    Chaser* ch1 = new Chaser(m_doc);
    m_doc->addFunction(ch1);

    Chaser* ch2 = new Chaser(m_doc);
    m_doc->addFunction(ch2);

    Collection* co1 = new Collection(m_doc);
    m_doc->addFunction(co1);

    Collection* co2 = new Collection(m_doc);
    m_doc->addFunction(co2);

    EFX* ef1 = new EFX(m_doc);
    m_doc->addFunction(ef1);

    EFX* ef2 = new EFX(m_doc);
    m_doc->addFunction(ef2);

    QDomDocument doc;

    QDomElement root = doc.createElement("Function");
    root.setAttribute("Type", "Chaser");

    QDomElement bus = doc.createElement("Bus");
    bus.setAttribute("Role", "Hold");
    QDomText busText = doc.createTextNode("16");
    bus.appendChild(busText);
    root.appendChild(bus);

    QDomElement dir = doc.createElement("Direction");
    QDomText dirText = doc.createTextNode("Backward");
    dir.appendChild(dirText);
    root.appendChild(dir);

    QDomElement run = doc.createElement("RunOrder");
    QDomText runText = doc.createTextNode("SingleShot");
    run.appendChild(runText);
    root.appendChild(run);

    QDomElement step0 = doc.createElement("Step");
    step0.setAttribute("Number", 0);
    QDomText step0Text = doc.createTextNode(QString::number(sc1->id()));
    step0.appendChild(step0Text);
    root.appendChild(step0);

    QDomElement step1 = doc.createElement("Step");
    step1.setAttribute("Number", 1);
    QDomText step1Text = doc.createTextNode(QString::number(sc2->id()));
    step1.appendChild(step1Text);
    root.appendChild(step1);

    QDomElement step2 = doc.createElement("Step");
    step2.setAttribute("Number", 2);
    QDomText step2Text = doc.createTextNode(QString::number(ch1->id()));
    step2.appendChild(step2Text);
    root.appendChild(step2);

    QDomElement step3 = doc.createElement("Step");
    step3.setAttribute("Number", 3);
    QDomText step3Text = doc.createTextNode(QString::number(ch2->id()));
    step3.appendChild(step3Text);
    root.appendChild(step3);

    QDomElement step4 = doc.createElement("Step");
    step4.setAttribute("Number", 4);
    QDomText step4Text = doc.createTextNode(QString::number(co1->id()));
    step4.appendChild(step4Text);
    root.appendChild(step4);

    QDomElement step5 = doc.createElement("Step");
    step5.setAttribute("Number", 5);
    QDomText step5Text = doc.createTextNode(QString::number(co2->id()));
    step5.appendChild(step5Text);
    root.appendChild(step5);

    QDomElement step6 = doc.createElement("Step");
    step6.setAttribute("Number", 6);
    QDomText step6Text = doc.createTextNode(QString::number(ef1->id()));
    step6.appendChild(step6Text);
    root.appendChild(step6);

    QDomElement step7 = doc.createElement("Step");
    step7.setAttribute("Number", 7);
    QDomText step7Text = doc.createTextNode(QString::number(ef2->id()));
    step7.appendChild(step7Text);
    root.appendChild(step7);

    // Nonexistent function
    QDomElement step8 = doc.createElement("Step");
    step8.setAttribute("Number", 8);
    QDomText step8Text = doc.createTextNode(QString::number(INT_MAX - 1));
    step8.appendChild(step8Text);
//.........这里部分代码省略.........
开发者ID:CCLinck21,项目名称:qlcplus,代码行数:101,代码来源:chaser_test.cpp

示例15: loadXML

void VCXYPad_Test::loadXML()
{
    QWidget w;

    QDomDocument xmldoc;
    QDomElement root = xmldoc.createElement("XYPad");
    xmldoc.appendChild(root);

    QDomElement pos = xmldoc.createElement("Position");
    pos.setAttribute("X", "10");
    pos.setAttribute("Y", "20");
    root.appendChild(pos);

    QDomElement fxi = xmldoc.createElement("Fixture");
    fxi.setAttribute("ID", "69");
    root.appendChild(fxi);

    QDomElement x = xmldoc.createElement("Axis");
    x.setAttribute("ID", "X");
    x.setAttribute("LowLimit", "0.1");
    x.setAttribute("HighLimit", "0.5");
    x.setAttribute("Reverse", "True");
    fxi.appendChild(x);

    QDomElement y = xmldoc.createElement("Axis");
    y.setAttribute("ID", "Y");
    y.setAttribute("LowLimit", "0.2");
    y.setAttribute("HighLimit", "0.6");
    y.setAttribute("Reverse", "True");
    fxi.appendChild(y);

    QDomElement fxi2 = xmldoc.createElement("Fixture");
    fxi2.setAttribute("ID", "50");
    root.appendChild(fxi2);

    QDomElement x2 = xmldoc.createElement("Axis");
    x2.setAttribute("ID", "X");
    x2.setAttribute("LowLimit", "0.0");
    x2.setAttribute("HighLimit", "1.0");
    x2.setAttribute("Reverse", "False");
    fxi2.appendChild(x2);

    QDomElement y2 = xmldoc.createElement("Axis");
    y2.setAttribute("ID", "Y");
    y2.setAttribute("LowLimit", "0.0");
    y2.setAttribute("HighLimit", "1.0");
    y2.setAttribute("Reverse", "False");
    fxi2.appendChild(y2);

    QDomElement wstate = xmldoc.createElement("WindowState");
    wstate.setAttribute("Width", "42");
    wstate.setAttribute("Height", "69");
    wstate.setAttribute("X", "3");
    wstate.setAttribute("Y", "4");
    wstate.setAttribute("Visible", "True");
    root.appendChild(wstate);

    QDomElement appearance = xmldoc.createElement("Appearance");
    QFont f(w.font());
    f.setPointSize(f.pointSize() + 3);
    QDomElement font = xmldoc.createElement("Font");
    QDomText fontText = xmldoc.createTextNode(f.toString());
    font.appendChild(fontText);
    appearance.appendChild(font);
    root.appendChild(appearance);

    QDomElement foobar = xmldoc.createElement("Foobar");
    root.appendChild(foobar);

    VCXYPad pad(&w, m_doc);
    QVERIFY(pad.loadXML(&root) == true);
    QCOMPARE(pad.m_fixtures.size(), 2);
    QCOMPARE(pad.pos(), QPoint(3, 4));
    QCOMPARE(pad.size(), QSize(42, 69));
    QCOMPARE(pad.m_area->position(), QPoint(10, 20));

    VCXYPadFixture fixture(m_doc);
    fixture.setFixture(69);
    QVERIFY(pad.m_fixtures.contains(fixture) == true);
    fixture.setFixture(50);
    QVERIFY(pad.m_fixtures.contains(fixture) == true);

    root.setTagName("YXPad");
    QVERIFY(pad.loadXML(&root) == false);
}
开发者ID:roberts-sandbox,项目名称:qlcplus,代码行数:85,代码来源:vcxypad_test.cpp


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