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 #ifndef MODEL_H
30 #define MODEL_H
31
32 #include "toolkit.h"
33 #include "../ui/tree.h"
34 #include "../common/context.h"
35 #include <QListView>
36 #include <QTreeView>
37 #include <QAbstractListModel>
38 #include <QAbstractTableModel>
39 #include <QAbstractItemModel>
40 #include <QItemSelectionModel>
41
42 class ListModel : public QAbstractListModel {
43 Q_OBJECT
44
45 UiObject *obj;
46 UiListPtr *list;
47 ui_model_getvalue_f getvalue;
48 ui_callback callback;
49 void *userdata;
50 QListView *view;
51
52 public:
53 ListModel(UiObject *obj, QListView *view, UiListPtr *list, ui_model_getvalue_f getvalue, ui_callback f,
void *userdata);
54
55 int rowCount(
const QModelIndex &parent = QModelIndex())
const;
56 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
57
58 public slots:
59 void selectionChanged(
60 const QItemSelection & selected,
61 const QItemSelection & deselected);
62 };
63
64 class TableModel : public QAbstractTableModel {
65 Q_OBJECT
66
67 UiObject *obj;
68 UiListPtr *list;
69 UiModelInfo *info;
70 QTreeView *view;
71 public:
72 TableModel(UiObject *obj, QTreeView *view, UiListPtr *list, UiModelInfo *info);
73
74 int rowCount(
const QModelIndex &parent = QModelIndex())
const;
75 int columnCount(
const QModelIndex &parent = QModelIndex())
const;
76 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole)
const;
77 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const;
78
79 void update();
80
81 public slots:
82 void selectionChanged(
83 const QItemSelection & selected,
84 const QItemSelection & deselected);
85 void activate(
const QModelIndex &);
86 };
87
88 UiListSelection* listSelection(QItemSelectionModel *s);
89
90 #endif
91
92