Редакция 136 | Редакция 158 | К новейшей редакции | Весь файл | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 136 | Редакция 138 | ||
---|---|---|---|
Строка 278... | Строка 278... | ||
278 | QWidget *editor,
|
278 | QWidget *editor,
|
279 | const QStyleOptionViewItem &option, |
279 | const QStyleOptionViewItem &option, |
280 | const QModelIndex& /* index */) const { |
280 | const QModelIndex& /* index */) const { |
281 | editor->setGeometry(option.rect); |
281 | editor->setGeometry(option.rect); |
282 | }
|
282 | }
|
- | 283 | ||
- | 284 | ||
- | 285 | ||
- | 286 | ||
- | 287 | ||
- | 288 | CPictureDelegate::CPictureDelegate( QObject * parent ) : QItemDelegate(parent) |
|
- | 289 | {
|
|
- | 290 | }
|
|
- | 291 | ||
- | 292 | void CPictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
|
- | 293 | {
|
|
- | 294 | m_pxPicture.fill( QColor(Qt::white) ); |
|
- | 295 | ||
- | 296 | const QAbstractItemModel * model = index.model(); |
|
- | 297 | QString sFileName = model->data( index, Qt::DisplayRole ).toString(); |
|
- | 298 | ||
- | 299 | if ( !sFileName.isEmpty() ) |
|
- | 300 | m_pxPicture.load( sFileName ); |
|
- | 301 | else { |
|
- | 302 | //QItemDelegate::paint(painter, option, index);
|
|
- | 303 | return; |
|
- | 304 | }
|
|
- | 305 | ||
- | 306 | QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ? |
|
- | 307 | ((option.state & QStyle::State_Active) ? QPalette::Normal : QPalette::Inactive ) : |
|
- | 308 | QPalette::Disabled; |
|
- | 309 | ||
- | 310 | if (option.state & QStyle::State_Selected) |
|
- | 311 | painter->fillRect(option.rect, option.palette.color(cg, QPalette::Highlight)); |
|
- | 312 | ||
- | 313 | int nX = option.rect.x() + ( ( option.rect.width() - m_pxPicture.rect().width() ) / 2 ); |
|
- | 314 | int nY = option.rect.y() + ( ( option.rect.height() - m_pxPicture.rect().height() ) / 2 ); |
|
- | 315 | painter->drawPixmap( nX, nY, m_pxPicture ); |
|
- | 316 | ||
- | 317 | ||
- | 318 | //// drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); // since we draw the grid ourselves
|
|
- | 319 | ||
- | 320 | /*
|
|
- | 321 | QPen pen = painter->pen();
|
|
- | 322 | painter->setPen(option.palette.color(QPalette::Mid));
|
|
- | 323 | painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
|
|
- | 324 | painter->drawLine(option.rect.topRight(), option.rect.bottomRight());
|
|
- | 325 | painter->setPen(pen);
|
|
- | 326 | */
|
|
- | 327 | }
|