예제 #1
0
 QXmlStreamAttributes Arrow::graphicAttributes() const
 {
   QXmlStreamAttributes attributes ;
   attributes.append("arrowType", QString::number(d->arrowType)) ;
   attributes.append("splineDisabled", QString::number(!d->spline));
   return attributes ;
 }
예제 #2
0
QXmlStreamAttributes NormalizeFilter2D::exportFilterSettingsXML()
{
    QXmlStreamAttributes attributes;
    attributes.append("autoLimits", QString::number(this->autoLimits));
    attributes.append("lowerLimit", QString::number(this->lowerLimit));
    attributes.append("upperLimit", QString::number(this->upperLimit));
    return attributes;
}
예제 #3
0
void CameraManager::save(QXmlStreamWriter& writer) {
   
    writer.writeStartElement("Camera"); // root element start

    writer.writeStartElement("input size"); // element1 start
    QXmlStreamAttributes inputSizes;
    inputSizes.append("width", QtUtil::toQString(_size.width));
    inputSizes.append("height", QtUtil::toQString(_size.width));
    writer.writeAttributes(inputSizes);
    writer.writeEndElement(); // element1 end

    writer.writeEndElement(); // root end
  
}
bool XmlScreenieSceneDao::writeScreenieScene(const ScreenieScene &screenieScene, ScreenieSceneSerializer::Mode mode)
{
    bool result = true;
    d->streamWriter->writeDTD("<!DOCTYPE screenie>");
    d->streamWriter->writeStartElement("screeniescene");

    QXmlStreamAttributes sceneAttributes;
    sceneAttributes.append("version", d->version.toString());
    sceneAttributes.append("template", screenieScene.isTemplate() ? "true" : "false");
    d->streamWriter->writeAttributes(sceneAttributes);
    {
        switch (mode) {
        case ScreenieSceneSerializer::FullScene:
            d->streamWriter->writeStartElement("background");
            {
                QXmlStreamAttributes backgroundAttributes;
                backgroundAttributes.append("enabled", screenieScene.isBackgroundEnabled() ? "true" : "false");
                backgroundAttributes.append("bgcolor", screenieScene.getBackgroundColor().name());
                d->streamWriter->writeAttributes(backgroundAttributes);
            }
            d->streamWriter->writeEndElement();
            result = writeScreenieModels(screenieScene, mode);
            break;
        case ScreenieSceneSerializer::SelectedItems:
            result = writeScreenieModels(screenieScene, mode);
            break;
        default:
#ifdef DEBUG
            qCritical("XmlScreenieSceneDao::writeScreenieScene: UNSUPPORTED mode: %d", mode);
#endif
            result = false;
        }
    }
    d->streamWriter->writeEndElement();
    return result;
}
예제 #5
0
bool OdtWriter::writeParagraphStyle(const QTextBlockFormat& format, const QString& name)
{
	QXmlStreamAttributes attributes;
	bool rtl = format.layoutDirection() == Qt::RightToLeft;
	if (rtl) {
		attributes.append(QString::fromLatin1("style:writing-mode"), QString::fromLatin1("rl"));
	}

	Qt::Alignment align = format.alignment();
	if (rtl && (align & Qt::AlignLeft)) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("left"));
	} else if (align & Qt::AlignRight) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("right"));
	} else if (align & Qt::AlignCenter) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("center"));
	} else if (align & Qt::AlignJustify) {
		attributes.append(QString::fromLatin1("fo:text-align"), QString::fromLatin1("justify"));
	}

	if (format.indent() > 0) {
		attributes.append(QString::fromLatin1("fo:margin-left"), QString::number(format.indent() * 0.5) + QString::fromLatin1("in"));
	}

	if (attributes.isEmpty()) {
		return false;
	}

	m_xml.writeStartElement(QString::fromLatin1("style:style"));
	m_xml.writeAttribute(QString::fromLatin1("style:name"), name);
	m_xml.writeAttribute(QString::fromLatin1("style:family"), QString::fromLatin1("paragraph"));
	m_xml.writeAttribute(QString::fromLatin1("style:parent-style-name"), QString::fromLatin1("Normal"));

	m_xml.writeEmptyElement(QString::fromLatin1("style:paragraph-properties"));
	m_xml.writeAttributes(attributes);
	m_xml.writeEndElement();

	return true;
}
예제 #6
0
bool OdtWriter::writeTextStyle(const QTextCharFormat& format, const QString& name)
{
	QXmlStreamAttributes attributes;
	if (format.fontWeight() == QFont::Bold) {
		attributes.append(QString::fromLatin1("fo:font-weight"), QString::fromLatin1("bold"));
	}
	if (format.fontItalic()) {
		attributes.append(QString::fromLatin1("fo:font-style"), QString::fromLatin1("italic"));
	}
	if (format.fontUnderline()) {
		attributes.append(QString::fromLatin1("style:text-underline-type"), QString::fromLatin1("single"));
		attributes.append(QString::fromLatin1("style:text-underline-style"), QString::fromLatin1("solid"));
	}
	if (format.fontStrikeOut()) {
		attributes.append(QString::fromLatin1("style:text-line-through-type"), QString::fromLatin1("single"));
	}
	if (format.verticalAlignment() == QTextCharFormat::AlignSuperScript) {
		attributes.append(QString::fromLatin1("style:text-position"), QString::fromLatin1("super"));
	} else if (format.verticalAlignment() == QTextCharFormat::AlignSubScript) {
		attributes.append(QString::fromLatin1("style:text-position"), QString::fromLatin1("sub"));
	}

	if (attributes.isEmpty()) {
		return false;
	}

	m_xml.writeStartElement(QString::fromLatin1("style:style"));
	m_xml.writeAttribute(QString::fromLatin1("style:name"), name);
	m_xml.writeAttribute(QString::fromLatin1("style:family"), QString::fromLatin1("text"));

	m_xml.writeEmptyElement(QString::fromLatin1("style:text-properties"));
	m_xml.writeAttributes(attributes);
	m_xml.writeEndElement();

	return true;
}
static PyObject *meth_QXmlStreamAttributes_append(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QString* a0;
        int a0State = 0;
        const QString* a1;
        int a1State = 0;
        const QString* a2;
        int a2State = 0;
        QXmlStreamAttributes *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1J1J1", &sipSelf, sipType_QXmlStreamAttributes, &sipCpp, sipType_QString,&a0, &a0State, sipType_QString,&a1, &a1State, sipType_QString,&a2, &a2State))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->append(*a0,*a1,*a2);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);
            sipReleaseType(const_cast<QString *>(a1),sipType_QString,a1State);
            sipReleaseType(const_cast<QString *>(a2),sipType_QString,a2State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        const QString* a0;
        int a0State = 0;
        const QString* a1;
        int a1State = 0;
        QXmlStreamAttributes *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1J1", &sipSelf, sipType_QXmlStreamAttributes, &sipCpp, sipType_QString,&a0, &a0State, sipType_QString,&a1, &a1State))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->append(*a0,*a1);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State);
            sipReleaseType(const_cast<QString *>(a1),sipType_QString,a1State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    {
        const QXmlStreamAttribute* a0;
        QXmlStreamAttributes *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QXmlStreamAttributes, &sipCpp, sipType_QXmlStreamAttribute, &a0))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->append(*a0);
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QXmlStreamAttributes, sipName_append, doc_QXmlStreamAttributes_append);

    return NULL;
}
예제 #8
0
파일: shared.cpp 프로젝트: Nephos/umbrello
bool applyTranslationToXMIFile(const char *fileName, const QStringList &attributes, TranslationMap &translations)
{

    QFile file(fileName);
    if (!file.open(QIODevice::ReadOnly))
        return false;
    QXmlStreamReader reader(&file);
    QFile outFile;
    if (!outFile.open(stdout, QIODevice::WriteOnly))
        return false;
    QXmlStreamWriter writer(&outFile);
    writer.setAutoFormatting (true);
    writer.setAutoFormattingIndent(1);
    writer.setCodec(reader.documentEncoding().toLatin1().constData());

    while (!reader.atEnd())
    {
        QXmlStreamReader::TokenType type = reader.readNext();
        switch(type)
        {
        case QXmlStreamReader::ProcessingInstruction:
            writer.writeProcessingInstruction(reader.processingInstructionTarget().toString(), reader.processingInstructionData().toString());
            break;

        case QXmlStreamReader::DTD:
            writer.writeDTD(reader.text().toString());
            break;

        case QXmlStreamReader::StartDocument:
            writer.writeStartDocument(reader.documentVersion().toString());
            break;

        case QXmlStreamReader::StartElement:
        {
            writer.writeStartElement(reader.namespaceUri().toString(), reader.name().toString());
            if (reader.namespaceDeclarations().size() > 0)
            {
                QXmlStreamNamespaceDeclaration ns = reader.namespaceDeclarations().first();
                writer.writeNamespace(ns.namespaceUri().toString(), ns.prefix().toString());
            }
            QXmlStreamAttributes writerAttributes;
            for(int index = 0; index < reader.attributes().size(); index++)
            {
                QXmlStreamAttribute attr = reader.attributes()[index];
                QString name = attr.qualifiedName().toString();
                if (!attributes.contains(name)) {
                    writerAttributes.append(attr);
                    continue;
                }
                QString value = attr.value().toString();
                if (value.isEmpty()) {
                    writerAttributes.append(attr);
                    continue;
                }
                if (!translations.contains(value))
                {
                    cerr << "could not find translation for attribute '" << qPrintable(name) << "':'" << qPrintable(value) << "'" << std::endl;
                    continue;
                }
                QString newValue = translations[value];
                if (newValue.isEmpty()) {
                    writerAttributes.append(attr);
                    continue;
                }
                //cerr << name.toUtf8().data() << ":" << value.toUtf8().data() << "->" << newValue.toUtf8().data() << endl;
                QXmlStreamAttribute newAttribute(name, newValue);
                writerAttributes.append(newAttribute);
                //qDebug() << writerAttributes;
            }
            writer.writeAttributes(writerAttributes);
            //QString content = xmlReader.readElementText(QXmlStreamReader::SkipChildElements);
            //writer.writeCharacters(content);
            break;
        }

        case QXmlStreamReader::Characters:
            writer.writeCharacters(reader.text().toString());
            break;

        case QXmlStreamReader::Comment:
            writer.writeComment(reader.text().toString());
            break;

        case QXmlStreamReader::EndElement:
            writer.writeEndElement();
            break;

        case QXmlStreamReader::EndDocument:
           writer.writeEndDocument();
           break;

        default:
            break;
        }

    }
    outFile.close();
    return true;
}
예제 #9
0
void LapTimerThread::writeXml()
{
    QXmlStreamReader xmlReader;
    coordTmpFile.open(QIODevice::ReadOnly | QIODevice::Text);
    xmlReader.setDevice(&coordTmpFile);
    xmlReader.readNext();
    int lapNum=0;
    //Reading from the file
    xmlReader.readNext();
    while (!xmlReader.isEndDocument())
    {
        if (xmlReader.isStartElement())
        {
            QString name = xmlReader.name().toString();
            if (name == "lap")
            {
                lapNum++;
            }

        }
        else if (xmlReader.isEndElement())
        {

        }
        xmlReader.readNext();
    }
    coordTmpFile.close();
    for (int i=0;i<lapNum-1;i++)// loop to generate kml file for each lap
    {

    QFile xmlKmlFile;
    QXmlStreamWriter bufferKml;

    xmlKmlFile.setFileName("data/"+dirName+"/"+dirName+"-"+QString::number(i+1)+".kml");
    xmlKmlFile.open(QIODevice::WriteOnly | QIODevice::Text);
    bufferKml.setDevice(&xmlKmlFile);
    bufferKml.setAutoFormatting(true);
    bufferKml.writeStartDocument();

    bufferKml.writeStartElement("kml");
    QXmlStreamAttributes atrr;
    atrr.append("xmlns","http://www.opengis.net/kml/2.2");
    atrr.append("xmlns:gx","http://www.google.com/kml/ext/2.2");
    atrr.append("xmlns:atom","http://www.w3.org/2005/Atom");
    bufferKml.writeAttributes(atrr);
    bufferKml.writeStartElement("Document");
    bufferKml.writeTextElement("open","1");
    bufferKml.writeTextElement("visibility","1");
    bufferKml.writeStartElement("name");
    bufferKml.writeCDATA("GPS Lap Timer - KML Log - "+QDate::currentDate().toString("yyyyMMdd")+QTime::currentTime().toString("hhmmss"));
    bufferKml.writeEndElement();
    //style - track
    bufferKml.writeStartElement("Style");
    bufferKml.writeAttribute(QXmlStreamAttribute("id","track"));
    bufferKml.writeStartElement("LineStyle");
    bufferKml.writeTextElement("color","7f0000ff");
    bufferKml.writeTextElement("width","4");
    bufferKml.writeEndElement();
    bufferKml.writeStartElement("IconStyle");
    bufferKml.writeTextElement("scale","1.3");
    bufferKml.writeStartElement("Icon");
    bufferKml.writeTextElement("href","http://earth.google.com/images/kml-icons/track-directional/track-0.png");
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    //style - start
    bufferKml.writeStartElement("Style");
    bufferKml.writeAttribute(QXmlStreamAttribute("id","start"));
    bufferKml.writeStartElement("IconStyle");
    bufferKml.writeTextElement("scale","1.3");
    bufferKml.writeStartElement("Icon");
    bufferKml.writeTextElement("href","http://maps.google.com/mapfiles/kml/paddle/grn-circle.png");
    bufferKml.writeEndElement();
    bufferKml.writeEmptyElement("hotSpot");
    atrr.clear();
    atrr.append("x","32");
    atrr.append("y","1");
    atrr.append("xunits","pixels");
    atrr.append("yunits","pixels");
    bufferKml.writeAttributes(atrr);
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    // style - end
    bufferKml.writeStartElement("Style");
    bufferKml.writeAttribute(QXmlStreamAttribute("id","end"));
    bufferKml.writeStartElement("IconStyle");
    bufferKml.writeTextElement("scale","1.3");
    bufferKml.writeStartElement("Icon");
    bufferKml.writeTextElement("href","http://maps.google.com/mapfiles/kml/paddle/red-circle.png");
    bufferKml.writeEndElement();
    bufferKml.writeEmptyElement("hotSpot");
    bufferKml.writeAttributes(atrr);
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    // style - statistics
    bufferKml.writeStartElement("Style");
    bufferKml.writeAttribute(QXmlStreamAttribute("id","statistics"));
    bufferKml.writeStartElement("IconStyle");
    bufferKml.writeTextElement("scale","1.3");
    bufferKml.writeStartElement("Icon");
    bufferKml.writeTextElement("href","http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png");
    bufferKml.writeEndElement();
    bufferKml.writeEmptyElement("hotSpot");
    atrr.clear();
    atrr.append("x","20");
    atrr.append("y","2");
    atrr.append("xunits","pixels");
    atrr.append("yunits","pixels");
    bufferKml.writeAttributes(atrr);
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    // style - waypoint
    bufferKml.writeStartElement("Style");
    bufferKml.writeAttribute(QXmlStreamAttribute("id","waypoint"));
    bufferKml.writeStartElement("IconStyle");
    bufferKml.writeTextElement("scale","1.3");
    bufferKml.writeStartElement("Icon");
    bufferKml.writeTextElement("href","http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png");
    bufferKml.writeEndElement();
    bufferKml.writeEmptyElement("hotSpot");
    bufferKml.writeAttributes(atrr);
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();

    QStringList xmlTmpTextBuffer;
    int lapTmpNum=0;
    bool lapNumFlag=false;

    bufferKml.writeStartElement("Folder");
    bufferKml.writeStartElement("name");
    bufferKml.writeCDATA("Lap #"+QString::number(i+1));
    bufferKml.writeEndElement();
    bufferKml.writeTextElement("open","1");

    //waypoints - load
    xmlReader.clear();
    wayptTmpFile.open(QIODevice::ReadOnly | QIODevice::Text);
    xmlReader.setDevice(&wayptTmpFile);
    xmlReader.readNext();
    xmlTmpTextBuffer.clear();
    xmlTextBuffer.clear();
    lapTmpNum=0;
    lapNumFlag=false;
    QStringList bestBuffer,devBuffer,timeBuffer;
    while (!xmlReader.isEndDocument())
    {
        if (xmlReader.isStartElement())
        {
            QString name = xmlReader.name().toString();

            if (name == "when" && lapNumFlag)//read time of each element
            {
               xmlTextBuffer.append(xmlReader.readElementText());
            }
            else if (name == "waypt" && lapNumFlag)
            {
                xmlTmpTextBuffer.append(xmlReader.readElementText());
            }
            else if (name == "best" && lapNumFlag)
            {
                bestBuffer.append(xmlReader.readElementText());
            }
            else if (name == "time" && lapNumFlag)
            {
                timeBuffer.append(xmlReader.readElementText());
            }
            else if (name == "dev" && lapNumFlag)
            {
                devBuffer.append(xmlReader.readElementText());
            }
            else if (name == "lap")
            {
                lapNumFlag=(lapTmpNum==i)?true:false;
                lapTmpNum++;
            }
        }
        else if (xmlReader.isEndElement())
        {

        }
        xmlReader.readNext();
    }
    wayptTmpFile.close();
    //waypoint - write
    for (int j=0;j<xmlTextBuffer.length();j++)
    {
        bufferKml.writeStartElement("Placemark");
        bufferKml.writeStartElement("name");
        if ((j+1)==xmlTextBuffer.length())
        bufferKml.writeCDATA("Finish");
        else
        bufferKml.writeCDATA("Waypoint"+QString::number(j+1));
        bufferKml.writeEndElement();
        bufferKml.writeStartElement("description");
        bufferKml.writeCDATA("Time: "+timeBuffer.at(j)+"; To best: "+devBuffer.at(j)+"; Best: "+bestBuffer.at(j));
        bufferKml.writeEndElement();
        bufferKml.writeStartElement("TimeStamp");
        bufferKml.writeTextElement("when",xmlTextBuffer.at(j));
        bufferKml.writeEndElement();
        if (j==xmlTextBuffer.length()-1)
        bufferKml.writeTextElement("styleUrl","#end");
        else
        bufferKml.writeTextElement("styleUrl","#waypoint");
        bufferKml.writeStartElement("Point");
        bufferKml.writeTextElement("coordinates",xmlTmpTextBuffer.at(j));
        bufferKml.writeEndElement();
        bufferKml.writeEndElement();
    }

    //track - load
    xmlReader.clear();
    coordTmpFile.open(QIODevice::ReadOnly | QIODevice::Text);
    xmlReader.setDevice(&coordTmpFile);
    xmlReader.readNext();
    xmlTmpTextBuffer.clear();
    xmlTextBuffer.clear();
    lapTmpNum=0;
    lapNumFlag=false;
    while (!xmlReader.isEndDocument())
    {
        if (xmlReader.isStartElement())
        {
            QString name = xmlReader.name().toString();

            if (name == "when" && lapNumFlag)//read time of each element
            {
               xmlTextBuffer.append(xmlReader.readElementText());
            }
            else if (name == "coord" && lapNumFlag)
            {
                xmlTmpTextBuffer.append(xmlReader.readElementText());
            }
            else if (name == "lap")
            {
                lapNumFlag=(lapTmpNum==i)?true:false;
                                lapTmpNum++;
            }
        }
        else if (xmlReader.isEndElement())
        {

        }
        xmlReader.readNext();
    }
    coordTmpFile.close();
    //track - write
    bufferKml.writeStartElement("Placemark");
    bufferKml.writeAttribute(QXmlStreamAttribute("id","tour"));
    bufferKml.writeStartElement("name");
    bufferKml.writeCDATA("track");
    bufferKml.writeEndElement();
    bufferKml.writeStartElement("description");
    bufferKml.writeCDATA("");
    bufferKml.writeEndElement();
    bufferKml.writeTextElement("styleUrl","#track");
    bufferKml.writeStartElement("gx:MultiTrack");
    bufferKml.writeTextElement("altitudeMode","absolute");
    bufferKml.writeTextElement("gx:interpolate","1");
    bufferKml.writeStartElement("gx:Track");
    for (int j=0;j<xmlTextBuffer.length();j++)
    {
        bufferKml.writeTextElement("when",xmlTextBuffer.at(j));
        bufferKml.writeTextElement("gx:coord",xmlTmpTextBuffer.at(j));
    }
    //data - alt - write
    bufferKml.writeStartElement("ExtendedData");
    bufferKml.writeEmptyElement("SchemaData");
    bufferKml.writeAttribute(QXmlStreamAttribute("schemaUrl","#schema"));
    bufferKml.writeStartElement("gx:SimpleArrayData");
    bufferKml.writeAttribute(QXmlStreamAttribute("name","elevation"));
    for (int j=0;j<xmlTextBuffer.length();j++)
    {
        bufferKml.writeTextElement("gx:value",QString(xmlTmpTextBuffer.at(j)).section(" ",2,2));
    }
    bufferKml.writeEndElement();
    //data - speed - load
    xmlReader.clear();
    speedTmpFile.open(QIODevice::ReadOnly | QIODevice::Text);
    xmlReader.setDevice(&speedTmpFile);
    xmlReader.readNext();
    xmlTmpTextBuffer.clear();
    xmlTextBuffer.clear();
    lapTmpNum=0;
    lapNumFlag=false;
    while (!xmlReader.isEndDocument())
    {
        if (xmlReader.isStartElement())
        {
            QString name = xmlReader.name().toString();

            if (name == "speed" && lapNumFlag)//read time of each element
            {
               xmlTextBuffer.append(xmlReader.readElementText());
            }
            else if (name == "lap")
            {
                lapNumFlag=(lapTmpNum==i)?true:false;
                lapTmpNum++;
            }
        }
        else if (xmlReader.isEndElement())
        {

        }
        xmlReader.readNext();
    }
    speedTmpFile.close();
    //data - speed - write
    bufferKml.writeStartElement("gx:SimpleArrayData");
    bufferKml.writeAttribute(QXmlStreamAttribute("name","speed"));
    for (int j=0;j<xmlTextBuffer.length();j++)
    {
        bufferKml.writeTextElement("gx:value",xmlTextBuffer.at(j));
    }
    bufferKml.writeEndElement();

    // close all opened element
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();
    bufferKml.writeEndElement();

    bufferKml.writeEndDocument();
    xmlKmlFile.close();
  }
}
예제 #10
0
 QXmlStreamAttributes SettingsItem::xmlAttributes() const {
   QXmlStreamAttributes result;
   result.append(XML_VALUE_ATTRIBUTE, serialize());
   return result;
 }
예제 #11
0
QXmlStreamAttributes GaussFilter2D::exportFilterSettingsXML()
{
    QXmlStreamAttributes attributes;
    attributes.append("radius", QString::number(this->radius));
    return attributes;
}
예제 #12
0
			QString FirefoxProfileSelectPage::GetImportOpmlFile ()
			{
				QString rssSql ("SELECT ann.id, ann.item_id, ann.anno_attribute_id, ann.content,"
						"bm.title FROM moz_items_annos ann,moz_bookmarks bm WHERE ann.item_id"
						" IN (SELECT item_id FROM moz_items_annos WHERE anno_attribute_id = (SELECT"
						" id FROM moz_anno_attributes WHERE name = 'livemark/feedURI')) AND ("
						"ann.anno_attribute_id = 4 OR ann.anno_attribute_id = 5) AND "
						"bm.id = ann.item_id");
				QSqlQuery rssQuery = GetQuery (rssSql);

				if (rssQuery.isValid ())
				{
					QSqlQuery query (*DB_);
					query.exec ("SELECT id FROM moz_anno_attributes WHERE name='livemark/siteURI'");
					query.next ();
					int site = query.value (0).toInt ();
					query.exec ("SELECT id FROM moz_anno_attributes WHERE name='livemark/feedURI'");
					query.next ();
					int feed = query.value (0).toInt ();

					QList<QVariant> opmlData;
					int prevItemId = -1;

					QMap<QString, QVariant> omplLine;
					do
					{
						if (rssQuery.value (2).toInt () == site)
							omplLine ["SiteUrl"] = rssQuery.value (3).toString ();
						if (rssQuery.value (2).toInt () == feed)
							omplLine ["FeedUrl"] = rssQuery.value (3).toString ();						
						if (prevItemId == rssQuery.value (1).toInt ())
							opmlData.push_back (omplLine);
						else
						{
							prevItemId = rssQuery.value (1).toInt ();
							omplLine ["Title"] = rssQuery.value (4).toString ();
						}
					}
					while (rssQuery.next ());
					QFile file ("firefox.opml");
					if (file.open (QIODevice::WriteOnly))
					{
						QXmlStreamWriter streamWriter (&file);
						streamWriter.setAutoFormatting (true);
						streamWriter.writeStartDocument ();
						streamWriter.writeStartElement ("opml");
						streamWriter.writeAttribute ("version", "1.0");
						streamWriter.writeStartElement ("head");
						streamWriter.writeStartElement ("text");
						streamWriter.writeEndElement ();
						streamWriter.writeEndElement ();
						streamWriter.writeStartElement ("body");
						streamWriter.writeStartElement ("outline");
						streamWriter.writeAttribute ("text", "Live Bookmarks");
						Q_FOREACH (const QVariant& hRowVar, opmlData)
						{
							streamWriter.writeStartElement ("outline");
							QMap<QString, QVariant> hRow = hRowVar.toMap ();
							QXmlStreamAttributes attr;
							attr.append ("title", hRow ["Title"].toString ());
							attr.append ("htmlUrl", hRow ["SiteUrl"].toString ());
							attr.append ("xmlUrl", hRow ["FeedUrl"].toString ());
							attr.append ("text", hRow ["Title"].toString ());
							streamWriter.writeAttributes (attr);
							streamWriter.writeEndElement ();
						}