Subversion Repositories OpenInventory

Rev

Rev 158 | Rev 201 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 158 Rev 180
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
-
 
15
#include "iconform.h"
-
 
16
14
//#include <QMainWindow>
17
//#include <QMainWindow>
15
//! [0]
18
//! [0]
16
class SpinBoxDelegate : public QItemDelegate
19
class SpinBoxDelegate : public QItemDelegate
17
{
20
{
18
    Q_OBJECT
21
    Q_OBJECT
19
22
20
public:
23
public:
21
    SpinBoxDelegate(QObject *parent = 0);
24
    SpinBoxDelegate(QObject *parent = 0);
22
25
23
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
26
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
24
                          const QModelIndex &index) const;
27
                          const QModelIndex &index) const;
25
28
26
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
29
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
27
    void setModelData(QWidget *editor, QAbstractItemModel *model,
30
    void setModelData(QWidget *editor, QAbstractItemModel *model,
28
                      const QModelIndex &index) const;
31
                      const QModelIndex &index) const;
29
32
30
    void updateEditorGeometry(QWidget *editor,
33
    void updateEditorGeometry(QWidget *editor,
31
        const QStyleOptionViewItem &option, const QModelIndex &index) const;
34
        const QStyleOptionViewItem &option, const QModelIndex &index) const;
32
35
33
36
34
37
35
    void setInctance(QString newInctance);
38
    void setInctance(QString newInctance);
36
    void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê
39
    void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê
37
40
38
41
39
42
40
43
41
private:
44
private:
42
45
43
46
44
    QString inctance; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê
47
    QString inctance; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê
45
    QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID
48
    QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID
46
49
47
50
48
51
49
52
50
53
51
54
52
55
53
};
56
};
54
//! [0]
57
//! [0]
55
58
56
class MyDEDelegate : public QItemDelegate {
59
class MyDEDelegate : public QItemDelegate {
57
       Q_OBJECT
60
       Q_OBJECT
58
   public:
61
   public:
59
       MyDEDelegate(bool calpopup = true,
62
       MyDEDelegate(bool calpopup = true,
60
                    QObject *parent = 0);
63
                    QObject *parent = 0);
61
       QWidget *createEditor(
64
       QWidget *createEditor(
62
                   QWidget *parent,
65
                   QWidget *parent,
63
                   const QStyleOptionViewItem &option,
66
                   const QStyleOptionViewItem &option,
64
                   const QModelIndex &index) const;
67
                   const QModelIndex &index) const;
65
       void setEditorData(QWidget *editor,
68
       void setEditorData(QWidget *editor,
66
                          const QModelIndex &index) const;
69
                          const QModelIndex &index) const;
67
       void setModelData(QWidget *editor,
70
       void setModelData(QWidget *editor,
68
                         QAbstractItemModel *model,
71
                         QAbstractItemModel *model,
69
                         const QModelIndex &index) const;
72
                         const QModelIndex &index) const;
70
      void updateEditorGeometry(
73
      void updateEditorGeometry(
71
              QWidget *editor,
74
              QWidget *editor,
72
              const QStyleOptionViewItem &option,
75
              const QStyleOptionViewItem &option,
73
              const QModelIndex &index) const;
76
              const QModelIndex &index) const;
74
   private:
77
   private:
75
        bool m_calpopup;
78
        bool m_calpopup;
76
    };
79
    };
77
80
78
81
79
class CPictureDelegate : public QItemDelegate
82
class CPictureDelegate : public QItemDelegate
80
{
83
{
81
    mutable QPixmap m_pxPicture;
84
    mutable QPixmap m_pxPicture;
82
 public:
85
 public:
83
         CPictureDelegate( QObject *parent );
86
         CPictureDelegate( QObject *parent );
84
87
85
         void paint(QPainter *painter, const QStyleOptionViewItem &option,
88
         void paint(QPainter *painter, const QStyleOptionViewItem &option,
86
                                const QModelIndex &index) const;
89
                                const QModelIndex &index) const;
87
90
88
         //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
91
         //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
89
};
92
};
90
93
91
94
-
 
95
class IconDelegate : public QItemDelegate
-
 
96
{
-
 
97
    mutable QPixmap m_pxPicture;
-
 
98
private:
-
 
99
        QTableView *tblView;
-
 
100
-
 
101
public:
-
 
102
         IconDelegate ( QObject *parent );
-
 
103
-
 
104
         QWidget *createEditor(
-
 
105
                     QWidget *parent,
-
 
106
                     const QStyleOptionViewItem &option,
-
 
107
                     const QModelIndex &index) const;
-
 
108
-
 
109
         void setEditorData(QWidget *editor,
-
 
110
                            const QModelIndex &index) const;
-
 
111
-
 
112
         void setModelData(QWidget *editor,
-
 
113
                           QAbstractItemModel *model,
-
 
114
                           const QModelIndex &index) const;
-
 
115
-
 
116
-
 
117
         void updateEditorGeometry(
-
 
118
                 QWidget *editor,
-
 
119
                 const QStyleOptionViewItem &option,
-
 
120
                 const QModelIndex &index) const;
-
 
121
-
 
122
         void paint(QPainter *painter, const QStyleOptionViewItem &option,
-
 
123
                                const QModelIndex &index) const;
-
 
124
-
 
125
        void setTableView(QTableView* table);
-
 
126
-
 
127
-
 
128
         //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
-
 
129
};
92
130
93
131
94
132
95
class TimeEditDelegate : public QItemDelegate
133
class TimeEditDelegate : public QItemDelegate
96
 {
134
 {
97
     Q_OBJECT
135
     Q_OBJECT
98
136
99
 public:
137
 public:
100
     TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;};
138
     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,
139
     void paint(QPainter *painter, const QStyleOptionViewItem &option,
102
               const QModelIndex &index) const;
140
               const QModelIndex &index) const;
103
141
104
 private:
142
 private:
105
     QString timeformat;
143
     QString timeformat;
106
 };
144
 };
107
145
108
146
109
#endif // DELEGATE_H
147
#endif // DELEGATE_H
110
 
148