Rev 179 | Rev 202 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 179 | Rev 187 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | MyModel::MyModel(QObject *parent) : |
3 | MyModel::MyModel(QObject *parent) : |
4 | QSqlTableModel(parent) |
4 | QSqlTableModel(parent) |
5 | {
|
5 | {
|
6 | setEditStrategy(QSqlTableModel::OnManualSubmit); |
6 | setEditStrategy(QSqlTableModel::OnManualSubmit); |
- | 7 | icon_index = -1; |
|
7 | }
|
8 | }
|
8 | 9 | ||
9 | Qt::ItemFlags MyModel::flags( |
10 | Qt::ItemFlags MyModel::flags( |
10 | const QModelIndex &index) const { |
11 | const QModelIndex &index) const { |
11 | Qt::ItemFlags flags = QSqlTableModel::flags(index); |
12 | Qt::ItemFlags flags = QSqlTableModel::flags(index); |
Line 221... | Line 222... | ||
221 | {
|
222 | {
|
222 | return (QSqlQueryModel::data(index).toInt() != 0) ? Qt::Checked : Qt::Unchecked; |
223 | return (QSqlQueryModel::data(index).toInt() != 0) ? Qt::Checked : Qt::Unchecked; |
223 | }
|
224 | }
|
224 | }
|
225 | }
|
225 | 226 | ||
226 | case Qt::SizeHintRole:return value; |
227 | case Qt::SizeHintRole: |
- | 228 | {
|
|
227 | 229 | ||
- | 230 | int height = value.toSize().height(); |
|
- | 231 | int widht = value.toSize().width(); |
|
- | 232 | if(index.column() == icon_index) { |
|
- | 233 | QVariant currentImage = QSqlTableModel::data(index, 0); |
|
- | 234 | QByteArray bytes = currentImage.toByteArray(); |
|
- | 235 | QPixmap pxmp;
|
|
- | 236 | ||
- | 237 | ||
- | 238 | if (currentImage.isValid()) { |
|
- | 239 | pxmp.loadFromData(bytes); |
|
- | 240 | if (height < pxmp.height()) height = pxmp.height() +10; |
|
- | 241 | if (widht < pxmp.width()) widht = pxmp.width() +10; |
|
- | 242 | return QVariant(QSize(widht, height)); |
|
- | 243 | ||
- | 244 | }
|
|
- | 245 | else return value; |
|
- | 246 | ||
- | 247 | }
|
|
- | 248 | ||
- | 249 | ||
- | 250 | ||
- | 251 | return value; |
|
- | 252 | }
|
|
228 | }
|
253 | }
|
229 | return value; |
254 | return value; |
230 | }
|
255 | }
|
231 | 256 | ||
232 | 257 |