mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-11 22:54:12 +02:00
Keep the project database current when folios, symbols and wires change
The project database is kept up to date edit by edit, and a script's qet.query() and the folio tables read it without a full rebuild. Three edits left it out of date until the next rebuild: - adding or removing a folio: the folios after it kept their old position and folio number, and a removed folio's diagram_info row stayed; - moving a symbol: its folio cell (element.pos) stayed where the symbol was added; - deleting a wire: its two ends stayed in the terminal table, which lists the terminals a wire ends on. Positions and folio numbers are now written again after a folio is added, removed or moved (one function for the three), the removed folio's diagram_info row goes, a moved symbol's cell is written when the database is next read (as drawing items are), and a deleted wire's ends go unless another wire ends there. Found by comparing the tables after random scripted edits with those a fresh open of the saved project gives. Left alone: labels and wire numbers made from a folio formula, which the drawing itself keeps until the project is reopened. Tests (tst_databasefromdocument): folioAddedAndRemoved, movedElementCell, deletedWireTerminals; each fails without its part of the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Wga9B92BNurDEtxxtCDxf
This commit is contained in:
@@ -126,6 +126,8 @@ class projectDataBase : public QObject
|
||||
void drawingItemDestroyed(QObject *object);
|
||||
//Queue the sender()'s link rows for rewriting.
|
||||
void linksChanged();
|
||||
//Queue the sender() element's folio cell for rewriting.
|
||||
void elementMoved();
|
||||
|
||||
public:
|
||||
|
||||
@@ -139,6 +141,8 @@ class projectDataBase : public QObject
|
||||
void createWiringListView();
|
||||
void createDrawingItemView();
|
||||
void populateDiagramTable();
|
||||
void updateFolioPositions();
|
||||
void flushElementPositions();
|
||||
void populateElementTable();
|
||||
void populateElementInfoTable();
|
||||
void populateDiagramInfoTable();
|
||||
@@ -214,6 +218,10 @@ class projectDataBase : public QObject
|
||||
//written: a link is made first and its contact group set after,
|
||||
//so the rows are written when next read, as drawing items are.
|
||||
QList<QPointer<Element>> m_dirty_link_elements;
|
||||
//Elements moved since their folio cell was last written: a move
|
||||
//sends xChanged and yChanged for every step of a drag, so the
|
||||
//cell is written when next read, as drawing items are.
|
||||
QList<QPointer<Element>> m_moved_elements;
|
||||
|
||||
#ifdef QET_EXPORT_PROJECT_DB
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user