MCPcopy Create free account
hub / github.com/KDE/labplot / save

Method save

src/backend/core/Project.cpp:471–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469// ##############################################################################
470
471void Project::save(const QPixmap& thumbnail, QXmlStreamWriter* writer) {
472 Q_D(Project);
473 // set the version and the modification time to the current values
474 d->setVersion(QStringLiteral(LVERSION));
475 d->modificationTime = QDateTime::currentDateTime();
476
477 writer->setAutoFormatting(true);
478 writer->writeStartDocument();
479 writer->writeDTD(QStringLiteral("<!DOCTYPE LabPlotXML>"));
480
481 writer->writeStartElement(QStringLiteral("project"));
482 writer->writeAttribute(QStringLiteral("version"), version());
483 writer->writeAttribute(QStringLiteral("xmlVersion"), QString::number(buildXmlVersion));
484 writer->writeAttribute(QStringLiteral("modificationTime"), modificationTime().toString(QStringLiteral("yyyy-dd-MM hh:mm:ss:zzz")));
485 writer->writeAttribute(QStringLiteral("author"), author());
486 writer->writeAttribute(QStringLiteral("saveCalculations"), QString::number(d->saveCalculations));
487
488 // save the state of the content dock widgets
489 writer->writeAttribute(QStringLiteral("dockWidgetState"), d->dockWidgetState);
490
491 // save the state of the default dock widgets, if activated
492 writer->writeAttribute(QStringLiteral("saveDefaultDockWidgetState"), QString::number(d->saveDefaultDockWidgetState));
493 if (d->saveDefaultDockWidgetState)
494 writer->writeAttribute(QStringLiteral("defaultDockWidgetState"), d->defaultDockWidgetState);
495
496 QString image;
497 if (!thumbnail.isNull()) {
498 QByteArray bArray;
499 QBuffer buffer(&bArray);
500 buffer.open(QIODevice::WriteOnly);
501 QPixmap scaledThumbnail = thumbnail.scaled(512, 512, Qt::KeepAspectRatio);
502 scaledThumbnail.save(&buffer, "JPEG");
503 image = QString::fromLatin1(bArray.toBase64().data());
504 }
505
506 writer->writeAttribute(QStringLiteral("thumbnail"), image);
507 writeBasicAttributes(writer);
508 writeCommentElement(writer);
509 save(writer);
510}
511
512/**
513 * \brief Save as XML

Callers

nothing calls this directly

Calls 5

setVersionMethod · 0.80
isNullMethod · 0.80
toStringMethod · 0.45
openMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected