void BtBookmarkLoader::saveItem(QTreeWidgetItem* item, QDomElement& parentElement)
{
	BtBookmarkFolder* folderItem = 0;
	BtBookmarkItem* bookmarkItem = 0;

	if ((folderItem = dynamic_cast<BtBookmarkFolder*>(item))) {
		QDomElement elem = parentElement.ownerDocument().createElement("Folder");
		elem.setAttribute("caption", folderItem->text(0));

		parentElement.appendChild(elem);

		for (int i = 0; i < folderItem->childCount(); i++) {
			saveItem(folderItem->child(i), elem);
		}
	}
	else if ((bookmarkItem = dynamic_cast<BtBookmarkItem*>(item))) {
		QDomElement elem = parentElement.ownerDocument().createElement("Bookmark");

		elem.setAttribute("key", bookmarkItem->englishKey());
		elem.setAttribute("description", bookmarkItem->description());
		elem.setAttribute("modulename", bookmarkItem->m_moduleName);
		elem.setAttribute("moduledescription", bookmarkItem->module() ? bookmarkItem->module()->config(CSwordModuleInfo::Description) : QString::null);

		parentElement.appendChild(elem);
	}
}
Exemplo n.º 2
0
void ViewListTreeWidget::save( QDomElement &element ) const
{
    int cnt = topLevelItemCount();
    if ( cnt == 0 ) {
        return;
    }
    QDomElement cs = element.ownerDocument().createElement( "categories" );
    element.appendChild( cs );
    for ( int i = 0; i < cnt; ++i ) {
        ViewListItem *itm = static_cast<ViewListItem*>( topLevelItem( i ) );
        if ( itm->type() != ViewListItem::ItemType_Category ) {
            continue;
        }
        QDomElement c = cs.ownerDocument().createElement( "category" );
        cs.appendChild( c );
        emit const_cast<ViewListTreeWidget*>( this )->updateViewInfo( itm );
        itm->save( c );
        for ( int j = 0; j < itm->childCount(); ++j ) {
            ViewListItem *vi = static_cast<ViewListItem*>( itm->child( j ) );
            if ( vi->type() != ViewListItem::ItemType_SubView ) {
                continue;
            }
            QDomElement el = c.ownerDocument().createElement( "view" );
            c.appendChild( el );
            emit const_cast<ViewListTreeWidget*>( this )->updateViewInfo( vi );
            vi->save( el );
            QDomElement elm = el.ownerDocument().createElement( "settings" );
            el.appendChild( elm );
            static_cast<ViewBase*>( vi->view() )->saveContext( elm );
        }
    }
}
Exemplo n.º 3
0
void Incidence::saveRecurrence(QDomElement &element) const
{
    QDomElement e = element.ownerDocument().createElement("recurrence");
    element.appendChild(e);
    e.setAttribute("cycle", mRecurrence.cycle);
    if(!mRecurrence.type.isEmpty())
        e.setAttribute("type", mRecurrence.type);
    writeString(e, "interval", QString::number(mRecurrence.interval));
    for(QStringList::ConstIterator it = mRecurrence.days.begin(); it != mRecurrence.days.end(); ++it)
    {
        writeString(e, "day", *it);
    }
    if(!mRecurrence.dayNumber.isEmpty())
        writeString(e, "daynumber", mRecurrence.dayNumber);
    if(!mRecurrence.month.isEmpty())
        writeString(e, "month", mRecurrence.month);
    if(!mRecurrence.rangeType.isEmpty())
    {
        QDomElement range = element.ownerDocument().createElement("range");
        e.appendChild(range);
        range.setAttribute("type", mRecurrence.rangeType);
        QDomText t = element.ownerDocument().createTextNode(mRecurrence.range);
        range.appendChild(t);
    }
    for(QValueList<QDate>::ConstIterator it = mRecurrence.exclusions.begin();
            it != mRecurrence.exclusions.end(); ++it)
    {
        writeString(e, "exclusion", dateToString(*it));
    }
}
Exemplo n.º 4
0
void Signature::save(const QDomElement &element)
{
    QDomElement e = element;

    QDomElement verification = e.ownerDocument().createElement("signature");
    verification.setAttribute("status", d->status);
    verification.setAttribute("sigStatus", d->sigSummary);
    verification.setAttribute("error", d->error);
    verification.setAttribute("fingerprint", d->fingerprint);
    verification.setAttribute("type", d->type);
    QDomText value;
    switch (d->type) {
        case NoType:
        case AsciiDetached:
            value = e.ownerDocument().createTextNode(d->signature);
            break;
        case BinaryDetached:
            value = e.ownerDocument().createTextNode(d->signature.toBase64());
            break;
    }
    verification.appendChild(value);


    e.appendChild(verification);
}
Exemplo n.º 5
0
//-----------------------------------------------------------------------------
void TemplateOptions::saveXmlElement(QDomElement element)
{
    QDomElement nodeTemplate = element.ownerDocument().createElement(TemplateOptions::GroupName);
    element.appendChild(nodeTemplate);

    QDomElement nodeImages = element.ownerDocument().createElement(TemplateOptions::FieldImages);
    nodeTemplate.appendChild(nodeImages);
    nodeImages.appendChild(element.ownerDocument().createTextNode(this->image()));

    QDomElement nodeFonts = element.ownerDocument().createElement(TemplateOptions::FieldFonts);
    nodeTemplate.appendChild(nodeFonts);
    nodeFonts.appendChild(element.ownerDocument().createTextNode(this->font()));
}
Exemplo n.º 6
0
void KWTextImage::save( QDomElement & parentElem )
{
    // This code is similar to KWPictureFrameSet::save
    KWDocument * doc = static_cast<KWTextDocument *>(parent)->textFrameSet()->kWordDocument();

    QDomElement imageElem = parentElem.ownerDocument().createElement( "PICTURE" );
    parentElem.appendChild( imageElem );
    //imageElem.setAttribute( "keepAspectRatio", "true" );
    QDomElement elem = parentElem.ownerDocument().createElement( "KEY" );
    imageElem.appendChild( elem );
    image().getKey().saveAttributes( elem );
    // Now we must take care that a <KEY> element will be written as a child of <PICTURES>
    doc->addTextImageRequest( this );
}
Exemplo n.º 7
0
void MainWindow::on_descriptionPlainTextEdit_textChanged()
{
    if(loadingTheInformations)
        return;
    QList<QListWidgetItem *> itemsUI=ui->itemList->selectedItems();
    if(itemsUI.size()!=1)
        return;
    quint32 selectedItem=itemsUI.first()->data(99).toUInt();
    QDomElement description = items[selectedItem].firstChildElement("description");
    while(!description.isNull())
    {
        if((!description.hasAttribute("lang") && ui->descriptionEditLanguageList->currentText()=="en")
                ||
                (description.hasAttribute("lang") && ui->descriptionEditLanguageList->currentText()==description.attribute("lang"))
                )
        {
            QDomText newTextElement=description.ownerDocument().createTextNode(ui->descriptionPlainTextEdit->toPlainText());
            QDomNodeList nodeList=description.childNodes();
            int sub_index=0;
            while(sub_index<nodeList.size())
            {
                description.removeChild(nodeList.at(sub_index));
                sub_index++;
            }
            description.appendChild(newTextElement);
            return;
        }
        description = description.nextSiblingElement("description");
    }
    QMessageBox::warning(this,tr("Warning"),tr("Text not found"));
}
Exemplo n.º 8
0
void PictureContent::toXml(QDomElement & pe) const
{
    AbstractContent::toXml(pe);
    pe.setTagName("picture");

    // save picture properties
    QDomDocument doc = pe.ownerDocument();
    QDomElement domElement;
    QDomText text;

    // save image url (wether is a local path or remote url)
    domElement = doc.createElement("path");
    pe.appendChild(domElement);
    text = doc.createTextNode(m_fileUrl);
    domElement.appendChild(text);

    // save the effects
    domElement = doc.createElement("effects");
    pe.appendChild(domElement);
    QList<PictureEffect> effectsList = m_afterLoadEffects;
    if (m_photo)
        effectsList.append(m_photo->effects());
    foreach (const PictureEffect & effect, effectsList) {
        QDomElement effectElement = doc.createElement("effect");
        effectElement.setAttribute("type", effect.effect);
        effectElement.setAttribute("param", effect.param);
        if(effect.effect == PictureEffect::Crop) {
            QString cropingRectStr;
            cropingRectStr = QString::number(effect.cropingRect.x()) + " " + QString::number(effect.cropingRect.y())
                + " " + QString::number(effect.cropingRect.width()) + " " + QString::number(effect.cropingRect.height());

            effectElement.setAttribute("cropingRect", cropingRectStr );
        }
        domElement.appendChild(effectElement);
    }
Exemplo n.º 9
0
void Archive::renameMergedStates(QDomNode notes, QMap<QString, QString> &mergedStates)
{
	QDomNode n = notes.firstChild();
	while ( ! n.isNull() ) {
		QDomElement element = n.toElement();
		if (!element.isNull()) {
			if (element.tagName() == "group" ) {
				renameMergedStates(n, mergedStates);
			} else if (element.tagName() == "note") {
				QString tags = XMLWork::getElementText(element, "tags");
				if (!tags.isEmpty()) {
					QStringList tagNames = tags.split(";");
					for (QStringList::Iterator it = tagNames.begin(); it != tagNames.end(); ++it) {
						QString &tag = *it;
						if (mergedStates.contains(tag)) {
							tag = mergedStates[tag];
						}
					}
					QString newTags = tagNames.join(";");
					QDomElement tagsElement = XMLWork::getElement(element, "tags");
					element.removeChild(tagsElement);
					QDomDocument document = element.ownerDocument();
					XMLWork::addElement(document, element, "tags", newTags);
				}
			}
		}
		n = n.nextSibling();
	}
}
Exemplo n.º 10
0
void Archive::importBasketIcon(QDomElement properties, const QString &extractionFolder)
{
	QString iconName = XMLWork::getElementText(properties, "icon");
	if (!iconName.isEmpty() && iconName != "basket") {
		QPixmap icon = KIconLoader::global()->loadIcon(
            iconName, KIconLoader::NoGroup, 16, KIconLoader::DefaultState,
            QStringList(), 0L, /*canReturnNull=*/true
            );
		// The icon does not exists on that computer, import it:
		if (icon.isNull()) {
			QDir dir;
			dir.mkdir(Global::savesFolder() + "basket-icons/");
			FormatImporter copier; // Only used to copy files synchronously
			// Of the icon path was eg. "/home/seb/icon.png", it was exported as "basket-icons/_home_seb_icon.png".
			// So we need to copy that image to "~/.kde/share/apps/basket/basket-icons/icon.png":
			int slashIndex = iconName.lastIndexOf('/');
			QString iconFileName = (slashIndex < 0 ? iconName : iconName.right(slashIndex - 2));
			QString source       = extractionFolder + "basket-icons/" + iconName.replace('/', '_');
			QString destination = Global::savesFolder() + "basket-icons/" + iconFileName;
			if (!dir.exists(destination))
				copier.copyFolder(source, destination);
			// Replace the emblem path in the tags.xml copy:
			QDomElement iconElement = XMLWork::getElement(properties, "icon");
			properties.removeChild(iconElement);
			QDomDocument document = properties.ownerDocument();
			XMLWork::addElement(document, properties, "icon", destination);
		}
	}
}
Exemplo n.º 11
0
void Package::saveTo(QDomElement& e) const {
    e.setAttribute("name", name);
    XMLUtils::addTextTag(e, "title", title);
    if (!this->url.isEmpty())
        XMLUtils::addTextTag(e, "url", this->url);
    if (!description.isEmpty())
        XMLUtils::addTextTag(e, "description", description);
    if (!this->getIcon().isEmpty())
        XMLUtils::addTextTag(e, "icon", this->getIcon());
    if (!this->license.isEmpty())
        XMLUtils::addTextTag(e, "license", this->license);
    for (int i = 0; i < this->categories.count(); i++) {
        XMLUtils::addTextTag(e, "category", this->categories.at(i));
    }

    // <link>
    QList<QString> rels = links.uniqueKeys();
    for (int i = 0; i < rels.size(); i++) {
        QString rel = rels.at(i);
        QList<QString> hrefs = links.values(rel);
        for (int j = hrefs.size() - 1; j >= 0; j--) {
            QDomElement e = e.ownerDocument().createElement("link");
            e.setAttribute("rel", rel);
            e.setAttribute("href", hrefs.at(j));
            e.appendChild(e);
        }
    }
}
Exemplo n.º 12
0
bool AttentionPlugin::outgoingStanza(int /*account*/, QDomElement& xml) {
    if(enabled) {
        if(xml.tagName() == "iq" && xml.attribute("type") == "result")
        {
            QDomNodeList list = xml.elementsByTagNameNS("http://jabber.org/protocol/disco#info", "query");
            if(!list.isEmpty())
            {
                QDomElement query = list.at(0).toElement();
                if(!query.hasAttribute("node")) {
                    QDomDocument doc = xml.ownerDocument();
                    QDomElement feature = doc.createElement("feature");
                    feature.setAttribute("var", "urn:xmpp:attention:0");
                    query.appendChild(feature);
                }
            }
        }
        else if(xml.tagName() == "presence")
        {
            QDomNodeList list = xml.elementsByTagNameNS("http://jabber.org/protocol/caps", "c");
            if(!list.isEmpty())
            {
                QDomElement c = list.at(0).toElement();
                if(c.hasAttribute("ext")) {
                    QString ext = c.attribute("ext");
                    ext += " at-pl";
                    c.setAttribute("ext", ext);
                }
            }
        }
    }
    return false;
}
Exemplo n.º 13
0
void eGuiOpPage::saveToXml(QDomElement &node) const
{
    QDomDocument xml = node.ownerDocument();
    eASSERT(!xml.isNull());

    QDomElement pageEl = xml.createElement("page");
    pageEl.setAttribute("id", m_opPage->getId());
    pageEl.setAttribute("name", QString(m_opPage->getUserName()));
    node.appendChild(pageEl);

    for (eInt i=0; i<items().size(); i++)
    {
        QGraphicsItem *item = items().at(i);
        eASSERT(item != eNULL);

        if (item->type() == QGraphicsTextItem::Type)
        {
            // Save comment item.
            QDomElement cmtEl = xml.createElement("comment");
            cmtEl.setAttribute("xpos", item->pos().x());
            cmtEl.setAttribute("ypos", item->pos().y());
            cmtEl.setAttribute("text", ((QGraphicsTextItem *)item)->toPlainText());
            pageEl.appendChild(cmtEl);
        }
        else
        {
            // Save GUI operator.
            ((eGuiOperator *)item)->saveToXml(pageEl);
        }
    }
}
Exemplo n.º 14
0
static void replaceNode(QDomElement &docElem, QDomNode &n, const QStringList &list, const QString &tag)
{
    for(QStringList::ConstIterator it = list.begin();
            it != list.end(); ++it)
    {
        QDomElement e = docElem.ownerDocument().createElement(tag);
        QDomText txt = docElem.ownerDocument().createTextNode(*it);
        e.appendChild(txt);
        docElem.insertAfter(e, n);
    }

    QDomNode next = n.nextSibling();
    docElem.removeChild(n);
    n = next;
//   kDebug(7021) << "Next tag = " << n.toElement().tagName();
}
Exemplo n.º 15
0
 void GwtField::xml(const GwtValue &value, QDomElement &parent) const {
     std::stringstream stream;
     print(value, stream, GwtPrintStyle::XmlFieldValue);
     auto doc = parent.ownerDocument();
     auto text = doc.createTextNode(stream.str().c_str());
     parent.appendChild(text);
 }
Exemplo n.º 16
0
// createRootXmlTags
//
// This function creates three QStrings, one being an <?xml .. ?> processing
// instruction, and the others being the opening and closing tags of an
// element, <foo> and </foo>.  This basically allows us to get the raw XML
// text needed to open/close an XML stream, without resorting to generating
// the XML ourselves.  This function uses QDom to do the generation, which
// ensures proper encoding and entity output.
static void createRootXmlTags(const QDomElement &root, QString *xmlHeader, QString *tagOpen, QString *tagClose)
{
	QDomElement e = root.cloneNode(false).toElement();

	// insert a dummy element to ensure open and closing tags are generated
	QDomElement dummy = e.ownerDocument().createElement("dummy");
	e.appendChild(dummy);

	// convert to xml->text
	QString str;
	{
		QTextStream ts(&str, QIODevice::WriteOnly);
		e.save(ts, 0);
	}

	// parse the tags out
	int n = str.indexOf('<');
	int n2 = str.indexOf('>', n);
	++n2;
	*tagOpen = str.mid(n, n2-n);
	n2 = str.lastIndexOf('>');
	n = str.lastIndexOf('<');
	++n2;
	*tagClose = str.mid(n, n2-n);

	// generate a nice xml processing header
	*xmlHeader = "<?xml version=\"1.0\"?>";
}
Exemplo n.º 17
0
// function that tries to extract a type from an 'attribute' element
// either the elements defines the type itself, or it is defined elsewhere
// in that case, the attribute 'ref' points to the node containing the
// definition
QDomElement
findAttElement(QDomElement e) {
    QDomNode d = e.ownerDocument().documentElement();
    QString ref = e.attribute("ref");
    QDomElement t;
    if (ref.isNull()) {
        // the element has no ref attribute: we scan it's children
        t = e;
        QString type = makeType(e.firstChild().toElement());
        if (type.isNull()) {
            err << "did not find a type" << endl;
        }
        t.setAttribute("type", type);
    } else {
        findTypeElement(ref, d, t);
        if (t.isNull()) {
            if (notfoundattribs.find("name") ==
                    notfoundattribs.end()) {
                err << "Hmm, no element with name '" << ref
                    << "' was found." << endl;
                notfoundattribs.insert("name");
            }
            t = e;
            t.setAttribute("name", ref);
        }
    }
    return t;
}
Exemplo n.º 18
0
// 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);
}
Exemplo n.º 19
0
bool PstoPlugin::processEvent(int account, QDomElement &e) {
    Q_UNUSED(account);
    Q_UNUSED(e);

    if (!enabled) {
        return false;
    }

    QDomDocument doc = e.ownerDocument();

    QString jid = e.childNodes().at(3).firstChild().nodeValue().split("/").at(0); // always here
    if (psto_jids.contains(jid)) {
        QString full_jid = e.childNodes().at(5).attributes()
                           .namedItem("from").nodeValue();

        QDomElement body = e.childNodes().at(5).firstChildElement(); // the same
        QDomText body_text = body.firstChild().toText();

        QDomElement html = doc.createElement("html");
        html.setAttribute("xmlns", "http://jabber.org/protocol/xhtml-im");
        body.parentNode().appendChild(html);

        QDomElement html_body = doc.createElement("body");
        html_body.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
        html.appendChild(html_body);

        QStringList message_strings = body_text.nodeValue().split("\n");

        int line_number = 0;
        foreach (QString line, message_strings) {
            processMessageString(line_number, line, full_jid, html_body);
            line_number++;
        }
Exemplo n.º 20
0
void GanttPrintingOptions::saveContext( QDomElement &settings ) const
{
    QDomElement e = settings.ownerDocument().createElement( "print-options" );
    settings.appendChild( e );
    e.setAttribute( "print-rowlabels", printRowLabels );
    e.setAttribute( "print-singlepage", singlePage );
}
Exemplo n.º 21
0
void QgsPolygon3DSymbol::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
{
  Q_UNUSED( context );

  QDomDocument doc = elem.ownerDocument();

  QDomElement elemDataProperties = doc.createElement( QStringLiteral( "data" ) );
  elemDataProperties.setAttribute( QStringLiteral( "alt-clamping" ), Qgs3DUtils::altClampingToString( mAltClamping ) );
  elemDataProperties.setAttribute( QStringLiteral( "alt-binding" ), Qgs3DUtils::altBindingToString( mAltBinding ) );
  elemDataProperties.setAttribute( QStringLiteral( "height" ), mHeight );
  elemDataProperties.setAttribute( QStringLiteral( "extrusion-height" ), mExtrusionHeight );
  elemDataProperties.setAttribute( QStringLiteral( "culling-mode" ), Qgs3DUtils::cullingModeToString( mCullingMode ) );
  elemDataProperties.setAttribute( QStringLiteral( "invert-normals" ), mInvertNormals ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
  elemDataProperties.setAttribute( QStringLiteral( "add-back-faces" ), mAddBackFaces ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
  elem.appendChild( elemDataProperties );

  QDomElement elemMaterial = doc.createElement( QStringLiteral( "material" ) );
  mMaterial.writeXml( elemMaterial );
  elem.appendChild( elemMaterial );

  QDomElement elemDDP = doc.createElement( QStringLiteral( "data-defined-properties" ) );
  mDataDefinedProperties.writeXml( elemDDP, propertyDefinitions() );
  elem.appendChild( elemDDP );

  QDomElement elemEdges = doc.createElement( QStringLiteral( "edges" ) );
  elemEdges.setAttribute( QStringLiteral( "enabled" ), mEdgesEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
  elemEdges.setAttribute( QStringLiteral( "width" ), mEdgeWidth );
  elemEdges.setAttribute( QStringLiteral( "color" ), QgsSymbolLayerUtils::encodeColor( mEdgeColor ) );
  elem.appendChild( elemEdges );
}
Exemplo n.º 22
0
ElementWrapper::ElementWrapper(const QDomElement& element) : d(new ElementWrapperPrivate)
{
    d->element = element;
    d->ownerDoc = element.ownerDocument(); //keep a copy of the (shared, thus cheap) document around to ensure the element isn't deleted too early (Bug 190068)
    d->xmlBaseParsed = false;
    d->xmlLangParsed = false;
}
Exemplo n.º 23
0
// stripExtraNS
//
// This function removes namespace information from various nodes for
// display purposes only (the element is pretty much useless for processing
// after this).  We do this because QXml is a bit overzealous about outputting
// redundant namespaces.
static QDomElement stripExtraNS(const QDomElement &e)
{
	// find closest parent with a namespace
	QDomNode par = e.parentNode();
	while(!par.isNull() && par.namespaceURI().isNull())
		par = par.parentNode();
	bool noShowNS = false;
	if(!par.isNull() && par.namespaceURI() == e.namespaceURI())
		noShowNS = true;

	// build qName (prefix:localName)
	QString qName;
	if(!e.prefix().isEmpty())
		qName = e.prefix() + ':' + e.localName();
	else
		qName = e.tagName();

	QDomElement i;
	int x;
	if(noShowNS)
		i = e.ownerDocument().createElement(qName);
	else
		i = e.ownerDocument().createElementNS(e.namespaceURI(), qName);

	// copy attributes
	QDomNamedNodeMap al = e.attributes();
	for(x = 0; x < al.count(); ++x) {
		QDomAttr a = al.item(x).cloneNode().toAttr();

		// don't show xml namespace
		if(a.namespaceURI() == NS_XML)
			i.setAttribute(QString("xml:") + a.name(), a.value());
		else
			i.setAttributeNodeNS(a);
	}

	// copy children
	QDomNodeList nl = e.childNodes();
	for(x = 0; x < nl.count(); ++x) {
		QDomNode n = nl.item(x);
		if(n.isElement())
			i.appendChild(stripExtraNS(n.toElement()));
		else
			i.appendChild(n.cloneNode());
	}
	return i;
}
Exemplo n.º 24
0
void ResourceAppointmentsTreeView::saveContext( QDomElement &settings ) const
{
    debugPlan;
    QDomElement e = settings.ownerDocument().createElement( "common" );
    settings.appendChild( e );
    e.setAttribute( "show-internal-appointments", model()->showInternalAppointments() );
    e.setAttribute( "show-external-appointments", model()->showExternalAppointments() );
}
Exemplo n.º 25
0
        bool XmlStateRoot::save(QDomElement& elParent) const {

            QDomDocument doc = elParent.ownerDocument();
            QDomElement elChild = doc.createElement(QLatin1String("Sky:Layout"));
            elParent.appendChild(elChild);

            return saveChildren(elChild);
        }
Exemplo n.º 26
0
        bool XmlStateView::save(QDomElement& elParent) const {

            QDomDocument doc = elParent.ownerDocument();
            QDomElement elChild = doc.createElement(QLatin1String("Sky:View"));
            elParent.appendChild(elChild);

            return saveIdentifier(elChild);
        }
Exemplo n.º 27
0
void MShape::write(QDomElement& obj)
{
  // Write basic data.
  Serializable::write(obj);

  // Write vertices.
  QDomElement verticesObj = obj.ownerDocument().createElement("vertices");
  for (int i=0; i<nVertices(); i++)
  {
    QDomElement vertexObj = obj.ownerDocument().createElement("vertex");
    vertexObj.setAttribute("x", QString::number(getVertex(i).x()));
    vertexObj.setAttribute("y", QString::number(getVertex(i).y()));
    verticesObj.appendChild(vertexObj);
  }

  obj.appendChild(verticesObj);
}
void MBasicNetworking::reset(QDomElement config) {
  cout << "Resetting Basic Networking Module: Loading configuration." << endl;
  currentProfileChanged = false;

  // if any of the following nodes/attributes does not exist, create them so
  // that we have a complete dom tree when we save the current items
  // later on.
  QDomElement e, e2;
  if (config.namedItem("ipconfig").isNull()) {
      e = config.ownerDocument().createElement("ipconfig");
      e.setAttribute("hostip", "");
      e.setAttribute("netmask", "");
      e.setAttribute("gateway", "");
      config.appendChild(e);
  }
  if (config.namedItem("device").isNull()) {
      e = config.ownerDocument().createElement("device");
      e.setAttribute("devicename", "");
      config.appendChild(e);
  }
  if (config.namedItem("dnsconfig").isNull()) {
      e = config.ownerDocument().createElement("dnsconfig");
      QDomElement e2 = config.ownerDocument().createElement("dns");
      e2.setAttribute("dnsip", "");
      config.appendChild(e);
      e.appendChild(e2);
  }

  root = new QDomElement(config);
//  root->appendChild(e);

  // get tcp/ip information
  hostip = config.namedItem("ipconfig").attributes().namedItem("hostip").toAttr().value();
  netmask = config.namedItem("ipconfig").attributes().namedItem("netmask").toAttr().value();
  gateway = config.namedItem("ipconfig").attributes().namedItem("gateway").toAttr().value();
  dnsip = config.namedItem("dnsconfig").namedItem("dns").attributes().namedItem("dnsip").toAttr().value();
  // get device name
  device = config.namedItem("device").attributes().namedItem("devicename").toAttr().value();

  widget->le_hostip->setText(hostip);
  widget->le_netmask->setText(netmask);
  widget->le_gateway->setText(gateway);
  widget->le_dnsip->setText(dnsip);
  widget->le_deviceName->setText(device);

}
Exemplo n.º 29
0
QDomElement DomUtil::namedChildElement( QDomElement& el, const QString& name )
{
    QDomElement child = el.namedItem( name ).toElement();
    if (child.isNull()) {
        child = el.ownerDocument().createElement( name );
        el.appendChild(child);
    }
    return child;
}
Exemplo n.º 30
0
void SubassemblyView::write ( QDomElement& xml_rep ) const
{
  QDomDocument document = xml_rep.ownerDocument();
  QDomElement subassembly_view_element =
    document.createElement( lC::STR::SUBASSEMBLY_VIEW );
  subassembly_view_element.setAttribute(lC::STR::SUBASSEMBLY,
                    subassembly_->dbURL().toString() );

  xml_rep.appendChild( subassembly_view_element );
}