Хранилища Subversion OpenInventory

Редакция

Редакция 225 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS

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