mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Add RemoveTerminalStripCommand class
This commit is contained in:
@@ -26,7 +26,9 @@
|
||||
* @param strip
|
||||
* @param parent
|
||||
*/
|
||||
AddTerminalStripCommand::AddTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent) :
|
||||
AddTerminalStripCommand::AddTerminalStripCommand(TerminalStrip *strip,
|
||||
QETProject *project,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_strip(strip),
|
||||
m_project(project)
|
||||
@@ -48,3 +50,30 @@ void AddTerminalStripCommand::redo() {
|
||||
m_project->addTerminalStrip(m_strip);
|
||||
}
|
||||
}
|
||||
|
||||
RemoveTerminalStripCommand::RemoveTerminalStripCommand(TerminalStrip *strip,
|
||||
QETProject *project,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
m_strip(strip),
|
||||
m_project(project)
|
||||
{
|
||||
setText(QObject::tr("Supprimer un groupe de bornes"));
|
||||
}
|
||||
|
||||
RemoveTerminalStripCommand::~RemoveTerminalStripCommand()
|
||||
{}
|
||||
|
||||
void RemoveTerminalStripCommand::undo()
|
||||
{
|
||||
if (m_project && m_strip) {
|
||||
m_project->addTerminalStrip(m_strip);
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveTerminalStripCommand::redo()
|
||||
{
|
||||
if (m_project && m_strip) {
|
||||
m_project->removeTerminalStrip(m_strip);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,18 @@ class AddTerminalStripCommand : public QUndoCommand
|
||||
QPointer<QETProject> m_project;
|
||||
};
|
||||
|
||||
class RemoveTerminalStripCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
RemoveTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent = nullptr);
|
||||
~RemoveTerminalStripCommand() override;
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
private:
|
||||
QPointer<TerminalStrip> m_strip;
|
||||
QPointer<QETProject> m_project;
|
||||
};
|
||||
|
||||
#endif // ADDTERMINALSTRIPCOMMAND_H
|
||||
|
||||
Reference in New Issue
Block a user