Хранилища Subversion OpenInventory

Редакция

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

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