mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-15 10:04:13 +02:00
Keep a .qetz project's engineering data in project.sqlite
Fourth stage of the zipped project file (#1440), format 2: what an engineer would put in a list -- folio title-block fields and properties, project properties, a symbol's uuid, type, prefix, information and links, a wire's ends, number, function, colour, section, cable and bus -- moves out of the XML into project.sqlite in the .qetz, and lives only there. The folio files keep where things are drawn. On opening it goes back into the document before the usual reader runs, so nothing else in QElectroTech changes yet (the program reading the database directly is the next step of the roadmap). Each moved item keeps a key in the XML (qetz-key: its uuid where unique); each moved block leaves a marker where it was, which keeps the whitespace around it apart. A block of a shape this does not model stays in the XML. A file is untrusted: the database is read with trusted_schema off, query_only, and only from names that are plain tables. Format 2 readers still open format 1; a format 1 reader refuses format 2. Tests (tst_qetcontainer): every example back exactly, whitespace included; databaseHoldsTheData (industrial.qet: the folio files hold no information, links, wire numbers or properties; the row counts match). Outside ctest: 341 of 341 projects QET can open give the same .qet through a format 2 .qetz. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Wga9B92BNurDEtxxtCDxf
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "qetcontainer.h"
|
||||
#include "qetcontainerdb.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QHash>
|
||||
@@ -180,6 +181,11 @@ QList<QetZip::Entry> QetContainer::split(const QDomDocument &project, const QStr
|
||||
return {};
|
||||
}
|
||||
|
||||
//The engineering data out of the document, into project.sqlite
|
||||
const QByteArray database = QetContainerDb::extract(root, error);
|
||||
if (database.isEmpty())
|
||||
return {};
|
||||
|
||||
QList<QetZip::Entry> parts;
|
||||
QSet<QString> taken;
|
||||
|
||||
@@ -245,6 +251,7 @@ QList<QetZip::Entry> QetContainer::split(const QDomDocument &project, const QStr
|
||||
entries.append(QetZip::Entry{QStringLiteral("mimetype"), QByteArray(MimeType), false});
|
||||
entries.append(QetZip::Entry{QStringLiteral("manifest.xml"), serialize(qetz), true});
|
||||
entries.append(QetZip::Entry{QStringLiteral("project.xml"), serialize(root), true});
|
||||
entries.append(QetZip::Entry{QStringLiteral("project.sqlite"), database, true});
|
||||
entries += parts;
|
||||
for (auto it = pictures.cbegin() ; it != pictures.cend() ; ++it)
|
||||
entries.append(QetZip::Entry{it.key(), it.value(), false}); //PNG is compressed already
|
||||
@@ -318,5 +325,11 @@ bool QetContainer::join(const QList<QetZip::Entry> &entries, QDomDocument *proje
|
||||
image.insertBefore(project->createTextNode(QString::fromLatin1(files.value(file).toBase64())),
|
||||
image.firstChild());
|
||||
}
|
||||
|
||||
//The engineering data back from project.sqlite (format 2 on)
|
||||
if (files.contains(QStringLiteral("project.sqlite"))
|
||||
&& !QetContainerDb::restore(project->documentElement(),
|
||||
files.value(QStringLiteral("project.sqlite")), error))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user