mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-17 19:34:13 +02:00
Change a symbol's information without building its folio (stage D5)
A script changing the information of a symbol on a folio not built, when nothing else shows that information (no symbol built holds it, no partner is linked to it, no label formula), changes it through the project database: the store and the symbol's element info row, undoable by uuid (ChangeStoredElementInformationCommand). Reading it back reads the store. Building the symbol later takes the change (projectDataBase::takeUnbuiltEdit(), in Element::fromXml()), the label and texts following as for any change. Saving a .qetz writes the changed information in the database in place of the rows the folio was read with, its file copied, the folio still not built; a symbol whose file holds no information block, or a .qet, builds the folio to save. 136-folio .qetz, "comment" set on the 3 513 symbols the database can change: 0.9 s, no folio built, saved in 6.1 s, none built (27 s and 116 folios when saving built them). The same edits on the 4 039 symbols with no partner and no formula, lazily and with every folio built: the two saved projects are the same file. tst_lazyfolios: a script changes a symbol not built, building none; saved as when built (fails when building ignores the change, and when the .qetz writer does); undone; the folio built afterwards shows it. ctest 96/96 eager and lazy; 342 corpus projects save the same in all four arms and export the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+25
-3
@@ -2360,9 +2360,20 @@ QDomDocument QETProject::toXml(QHash<int, QByteArray> *kept_folios, QStringList
|
||||
if (keep) {
|
||||
//Partners built alone and linked or unlinked since: their folio
|
||||
//is not what was read
|
||||
for (Diagram *diagram : std::as_const(m_diagrams_list))
|
||||
if (!diagram->isLoaded() && diagram->partialChanged())
|
||||
buildFolios({diagram});
|
||||
//and symbols whose information was changed through the project
|
||||
//database while their folio was not built: built together
|
||||
//-- a .qetz writes those in its database instead, when it can
|
||||
const QSet<QUuid> edited = m_data_base.foliosWithUnbuiltEdits();
|
||||
QList<Diagram *> changed;
|
||||
for (Diagram *diagram : std::as_const(m_diagrams_list)) {
|
||||
if (diagram->isLoaded()) continue;
|
||||
bool need_build = !kept_parts;
|
||||
if (edited.contains(diagram->uuid()) && kept_parts)
|
||||
m_data_base.unbuiltEditsOnFolio(diagram->uuid(), &need_build);
|
||||
if (diagram->partialChanged() || (edited.contains(diagram->uuid()) && need_build))
|
||||
changed << diagram;
|
||||
}
|
||||
buildFolios(changed);
|
||||
for (Diagram *diagram : std::as_const(m_diagrams_list))
|
||||
if (diagram->headerChanged())
|
||||
buildFolioToShow(diagram);
|
||||
@@ -2483,6 +2494,17 @@ QDomDocument QETProject::toXml(QHash<int, QByteArray> *kept_folios, QStringList
|
||||
auto placeholder = xml_doc.createElement(QStringLiteral("diagram"));
|
||||
placeholder.setAttribute(QStringLiteral("qetz-kept-part"), diagram->deferredPart());
|
||||
placeholder.setAttribute(QStringLiteral("uuid"), diagram->uuid().toString());
|
||||
//Symbols whose information changed while the folio was
|
||||
//not built: the rows QetContainer::split() writes for them
|
||||
const QHash<QUuid, DiagramContext> edits = m_data_base.unbuiltEditsOnFolio(diagram->uuid());
|
||||
for (auto it = edits.cbegin() ; it != edits.cend() ; ++it) {
|
||||
auto symbol = xml_doc.createElement(QStringLiteral("qetz-edited-element"));
|
||||
symbol.setAttribute(QStringLiteral("uuid"), it.key().toString());
|
||||
auto information = xml_doc.createElement(QStringLiteral("elementInformations"));
|
||||
it.value().toXml(information, QStringLiteral("elementInformation"));
|
||||
symbol.appendChild(information);
|
||||
placeholder.appendChild(symbol);
|
||||
}
|
||||
kept_parts->append(diagram->deferredPart());
|
||||
project_root.appendChild(placeholder);
|
||||
++order_num;
|
||||
|
||||
Reference in New Issue
Block a user