mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 10:04:13 +02:00
Merge pull request #645 from ispyisail/feature-autonum-undo
Cover auto-numbering counter changes with undo/redo (discussion #608)
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "../qetgraphicsitem/terminal.h"
|
||||
#include "../ui/elementpropertieswidget.h"
|
||||
#include "../undocommand/changeelementinformationcommand.h"
|
||||
#include "../undocommand/setautonumcontextcommand.h"
|
||||
#include "dynamicelementtextitem.h"
|
||||
#include "elementtextitemgroup.h"
|
||||
#include "iostream"
|
||||
@@ -1645,7 +1646,7 @@ void Element::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||
(ex K for coil) with condition :
|
||||
formula is empty, text tagged "label" is emptty or "_";
|
||||
*/
|
||||
void Element::setUpFormula(bool code_letter)
|
||||
void Element::setUpFormula(bool code_letter, QUndoCommand *parent_undo)
|
||||
{
|
||||
Q_UNUSED(code_letter)
|
||||
|
||||
@@ -1674,8 +1675,21 @@ void Element::setUpFormula(bool code_letter)
|
||||
nc,
|
||||
diagram(),
|
||||
element_currentAutoNum);
|
||||
diagram()->project()->addElementAutoNum(element_currentAutoNum,
|
||||
ncc.next());
|
||||
|
||||
NumerotationContext new_context = ncc.next();
|
||||
QETProject *project = diagram()->project();
|
||||
auto setter = [project](const QString &k, const NumerotationContext &c) {project->addElementAutoNum(k, c);};
|
||||
|
||||
if (parent_undo)
|
||||
{
|
||||
new SetAutoNumContextCommand(setter, element_currentAutoNum, nc, new_context, parent_undo);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto *undo = new SetAutoNumContextCommand(setter, element_currentAutoNum, nc, new_context);
|
||||
undo->setText(tr("Numéroter automatiquement un élément", "undo caption"));
|
||||
diagram()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
if(!m_freeze_label && !formula.isEmpty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user