Rev 158 | Rev 201 | 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" |
||
16 | |||
126 | pingvin | 17 | //#include <QMainWindow> |
122 | pingvin | 18 | //! [0] |
19 | class SpinBoxDelegate : public QItemDelegate |
||
20 | { |
||
21 | Q_OBJECT |
||
22 | |||
23 | public: |
||
24 | SpinBoxDelegate(QObject *parent = 0); |
||
25 | |||
26 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
27 | const QModelIndex &index) const; |
||
28 | |||
29 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
30 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
31 | const QModelIndex &index) const; |
||
32 | |||
33 | void updateEditorGeometry(QWidget *editor, |
||
34 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
126 | pingvin | 35 | |
36 | |||
37 | |||
38 | void setInctance(QString newInctance); |
||
39 | void getItems(); // |
||
40 | |||
41 | |||
42 | |||
43 | |||
44 | private: |
||
45 | |||
46 | |||
47 | QString inctance; // -, |
||
48 | QMap <QString, QString> items; // ID |
||
49 | |||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
122 | pingvin | 56 | }; |
57 | //! [0] |
||
58 | |||
59 | class MyDEDelegate : public QItemDelegate { |
||
60 | Q_OBJECT |
||
61 | public: |
||
62 | MyDEDelegate(bool calpopup = true, |
||
63 | QObject *parent = 0); |
||
64 | QWidget *createEditor( |
||
65 | QWidget *parent, |
||
66 | const QStyleOptionViewItem &option, |
||
67 | const QModelIndex &index) const; |
||
68 | void setEditorData(QWidget *editor, |
||
69 | const QModelIndex &index) const; |
||
70 | void setModelData(QWidget *editor, |
||
71 | QAbstractItemModel *model, |
||
72 | const QModelIndex &index) const; |
||
73 | void updateEditorGeometry( |
||
74 | QWidget *editor, |
||
75 | const QStyleOptionViewItem &option, |
||
76 | const QModelIndex &index) const; |
||
77 | private: |
||
78 | bool m_calpopup; |
||
79 | }; |
||
80 | |||
81 | |||
138 | pingvin | 82 | class CPictureDelegate : public QItemDelegate |
83 | { |
||
84 | mutable QPixmap m_pxPicture; |
||
85 | public: |
||
86 | CPictureDelegate( QObject *parent ); |
||
122 | pingvin | 87 | |
138 | pingvin | 88 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
89 | const QModelIndex &index) const; |
||
90 | |||
91 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
92 | }; |
||
93 | |||
94 | |||
180 | pingvin | 95 | class IconDelegate : public QItemDelegate |
96 | { |
||
97 | mutable QPixmap m_pxPicture; |
||
98 | private: |
||
99 | QTableView *tblView; |
||
138 | pingvin | 100 | |
180 | pingvin | 101 | public: |
102 | IconDelegate ( QObject *parent ); |
||
158 | pingvin | 103 | |
180 | pingvin | 104 | QWidget *createEditor( |
105 | QWidget *parent, |
||
106 | const QStyleOptionViewItem &option, |
||
107 | const QModelIndex &index) const; |
||
158 | pingvin | 108 | |
180 | pingvin | 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 | }; |
||
130 | |||
131 | |||
132 | |||
158 | pingvin | 133 | class TimeEditDelegate : public QItemDelegate |
134 | { |
||
135 | Q_OBJECT |
||
136 | |||
137 | public: |
||
138 | TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;}; |
||
139 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
140 | const QModelIndex &index) const; |
||
141 | |||
142 | private: |
||
143 | QString timeformat; |
||
144 | }; |
||
145 | |||
146 | |||
122 | pingvin | 147 | #endif // DELEGATE_H |