Хранилища Subversion OpenInventory

Редакция

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

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