Редакция 219 | Редакция 225 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
122 | pingvin | 1 | #ifndef DELEGATE_H |
2 | #define DELEGATE_H |
||
3 | |||
4 | #include <QItemDelegate> |
||
5 | #include <QModelIndex> |
||
6 | #include <QObject> |
||
7 | #include <QSize> |
||
8 | #include <QSpinBox> |
||
126 | pingvin | 9 | #include <QSqlQuery> |
10 | #include <QtSql> |
||
11 | #include <QtGui> |
||
12 | #include <QSqlDatabase> |
||
13 | #include <QMessageBox> |
||
180 | pingvin | 14 | |
15 | #include "iconform.h" |
||
201 | pingvin | 16 | #include "fileform.h" |
180 | pingvin | 17 | |
126 | pingvin | 18 | //#include <QMainWindow> |
122 | pingvin | 19 | //! [0] |
224 | pingvin | 20 | |
21 | |||
122 | pingvin | 22 | class SpinBoxDelegate : public QItemDelegate |
23 | { |
||
24 | Q_OBJECT |
||
25 | |||
26 | public: |
||
27 | SpinBoxDelegate(QObject *parent = 0); |
||
28 | |||
29 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
30 | const QModelIndex &index) const; |
||
31 | |||
32 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
33 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
34 | const QModelIndex &index) const; |
||
35 | |||
36 | void updateEditorGeometry(QWidget *editor, |
||
37 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
126 | pingvin | 38 | |
39 | |||
40 | |||
41 | void setInctance(QString newInctance); |
||
42 | void getItems(); // |
||
43 | |||
44 | |||
45 | |||
46 | |||
47 | private: |
||
48 | |||
49 | |||
50 | QString inctance; // -, |
||
51 | QMap <QString, QString> items; // ID |
||
52 | |||
219 | pingvin | 53 | }; |
126 | pingvin | 54 | |
55 | |||
56 | |||
57 | |||
58 | |||
224 | pingvin | 59 | |
60 | |||
219 | pingvin | 61 | class FilterConditionDelegate : public QItemDelegate |
62 | { |
||
63 | Q_OBJECT |
||
126 | pingvin | 64 | |
219 | pingvin | 65 | public: |
66 | FilterConditionDelegate(QObject *parent = 0); |
||
67 | |||
68 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
69 | const QModelIndex &index) const; |
||
70 | |||
71 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
72 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
73 | const QModelIndex &index) const; |
||
74 | |||
75 | void updateEditorGeometry(QWidget *editor, |
||
76 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
77 | |||
78 | |||
79 | |||
80 | void setClassID(QString newClassID); |
||
81 | // void getItems(); // |
||
82 | |||
83 | void setItems(QStringList new_items){items = new_items;} |
||
84 | |||
85 | |||
86 | private: |
||
87 | |||
88 | |||
89 | QString class_id; // -, |
||
90 | // QMap <QString, QString> items; // ID |
||
91 | QStringList items; // |
||
122 | pingvin | 92 | }; |
219 | pingvin | 93 | |
94 | |||
95 | |||
224 | pingvin | 96 | class FilterValueDelegate : public QItemDelegate |
97 | { |
||
98 | Q_OBJECT |
||
219 | pingvin | 99 | |
224 | pingvin | 100 | public: |
101 | FilterValueDelegate(QObject *parent = 0); |
||
102 | |||
103 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
104 | const QModelIndex &index) const; |
||
105 | |||
106 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
107 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
108 | const QModelIndex &index) const; |
||
109 | |||
110 | void updateEditorGeometry(QWidget *editor, |
||
111 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
112 | |||
113 | |||
114 | |||
115 | void setClassID(QString newClassID); |
||
116 | // void getItems(); // |
||
117 | |||
118 | void setItems(QStringList new_items){items = new_items;} |
||
119 | |||
120 | |||
121 | private: |
||
122 | |||
123 | |||
124 | QString class_id; // -, |
||
125 | // QMap <QString, QString> items; // ID |
||
126 | QStringList items; // |
||
127 | }; |
||
128 | |||
129 | |||
130 | |||
131 | |||
122 | pingvin | 132 | //! [0] |
219 | pingvin | 133 | class FilterSpinBoxDelegate : public QItemDelegate |
134 | { |
||
135 | Q_OBJECT |
||
122 | pingvin | 136 | |
219 | pingvin | 137 | public: |
138 | FilterSpinBoxDelegate(QObject *parent = 0); |
||
139 | |||
140 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
141 | const QModelIndex &index) const; |
||
142 | |||
143 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
144 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
145 | const QModelIndex &index) const; |
||
146 | |||
147 | void updateEditorGeometry(QWidget *editor, |
||
148 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
149 | |||
150 | |||
151 | |||
152 | void setClassID(QString newClassID); |
||
153 | void getItems(); // |
||
154 | |||
155 | |||
156 | |||
157 | |||
158 | private: |
||
159 | |||
160 | |||
161 | QString class_id; // -, |
||
162 | QMap <QString, QString> items; // ID |
||
163 | }; |
||
164 | |||
165 | |||
166 | |||
167 | |||
168 | |||
169 | |||
170 | |||
171 | |||
172 | //! [0] |
||
173 | |||
122 | pingvin | 174 | class MyDEDelegate : public QItemDelegate { |
175 | Q_OBJECT |
||
176 | public: |
||
177 | MyDEDelegate(bool calpopup = true, |
||
178 | QObject *parent = 0); |
||
179 | QWidget *createEditor( |
||
180 | QWidget *parent, |
||
181 | const QStyleOptionViewItem &option, |
||
182 | const QModelIndex &index) const; |
||
183 | void setEditorData(QWidget *editor, |
||
184 | const QModelIndex &index) const; |
||
185 | void setModelData(QWidget *editor, |
||
186 | QAbstractItemModel *model, |
||
187 | const QModelIndex &index) const; |
||
188 | void updateEditorGeometry( |
||
189 | QWidget *editor, |
||
190 | const QStyleOptionViewItem &option, |
||
191 | const QModelIndex &index) const; |
||
192 | private: |
||
193 | bool m_calpopup; |
||
194 | }; |
||
195 | |||
196 | |||
138 | pingvin | 197 | class CPictureDelegate : public QItemDelegate |
198 | { |
||
199 | mutable QPixmap m_pxPicture; |
||
200 | public: |
||
201 | CPictureDelegate( QObject *parent ); |
||
122 | pingvin | 202 | |
138 | pingvin | 203 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
204 | const QModelIndex &index) const; |
||
205 | |||
206 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
207 | }; |
||
208 | |||
209 | |||
180 | pingvin | 210 | class IconDelegate : public QItemDelegate |
211 | { |
||
212 | mutable QPixmap m_pxPicture; |
||
213 | private: |
||
214 | QTableView *tblView; |
||
138 | pingvin | 215 | |
180 | pingvin | 216 | public: |
217 | IconDelegate ( QObject *parent ); |
||
158 | pingvin | 218 | |
180 | pingvin | 219 | QWidget *createEditor( |
220 | QWidget *parent, |
||
221 | const QStyleOptionViewItem &option, |
||
222 | const QModelIndex &index) const; |
||
158 | pingvin | 223 | |
180 | pingvin | 224 | void setEditorData(QWidget *editor, |
225 | const QModelIndex &index) const; |
||
226 | |||
227 | void setModelData(QWidget *editor, |
||
228 | QAbstractItemModel *model, |
||
229 | const QModelIndex &index) const; |
||
230 | |||
231 | |||
232 | void updateEditorGeometry( |
||
233 | QWidget *editor, |
||
234 | const QStyleOptionViewItem &option, |
||
235 | const QModelIndex &index) const; |
||
236 | |||
237 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
238 | const QModelIndex &index) const; |
||
239 | |||
240 | void setTableView(QTableView* table); |
||
241 | |||
242 | |||
243 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
244 | }; |
||
245 | |||
201 | pingvin | 246 | class FileDelegate : public QItemDelegate |
247 | { |
||
248 | mutable QByteArray m_Data; |
||
249 | private: |
||
250 | // QTableView *tblView; |
||
180 | pingvin | 251 | |
201 | pingvin | 252 | public: |
253 | FileDelegate ( QObject *parent ); |
||
180 | pingvin | 254 | |
201 | pingvin | 255 | QWidget *createEditor( |
256 | QWidget *parent, |
||
257 | const QStyleOptionViewItem &option, |
||
258 | const QModelIndex &index) const; |
||
259 | |||
260 | void setEditorData(QWidget *editor, |
||
261 | const QModelIndex &index) const; |
||
262 | |||
263 | void setModelData(QWidget *editor, |
||
264 | QAbstractItemModel *model, |
||
265 | const QModelIndex &index) const; |
||
266 | |||
267 | |||
268 | void updateEditorGeometry( |
||
269 | QWidget *editor, |
||
270 | const QStyleOptionViewItem &option, |
||
271 | const QModelIndex &index) const; |
||
272 | |||
273 | /* |
||
274 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
275 | const QModelIndex &index) const; |
||
276 | */ |
||
277 | |||
278 | |||
279 | |||
280 | // void setTableView(QTableView* table); |
||
281 | |||
282 | |||
283 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
284 | }; |
||
285 | |||
158 | pingvin | 286 | class TimeEditDelegate : public QItemDelegate |
287 | { |
||
288 | Q_OBJECT |
||
289 | |||
290 | public: |
||
291 | TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;}; |
||
292 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
293 | const QModelIndex &index) const; |
||
294 | |||
295 | private: |
||
296 | QString timeformat; |
||
297 | }; |
||
298 | |||
299 | |||
122 | pingvin | 300 | #endif // DELEGATE_H |