-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifcommand.h
More file actions
60 lines (46 loc) · 1.77 KB
/
modifcommand.h
File metadata and controls
60 lines (46 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef MODIFCOMMAND_H
#define MODIFCOMMAND_H
#include <QUndoCommand>
#include <QStandardItemModel>
#include <QVariant>
#include <QModelIndex>
#include <QTableView>
#define COLHIDDENWIDTH 5
typedef struct ModifInfo
{
QModelIndex index;
QVariant oldData;
QVariant data;
}MODIFINFO;
typedef QVector<MODIFINFO> ModifCommandList;
enum ModifCommandType
{
singleModelIndex = 1,
ListModelIndex = 2,
hiddenRow = 3,
hiddenCol = 4, //为了让界面上知道这个中间还有列,所以并不是隐藏,而是把列宽缩小到5
expandCol = 5, //取消隐藏,默认展开到最适合的大小
};
class ModifCommand : public QUndoCommand
{
public:
explicit ModifCommand(QStandardItemModel *model, QModelIndex index,
QVariant oldData, QVariant data, ModifCommandType type, Qt::ItemDataRole role = Qt::EditRole, QUndoCommand *parent = nullptr);
explicit ModifCommand(QStandardItemModel *model, ModifCommandList list, ModifCommandType type, Qt::ItemDataRole role = Qt::EditRole, QUndoCommand *parent = nullptr);
explicit ModifCommand(QStandardItemModel *model, QList<int> nRows, QTableView* tableView, ModifCommandType type, QUndoCommand *parent = nullptr);
explicit ModifCommand(QStandardItemModel *model, QMap<int, int> colWidth, QTableView* tableView, ModifCommandType type, QUndoCommand *parent = nullptr);
void undo() override;
void redo() override;
private:
QStandardItemModel *model;
QModelIndex index;
QVariant oldData;
QVariant data;
ModifCommandType m_type;
Qt::ItemDataRole m_role;
QList<int> m_setRows;
QMap<int, int> m_colWidth;
ModifCommandList m_commandList;
QTableView* m_tableView;
};
#endif // MODIFCOMMAND_H