mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-18 03:54:14 +02:00
.qetz: bring an older database to the current format one step at a time
The reader of project.sqlite knew two formats at once: every query asked the database which column names to use (v2() ? "folio_id" : "folio_uuid" and so on), and each new format would have added another branch to every query. Asked in discussion #1440. An older database is now brought up a format at a time when a .qetz opens (readyToRead()): format 2 to 3 renames its tables' columns, adds the show columns and puts the symbols' and wires' uuids and the symbols' type back in the folio files; 3 to 4 has nothing to change for reading. The reader then knows only the current format. The next format adds one step. Checked: the format 2 test file (tests/qttest/fixtures/qetz_format2.qetz) resaved as .qet and as .qetz gives the same files as master. format2Read now also checks that every symbol and wire gets its uuid and type back: it failed with the type left out of the step, which the test did not see before. ctest 106/106. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -736,6 +736,22 @@ private slots:
|
||||
QVERIFY2(QetContainer::join(entries, &project, &error), qPrintable(error));
|
||||
QVERIFY(project.toString().contains(QStringLiteral("<elementInformation ")));
|
||||
QVERIFY(!project.toString().contains(QStringLiteral("qetz-")));
|
||||
//Format 2 moved the uuids of symbols and wires and the symbols'
|
||||
//type out of the folio files: they come back
|
||||
int symbols = 0, wires = 0;
|
||||
const QDomNodeList diagrams = project.elementsByTagName(QStringLiteral("diagram"));
|
||||
for (int i = 0 ; i < diagrams.size() ; ++i) {
|
||||
const QDomElement d = diagrams.at(i).toElement();
|
||||
for (QDomElement e = d.firstChildElement(QStringLiteral("elements")).firstChildElement(QStringLiteral("element"));
|
||||
!e.isNull() ; e = e.nextSiblingElement(QStringLiteral("element")), ++symbols) {
|
||||
QVERIFY(!QUuid(e.attribute(QStringLiteral("uuid"))).isNull());
|
||||
QVERIFY(e.attribute(QStringLiteral("type")).startsWith(QStringLiteral("embed://")));
|
||||
}
|
||||
for (QDomElement c = d.firstChildElement(QStringLiteral("conductors")).firstChildElement(QStringLiteral("conductor"));
|
||||
!c.isNull() ; c = c.nextSiblingElement(QStringLiteral("conductor")), ++wires)
|
||||
QVERIFY(!QUuid(c.attribute(QStringLiteral("uuid"))).isNull());
|
||||
}
|
||||
QVERIFY(symbols > 0 && wires > 0);
|
||||
const QList<QetZip::Entry> resaved = QetContainer::split(project, QString(), &error);
|
||||
QVERIFY2(!resaved.isEmpty(), qPrintable(error));
|
||||
const QString d = backDifference(project, resaved);
|
||||
|
||||
Reference in New Issue
Block a user