Undo and Redo command
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#ifndef UNDO_H
|
||||
#define UNDO_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QLineEdit>
|
||||
|
||||
class LineEditCommand : public QUndoCommand {
|
||||
public:
|
||||
LineEditCommand(QLineEdit* edit, const QString& oldText, const QString& newText)
|
||||
: m_edit(edit), m_oldText(oldText), m_newText(newText) {}
|
||||
|
||||
void undo() override { m_edit->setText(m_oldText); }
|
||||
void redo() override { m_edit->setText(m_newText); }
|
||||
|
||||
private:
|
||||
QLineEdit* m_edit;
|
||||
QString m_oldText;
|
||||
QString m_newText;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
Reference in New Issue
Block a user