Rev 138 | Rev 180 | 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> |
||
14 | //#include <QMainWindow> |
||
122 | pingvin | 15 | //! [0] |
16 | class SpinBoxDelegate : public QItemDelegate |
||
17 | { |
||
18 | Q_OBJECT |
||
19 | |||
20 | public: |
||
21 | SpinBoxDelegate(QObject *parent = 0); |
||
22 | |||
23 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
24 | const QModelIndex &index) const; |
||
25 | |||
26 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
27 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
28 | const QModelIndex &index) const; |
||
29 | |||
30 | void updateEditorGeometry(QWidget *editor, |
||
31 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
126 | pingvin | 32 | |
33 | |||
34 | |||
35 | void setInctance(QString newInctance); |
||
36 | void getItems(); // |
||
37 | |||
38 | |||
39 | |||
40 | |||
41 | private: |
||
42 | |||
43 | |||
44 | QString inctance; // -, |
||
45 | QMap <QString, QString> items; // ID |
||
46 | |||
47 | |||
48 | |||
49 | |||
50 | |||
51 | |||
52 | |||
122 | pingvin | 53 | }; |
54 | //! [0] |
||
55 | |||
56 | class MyDEDelegate : public QItemDelegate { |
||
57 | Q_OBJECT |
||
58 | public: |
||
59 | MyDEDelegate(bool calpopup = true, |
||
60 | QObject *parent = 0); |
||
61 | QWidget *createEditor( |
||
62 | QWidget *parent, |
||
63 | const QStyleOptionViewItem &option, |
||
64 | const QModelIndex &index) const; |
||
65 | void setEditorData(QWidget *editor, |
||
66 | const QModelIndex &index) const; |
||
67 | void setModelData(QWidget *editor, |
||
68 | QAbstractItemModel *model, |
||
69 | const QModelIndex &index) const; |
||
70 | void updateEditorGeometry( |
||
71 | QWidget *editor, |
||
72 | const QStyleOptionViewItem &option, |
||
73 | const QModelIndex &index) const; |
||
74 | private: |
||
75 | bool m_calpopup; |
||
76 | }; |
||
77 | |||
78 | |||
138 | pingvin | 79 | class CPictureDelegate : public QItemDelegate |
80 | { |
||
81 | mutable QPixmap m_pxPicture; |
||
82 | public: |
||
83 | CPictureDelegate( QObject *parent ); |
||
122 | pingvin | 84 | |
138 | pingvin | 85 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
86 | const QModelIndex &index) const; |
||
87 | |||
88 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
89 | }; |
||
90 | |||
91 | |||
92 | |||
158 | pingvin | 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 | |||
122 | pingvin | 109 | #endif // DELEGATE_H |