diff --git a/src/private/multisplitter/Item.cpp b/src/private/multisplitter/Item.cpp index 886d4c5e..3b040dd1 100644 --- a/src/private/multisplitter/Item.cpp +++ b/src/private/multisplitter/Item.cpp @@ -60,7 +60,8 @@ inline Qt::Orientation orientationForLocation(Item::Location loc) return Qt::Vertical; } -inline Qt::Orientation oppositeOrientation(Qt::Orientation o) { +inline Qt::Orientation oppositeOrientation(Qt::Orientation o) +{ return o == Qt::Vertical ? Qt::Horizontal : Qt::Vertical; } @@ -76,6 +77,22 @@ inline QRect adjustedRect(QRect r, Qt::Orientation o, int p1, int p2) return r; } +namespace Layouting { +struct LengthOnSide +{ + int length = 0; + int minLength = 0; + + int available() const { + return qMax(0, length - minLength); + } + + int missing() const { + return qMax(0, minLength - length); + } +}; +} + ItemContainer *Item::root() const { return m_parent ? m_parent->root() @@ -2330,8 +2347,8 @@ int ItemContainer::availableLength() const : availableSize().width(); } -ItemContainer::LengthOnSide ItemContainer::lengthOnSide(const SizingInfo::List &sizes, int fromIndex, - Side side, Qt::Orientation o) const +LengthOnSide ItemContainer::lengthOnSide(const SizingInfo::List &sizes, int fromIndex, + Side side, Qt::Orientation o) const { if (fromIndex < 0) return {}; @@ -2455,17 +2472,6 @@ int ItemContainer::availableOnSide_recursive(const Item *child, Side side, Qt::O } } -QVariantList ItemContainer::items() const -{ - QVariantList items; - items.reserve(d->m_children.size()); - - for (auto item : d->m_children) - items << QVariant::fromValue(item); - - return items; -} - void ItemContainer::growNeighbours(Item *side1Neighbour, Item *side2Neighbour) { if (!side1Neighbour && !side2Neighbour) diff --git a/src/private/multisplitter/Item_p.h b/src/private/multisplitter/Item_p.h index 2e492467..0cf2f95e 100644 --- a/src/private/multisplitter/Item_p.h +++ b/src/private/multisplitter/Item_p.h @@ -45,6 +45,7 @@ class ItemContainer; class Item; class Separator; class GuestInterface; +class LengthOnSide; enum Side { Side1, @@ -361,24 +362,10 @@ private: GuestInterface *m_guest = nullptr; }; -class ItemContainer : public Item { +class ItemContainer : public Item +{ Q_OBJECT - Q_PROPERTY(QVariantList items READ items NOTIFY itemsChanged) public: - - struct LengthOnSide { - int length = 0; - int minLength = 0; - - int available() const { - return qMax(0, length - minLength); - } - - int missing() const { - return qMax(0, minLength - length); - } - }; - explicit ItemContainer(QWidget *hostWidget, ItemContainer *parent); explicit ItemContainer(QWidget *parent); ~ItemContainer(); @@ -432,7 +419,6 @@ private: void setOrientation(Qt::Orientation); int length() const; QRect rect() const; - QVariantList items() const; void updateChildPercentages(); void updateChildPercentages_recursive(); void updateWidgetGeometries() override; @@ -450,7 +436,10 @@ private: ///@brief grows an item by @p amount. It calculates how much to grow on side1 and on side2 ///Then calls growItem(item, side1Growth, side2Growth) which will effectively grow it, ///and shrink the neighbours which are donating the size. - void growItem(Item *, int amount, GrowthStrategy, NeighbourSqueezeStrategy neighbourSqueezeStrategy, bool accountForNewSeparator = false, ChildrenResizeStrategy = ChildrenResizeStrategy::Percentage); + void growItem(Item *, int amount, GrowthStrategy, + NeighbourSqueezeStrategy neighbourSqueezeStrategy, + bool accountForNewSeparator = false, + ChildrenResizeStrategy = ChildrenResizeStrategy::Percentage); void growItem(int index, SizingInfo::List &sizes, int missing, GrowthStrategy, NeighbourSqueezeStrategy neighbourSqueezeStrategy, bool accountForNewSeparator = false);