Редакция 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 | |||
226 | pingvin | 22 | typedef struct field { |
23 | |||
24 | QString ID; |
||
25 | QString FieldName; |
||
26 | QString FieldAlias; |
||
27 | QString FieldType; |
||
28 | QString DefaultValue; |
||
29 | QString ClassIdentifer; |
||
30 | QString Comment; |
||
31 | |||
32 | } TField; // |
||
33 | |||
34 | |||
35 | |||
122 | pingvin | 36 | class SpinBoxDelegate : public QItemDelegate |
37 | { |
||
38 | Q_OBJECT |
||
39 | |||
40 | public: |
||
41 | SpinBoxDelegate(QObject *parent = 0); |
||
42 | |||
43 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
44 | const QModelIndex &index) const; |
||
45 | |||
46 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
47 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
48 | const QModelIndex &index) const; |
||
49 | |||
50 | void updateEditorGeometry(QWidget *editor, |
||
51 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
126 | pingvin | 52 | |
53 | |||
54 | |||
55 | void setInctance(QString newInctance); |
||
56 | void getItems(); // |
||
57 | |||
58 | |||
59 | |||
60 | |||
61 | private: |
||
62 | |||
63 | |||
64 | QString inctance; // -, |
||
65 | QMap <QString, QString> items; // ID |
||
66 | |||
219 | pingvin | 67 | }; |
126 | pingvin | 68 | |
69 | |||
70 | |||
71 | |||
72 | |||
224 | pingvin | 73 | |
74 | |||
219 | pingvin | 75 | class FilterConditionDelegate : public QItemDelegate |
76 | { |
||
77 | Q_OBJECT |
||
126 | pingvin | 78 | |
219 | pingvin | 79 | public: |
80 | FilterConditionDelegate(QObject *parent = 0); |
||
81 | |||
82 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
83 | const QModelIndex &index) const; |
||
84 | |||
85 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
86 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
87 | const QModelIndex &index) const; |
||
88 | |||
89 | void updateEditorGeometry(QWidget *editor, |
||
90 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
91 | |||
92 | |||
93 | |||
94 | void setClassID(QString newClassID); |
||
95 | // void getItems(); // |
||
96 | |||
97 | void setItems(QStringList new_items){items = new_items;} |
||
98 | |||
99 | |||
100 | private: |
||
101 | |||
102 | |||
103 | QString class_id; // -, |
||
104 | // QMap <QString, QString> items; // ID |
||
105 | QStringList items; // |
||
122 | pingvin | 106 | }; |
219 | pingvin | 107 | |
108 | |||
109 | |||
224 | pingvin | 110 | class FilterValueDelegate : public QItemDelegate |
111 | { |
||
112 | Q_OBJECT |
||
219 | pingvin | 113 | |
226 | pingvin | 114 | |
115 | |||
116 | |||
117 | |||
118 | |||
119 | |||
224 | pingvin | 120 | public: |
121 | FilterValueDelegate(QObject *parent = 0); |
||
122 | |||
123 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
124 | const QModelIndex &index) const; |
||
125 | |||
126 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
127 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
128 | const QModelIndex &index) const; |
||
129 | |||
130 | void updateEditorGeometry(QWidget *editor, |
||
131 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
132 | |||
133 | |||
134 | |||
135 | void setClassID(QString newClassID); |
||
136 | // void getItems(); // |
||
137 | |||
138 | void setItems(QStringList new_items){items = new_items;} |
||
139 | |||
140 | |||
141 | private: |
||
142 | |||
143 | |||
144 | QString class_id; // -, |
||
145 | // QMap <QString, QString> items; // ID |
||
225 | pingvin | 146 | mutable QStringList items; // |
147 | static QString getClassInctanc(QString class_id);// |
||
226 | pingvin | 148 | static QString getFieldType(QString class_id, QString fieldName);// |
149 | static TField getField(const QModelIndex &index); // ( ) |
||
227 | pingvin | 150 | static QMap<QString, QString> getItems(QString inctance); // - |
151 | |||
224 | pingvin | 152 | }; |
153 | |||
154 | |||
155 | |||
156 | |||
122 | pingvin | 157 | //! [0] |
219 | pingvin | 158 | class FilterSpinBoxDelegate : public QItemDelegate |
159 | { |
||
160 | Q_OBJECT |
||
122 | pingvin | 161 | |
219 | pingvin | 162 | public: |
163 | FilterSpinBoxDelegate(QObject *parent = 0); |
||
164 | |||
165 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
166 | const QModelIndex &index) const; |
||
167 | |||
168 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
169 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
170 | const QModelIndex &index) const; |
||
171 | |||
172 | void updateEditorGeometry(QWidget *editor, |
||
173 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
174 | |||
175 | |||
176 | |||
177 | void setClassID(QString newClassID); |
||
178 | void getItems(); // |
||
179 | |||
180 | |||
181 | |||
182 | |||
183 | private: |
||
184 | |||
185 | |||
186 | QString class_id; // -, |
||
187 | QMap <QString, QString> items; // ID |
||
188 | }; |
||
189 | |||
190 | |||
191 | |||
192 | |||
193 | |||
194 | |||
195 | |||
196 | |||
197 | //! [0] |
||
198 | |||
122 | pingvin | 199 | class MyDEDelegate : public QItemDelegate { |
200 | Q_OBJECT |
||
201 | public: |
||
202 | MyDEDelegate(bool calpopup = true, |
||
203 | QObject *parent = 0); |
||
204 | QWidget *createEditor( |
||
205 | QWidget *parent, |
||
206 | const QStyleOptionViewItem &option, |
||
207 | const QModelIndex &index) const; |
||
208 | void setEditorData(QWidget *editor, |
||
209 | const QModelIndex &index) const; |
||
210 | void setModelData(QWidget *editor, |
||
211 | QAbstractItemModel *model, |
||
212 | const QModelIndex &index) const; |
||
213 | void updateEditorGeometry( |
||
214 | QWidget *editor, |
||
215 | const QStyleOptionViewItem &option, |
||
216 | const QModelIndex &index) const; |
||
217 | private: |
||
218 | bool m_calpopup; |
||
219 | }; |
||
220 | |||
221 | |||
138 | pingvin | 222 | class CPictureDelegate : public QItemDelegate |
223 | { |
||
224 | mutable QPixmap m_pxPicture; |
||
225 | public: |
||
226 | CPictureDelegate( QObject *parent ); |
||
122 | pingvin | 227 | |
138 | pingvin | 228 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
229 | const QModelIndex &index) const; |
||
230 | |||
231 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
232 | }; |
||
233 | |||
234 | |||
180 | pingvin | 235 | class IconDelegate : public QItemDelegate |
236 | { |
||
237 | mutable QPixmap m_pxPicture; |
||
238 | private: |
||
239 | QTableView *tblView; |
||
138 | pingvin | 240 | |
180 | pingvin | 241 | public: |
242 | IconDelegate ( QObject *parent ); |
||
158 | pingvin | 243 | |
180 | pingvin | 244 | QWidget *createEditor( |
245 | QWidget *parent, |
||
246 | const QStyleOptionViewItem &option, |
||
247 | const QModelIndex &index) const; |
||
158 | pingvin | 248 | |
180 | pingvin | 249 | void setEditorData(QWidget *editor, |
250 | const QModelIndex &index) const; |
||
251 | |||
252 | void setModelData(QWidget *editor, |
||
253 | QAbstractItemModel *model, |
||
254 | const QModelIndex &index) const; |
||
255 | |||
256 | |||
257 | void updateEditorGeometry( |
||
258 | QWidget *editor, |
||
259 | const QStyleOptionViewItem &option, |
||
260 | const QModelIndex &index) const; |
||
261 | |||
262 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
263 | const QModelIndex &index) const; |
||
264 | |||
265 | void setTableView(QTableView* table); |
||
266 | |||
267 | |||
268 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
269 | }; |
||
270 | |||
201 | pingvin | 271 | class FileDelegate : public QItemDelegate |
272 | { |
||
273 | mutable QByteArray m_Data; |
||
274 | private: |
||
275 | // QTableView *tblView; |
||
180 | pingvin | 276 | |
201 | pingvin | 277 | public: |
278 | FileDelegate ( QObject *parent ); |
||
180 | pingvin | 279 | |
201 | pingvin | 280 | QWidget *createEditor( |
281 | QWidget *parent, |
||
282 | const QStyleOptionViewItem &option, |
||
283 | const QModelIndex &index) const; |
||
284 | |||
285 | void setEditorData(QWidget *editor, |
||
286 | const QModelIndex &index) const; |
||
287 | |||
288 | void setModelData(QWidget *editor, |
||
289 | QAbstractItemModel *model, |
||
290 | const QModelIndex &index) const; |
||
291 | |||
292 | |||
293 | void updateEditorGeometry( |
||
294 | QWidget *editor, |
||
295 | const QStyleOptionViewItem &option, |
||
296 | const QModelIndex &index) const; |
||
297 | |||
298 | /* |
||
299 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
300 | const QModelIndex &index) const; |
||
301 | */ |
||
302 | |||
303 | |||
304 | |||
305 | // void setTableView(QTableView* table); |
||
306 | |||
307 | |||
308 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
309 | }; |
||
310 | |||
158 | pingvin | 311 | class TimeEditDelegate : public QItemDelegate |
312 | { |
||
313 | Q_OBJECT |
||
314 | |||
315 | public: |
||
316 | TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;}; |
||
317 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
318 | const QModelIndex &index) const; |
||
319 | |||
320 | private: |
||
321 | QString timeformat; |
||
322 | }; |
||
323 | |||
324 | |||
122 | pingvin | 325 | #endif // DELEGATE_H |