mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-18 20:14:14 +02:00
8ad33f6281
With QET_LAZY_FOLIOS=1, a project opened from a .qetz's index saves a .qetz without building the folios it never built, when building them would write the same: their parts are copied as they were and their rows of the document's engineering data from the project.sqlite they were read from (QetContainerDb::extract() with kept_from, QetContainer::split() with the old entries, pictures included). Whether a folio may be kept follows the rules of stage 5.5 (QETProject::toXml() with kept_parts): nothing project-wide changed since opening; a folio whose own data changed is built with its partners; after an edit, folios holding a table filled from the database are built; the partners still waiting of every built folio are built. Trusted only for a project opened from a format 3 index written by this version whose folios are named by their uuid. Format 3 names a folio by its uuid in the database (doc_meta folio_ids = uuid) when every folio has one of its own, so that a kept folio keeps its rows whatever its place; copies keep the rows' order (ORDER BY rowid). A folio not built keeps the name of its part until it is built (Diagram::deferredPart()). Measured, the 136-folio f2099 opened from its .qetz and saved as a .qetz: 4.75 s with no folio built, 33 s with every folio built; its 136 folio parts copied byte for byte; a kept save of a kept save is the same bytes. industrial.qetz untouched: 28 of its 47 folios not built are built to save (link chains, as in 5.5); after everyday edits on its busiest folio, 7 stay not built. tst_lazyfolios: an untouched .qetz saved without building, read back, holds the project; edits saved without building hold, read back, what the same edits saved with every folio built hold (read back too: a wire numbered from its potential is saved with no sequential numbers whichever the way -- reading it back renumbers it, a separate issue); fails when a kept folio's symbol information is not copied. Corpus, 342 projects: a .qetz saved without building, read and saved as .qet = eager = master on all 342. ctest 96/96 with and without QET_LAZY_FOLIOS=1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
3.0 KiB
C++
76 lines
3.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 QETCONTAINER_H
|
|
#define QETCONTAINER_H
|
|
|
|
#include "qetzip.h"
|
|
|
|
#include <QDomDocument>
|
|
#include <QHash>
|
|
|
|
/**
|
|
@brief The QetContainer namespace
|
|
Splits a project document into the parts of a .qetz file and joins
|
|
them back:
|
|
|
|
mimetype first, stored
|
|
manifest.xml format and oldest format allowed to read it
|
|
project.xml the project, each part replaced by
|
|
<qetz-part file="..."/>
|
|
project.sqlite the engineering data (format 2,
|
|
QetContainerDb): title-block fields, symbol
|
|
information, links, wires
|
|
folios/<uuid>.xml one per folio
|
|
elements/.../<name> the project's symbol definitions
|
|
titleblocks/<name>.titleblock
|
|
images/<sha256>.png folio pictures, once each, not base64
|
|
|
|
join(split(d)) is d. Nothing here knows what the parts mean: the
|
|
project is read and written by the same code as a .qet file.
|
|
*/
|
|
namespace QetContainer
|
|
{
|
|
extern const char MimeType[];
|
|
/// The format written; files of a later format are refused by join()
|
|
/// unless their min-reader allows this one.
|
|
constexpr int Format = 3;
|
|
|
|
QList<QetZip::Entry> split(const QDomDocument &project,
|
|
const QString &writer = QString(),
|
|
QString *error = nullptr,
|
|
const QByteArray &index = QByteArray(),
|
|
const QHash<QString, QByteArray> &kept_from = QHash<QString, QByteArray>());
|
|
bool join(const QList<QetZip::Entry> &entries, QDomDocument *project,
|
|
QString *error = nullptr, QStringList *folio_files = nullptr);
|
|
/// A folio part of @p files, which join() left out, with its
|
|
/// pictures and its engineering data back (stage D2)
|
|
bool readFolio(const QHash<QString, QByteArray> &files, const QString &file,
|
|
QDomDocument *folio, QString *error = nullptr);
|
|
|
|
/// Take what QElectroTech computes out of a folio (format 3)
|
|
void dropComputed(QDomElement diagram, bool terminal_lists);
|
|
/// Parse @p xml as a .qet is read (QETProject::openFile)
|
|
bool parse(const QByteArray &xml, QDomDocument *document, QString *error = nullptr);
|
|
/// true if @p content is a zip, so a .qetz rather than a .qet
|
|
bool isZip(const QByteArray &content);
|
|
/// The project document in @p content, a .qet or a .qetz
|
|
bool readDocument(const QByteArray &content, QDomDocument *document, QString *error = nullptr);
|
|
}
|
|
|
|
#endif // QETCONTAINER_H
|