QListView: Honor css :first/:middle/:last Pseudo-States
Properly set QStyleOptionViewItem::viewItemPosition to honor the css Pseudo-States. Task-number: QTBUG-27110 Change-Id: I9b9bb4913210feb665fd9d00a71dc4a953a93606 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
This commit is contained in:
parent
daabb8f63d
commit
1aa3edf3f8
@ -980,9 +980,18 @@ void QListView::paintEvent(QPaintEvent *e)
|
||||
? qMax(viewport()->size().width(), d->contentsSize().width()) - 2 * d->spacing()
|
||||
: qMax(viewport()->size().height(), d->contentsSize().height()) - 2 * d->spacing();
|
||||
|
||||
const int rowCount = d->commonListView->rowCount();
|
||||
QVector<QModelIndex>::const_iterator end = toBeRendered.constEnd();
|
||||
for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end; ++it) {
|
||||
Q_ASSERT((*it).isValid());
|
||||
if (rowCount == 1)
|
||||
option.viewItemPosition = QStyleOptionViewItem::OnlyOne;
|
||||
else if ((*it).row() == 0)
|
||||
option.viewItemPosition = QStyleOptionViewItem::Beginning;
|
||||
else if ((*it).row() == rowCount - 1)
|
||||
option.viewItemPosition = QStyleOptionViewItem::End;
|
||||
else
|
||||
option.viewItemPosition = QStyleOptionViewItem::Middle;
|
||||
option.rect = visualRect(*it);
|
||||
|
||||
if (flow() == TopToBottom)
|
||||
|
Loading…
Reference in New Issue
Block a user