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

@ -2,6 +2,7 @@
#include "../formats/jsonparser.h"
#include "commands/insertrowscommand.h"
#include "commands/removerowscommand.h"
#include "modelitem.h"
QHash<int, QByteArray> TableModel::ROLE_NAMES = {{NameRole, "Name"},
@ -108,9 +109,8 @@ bool TableModel::removeRows(int firstRow, int nRows, const QModelIndex& parentIn
return false;
}
beginRemoveRows(QModelIndex(), firstRow, lastRow);
m_items.remove(firstRow, nRows);
endRemoveRows();
RemoveRowsCommand* removeCommand = new RemoveRowsCommand(this, firstRow, nRows);
m_undoStack->push(removeCommand);
return true;
}