Хранилища Subversion OpenInventory

Сравнить редакции

Не учитывать пробелы Редакция 138 → Редакция 137

/trunk/DBViewer/delegate.cpp
280,48 → 280,3
const QModelIndex& /* index */) const {
editor->setGeometry(option.rect);
}
 
 
 
 
 
CPictureDelegate::CPictureDelegate( QObject * parent ) : QItemDelegate(parent)
{
}
 
void CPictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
m_pxPicture.fill( QColor(Qt::white) );
 
const QAbstractItemModel * model = index.model();
QString sFileName = model->data( index, Qt::DisplayRole ).toString();
 
if ( !sFileName.isEmpty() )
m_pxPicture.load( sFileName );
else {
//QItemDelegate::paint(painter, option, index);
return;
}
 
QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ?
((option.state & QStyle::State_Active) ? QPalette::Normal : QPalette::Inactive ) :
QPalette::Disabled;
 
if (option.state & QStyle::State_Selected)
painter->fillRect(option.rect, option.palette.color(cg, QPalette::Highlight));
 
int nX = option.rect.x() + ( ( option.rect.width() - m_pxPicture.rect().width() ) / 2 );
int nY = option.rect.y() + ( ( option.rect.height() - m_pxPicture.rect().height() ) / 2 );
painter->drawPixmap( nX, nY, m_pxPicture );
 
 
//// drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); // since we draw the grid ourselves
 
/*
QPen pen = painter->pen();
painter->setPen(option.palette.color(QPalette::Mid));
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
painter->drawLine(option.rect.topRight(), option.rect.bottomRight());
painter->setPen(pen);
*/
}