Пример #1
0
QString AlterNote::wrap() {

    QString returnValue;
    QXmlStreamWriter *writer = new QXmlStreamWriter(&returnValue);
    writer->setAutoFormatting(true);
    writer->setCodec("UTF-8");
    writer->writeStartDocument();
    writer->writeDTD("<!DOCTYPE NixNote-Query>");
    writer->writeStartElement("nixnote-alternote");
    writer->writeAttribute("version", "2");
    writer->writeAttribute("application", "NixNote");
    writer->writeAttribute("applicationVersion", "2.x");
    writer->writeStartElement("AlterNote");
    for (int i=0; i<lids.size(); i++)
        writer->writeTextElement("id", QString::number(lids[i]));
    writer->writeTextElement("Notebook", notebook);
    writer->writeTextElement("Query", query);
    for (int i=0; i<addTagNames.size(); i++)
        writer->writeTextElement("AddTag", addTagNames[i]);
    for (int i=0; i<delTagNames.size(); i++)
        writer->writeTextElement("DelTag", delTagNames[i]);
    if (clearReminder)
        writer->writeTextElement("ClearReminder", "true");
    if (reminderCompleted)
        writer->writeTextElement("ReminderComplete", "true");
    writer->writeEndElement();
    writer->writeEndElement();
    writer->writeEndDocument();
    return returnValue;
}
Пример #2
0
bool HtmlExporter::startFile(QFile& file,
                             const QString& basename,
                             QXmlStreamWriter& stream,
                             int currentPage,
                             int totalPages)
{
  if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
  {
    errorHandler->handleIOError(file);
    return false;
  }

  stream.setDevice(&file);
  stream.setAutoFormatting(true);
  stream.setAutoFormattingIndent(2);
  stream.setCodec("utf-8");

  // Get the CSS either from the resources or from the settings directory
  writeHtmlStart(stream,
                 atools::settings::Settings::getOverloadedPath(":/littlenavmap/resources/css/export.css"));
  writeHtmlHeader(stream);
  writeHtmlNav(stream, basename, currentPage, totalPages);

  stream.writeStartElement("table");
  stream.writeStartElement("tbody");
  return true;
}
Пример #3
0
QByteArray XMLerSaveFileThread::toBuffer ( BaseXMLNode *node )
{
  QByteArray data;
  QBuffer buffer ( &data );
  bool result_open = buffer.open ( QIODevice::WriteOnly );
  if ( !result_open ) {
    emit error ( tr("Can not open memory buffer.") );
    return data;
  }
  QXmlStreamWriter writer ( &buffer );
  writer.setCodec ( DEFAULT_ENCODING );
  QString msg_progress = tr( "Save XML to memory buffer" );
  emit beginProgress ( msg_progress, 0 );
  emit beginProgress ( msg_progress, node->size() );

  qint64 pos = 0;
  bool result = saveNode ( writer, node, pos );
  
  if ( !result ) {
    emit error ( tr("Error while writing the node") );
    return QByteArray();
  }
  
  return data;
}
void
SoundSettings::saveXML (
        const QString   &xmlFileName,
        const QString   &origFileName,
        const QString   &copyFileName,
        const QString   &title)
{
    QXmlStreamWriter *writer;
    QFile             file (xmlFileName);

    SYS_DEBUG ("-----------------------------------------------------");
    SYS_DEBUG ("*** xmlFileName = %s", SYS_STR(xmlFileName));

    if (!file.open(QIODevice::WriteOnly)) {
        SYS_WARNING ("Unable to open file for writing: %s",
                SYS_STR(xmlFileName));
        return;
    }

    /*
     *
     */
    writer = new QXmlStreamWriter();
    writer->setDevice (&file);
    writer->setAutoFormatting(true);
    writer->setCodec ("UTF-8");
    writer->writeStartDocument ();
    writer->writeStartElement ("soundsettings-applet");

    writer->writeStartElement("orig-file");
        writer->writeCharacters (origFileName);
    writer->writeEndElement ();

    writer->writeStartElement("copy-file");
        writer->writeCharacters (copyFileName);
    writer->writeEndElement ();

    writer->writeStartElement("title");
        writer->writeCharacters (title);
    writer->writeEndElement ();

    /*
     *
     */
    writer->writeEndElement();
    writer->writeEndDocument();

    delete writer;
    file.close ();
}
Пример #5
0
bool Deck::exportToXml(QString fileName)
{
    QXmlStreamWriter xml;
    QFile file(fileName);

    file.open(QIODevice::WriteOnly | QIODevice::Text);

    if(!file.isOpen())
        return false;

    xml.setAutoFormatting(true);
    xml.setCodec("UTF-8");

    xml.setDevice(&file);

    xml.writeStartDocument();

    /// --<dana>
    xml.writeStartElement(XML_TAG_ROOT);

    xml.writeStartElement(XML_TAG_VERSION);
    xml.writeCharacters(appVersionToString());
    xml.writeEndElement();

    /// --<deck>
    xml.writeStartElement(XML_TAG_DECK);

    xml.writeStartElement(XML_TAG_NAME);
    xml.writeCharacters(name);
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_DESC);
    xml.writeCharacters(desc);
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_ICON);
    xml.writeCharacters("icon.png");
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_GUID);
    xml.writeCharacters(guid.toString());
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_CREATED);
    xml.writeCharacters(createdTime.toString());
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_UPDATED);
    xml.writeCharacters(updatedTime.toString());
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_AUTHOR);
    xml.writeCharacters(author);
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_TAGS);
    xml.writeCharacters(tags);
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_FLAGS);
    xml.writeCharacters(QString::number(flags));
    xml.writeEndElement();

    xml.writeStartElement(XML_TAG_INHAND);
    xml.writeCharacters(QString::number(inhand));
    xml.writeEndElement();

    xml.writeDTD(format.toString());

    xml.writeEndElement();
    /// --</deck>

    /// --<cards>
    xml.writeStartElement(XML_TAG_CARDS);

    Card *card = 0;
    int count = cards.count();
    for(int index = 0; index < count; index++) {
        card = cards.at(index);

        xml.writeStartElement(XML_TAG_CARD);
        // ---------------------------------
        xml.writeStartElement(XML_TAG_FRONT);
        xml.writeCDATA(card->getFront());
        xml.writeEndElement();

        xml.writeStartElement(XML_TAG_BACK);
        xml.writeCDATA(card->getBack());
        xml.writeEndElement();

        xml.writeStartElement(XML_TAG_FLAGS);
        xml.writeCDATA(QString::number(card->getFlags()));
        xml.writeEndElement();

        /*
        xml.writeStartElement("level");
        xml.writeDTD(QString::number(card->getLevel()));
        xml.writeEndElement();
        */
        // ---------------------------------
        xml.writeEndElement();
    }
    xml.writeEndElement();
    /// --</cards>

    xml.writeEndDocument();
    /// --</dana>

    file.close();

    return true;
}