mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-19 05:44:13 +02:00
Cover auto-numbering counter changes with undo/redo
Placing an auto-numbered element or conductor advances a shared NumerotationContext counter (QETProject::addConductorAutoNum/ addElementAutoNum) as a side effect that sat entirely outside the undo stack. Undoing the placement removed the visible number but left the counter advanced, so every undo of an auto-numbered placement silently burned a number, with no way to get it back short of a manual reset. Adds SetAutoNumContextCommand, a small QUndoCommand storing the old/new NumerotationContext and calling the matching add*AutoNum() setter on undo()/redo() -- the same shape QPropertyUndoCommand already uses next to it in ConductorAutoNumerotation::applyText(). Wires it into the two conductor call sites (the static newProperties(), and numerateNewConductor(), both in ConductorAutoNumerotation) and the element call site (Element::setUpFormula(), called from DiagramEventAddElement::addElement() when a new element is dropped onto a diagram). setUpFormula() now takes an optional parent QUndoCommand; addElement() calls it before pushing its own undo_object so the counter change lands in the same undo macro as the element's placement -- one Ctrl+Z reverts both together, instead of leaving the counter adrift. The project-properties config dialog's own add*AutoNum() calls (editing the numbering rule itself, not a side effect of placing something) are deliberately left untouched, as are the load-time folio-sequential bookkeeping calls in Diagram::loadElmtFolioSeq()/loadCndFolioSeq() and the bulk folio-renumbering passes in QETProject -- none of those run as part of an undoable user gesture. Implements the scope proposed in discussion #608.
This commit is contained in:
@@ -35,6 +35,7 @@ class Terminal;
|
||||
class Conductor;
|
||||
class DynamicElementTextItem;
|
||||
class ElementTextItemGroup;
|
||||
class QUndoCommand;
|
||||
|
||||
/**
|
||||
This is the base class for electrical elements.
|
||||
@@ -142,7 +143,7 @@ class Element : public QetGraphicsItem
|
||||
{return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceStruct()
|
||||
{return m_autoNum_seq;}
|
||||
void setUpFormula(bool code_letter = true);
|
||||
void setUpFormula(bool code_letter = true, QUndoCommand *parent_undo = nullptr);
|
||||
void setPrefix(QString);
|
||||
QString getPrefix() const;
|
||||
void freezeLabel(bool freeze);
|
||||
|
||||
Reference in New Issue
Block a user