Enabled clipping for DLListDelegate and ULListDelegate. The text should only be drawn in the own column.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3508 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-09-16 16:18:27 +00:00
parent a719cbce7b
commit dccfbf20b0
2 changed files with 16 additions and 2 deletions

View File

@ -55,6 +55,10 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
qlonglong completed;
qlonglong downloadtime;
// prepare
painter->save();
painter->setClipRect(opt.rect);
//set text color
QVariant value = index.data(Qt::TextColorRole);
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
@ -75,7 +79,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
} else {
value = index.data(Qt::BackgroundColorRole);
value = index.data(Qt::BackgroundRole);
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
}
@ -215,6 +219,9 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
default:
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
}
// done
painter->restore();
}
QSize DLListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const

View File

@ -48,6 +48,10 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
QString temp , status;
qlonglong transferred;
// prepare
painter->save();
painter->setClipRect(opt.rect);
//set text color
QVariant value = index.data(Qt::TextColorRole);
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
@ -68,7 +72,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
} else {
value = index.data(Qt::BackgroundColorRole);
value = index.data(Qt::BackgroundRole);
if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
painter->fillRect(option.rect, qvariant_cast<QColor>(value));
}
@ -163,6 +167,9 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
default:
painter->drawText(option.rect, Qt::AlignCenter, index.data().toString());
}
// done
painter->restore();
}
QSize ULListDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const