|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to this, the behaviour of count(), itemAt() and removeAt() was
different between QGraphicsLinearLayout and QGraphicsGridLayout.
QGraphicsGridLayout does it right.
This adds some behaviour changes:
1. QGraphicsLinearLayout::count() is no longer affected by inserted
stretches (through insertStretch)
This means that code like this will break:
QGraphicsLinearLayout *linearLayout = new QGraphicsLinearLayout;
linearLayout->addItem(new QGraphicsWidget);
linearLayout->addStretch();
int count = linearLayout->count();
linearLayout->removeAt(count - 1);
// before this patch it would do nothing (and it wouldn't
// actually remove the stretch), with the new patch it would
// remove the QGraphicsWidget.
2. count(), itemAt() and removeAt() now prints a warning for an invalid
index.
The documentation actually says that "The reimplementation can assume
that index is valid (i.e., it respects the value of count()", but I
decided that its too risky to not assume that it is valid, since it
would break the following common pattern:
while(layout->itemAt(0)) {
layout->removeAt(0);
}
Cleaned up autotests (and a small codeblock) that assumed
itemAt/removeAt with an invalid index to work, since we should try to
follow our own advice. :-)
This change is also an alignment with what QGraphicsGridLayout does
(it checks the index argument and prints a warning too.)
|