Rev 180 | Rev 224 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
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] |
20 | class SpinBoxDelegate : public QItemDelegate |
||
21 | { |
||
22 | Q_OBJECT |
||
23 | |||
24 | public: |
||
25 | SpinBoxDelegate(QObject *parent = 0); |
||
26 | |||
27 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
28 | const QModelIndex &index) const; |
||
29 | |||
30 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
31 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
32 | const QModelIndex &index) const; |
||
33 | |||
34 | void updateEditorGeometry(QWidget *editor, |
||
35 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
126 | pingvin | 36 | |
37 | |||
38 | |||
39 | void setInctance(QString newInctance); |
||
40 | void getItems(); // |
||
41 | |||
42 | |||
43 | |||
44 | |||
45 | private: |
||
46 | |||
47 | |||
48 | QString inctance; // -, |
||
49 | QMap <QString, QString> items; // ID |
||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | |||
122 | pingvin | 57 | }; |
58 | //! [0] |
||
59 | |||
60 | class MyDEDelegate : public QItemDelegate { |
||
61 | Q_OBJECT |
||
62 | public: |
||
63 | MyDEDelegate(bool calpopup = true, |
||
64 | QObject *parent = 0); |
||
65 | QWidget *createEditor( |
||
66 | QWidget *parent, |
||
67 | const QStyleOptionViewItem &option, |
||
68 | const QModelIndex &index) const; |
||
69 | void setEditorData(QWidget *editor, |
||
70 | const QModelIndex &index) const; |
||
71 | void setModelData(QWidget *editor, |
||
72 | QAbstractItemModel *model, |
||
73 | const QModelIndex &index) const; |
||
74 | void updateEditorGeometry( |
||
75 | QWidget *editor, |
||
76 | const QStyleOptionViewItem &option, |
||
77 | const QModelIndex &index) const; |
||
78 | private: |
||
79 | bool m_calpopup; |
||
80 | }; |
||
81 | |||
82 | |||
138 | pingvin | 83 | class CPictureDelegate : public QItemDelegate |
84 | { |
||
85 | mutable QPixmap m_pxPicture; |
||
86 | public: |
||
87 | CPictureDelegate( QObject *parent ); |
||
122 | pingvin | 88 | |
138 | pingvin | 89 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
90 | const QModelIndex &index) const; |
||
91 | |||
92 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
93 | }; |
||
94 | |||
95 | |||
180 | pingvin | 96 | class IconDelegate : public QItemDelegate |
97 | { |
||
98 | mutable QPixmap m_pxPicture; |
||
99 | private: |
||
100 | QTableView *tblView; |
||
138 | pingvin | 101 | |
180 | pingvin | 102 | public: |
103 | IconDelegate ( QObject *parent ); |
||
158 | pingvin | 104 | |
180 | pingvin | 105 | QWidget *createEditor( |
106 | QWidget *parent, |
||
107 | const QStyleOptionViewItem &option, |
||
108 | const QModelIndex &index) const; |
||
158 | pingvin | 109 | |
180 | pingvin | 110 | void setEditorData(QWidget *editor, |
111 | const QModelIndex &index) const; |
||
112 | |||
113 | void setModelData(QWidget *editor, |
||
114 | QAbstractItemModel *model, |
||
115 | const QModelIndex &index) const; |
||
116 | |||
117 | |||
118 | void updateEditorGeometry( |
||
119 | QWidget *editor, |
||
120 | const QStyleOptionViewItem &option, |
||
121 | const QModelIndex &index) const; |
||
122 | |||
123 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
124 | const QModelIndex &index) const; |
||
125 | |||
126 | void setTableView(QTableView* table); |
||
127 | |||
128 | |||
129 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
130 | }; |
||
131 | |||
201 | pingvin | 132 | class FileDelegate : public QItemDelegate |
133 | { |
||
134 | mutable QByteArray m_Data; |
||
135 | private: |
||
136 | // QTableView *tblView; |
||
180 | pingvin | 137 | |
201 | pingvin | 138 | public: |
139 | FileDelegate ( QObject *parent ); |
||
180 | pingvin | 140 | |
201 | pingvin | 141 | QWidget *createEditor( |
142 | QWidget *parent, |
||
143 | const QStyleOptionViewItem &option, |
||
144 | const QModelIndex &index) const; |
||
145 | |||
146 | void setEditorData(QWidget *editor, |
||
147 | const QModelIndex &index) const; |
||
148 | |||
149 | void setModelData(QWidget *editor, |
||
150 | QAbstractItemModel *model, |
||
151 | const QModelIndex &index) const; |
||
152 | |||
153 | |||
154 | void updateEditorGeometry( |
||
155 | QWidget *editor, |
||
156 | const QStyleOptionViewItem &option, |
||
157 | const QModelIndex &index) const; |
||
158 | |||
159 | /* |
||
160 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
161 | const QModelIndex &index) const; |
||
162 | */ |
||
163 | |||
164 | |||
165 | |||
166 | // void setTableView(QTableView* table); |
||
167 | |||
168 | |||
169 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
170 | }; |
||
171 | |||
158 | pingvin | 172 | class TimeEditDelegate : public QItemDelegate |
173 | { |
||
174 | Q_OBJECT |
||
175 | |||
176 | public: |
||
177 | TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;}; |
||
178 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
179 | const QModelIndex &index) const; |
||
180 | |||
181 | private: |
||
182 | QString timeformat; |
||
183 | }; |
||
184 | |||
185 | |||
122 | pingvin | 186 | #endif // DELEGATE_H |