Rev 180 | Rev 219 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 180 | Rev 201 | ||
---|---|---|---|
1 | #ifndef DELEGATE_H
|
1 | #ifndef DELEGATE_H
|
2 | #define DELEGATE_H
|
2 | #define DELEGATE_H
|
3 | 3 | ||
4 | #include <QItemDelegate>
|
4 | #include <QItemDelegate>
|
5 | #include <QModelIndex>
|
5 | #include <QModelIndex>
|
6 | #include <QObject>
|
6 | #include <QObject>
|
7 | #include <QSize>
|
7 | #include <QSize>
|
8 | #include <QSpinBox>
|
8 | #include <QSpinBox>
|
9 | #include <QSqlQuery>
|
9 | #include <QSqlQuery>
|
10 | #include <QtSql>
|
10 | #include <QtSql>
|
11 | #include <QtGui>
|
11 | #include <QtGui>
|
12 | #include <QSqlDatabase>
|
12 | #include <QSqlDatabase>
|
13 | #include <QMessageBox>
|
13 | #include <QMessageBox>
|
14 | 14 | ||
15 | #include "iconform.h"
|
15 | #include "iconform.h"
|
- | 16 | #include "fileform.h"
|
|
16 | 17 | ||
17 | //#include <QMainWindow>
|
18 | //#include <QMainWindow>
|
18 | //! [0]
|
19 | //! [0]
|
19 | class SpinBoxDelegate : public QItemDelegate |
20 | class SpinBoxDelegate : public QItemDelegate |
20 | {
|
21 | {
|
21 | Q_OBJECT |
22 | Q_OBJECT |
22 | 23 | ||
23 | public: |
24 | public: |
24 | SpinBoxDelegate(QObject *parent = 0); |
25 | SpinBoxDelegate(QObject *parent = 0); |
25 | 26 | ||
26 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
27 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, |
27 | const QModelIndex &index) const; |
28 | const QModelIndex &index) const; |
28 | 29 | ||
29 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
30 | void setEditorData(QWidget *editor, const QModelIndex &index) const; |
30 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
31 | void setModelData(QWidget *editor, QAbstractItemModel *model, |
31 | const QModelIndex &index) const; |
32 | const QModelIndex &index) const; |
32 | 33 | ||
33 | void updateEditorGeometry(QWidget *editor, |
34 | void updateEditorGeometry(QWidget *editor, |
34 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
35 | const QStyleOptionViewItem &option, const QModelIndex &index) const; |
35 | 36 | ||
36 | 37 | ||
37 | 38 | ||
38 | void setInctance(QString newInctance); |
39 | void setInctance(QString newInctance); |
39 | void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê |
40 | void getItems(); // ïîëó÷àåì ñâÿçàííûé ñïèñîê |
40 | 41 | ||
41 | 42 | ||
42 | 43 | ||
43 | 44 | ||
44 | private: |
45 | private: |
45 | 46 | ||
46 | 47 | ||
47 | QString inctance; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê |
48 | QString inctance; // òàáëèöà-õðàíèëèùå, îòêóäà áóäåì áðàòü ñïèñîê |
48 | QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID |
49 | QMap <QString, QString> items; // çäåñü áóäåì õðàíèòü ñâÿçàííûé ñïèñîê èìåò îáúåêòîâ è èõ èäåíòèôèêàòîðîâ ID |
49 | 50 | ||
50 | 51 | ||
51 | 52 | ||
52 | 53 | ||
53 | 54 | ||
54 | 55 | ||
55 | 56 | ||
56 | }; |
57 | }; |
57 | //! [0]
|
58 | //! [0]
|
58 | 59 | ||
59 | class MyDEDelegate : public QItemDelegate { |
60 | class MyDEDelegate : public QItemDelegate { |
60 | Q_OBJECT |
61 | Q_OBJECT |
61 | public: |
62 | public: |
62 | MyDEDelegate(bool calpopup = true, |
63 | MyDEDelegate(bool calpopup = true, |
63 | QObject *parent = 0); |
64 | QObject *parent = 0); |
64 | QWidget *createEditor( |
65 | QWidget *createEditor( |
65 | QWidget *parent,
|
66 | QWidget *parent,
|
66 | const QStyleOptionViewItem &option, |
67 | const QStyleOptionViewItem &option, |
67 | const QModelIndex &index) const; |
68 | const QModelIndex &index) const; |
68 | void setEditorData(QWidget *editor, |
69 | void setEditorData(QWidget *editor, |
69 | const QModelIndex &index) const; |
70 | const QModelIndex &index) const; |
70 | void setModelData(QWidget *editor, |
71 | void setModelData(QWidget *editor, |
71 | QAbstractItemModel *model,
|
72 | QAbstractItemModel *model,
|
72 | const QModelIndex &index) const; |
73 | const QModelIndex &index) const; |
73 | void updateEditorGeometry( |
74 | void updateEditorGeometry( |
74 | QWidget *editor,
|
75 | QWidget *editor,
|
75 | const QStyleOptionViewItem &option, |
76 | const QStyleOptionViewItem &option, |
76 | const QModelIndex &index) const; |
77 | const QModelIndex &index) const; |
77 | private: |
78 | private: |
78 | bool m_calpopup; |
79 | bool m_calpopup; |
79 | }; |
80 | }; |
80 | 81 | ||
81 | 82 | ||
82 | class CPictureDelegate : public QItemDelegate |
83 | class CPictureDelegate : public QItemDelegate |
83 | {
|
84 | {
|
84 | mutable QPixmap m_pxPicture;
|
85 | mutable QPixmap m_pxPicture;
|
85 | public: |
86 | public: |
86 | CPictureDelegate( QObject *parent ); |
87 | CPictureDelegate( QObject *parent ); |
87 | 88 | ||
88 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
89 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
89 | const QModelIndex &index) const; |
90 | const QModelIndex &index) const; |
90 | 91 | ||
91 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
92 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
92 | }; |
93 | }; |
93 | 94 | ||
94 | 95 | ||
95 | class IconDelegate : public QItemDelegate |
96 | class IconDelegate : public QItemDelegate |
96 | {
|
97 | {
|
97 | mutable QPixmap m_pxPicture;
|
98 | mutable QPixmap m_pxPicture;
|
98 | private: |
99 | private: |
99 | QTableView *tblView; |
100 | QTableView *tblView; |
100 | 101 | ||
101 | public: |
102 | public: |
102 | IconDelegate ( QObject *parent ); |
103 | IconDelegate ( QObject *parent ); |
103 | 104 | ||
104 | QWidget *createEditor( |
105 | QWidget *createEditor( |
105 | QWidget *parent,
|
106 | QWidget *parent,
|
106 | const QStyleOptionViewItem &option, |
107 | const QStyleOptionViewItem &option, |
107 | const QModelIndex &index) const; |
108 | const QModelIndex &index) const; |
108 | 109 | ||
109 | void setEditorData(QWidget *editor, |
110 | void setEditorData(QWidget *editor, |
110 | const QModelIndex &index) const; |
111 | const QModelIndex &index) const; |
111 | 112 | ||
112 | void setModelData(QWidget *editor, |
113 | void setModelData(QWidget *editor, |
113 | QAbstractItemModel *model,
|
114 | QAbstractItemModel *model,
|
114 | const QModelIndex &index) const; |
115 | const QModelIndex &index) const; |
115 | 116 | ||
116 | 117 | ||
117 | void updateEditorGeometry( |
118 | void updateEditorGeometry( |
118 | QWidget *editor,
|
119 | QWidget *editor,
|
119 | const QStyleOptionViewItem &option, |
120 | const QStyleOptionViewItem &option, |
120 | const QModelIndex &index) const; |
121 | const QModelIndex &index) const; |
121 | 122 | ||
122 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
123 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
123 | const QModelIndex &index) const; |
124 | const QModelIndex &index) const; |
124 | 125 | ||
125 | void setTableView(QTableView* table); |
126 | void setTableView(QTableView* table); |
126 | 127 | ||
127 | 128 | ||
128 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
129 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
129 | }; |
130 | }; |
130 | 131 | ||
- | 132 | class FileDelegate : public QItemDelegate |
|
- | 133 | {
|
|
- | 134 | mutable QByteArray m_Data;
|
|
- | 135 | private: |
|
- | 136 | // QTableView *tblView;
|
|
- | 137 | ||
- | 138 | public: |
|
- | 139 | FileDelegate ( QObject *parent ); |
|
- | 140 | ||
- | 141 | QWidget *createEditor( |
|
- | 142 | QWidget *parent,
|
|
- | 143 | const QStyleOptionViewItem &option, |
|
- | 144 | const QModelIndex &index) const; |
|
- | 145 | ||
- | 146 | void setEditorData(QWidget *editor, |
|
- | 147 | const QModelIndex &index) const; |
|
- | 148 | ||
- | 149 | void setModelData(QWidget *editor, |
|
- | 150 | QAbstractItemModel *model,
|
|
- | 151 | const QModelIndex &index) const; |
|
131 | 152 | ||
132 | 153 | ||
- | 154 | void updateEditorGeometry( |
|
- | 155 | QWidget *editor,
|
|
- | 156 | const QStyleOptionViewItem &option, |
|
- | 157 | const QModelIndex &index) const; |
|
- | 158 | ||
- | 159 | /*
|
|
- | 160 | void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
|
- | 161 | const QModelIndex &index) const;
|
|
- | 162 | */
|
|
- | 163 | ||
- | 164 | ||
- | 165 | ||
- | 166 | // void setTableView(QTableView* table);
|
|
- | 167 | ||
- | 168 | ||
- | 169 | //QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
- | 170 | }; |
|
- | 171 | ||
133 | class TimeEditDelegate : public QItemDelegate |
172 | class TimeEditDelegate : public QItemDelegate |
134 | {
|
173 | {
|
135 | Q_OBJECT |
174 | Q_OBJECT |
136 | 175 | ||
137 | public: |
176 | public: |
138 | TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;}; |
177 | TimeEditDelegate(const QString timeFormat = "dd.MM.yyyy hh:mm:ss",QObject *parent = 0) : QItemDelegate(parent) {this->timeformat = timeFormat;}; |
139 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
178 | void paint(QPainter *painter, const QStyleOptionViewItem &option, |
140 | const QModelIndex &index) const; |
179 | const QModelIndex &index) const; |
141 | 180 | ||
142 | private: |
181 | private: |
143 | QString timeformat;
|
182 | QString timeformat;
|
144 | }; |
183 | }; |
145 | 184 | ||
146 | 185 | ||
147 | #endif // DELEGATE_H
|
186 | #endif // DELEGATE_H
|
148 | 187 |