/trunk/DBViewer/delegate.cpp |
---|
280,3 → 280,48 |
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); |
*/ |
} |
/trunk/DBViewer/mainwindow.cpp |
---|
48,8 → 48,8 |
connect(ui->getsettingAct, SIGNAL(triggered()), this, SLOT(getSetting())); // âûáîð â ãëàâíîé ôîðìå â ìåíþ "Áàçà äàííûõ" ïóíêòà "Ïàðàìåòðû ñîåäèíåíèÿ" |
connect(setFrm.pushButton, SIGNAL(clicked()), this, SLOT(applySetting())); |
picture_delegate = new CPictureDelegate(this); |
} |
MainWindow::~MainWindow() |
/trunk/DBViewer/delegate.h |
---|
76,5 → 76,18 |
}; |
class CPictureDelegate : public QItemDelegate |
{ |
mutable QPixmap m_pxPicture; |
public: |
CPictureDelegate( QObject *parent ); |
void paint(QPainter *painter, const QStyleOptionViewItem &option, |
const QModelIndex &index) const; |
//QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; |
}; |
#endif // DELEGATE_H |
/trunk/DBViewer/mainwindow.h |
---|
122,6 → 122,7 |
// â êà÷åñòâå çíà÷åíèé ïîëó÷èì ñïèñîê òàáëèö-õðàíèëèù îáúåêòîâ ðîäèòåëüñêèõ êëàññîâ |
SpinBoxDelegate spinDelegate; |
QItemDelegate standart_delegate; |
CPictureDelegate * picture_delegate; |
/trunk/DBViewer/database.cpp |
---|
415,6 → 415,9 |
QString parent_class_inctance; |
QString pointer_name; |
QString filtr_tmp; |
// sql_mogel->clear(); |
ui->pushButton->setEnabled(true); |
477,6 → 480,7 |
ui->tableView->setItemDelegateForColumn(colomns_indexes.at(i), &standart_delegate ); // è ïðèñâàèâàåì ñòàíäàðòíûé äåëåãàò |
// ui->tableView->setItemDelegateForColumn(colomns_indexes.at(i), &picture_delegate); |
} |
489,6 → 493,15 |
ui->tableView->setItemDelegateForColumn(2, picture_delegate); |
ui->tableView->setRowHeight(1, 100); |
QStringList parentInctancesList = pointersList.values(); // çäåñü ñïèñîê ñîîòâåòñòâóþùèõ õðàíèëèù |
for (i=0; i < pointersNames.size(); i++){ // äëÿ âñåõ ïîëåé-óêàçàòåëåé: |