Editing an item is now undo/redo-able.
This commit is contained in:
30
model/commands/edititemcommand.h
Normal file
30
model/commands/edititemcommand.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef EDITITEMCOMMAND_H
|
||||
#define EDITITEMCOMMAND_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QUndoCommand>
|
||||
|
||||
class TableModel;
|
||||
|
||||
class EditItemCommand : public QUndoCommand {
|
||||
public:
|
||||
EditItemCommand(TableModel* model,
|
||||
const QModelIndex& index,
|
||||
QMap<int, QVariant>& changedValues,
|
||||
QUndoCommand* parent = nullptr);
|
||||
/// QUndoCommand interface
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
private:
|
||||
TableModel* m_model = nullptr;
|
||||
const int m_row;
|
||||
QMap<int, QVariant> m_oldValues;
|
||||
QMap<int, QVariant> m_newValues;
|
||||
|
||||
/// private functions
|
||||
const QMap<int, QVariant> getOldValues(const QModelIndex& index,
|
||||
const QMap<int, QVariant>& changedValues) const;
|
||||
};
|
||||
|
||||
#endif // EDITITEMCOMMAND_H
|
||||
Reference in New Issue
Block a user