QHeaderView - prevent negative default+minimum section sizes
In 96f1fe8855
we agreed that sections
with negative sizes did not make sense. Of the same reason default
section sizes and minimum section sizes should be not negative.
Change-Id: I6a770e7f510d8e2bb90bfd8f38b4fa0566fc137b
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
parent
e78b3e80e6
commit
524c3e05e8
@ -1469,6 +1469,8 @@ int QHeaderView::defaultSectionSize() const
|
||||
void QHeaderView::setDefaultSectionSize(int size)
|
||||
{
|
||||
Q_D(QHeaderView);
|
||||
if (size < 0)
|
||||
return;
|
||||
d->setDefaultSectionSize(size);
|
||||
}
|
||||
|
||||
@ -1502,6 +1504,8 @@ int QHeaderView::minimumSectionSize() const
|
||||
void QHeaderView::setMinimumSectionSize(int size)
|
||||
{
|
||||
Q_D(QHeaderView);
|
||||
if (size < 0)
|
||||
return;
|
||||
d->minimumSectionSize = size;
|
||||
}
|
||||
|
||||
|
@ -338,23 +338,21 @@ void tst_QHeaderView::getSetCheck()
|
||||
|
||||
// int QHeaderView::defaultSectionSize()
|
||||
// void QHeaderView::setDefaultSectionSize(int)
|
||||
obj1.setDefaultSectionSize(-1);
|
||||
QVERIFY(obj1.defaultSectionSize() >= 0);
|
||||
obj1.setDefaultSectionSize(0);
|
||||
QCOMPARE(0, obj1.defaultSectionSize());
|
||||
obj1.setDefaultSectionSize(INT_MIN);
|
||||
QCOMPARE(INT_MIN, obj1.defaultSectionSize());
|
||||
obj1.setDefaultSectionSize(INT_MAX);
|
||||
QCOMPARE(INT_MAX, obj1.defaultSectionSize());
|
||||
// ### the test above does not make sense for values below 0
|
||||
|
||||
// int QHeaderView::minimumSectionSize()
|
||||
// void QHeaderView::setMinimumSectionSize(int)
|
||||
obj1.setMinimumSectionSize(-1);
|
||||
QVERIFY(obj1.minimumSectionSize() >= 0);
|
||||
obj1.setMinimumSectionSize(0);
|
||||
QCOMPARE(0, obj1.minimumSectionSize());
|
||||
obj1.setMinimumSectionSize(INT_MIN);
|
||||
QCOMPARE(INT_MIN, obj1.minimumSectionSize());
|
||||
obj1.setMinimumSectionSize(INT_MAX);
|
||||
QCOMPARE(INT_MAX, obj1.minimumSectionSize());
|
||||
// ### the test above does not make sense for values below 0
|
||||
|
||||
// int QHeaderView::offset()
|
||||
// void QHeaderView::setOffset(int)
|
||||
|
Loading…
Reference in New Issue
Block a user