Add RemoveTerminalStripCommand class

This commit is contained in:
joshua
2021-04-06 20:05:40 +02:00
parent 2cf5ea11fd
commit 5d17461c6e
2 changed files with 44 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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