Хранилища Subversion OpenInventory

Редакция

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

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