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