mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-14 05:09:59 +01:00
Improve undo command when remove a terminal strip
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "addterminalstripcommand.h"
|
||||
#include "../../qetproject.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include "../qetgraphicsitem/element.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -56,7 +57,8 @@ RemoveTerminalStripCommand::RemoveTerminalStripCommand(TerminalStrip *strip,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_strip(strip),
|
||||
m_project(project)
|
||||
m_project(project),
|
||||
m_elements(strip->terminalElement())
|
||||
{
|
||||
setText(QObject::tr("Supprimer un groupe de bornes"));
|
||||
}
|
||||
@@ -67,6 +69,9 @@ RemoveTerminalStripCommand::~RemoveTerminalStripCommand()
|
||||
void RemoveTerminalStripCommand::undo()
|
||||
{
|
||||
if (m_project && m_strip) {
|
||||
for (auto elmt : m_elements) {
|
||||
m_strip->addTerminal(elmt);
|
||||
}
|
||||
m_project->addTerminalStrip(m_strip);
|
||||
}
|
||||
}
|
||||
@@ -74,6 +79,9 @@ void RemoveTerminalStripCommand::undo()
|
||||
void RemoveTerminalStripCommand::redo()
|
||||
{
|
||||
if (m_project && m_strip) {
|
||||
for (auto elmt : m_elements) {
|
||||
m_strip->removeTerminal(elmt);
|
||||
}
|
||||
m_project->removeTerminalStrip(m_strip);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
class TerminalStrip;
|
||||
class QETProject;
|
||||
class Element;
|
||||
|
||||
class AddTerminalStripCommand : public QUndoCommand
|
||||
{
|
||||
@@ -50,6 +51,7 @@ class RemoveTerminalStripCommand : public QUndoCommand
|
||||
private:
|
||||
QPointer<TerminalStrip> m_strip;
|
||||
QPointer<QETProject> m_project;
|
||||
QVector<QPointer<Element>> m_elements;
|
||||
};
|
||||
|
||||
#endif // ADDTERMINALSTRIPCOMMAND_H
|
||||
|
||||
Reference in New Issue
Block a user