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