Deleting items from the model can now be made undone/redone.

This commit is contained in:
2025-12-11 15:49:16 +01:00
parent 0166a00d9d
commit c75d35179b
5 changed files with 80 additions and 3 deletions

View File

@ -0,0 +1,28 @@
#ifndef REMOVEROWSCOMMAND_H
#define REMOVEROWSCOMMAND_H
#include <QUndoCommand>
class TableModel;
class RemoveRowsCommand : public QUndoCommand {
public:
// TODO don't use simple pointer to model
/// Using simple pointer to model because there was a crash when closing the application with an
/// unclean undo stack
RemoveRowsCommand(TableModel* model,
const int startRow,
const int nRows,
QUndoCommand* parent = nullptr);
/// QUndoCommand interface
void undo() override;
void redo() override;
private:
TableModel* m_tableModel;
const int m_startRow;
QList<QHash<int, QVariant>> m_valueList;
};
#endif // REMOVEROWSCOMMAND_H