Редакция 163 | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
52 | pingvin | 1 | #ifndef DELEGATE_H |
2 | #define DELEGATE_H |
||
3 | #include <QItemDelegate> |
||
4 | #include <QModelIndex> |
||
134 | pingvin | 5 | #include <QSqlQuery> |
52 | pingvin | 6 | #include <QObject> |
7 | #include <QSize> |
||
8 | #include <QSpinBox> |
||
134 | pingvin | 9 | #include <QMap> |
165 | pingvin | 10 | #include <QTableView> |
11 | |||
163 | pingvin | 12 | #include "iconform.h" |
52 | pingvin | 13 | |
14 | //! [0] |
||
15 | class SpinBoxDelegate : public QItemDelegate |
||
16 | { |
||
17 | Q_OBJECT |
||
18 | |||
19 | public: |
||
20 | SpinBoxDelegate(QObject *parent = 0); |
||
21 | |||
22 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
23 | const QModelIndex &index) const; |
||
24 | |||
25 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
26 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
27 | const QModelIndex &index) const; |
||
28 | |||
29 | void updateEditorGeometry(QWidget *editor, |
||
30 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
134 | pingvin | 31 | |
32 | void getItems(); // |
||
33 | |||
34 | private: |
||
35 | QMap <QString, QString> items; // ID |
||
36 | |||
37 | |||
52 | pingvin | 38 | }; |
39 | //! [0] |
||
40 | |||
41 | class MyDEDelegate : public QItemDelegate { |
||
42 | Q_OBJECT |
||
43 | public: |
||
44 | MyDEDelegate(bool calpopup = true, |
||
45 | QObject *parent = 0); |
||
46 | QWidget *createEditor( |
||
47 | QWidget *parent, |
||
48 | const QStyleOptionViewItem &option, |
||
49 | const QModelIndex &index) const; |
||
50 | void setEditorData(QWidget *editor, |
||
51 | const QModelIndex &index) const; |
||
52 | void setModelData(QWidget *editor, |
||
53 | QAbstractItemModel *model, |
||
54 | const QModelIndex &index) const; |
||
55 | void updateEditorGeometry( |
||
56 | QWidget *editor, |
||
57 | const QStyleOptionViewItem &option, |
||
58 | const QModelIndex &index) const; |
||
59 | private: |
||
60 | bool m_calpopup; |
||
61 | }; |
||
62 | |||
161 | pingvin | 63 | |
64 | class CPictureDelegate : public QItemDelegate |
||
65 | { |
||
66 | mutable QPixmap m_pxPicture; |
||
165 | pingvin | 67 | private: |
68 | QTableView *tblView; |
||
69 | |||
70 | public: |
||
161 | pingvin | 71 | CPictureDelegate( QObject *parent ); |
72 | |||
165 | pingvin | 73 | QWidget *createEditor( |
74 | QWidget *parent, |
||
75 | const QStyleOptionViewItem &option, |
||
76 | const QModelIndex &index) const; |
||
77 | |||
78 | void setEditorData(QWidget *editor, |
||
79 | const QModelIndex &index) const; |
||
80 | |||
81 | void setModelData(QWidget *editor, |
||
82 | QAbstractItemModel *model, |
||
83 | const QModelIndex &index) const; |
||
84 | |||
85 | |||
86 | void updateEditorGeometry( |
||
87 | QWidget *editor, |
||
88 | const QStyleOptionViewItem &option, |
||
89 | const QModelIndex &index) const; |
||
90 | |||
161 | pingvin | 91 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
92 | const QModelIndex &index) const; |
||
93 | |||
165 | pingvin | 94 | void setTableView(QTableView* table); |
95 | |||
96 | |||
161 | pingvin | 97 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
98 | }; |
||
99 | |||
100 | |||
101 | |||
102 | |||
52 | pingvin | 103 | #endif // DELEGATE_H |