Хранилища Subversion OpenInventory

Редакция

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

Редакция 138 Редакция 158
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
//#include <QMainWindow>
14
//#include <QMainWindow>
15
//! [0]
15
//! [0]
16
class SpinBoxDelegate : public QItemDelegate
16
class SpinBoxDelegate : public QItemDelegate
17
{
17
{
18
    Q_OBJECT
18
    Q_OBJECT
19
19
20
public:
20
public:
21
    SpinBoxDelegate(QObject *parent = 0);
21
    SpinBoxDelegate(QObject *parent = 0);
22
22
23
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
23
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
24
                          const QModelIndex &index) const;
24
                          const QModelIndex &index) const;
25
25
26
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
26
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
27
    void setModelData(QWidget *editor, QAbstractItemModel *model,
27
    void setModelData(QWidget *editor, QAbstractItemModel *model,
28
                      const QModelIndex &index) const;
28
                      const QModelIndex &index) const;
29
29
30
    void updateEditorGeometry(QWidget *editor,
30
    void updateEditorGeometry(QWidget *editor,
31
        const QStyleOptionViewItem &option, const QModelIndex &index) const;
31
        const QStyleOptionViewItem &option, const QModelIndex &index) const;
32
32
33
33
34
34
35
    void setInctance(QString newInctance);
35
    void setInctance(QString newInctance);
36
    void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê
36
    void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê
37
37
38
38
39
39
40
40
41
private:
41
private:
42
42
43
43
44
    QString inctance; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê
44
    QString inctance; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê
45
    QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID
45
    QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID
46
46
47
47
48
48
49
49
50
50
51
51
52
52
53
};
53
};
54
//! [0]
54
//! [0]
55
55
56
class MyDEDelegate : public QItemDelegate {
56
class MyDEDelegate : public QItemDelegate {
57
       Q_OBJECT
57
       Q_OBJECT
58
   public:
58
   public:
59
       MyDEDelegate(bool calpopup = true,
59
       MyDEDelegate(bool calpopup = true,
60
                    QObject *parent = 0);
60
                    QObject *parent = 0);
61
       QWidget *createEditor(
61
       QWidget *createEditor(
62
                   QWidget *parent,
62
                   QWidget *parent,
63
                   const QStyleOptionViewItem &option,
63
                   const QStyleOptionViewItem &option,
64
                   const QModelIndex &index) const;
64
                   const QModelIndex &index) const;
65
       void setEditorData(QWidget *editor,
65
       void setEditorData(QWidget *editor,
66
                          const QModelIndex &index) const;
66
                          const QModelIndex &index) const;
67
       void setModelData(QWidget *editor,
67
       void setModelData(QWidget *editor,
68
                         QAbstractItemModel *model,
68
                         QAbstractItemModel *model,
69
                         const QModelIndex &index) const;
69
                         const QModelIndex &index) const;
70
      void updateEditorGeometry(
70
      void updateEditorGeometry(
71
              QWidget *editor,
71
              QWidget *editor,
72
              const QStyleOptionViewItem &option,
72
              const QStyleOptionViewItem &option,
73
              const QModelIndex &index) const;
73
              const QModelIndex &index) const;
74
   private:
74
   private:
75
        bool m_calpopup;
75
        bool m_calpopup;
76
    };
76
    };
77
77
78
78
79
class CPictureDelegate : public QItemDelegate
79
class CPictureDelegate : public QItemDelegate
80
{
80
{
81
    mutable QPixmap m_pxPicture;
81
    mutable QPixmap m_pxPicture;
82
 public:
82
 public:
83
         CPictureDelegate( QObject *parent );
83
         CPictureDelegate( QObject *parent );
84
84
85
         void paint(QPainter *painter, const QStyleOptionViewItem &option,
85
         void paint(QPainter *painter, const QStyleOptionViewItem &option,
86
                                const QModelIndex &index) const;
86
                                const QModelIndex &index) const;
87
87
88
         //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
88
         //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
89
};
89
};
90
90
91
91
92
92
-
 
93
-
 
94
-
 
95
class TimeEditDelegate : public QItemDelegate
-
 
96
 {
-
 
97
     Q_OBJECT
-
 
98
-
 
99
 public:
-
 
100
     TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;};
-
 
101
     void paint(QPainter *painter, const QStyleOptionViewItem &option,
-
 
102
               const QModelIndex &index) const;
-
 
103
-
 
104
 private:
-
 
105
     QString timeformat;
-
 
106
 };
-
 
107
-
 
108
93
#endif // DELEGATE_H
109
#endif // DELEGATE_H
94
 
110