mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-16 02:34:14 +02:00
39855e1bb5
#1473 keys the .qetz database's rows by the items' uuids, stores true/false as 1/0 and writes the format to PRAGMA user_version, as format 3. This branch's own changes (computed text left out of the folios, tables without keys, folios kept as they were) become format 4; formats 2 and 3 are still read. Folios kept as they were copy their rows by folio uuid, and the keys of those rows are kept from the other items' keys. The document's tables are named doc_<name> only beside the project database's own tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.4 KiB
C++
65 lines
2.4 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 QETCONTAINERDB_H
|
|
#define QETCONTAINERDB_H
|
|
|
|
#include <QByteArray>
|
|
#include <QDomElement>
|
|
|
|
#include <memory>
|
|
|
|
/**
|
|
@brief The QetContainerDb namespace
|
|
The engineering data of a project, moved between its document and the
|
|
project.sqlite of a .qetz: what a folio's title block says, a symbol's
|
|
information, a coil's contacts, a wire's ends and number. In a .qetz
|
|
these live only in the database; the folio files keep where things are
|
|
drawn. extract() takes them out of the document into a database,
|
|
restore() puts them back, so that restore(extract(d)) is d.
|
|
|
|
A row's key is its item's uuid, which stays in the folio file. An item
|
|
without a uuid of its own -- none, or one another item shares -- gets a
|
|
uuid made from what it holds, left in the document as qetz-key or
|
|
qetz-folio. A block of a shape
|
|
this does not model -- a value holding elements, say -- stays in the
|
|
document, so nothing can be lost by moving.
|
|
*/
|
|
namespace QetContainerDb
|
|
{
|
|
QByteArray extract(QDomElement project, QString *error = nullptr,
|
|
const QByteArray &index = QByteArray(),
|
|
const QByteArray &kept_from = QByteArray());
|
|
bool restore(QDomElement project, const QByteArray &database, QString *error = nullptr);
|
|
bool restoreFolio(QDomElement diagram, const QByteArray &database, QString *error = nullptr);
|
|
/// restoreFolio() for the folios of one database, opened once
|
|
class FolioReader
|
|
{
|
|
public:
|
|
explicit FolioReader(const QByteArray &database);
|
|
~FolioReader();
|
|
bool restore(QDomElement diagram, QString *error = nullptr);
|
|
private:
|
|
struct Private;
|
|
std::unique_ptr<Private> d;
|
|
};
|
|
/// true if @p database is of the format this writes
|
|
bool currentFormat(const QByteArray &database);
|
|
}
|
|
|
|
#endif // QETCONTAINERDB_H
|