Files
qelectrotech-source-mirror/sources/container/qetzwriter.cpp
T
ispyisail 93157a579d Move reading and writing a .qetz out of QETProject
QETZ-DB-FIRST stage 3a. QETProject::openFile() unzipped and joined a .qetz
itself and kept what it held beside the document in three members of its
own (the entries, each folio's part, the pictures), and writeContainer()
split and zipped it. Both now live in their own classes under
sources/container: QetzReader reads a .qet or a .qetz and keeps what a
.qetz holds for as long as the project is open; QetzWriter writes the
document as a .qetz.

No behaviour change: the same calls in the same order. This is the seam
stage 3b needs, where opening fills the working database straight from
project.sqlite instead of rebuilding it from the joined XML.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 18:31:37 +13:00

40 lines
1.5 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "qetzwriter.h"
#include "../qetversion.h"
#include "qetcontainer.h"
#include "qetzip.h"
/**
@brief QetzWriter::write
Write the project document @p project to @p path as a .qetz: the same
document, in parts, zipped (#1440). The file is replaced only once
the whole archive is written. @p kept_from: the entries of the .qetz
read, whose parts the folios not built are copied from.
*/
bool QetzWriter::write(const QDomDocument &project, const QString &path, QString *error,
const QHash<QString, QByteArray> &kept_from)
{
QList<QetZip::Entry> entries = QetContainer::split(
project,
QStringLiteral("QElectroTech %1").arg(QetVersion::currentVersion().toString()),
error, kept_from);
return !entries.isEmpty() && QetZip::write(path, entries, error);
}