Хранилища Subversion OpenInventory

Редакция

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

Редакция Автор № строки Строка
122 pingvin 1
#ifndef DELEGATE_H
2
#define DELEGATE_H
3
 
4
#include <QItemDelegate>
5
#include <QModelIndex>
6
#include <QObject>
7
#include <QSize>
8
#include <QSpinBox>
126 pingvin 9
#include <QSqlQuery>
10
#include <QtSql>
11
#include <QtGui>
12
#include <QSqlDatabase>
13
#include <QMessageBox>
180 pingvin 14
 
15
#include "iconform.h"
201 pingvin 16
#include "fileform.h"
180 pingvin 17
 
126 pingvin 18
//#include <QMainWindow>
122 pingvin 19
//! [0]
224 pingvin 20
 
21
 
226 pingvin 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
 
122 pingvin 36
class SpinBoxDelegate : public QItemDelegate
37
{
38
    Q_OBJECT
39
 
40
public:
41
    SpinBoxDelegate(QObject *parent = 0);
42
 
43
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
44
                          const QModelIndex &index) const;
45
 
46
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
47
    void setModelData(QWidget *editor, QAbstractItemModel *model,
48
                      const QModelIndex &index) const;
49
 
50
    void updateEditorGeometry(QWidget *editor,
51
        const QStyleOptionViewItem &option, const QModelIndex &index) const;
126 pingvin 52
 
53
 
54
 
55
    void setInctance(QString newInctance);
56
    void getItems(); //   
57
 
58
 
59
 
60
 
61
private:
62
 
63
 
64
    QString inctance; // -,    
65
    QMap <QString, QString> items; //           ID
66
 
219 pingvin 67
};
126 pingvin 68
 
69
 
70
 
71
 
72
 
224 pingvin 73
 
74
 
219 pingvin 75
class FilterConditionDelegate : public QItemDelegate
76
{
77
    Q_OBJECT
126 pingvin 78
 
219 pingvin 79
public:
80
    FilterConditionDelegate(QObject *parent = 0);
81
 
82
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
83
                          const QModelIndex &index) const;
84
 
85
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
86
    void setModelData(QWidget *editor, QAbstractItemModel *model,
87
                      const QModelIndex &index) const;
88
 
89
    void updateEditorGeometry(QWidget *editor,
90
        const QStyleOptionViewItem &option, const QModelIndex &index) const;
91
 
92
 
93
 
94
    void setClassID(QString newClassID);
95
//    void getItems(); //   
96
 
97
    void setItems(QStringList new_items){items = new_items;}
98
 
99
 
100
private:
101
 
102
 
103
    QString class_id; // -,    
104
//    QMap <QString, QString> items; //           ID
105
    QStringList items; // 
122 pingvin 106
};
219 pingvin 107
 
108
 
109
 
224 pingvin 110
class FilterValueDelegate : public QItemDelegate
111
{
112
    Q_OBJECT
219 pingvin 113
 
226 pingvin 114
 
115
 
116
 
117
 
118
 
119
 
224 pingvin 120
public:
121
    FilterValueDelegate(QObject *parent = 0);
122
 
123
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
124
                          const QModelIndex &index) const;
125
 
126
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
127
    void setModelData(QWidget *editor, QAbstractItemModel *model,
128
                      const QModelIndex &index) const;
129
 
130
    void updateEditorGeometry(QWidget *editor,
131
        const QStyleOptionViewItem &option, const QModelIndex &index) const;
132
 
133
 
134
 
135
    void setClassID(QString newClassID);
136
//    void getItems(); //   
137
 
138
    void setItems(QStringList new_items){items = new_items;}
139
 
140
 
141
private:
142
 
143
 
144
    QString class_id; // -,    
145
//    QMap <QString, QString> items; //           ID
225 pingvin 146
mutable QStringList items; // 
147
static  QString getClassInctanc(QString class_id);//  
226 pingvin 148
static  QString getFieldType(QString class_id, QString fieldName);//   
149
static TField getField(const QModelIndex &index); //   (  )    
224 pingvin 150
};
151
 
152
 
153
 
154
 
122 pingvin 155
//! [0]
219 pingvin 156
class FilterSpinBoxDelegate : public QItemDelegate
157
{
158
    Q_OBJECT
122 pingvin 159
 
219 pingvin 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
 
122 pingvin 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
 
138 pingvin 220
class CPictureDelegate : public QItemDelegate
221
{
222
    mutable QPixmap m_pxPicture;
223
 public:
224
         CPictureDelegate( QObject *parent );
122 pingvin 225
 
138 pingvin 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
 
180 pingvin 233
class IconDelegate : public QItemDelegate
234
{
235
    mutable QPixmap m_pxPicture;
236
private:
237
        QTableView *tblView;
138 pingvin 238
 
180 pingvin 239
public:
240
         IconDelegate ( QObject *parent );
158 pingvin 241
 
180 pingvin 242
         QWidget *createEditor(
243
                     QWidget *parent,
244
                     const QStyleOptionViewItem &option,
245
                     const QModelIndex &index) const;
158 pingvin 246
 
180 pingvin 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
 
201 pingvin 269
class FileDelegate : public QItemDelegate
270
{
271
    mutable QByteArray m_Data;
272
private:
273
        // QTableView *tblView;
180 pingvin 274
 
201 pingvin 275
public:
276
         FileDelegate ( QObject *parent );
180 pingvin 277
 
201 pingvin 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
 
158 pingvin 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
 
122 pingvin 323
#endif // DELEGATE_H