ui/qt/model.h

changeset 108
77254bd6dccb
parent 103
6606616eca9f
child 109
c3dfcb8f0be7
equal deleted inserted replaced
107:b34bd1557c6c 108:77254bd6dccb
38 #include <QAbstractTableModel> 38 #include <QAbstractTableModel>
39 #include <QAbstractItemModel> 39 #include <QAbstractItemModel>
40 #include <QItemSelectionModel> 40 #include <QItemSelectionModel>
41 41
42 42
43
44 class ListModel : public QAbstractListModel {
45 Q_OBJECT
46
47 ui_getvaluefunc2 getvalue;
48 void *getvaluedata;
49 ui_callback onactivate;
50 void *onactivatedata;
51 ui_callback onselection;
52 void *onselectiondata;
53
54 public:
55 UiObject *obj;
56 UiVar *var;
57 QListView *view;
58
59 ListModel(UiObject *obj, QListView *view, UiVar *var, ui_getvaluefunc2 getvalue, void *getvaluedata);
60
61 void setActivationCallback(ui_callback f, void *userdata);
62 void setSelectionCallback(ui_callback f, void *userdata);
63
64 void update(int row);
65
66 int rowCount(const QModelIndex &parent = QModelIndex()) const;
67 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
68
69 public slots:
70 void selectionChanged(
71 const QItemSelection & selected,
72 const QItemSelection & deselected);
73 };
74
75 class TableModel : public QAbstractListModel {
76 Q_OBJECT
77
78 UiModel *model;
79 ui_callback onactivate;
80 void *onactivatedata;
81 ui_callback onselection;
82 void *onselectiondata;
83
84 public:
85 UiObject *obj;
86 UiVar *var;
87 QTreeView *view;
88
89 TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model);
90
91 void setActivationCallback(ui_callback f, void *userdata);
92 void setSelectionCallback(ui_callback f, void *userdata);
93
94 void update(int row);
95
96 int rowCount(const QModelIndex &parent = QModelIndex()) const;
97 int columnCount(const QModelIndex &parent = QModelIndex()) const;
98 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
99 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
100
101 public slots:
102 void selectionChanged(
103 const QItemSelection & selected,
104 const QItemSelection & deselected);
105 };
106
107
108 UiListSelection ui_selection_model_to_selection(QItemSelectionModel *model);
109
110 extern "C" {
111
112 void ui_listmodel_update(UiList *list, int row);
113 void ui_listmodel_setselection(UiList *list, UiListSelection sel);
114 UiListSelection ui_listmodel_getselection(UiList *list);
115
116 }
117
43 #endif /* MODEL_H */ 118 #endif /* MODEL_H */
44 119

mercurial