Adding new items to the model can now be made undone/redone.

This commit is contained in:
2025-12-11 15:46:28 +01:00
parent 432e81d4be
commit 0166a00d9d
7 changed files with 114 additions and 18 deletions

View File

@ -0,0 +1,28 @@
#ifndef INSERTROWSCOMMAND_H
#define INSERTROWSCOMMAND_H
#include <QUndoCommand>
class TableModel;
class InsertRowsCommand : 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
InsertRowsCommand(TableModel* model,
int startRow,
QList<QHash<int, QVariant> > valueList,
QUndoCommand* parent = nullptr);
/// QUndoCommand interface
void undo() override;
void redo() override;
private:
TableModel* m_tableModel;
const int m_startRow;
const QList<QHash<int, QVariant> > m_valueList;
};
#endif // INSERTROWSCOMMAND_H