Редакция 161 | К новейшей редакции | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
52 | pingvin | 1 | #ifndef DELEGATE_H |
2 | #define DELEGATE_H |
||
3 | #include <QItemDelegate> |
||
4 | #include <QModelIndex> |
||
134 | pingvin | 5 | #include <QSqlQuery> |
52 | pingvin | 6 | #include <QObject> |
7 | #include <QSize> |
||
8 | #include <QSpinBox> |
||
134 | pingvin | 9 | #include <QMap> |
163 | pingvin | 10 | #include "iconform.h" |
52 | pingvin | 11 | |
12 | //! [0] |
||
13 | class SpinBoxDelegate : public QItemDelegate |
||
14 | { |
||
15 | Q_OBJECT |
||
16 | |||
17 | public: |
||
18 | SpinBoxDelegate(QObject *parent = 0); |
||
19 | |||
20 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
21 | const QModelIndex &index) const; |
||
22 | |||
23 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
24 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
25 | const QModelIndex &index) const; |
||
26 | |||
27 | void updateEditorGeometry(QWidget *editor, |
||
28 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
134 | pingvin | 29 | |
30 | void getItems(); // |
||
31 | |||
32 | private: |
||
33 | QMap <QString, QString> items; // ID |
||
34 | |||
35 | |||
52 | pingvin | 36 | }; |
37 | //! [0] |
||
38 | |||
39 | class MyDEDelegate : public QItemDelegate { |
||
40 | Q_OBJECT |
||
41 | public: |
||
42 | MyDEDelegate(bool calpopup = true, |
||
43 | QObject *parent = 0); |
||
44 | QWidget *createEditor( |
||
45 | QWidget *parent, |
||
46 | const QStyleOptionViewItem &option, |
||
47 | const QModelIndex &index) const; |
||
48 | void setEditorData(QWidget *editor, |
||
49 | const QModelIndex &index) const; |
||
50 | void setModelData(QWidget *editor, |
||
51 | QAbstractItemModel *model, |
||
52 | const QModelIndex &index) const; |
||
53 | void updateEditorGeometry( |
||
54 | QWidget *editor, |
||
55 | const QStyleOptionViewItem &option, |
||
56 | const QModelIndex &index) const; |
||
57 | private: |
||
58 | bool m_calpopup; |
||
59 | }; |
||
60 | |||
161 | pingvin | 61 | |
62 | class CPictureDelegate : public QItemDelegate |
||
63 | { |
||
64 | mutable QPixmap m_pxPicture; |
||
65 | public: |
||
66 | CPictureDelegate( QObject *parent ); |
||
67 | |||
68 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
||
69 | const QModelIndex &index) const; |
||
70 | |||
71 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
72 | }; |
||
73 | |||
74 | |||
75 | |||
76 | |||
52 | pingvin | 77 | #endif // DELEGATE_H |