Files
qelectrotech-source-mirror/sources/container/qetzreader.h
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

60 lines
2.0 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/>.
*/
#ifndef QETZREADER_H
#define QETZREADER_H
#include "qetcontainer.h"
#include <QByteArray>
#include <QDomDocument>
#include <QHash>
#include <QString>
#include <QStringList>
/**
@brief The QetzReader class
Reads the bytes of a project file, a .qet or a .qetz, into its project
document, and keeps what a .qetz holds beside that document for as long
as the project is open: its entries (a save copies the parts of the
folios not built from them), the part each folio was read from, its
pictures and its format.
*/
class QetzReader
{
public:
bool read(const QByteArray &content, QDomDocument *document, QString *error = nullptr);
/// The format the .qetz says it is; 0 for a .qet
int format() const {return m_format;}
/// The entries of the .qetz read, by name
const QHash<QString, QByteArray> &files() const {return m_files;}
QByteArray file(const QString &name) const {return m_files.value(name);}
/// The part each folio was read from, in order
const QStringList &folioParts() const {return m_folio_parts;}
/// The picture in @p file, or an empty array when there is none
QByteArray picture(const QString &file) const {return m_pictures.value(file);}
private:
QHash<QString, QByteArray> m_files;
QStringList m_folio_parts;
QetContainer::Pictures m_pictures;
int m_format = 0;
};
#endif // QETZREADER_H