diff --git a/containment/plugin/layoutmanager.cpp b/containment/plugin/layoutmanager.cpp index d74403a08..640849840 100644 --- a/containment/plugin/layoutmanager.cpp +++ b/containment/plugin/layoutmanager.cpp @@ -514,83 +514,38 @@ void LayoutManager::save() reorderParabolicSpacers(); - int startChilds{0}; - for(int i=0; ichildItems().count(); ++i) { - QQuickItem *item = m_startLayout->childItems()[i]; - bool isInternalSplitter = item->property("isInternalViewSplitter").toBool(); - bool isParabolicEdgeSpacer = item->property("isParabolicEdgeSpacer").toBool(); - if (!isInternalSplitter && !isParabolicEdgeSpacer) { - QVariant appletVariant = item->property("applet"); - if (!appletVariant.isValid()) { - continue; - } - - QObject *applet = appletVariant.value(); - - if (!applet) { - continue; - } - - uint id = applet->property("id").toUInt(); - - if (id>0) { - startChilds++; - appletIds << id; - } - } - } - - int mainChilds{0}; - for(int i=0; ichildItems().count(); ++i) { - QQuickItem *item = m_mainLayout->childItems()[i]; - bool isInternalSplitter = item->property("isInternalViewSplitter").toBool(); - bool isParabolicEdgeSpacer = item->property("isParabolicEdgeSpacer").toBool(); - if (!isInternalSplitter && !isParabolicEdgeSpacer) { - QVariant appletVariant = item->property("applet"); - if (!appletVariant.isValid()) { - continue; - } + auto collectLayoutAppletIds = [](QQuickItem *layout, QList &appletIds) { + int childCount = 0; + for (int i=0; ichildItems().count(); ++i) { + QQuickItem *item = layout->childItems()[i]; + bool isInternalSplitter = item->property("isInternalViewSplitter").toBool(); + bool isParabolicEdgeSpacer = item->property("isParabolicEdgeSpacer").toBool(); + if (!isInternalSplitter && !isParabolicEdgeSpacer) { + QVariant appletVariant = item->property("applet"); + if (!appletVariant.isValid()) { + continue; + } - QObject *applet = appletVariant.value(); + QObject *applet = appletVariant.value(); - if (!applet) { - continue; - } + if (!applet) { + continue; + } - uint id = applet->property("id").toUInt(); + uint id = applet->property("id").toUInt(); - if (id>0) { - mainChilds++; - appletIds << id; + if (id>0) { + childCount++; + appletIds << id; + } } } - } + return childCount; + }; - int endChilds{0}; - for(int i=0; ichildItems().count(); ++i) { - QQuickItem *item = m_endLayout->childItems()[i]; - bool isInternalSplitter = item->property("isInternalViewSplitter").toBool(); - bool isParabolicEdgeSpacer = item->property("isParabolicEdgeSpacer").toBool(); - if (!isInternalSplitter && !isParabolicEdgeSpacer) { - QVariant appletVariant = item->property("applet"); - if (!appletVariant.isValid()) { - continue; - } - - QObject *applet = appletVariant.value(); - - if (!applet) { - continue; - } - - uint id = applet->property("id").toUInt(); - - if (id>0) { - endChilds++; - appletIds << id; - } - } - } + int startChilds = collectLayoutAppletIds(m_startLayout, appletIds); + int mainChilds = collectLayoutAppletIds(m_mainLayout, appletIds); + int endChilds = collectLayoutAppletIds(m_endLayout, appletIds); Latte::Types::Alignment alignment = static_cast((*m_configuration)["alignment"].toInt());