Редакция 52 | Редакция 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> |
52 | pingvin | 10 | |
11 | //! [0] |
||
12 | class SpinBoxDelegate : public QItemDelegate |
||
13 | { |
||
14 | Q_OBJECT |
||
15 | |||
16 | public: |
||
17 | SpinBoxDelegate(QObject *parent = 0); |
||
18 | |||
19 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
||
20 | const QModelIndex &index) const; |
||
21 | |||
22 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
||
23 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
||
24 | const QModelIndex &index) const; |
||
25 | |||
26 | void updateEditorGeometry(QWidget *editor, |
||
27 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
||
134 | pingvin | 28 | |
29 | void getItems(); // |
||
30 | |||
31 | private: |
||
32 | QMap <QString, QString> items; // ID |
||
33 | |||
34 | |||
52 | pingvin | 35 | }; |
36 | //! [0] |
||
37 | |||
38 | class MyDEDelegate : public QItemDelegate { |
||
39 | Q_OBJECT |
||
40 | public: |
||
41 | MyDEDelegate(bool calpopup = true, |
||
42 | QObject *parent = 0); |
||
43 | QWidget *createEditor( |
||
44 | QWidget *parent, |
||
45 | const QStyleOptionViewItem &option, |
||
46 | const QModelIndex &index) const; |
||
47 | void setEditorData(QWidget *editor, |
||
48 | const QModelIndex &index) const; |
||
49 | void setModelData(QWidget *editor, |
||
50 | QAbstractItemModel *model, |
||
51 | const QModelIndex &index) const; |
||
52 | void updateEditorGeometry( |
||
53 | QWidget *editor, |
||
54 | const QStyleOptionViewItem &option, |
||
55 | const QModelIndex &index) const; |
||
56 | private: |
||
57 | bool m_calpopup; |
||
58 | }; |
||
59 | |||
60 | #endif // DELEGATE_H |