Sync QItemDelegate::doLayout with QCommonStylePrivate::viewItemLayout

QItemDelegate::doLayout added a margin after the checkbox which is not
done within QCommonStylePrivate::viewItemLayout. This created a small
but visual difference between using QItemDelegate or QStyledItemDelegate.
The additional margin was removed from viewItemLayout somehwere between
4.4 and 4.5 so it was intentional.

Change-Id: I2fc3f287fe8b181355edeebec9626c49d85fe74d
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This commit is contained in:
Christian Ehrlicher 2018-01-17 12:01:44 +01:00
parent 4944f4d57c
commit e6fa35ff14
2 changed files with 5 additions and 5 deletions

View File

@ -845,7 +845,7 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
if (option.direction == Qt::RightToLeft) { if (option.direction == Qt::RightToLeft) {
check.setRect(x + w - cw, y, cw, h); check.setRect(x + w - cw, y, cw, h);
} else { } else {
check.setRect(x + checkMargin, y, cw, h); check.setRect(x, y, cw, h);
} }
} }

View File

@ -488,7 +488,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50) << QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000) << QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400) << QRect(0, 0, 400, 400)
<< QRect(m, 0, 50 + 2*m, 1000) << QRect(0, 0, 50 + 2*m, 1000)
<< QRect(50 + 2*m, 0, 1000 + 2*m, 1000 + m) << QRect(50 + 2*m, 0, 1000 + 2*m, 1000 + m)
<< QRect(50 + 2*m, 1000 + m, 1000 + 2*m, 400); << QRect(50 + 2*m, 1000 + m, 1000 + 2*m, 400);
/* /*
@ -524,7 +524,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50) << QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000) << QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400) << QRect(0, 0, 400, 400)
<< QRect(m, 0, 50 + 2 * m, 1000) << QRect(0, 0, 50 + 2 * m, 1000)
<< QRect(50 + 2 * m, 400 + m, 1000 + 2 * m, 1000) << QRect(50 + 2 * m, 400 + m, 1000 + 2 * m, 1000)
<< QRect(50 + 2 * m, 0, 1000 + 2 * m, 400 + m); << QRect(50 + 2 * m, 0, 1000 + 2 * m, 400 + m);
@ -548,7 +548,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50) << QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000) << QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400) << QRect(0, 0, 400, 400)
<< QRect(m, 0, 50 + 2 * m, 1000) << QRect(0, 0, 50 + 2 * m, 1000)
<< QRect(50 + 2 * m, 0, 1000 + 2 * m, 1000) << QRect(50 + 2 * m, 0, 1000 + 2 * m, 1000)
<< QRect(1050 + 4 * m, 0, 400 + 2 * m, 1000); << QRect(1050 + 4 * m, 0, 400 + 2 * m, 1000);
@ -572,7 +572,7 @@ void tst_QItemDelegate::doLayout_data()
<< QRect(0, 0, 50, 50) << QRect(0, 0, 50, 50)
<< QRect(0, 0, 1000, 1000) << QRect(0, 0, 1000, 1000)
<< QRect(0, 0, 400, 400) << QRect(0, 0, 400, 400)
<< QRect(m, 0, 50 + 2 * m, 1000) << QRect(0, 0, 50 + 2 * m, 1000)
<< QRect(450 + 4 * m, 0, 1000 + 2 * m, 1000) << QRect(450 + 4 * m, 0, 1000 + 2 * m, 1000)
<< QRect(50 + 2 * m, 0, 400 + 2 * m, 1000); << QRect(50 + 2 * m, 0, 400 + 2 * m, 1000);