Редакция 224 | Редакция 226 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | 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 |
||
225 | pingvin | 126 | mutable QStringList items; // |
127 | static QString getClassInctanc(QString class_id);// |
||
128 | static QString grtFieldType(QString class_id, QString fieldName);// |
||
129 | |||
224 | pingvin | 130 | }; |
131 | |||
132 | |||
133 | |||
134 | |||
122 | pingvin | 135 | //! [0] |
219 | pingvin | 136 | class FilterSpinBoxDelegate : public QItemDelegate |
137 | { |
||
138 | Q_OBJECT |
||
122 | pingvin | 139 | |
219 | pingvin | 140 | public: |
141 | FilterSpinBoxDelegate(QObject *parent = 0); |
||
142 | |||
143 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
144 | const QModelIndex &index) const; |
||
145 | |||
146 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
147 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
148 | const QModelIndex &index) const; |
||
149 | |||
150 | void updateEditorGeometry(QWidget *editor, |
||
151 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
152 | |||
153 | |||
154 | |||
155 | void setClassID(QString newClassID); |
||
156 | void getItems(); // |
||
157 | |||
158 | |||
159 | |||
160 | |||
161 | private: |
||
162 | |||
163 | |||
164 | QString class_id; // -, |
||
165 | QMap <QString, QString> items; // ID |
||
166 | }; |
||
167 | |||
168 | |||
169 | |||
170 | |||
171 | |||
172 | |||
173 | |||
174 | |||
175 | //! [0] |
||
176 | |||
122 | pingvin | 177 | class MyDEDelegate : public QItemDelegate { |
178 | Q_OBJECT |
||
179 | public: |
||
180 | MyDEDelegate(bool calpopup = true, |
||
181 | QObject *parent = 0); |
||
182 | QWidget *createEditor( |
||
183 | QWidget *parent, |
||
184 | const QStyleOptionViewItem &option, |
||
185 | const QModelIndex &index) const; |
||
186 | void setEditorData(QWidget *editor, |
||
187 | const QModelIndex &index) const; |
||
188 | void setModelData(QWidget *editor, |
||
189 | QAbstractItemModel *model, |
||
190 | const QModelIndex &index) const; |
||
191 | void updateEditorGeometry( |
||
192 | QWidget *editor, |
||
193 | const QStyleOptionViewItem &option, |
||
194 | const QModelIndex &index) const; |
||
195 | private: |
||
196 | bool m_calpopup; |
||
197 | }; |
||
198 | |||
199 | |||
138 | pingvin | 200 | class CPictureDelegate : public QItemDelegate |
201 | { |
||
202 | mutable QPixmap m_pxPicture; |
||
203 | public: |
||
204 | CPictureDelegate( QObject *parent ); |
||
122 | pingvin | 205 | |
138 | pingvin | 206 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
207 | const QModelIndex &index) const; |
||
208 | |||
209 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
210 | }; |
||
211 | |||
212 | |||
180 | pingvin | 213 | class IconDelegate : public QItemDelegate |
214 | { |
||
215 | mutable QPixmap m_pxPicture; |
||
216 | private: |
||
217 | QTableView *tblView; |
||
138 | pingvin | 218 | |
180 | pingvin | 219 | public: |
220 | IconDelegate ( QObject *parent ); |
||
158 | pingvin | 221 | |
180 | pingvin | 222 | QWidget *createEditor( |
223 | QWidget *parent, |
||
224 | const QStyleOptionViewItem &option, |
||
225 | const QModelIndex &index) const; |
||
158 | pingvin | 226 | |
180 | pingvin | 227 | void setEditorData(QWidget *editor, |
228 | const QModelIndex &index) const; |
||
229 | |||
230 | void setModelData(QWidget *editor, |
||
231 | QAbstractItemModel *model, |
||
232 | const QModelIndex &index) const; |
||
233 | |||
234 | |||
235 | void updateEditorGeometry( |
||
236 | QWidget *editor, |
||
237 | const QStyleOptionViewItem &option, |
||
238 | const QModelIndex &index) const; |
||
239 | |||
240 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
241 | const QModelIndex &index) const; |
||
242 | |||
243 | void setTableView(QTableView* table); |
||
244 | |||
245 | |||
246 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
247 | }; |
||
248 | |||
201 | pingvin | 249 | class FileDelegate : public QItemDelegate |
250 | { |
||
251 | mutable QByteArray m_Data; |
||
252 | private: |
||
253 | // QTableView *tblView; |
||
180 | pingvin | 254 | |
201 | pingvin | 255 | public: |
256 | FileDelegate ( QObject *parent ); |
||
180 | pingvin | 257 | |
201 | pingvin | 258 | QWidget *createEditor( |
259 | QWidget *parent, |
||
260 | const QStyleOptionViewItem &option, |
||
261 | const QModelIndex &index) const; |
||
262 | |||
263 | void setEditorData(QWidget *editor, |
||
264 | const QModelIndex &index) const; |
||
265 | |||
266 | void setModelData(QWidget *editor, |
||
267 | QAbstractItemModel *model, |
||
268 | const QModelIndex &index) const; |
||
269 | |||
270 | |||
271 | void updateEditorGeometry( |
||
272 | QWidget *editor, |
||
273 | const QStyleOptionViewItem &option, |
||
274 | const QModelIndex &index) const; |
||
275 | |||
276 | /* |
||
277 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
278 | const QModelIndex &index) const; |
||
279 | */ |
||
280 | |||
281 | |||
282 | |||
283 | // void setTableView(QTableView* table); |
||
284 | |||
285 | |||
286 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
287 | }; |
||
288 | |||
158 | pingvin | 289 | class TimeEditDelegate : public QItemDelegate |
290 | { |
||
291 | Q_OBJECT |
||
292 | |||
293 | public: |
||
294 | TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;}; |
||
295 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
296 | const QModelIndex &index) const; |
||
297 | |||
298 | private: |
||
299 | QString timeformat; |
||
300 | }; |
||
301 | |||
302 | |||
122 | pingvin | 303 | #endif // DELEGATE_H |