Редакция 163 | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 163 | Редакция 165 | ||
---|---|---|---|
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 <QSqlQuery>
|
6 | #include <QObject>
|
6 | #include <QObject>
|
7 | #include <QSize>
|
7 | #include <QSize>
|
8 | #include <QSpinBox>
|
8 | #include <QSpinBox>
|
9 | #include <QMap>
|
9 | #include <QMap>
|
- | 10 | #include <QTableView>
|
|
- | 11 | ||
10 | #include "iconform.h"
|
12 | #include "iconform.h"
|
11 | 13 | ||
12 | //! [0]
|
14 | //! [0]
|
13 | class SpinBoxDelegate : public QItemDelegate |
15 | class SpinBoxDelegate : public QItemDelegate |
14 | {
|
16 | {
|
15 | Q_OBJECT |
17 | Q_OBJECT |
16 | 18 | ||
17 | public: |
19 | public: |
18 | SpinBoxDelegate(QObject *parent = 0); |
20 | SpinBoxDelegate(QObject *parent = 0); |
19 | 21 | ||
20 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
22 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
21 | const QModelIndex &index) const; |
23 | const QModelIndex &index) const; |
22 | 24 | ||
23 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
25 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
24 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
26 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
25 | const QModelIndex &index) const; |
27 | const QModelIndex &index) const; |
26 | 28 | ||
27 | void updateEditorGeometry(QWidget *editor, |
29 | void updateEditorGeometry(QWidget *editor, |
28 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
30 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
29 | 31 | ||
30 | void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê |
32 | void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê |
31 | 33 | ||
32 | private: |
34 | private: |
33 | QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID |
35 | QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID |
34 | 36 | ||
35 | 37 | ||
36 | }; |
38 | }; |
37 | //! [0]
|
39 | //! [0]
|
38 | 40 | ||
39 | class MyDEDelegate : public QItemDelegate { |
41 | class MyDEDelegate : public QItemDelegate { |
40 | Q_OBJECT |
42 | Q_OBJECT |
41 | public: |
43 | public: |
42 | MyDEDelegate(bool calpopup = true, |
44 | MyDEDelegate(bool calpopup = true, |
43 | QObject *parent = 0); |
45 | QObject *parent = 0); |
44 | QWidget *createEditor( |
46 | QWidget *createEditor( |
45 | QWidget *parent,
|
47 | QWidget *parent,
|
46 | const QStyleOptionViewItem &option, |
48 | const QStyleOptionViewItem &option, |
47 | const QModelIndex &index) const; |
49 | const QModelIndex &index) const; |
48 | void setEditorData(QWidget *editor, |
50 | void setEditorData(QWidget *editor, |
49 | const QModelIndex &index) const; |
51 | const QModelIndex &index) const; |
50 | void setModelData(QWidget *editor, |
52 | void setModelData(QWidget *editor, |
51 | QAbstractItemModel *model,
|
53 | QAbstractItemModel *model,
|
52 | const QModelIndex &index) const; |
54 | const QModelIndex &index) const; |
53 | void updateEditorGeometry( |
55 | void updateEditorGeometry( |
54 | QWidget *editor,
|
56 | QWidget *editor,
|
55 | const QStyleOptionViewItem &option, |
57 | const QStyleOptionViewItem &option, |
56 | const QModelIndex &index) const; |
58 | const QModelIndex &index) const; |
57 | private: |
59 | private: |
58 | bool m_calpopup; |
60 | bool m_calpopup; |
59 | }; |
61 | }; |
60 | 62 | ||
61 | 63 | ||
62 | class CPictureDelegate : public QItemDelegate |
64 | class CPictureDelegate : public QItemDelegate |
63 | {
|
65 | {
|
64 | mutable QPixmap m_pxPicture;
|
66 | mutable QPixmap m_pxPicture;
|
- | 67 | private: |
|
- | 68 | QTableView *tblView; |
|
- | 69 | ||
65 | public: |
70 | public: |
66 | CPictureDelegate( QObject *parent ); |
71 | CPictureDelegate( QObject *parent ); |
67 | 72 | ||
- | 73 | QWidget *createEditor( |
|
- | 74 | QWidget *parent,
|
|
- | 75 | const QStyleOptionViewItem &option, |
|
- | 76 | const QModelIndex &index) const; |
|
- | 77 | ||
- | 78 | void setEditorData(QWidget *editor, |
|
- | 79 | const QModelIndex &index) const; |
|
- | 80 | ||
- | 81 | void setModelData(QWidget *editor, |
|
- | 82 | QAbstractItemModel *model,
|
|
- | 83 | const QModelIndex &index) const; |
|
- | 84 | ||
- | 85 | ||
- | 86 | void updateEditorGeometry( |
|
- | 87 | QWidget *editor,
|
|
- | 88 | const QStyleOptionViewItem &option, |
|
- | 89 | const QModelIndex &index) const; |
|
- | 90 | ||
68 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
91 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
69 | const QModelIndex &index) const; |
92 | const QModelIndex &index) const; |
70 | 93 | ||
- | 94 | void setTableView(QTableView* table); |
|
- | 95 | ||
- | 96 | ||
71 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
97 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
72 | }; |
98 | }; |
73 | 99 | ||
74 | 100 | ||
75 | 101 | ||
76 | 102 | ||
77 | #endif // DELEGATE_H
|
103 | #endif // DELEGATE_H
|
78 | 104 |