22 lines
497 B
C++
22 lines
497 B
C++
#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
|