Редакция 52 | Редакция 161 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 52 | Редакция 134 | ||
---|---|---|---|
1 | #ifndef DELEGATE_H
|
1 | #ifndef DELEGATE_H
|
2 | #define DELEGATE_H
|
2 | #define DELEGATE_H
|
3 | #include <QItemDelegate>
|
3 | #include <QItemDelegate>
|
4 | #include <QModelIndex>
|
4 | #include <QModelIndex>
|
- | 5 | #include <QSqlQuery>
|
|
5 | #include <QObject>
|
6 | #include <QObject>
|
6 | #include <QSize>
|
7 | #include <QSize>
|
7 | #include <QSpinBox>
|
8 | #include <QSpinBox>
|
- | 9 | #include <QMap>
|
|
8 | 10 | ||
9 | //! [0]
|
11 | //! [0]
|
10 | class SpinBoxDelegate : public QItemDelegate |
12 | class SpinBoxDelegate : public QItemDelegate |
11 | {
|
13 | {
|
12 | Q_OBJECT |
14 | Q_OBJECT |
13 | 15 | ||
14 | public: |
16 | public: |
15 | SpinBoxDelegate(QObject *parent = 0); |
17 | SpinBoxDelegate(QObject *parent = 0); |
16 | 18 | ||
17 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
19 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
18 | const QModelIndex &index) const; |
20 | const QModelIndex &index) const; |
19 | 21 | ||
20 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
22 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
21 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
23 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
22 | const QModelIndex &index) const; |
24 | const QModelIndex &index) const; |
23 | 25 | ||
24 | void updateEditorGeometry(QWidget *editor, |
26 | void updateEditorGeometry(QWidget *editor, |
25 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
27 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
- | 28 | ||
- | 29 | void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê |
|
- | 30 | ||
- | 31 | private: |
|
- | 32 | QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID |
|
- | 33 | ||
- | 34 | ||
26 | }; |
35 | }; |
27 | //! [0]
|
36 | //! [0]
|
28 | 37 | ||
29 | class MyDEDelegate : public QItemDelegate { |
38 | class MyDEDelegate : public QItemDelegate { |
30 | Q_OBJECT |
39 | Q_OBJECT |
31 | public: |
40 | public: |
32 | MyDEDelegate(bool calpopup = true, |
41 | MyDEDelegate(bool calpopup = true, |
33 | QObject *parent = 0); |
42 | QObject *parent = 0); |
34 | QWidget *createEditor( |
43 | QWidget *createEditor( |
35 | QWidget *parent,
|
44 | QWidget *parent,
|
36 | const QStyleOptionViewItem &option, |
45 | const QStyleOptionViewItem &option, |
37 | const QModelIndex &index) const; |
46 | const QModelIndex &index) const; |
38 | void setEditorData(QWidget *editor, |
47 | void setEditorData(QWidget *editor, |
39 | const QModelIndex &index) const; |
48 | const QModelIndex &index) const; |
40 | void setModelData(QWidget *editor, |
49 | void setModelData(QWidget *editor, |
41 | QAbstractItemModel *model,
|
50 | QAbstractItemModel *model,
|
42 | const QModelIndex &index) const; |
51 | const QModelIndex &index) const; |
43 | void updateEditorGeometry( |
52 | void updateEditorGeometry( |
44 | QWidget *editor,
|
53 | QWidget *editor,
|
45 | const QStyleOptionViewItem &option, |
54 | const QStyleOptionViewItem &option, |
46 | const QModelIndex &index) const; |
55 | const QModelIndex &index) const; |
47 | private: |
56 | private: |
48 | bool m_calpopup; |
57 | bool m_calpopup; |
49 | }; |
58 | }; |
50 | 59 | ||
51 | #endif // DELEGATE_H
|
60 | #endif // DELEGATE_H
|
52 | 61 |