Also simplify layouts that only have 1 child
Those have any orientation, so can be simplified, as its "orientation" matches its parent one
This commit is contained in:
@@ -3136,7 +3136,7 @@ void ItemContainer::simplify()
|
||||
if (ItemContainer *childContainer = child->asContainer()) {
|
||||
childContainer->simplify(); // recurse down the hierarchy
|
||||
|
||||
if (childContainer->orientation() == d->m_orientation) {
|
||||
if (childContainer->orientation() == d->m_orientation || childContainer->d->m_children.size() == 1) {
|
||||
// This sub-container is reduntant, as it has the same orientation as its parent
|
||||
// Canibalize it.
|
||||
for (Item *child2 : childContainer->childItems()) {
|
||||
|
||||
@@ -1066,6 +1066,7 @@ void TestMultiSplitter::tst_misc2()
|
||||
Item *item3 = root3->childItems().constFirst();
|
||||
ItemContainer *root4 = createRootWithSingleItem();
|
||||
ItemContainer *root5 = createRootWithSingleItem();
|
||||
Item *item5 = root5->childItems().constFirst();
|
||||
|
||||
root->insertItem(root1, Item::Location_OnTop);
|
||||
QVERIFY(root->checkSanity());
|
||||
@@ -1079,7 +1080,7 @@ void TestMultiSplitter::tst_misc2()
|
||||
root->insertItem(root5, Item::Location_OnLeft);
|
||||
QVERIFY(root->checkSanity());
|
||||
|
||||
root5->parentContainer()->removeItem(root5);
|
||||
item5->parentContainer()->removeItem(item5);
|
||||
QVERIFY(root->checkSanity());
|
||||
QVERIFY(serializeDeserializeTest(root));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user