diff --git a/layouts/boxlayout.cpp b/layouts/boxlayout.cpp index 6de09d60d..3840c1976 100644 --- a/layouts/boxlayout.cpp +++ b/layouts/boxlayout.cpp @@ -41,6 +41,7 @@ public: BoxLayout *const q; Direction direction; QList children; + bool expandingBoth; bool multiRow; int rowCount; int colCount() const { @@ -49,7 +50,7 @@ public: Private(BoxLayout *parent) : q(parent) - , direction(LeftToRight), multiRow(false) , rowCount(1) + , direction(LeftToRight), expandingBoth(false), multiRow(false) , rowCount(1) { } @@ -87,10 +88,14 @@ public: } - // returns the direction in which this layout expands + // returns the directions in which this layout expands // or shrinks - Qt::Orientation expandingDirection() const + Qt::Orientations expandingDirections() const { + if (expandingBoth) { + return Qt::Horizontal|Qt::Vertical; + } + switch (direction) { case LeftToRight: case RightToLeft: @@ -300,17 +305,7 @@ BoxLayout::~BoxLayout() Qt::Orientations BoxLayout::expandingDirections() const { - switch (d->direction) { - case LeftToRight: - case RightToLeft: - return Qt::Horizontal; - case TopToBottom: - case BottomToTop: - return Qt::Vertical; - default: - Q_ASSERT(false); - return 0; - } + return d->expandingDirections(); } int BoxLayout::count() const @@ -455,7 +450,7 @@ void BoxLayout::relayout() break; } const LayoutItem *item = d->children[f]; - const bool itemExp = (item->expandingDirections() & d->expandingDirection()); + const bool itemExp = (item->expandingDirections() & d->expandingDirections()); isExpanding = isExpanding && itemExp; minItemSize = qMax(minItemSize, d->size(item->minimumSize())); maxItemSize = qMin(maxItemSize, d->size(item->maximumSize())); @@ -556,6 +551,11 @@ void BoxLayout::setMultiRow(bool b) d->multiRow = b; } +void BoxLayout::setExpandingBoth(bool both) +{ + d->expandingBoth = both; +} + HBoxLayout::HBoxLayout(LayoutItem *parent) : BoxLayout(LeftToRight, parent) { diff --git a/layouts/boxlayout.h b/layouts/boxlayout.h index 13fd0ce08..9882d6383 100644 --- a/layouts/boxlayout.h +++ b/layouts/boxlayout.h @@ -67,9 +67,12 @@ class PLASMA_EXPORT BoxLayout : public Layout /** Inserts a new item into the layout at the specified index. */ void insertItem(int index, LayoutItem *l); - /** Set weither this layout will take severals row */ + /** Set whether this layout will take several rows */ void setMultiRow(bool b); + /** Set whether this layout will expand in both directions */ + void setExpandingBoth(bool both); + // reimplemented from Layout virtual void addItem(LayoutItem *l); virtual void removeItem(LayoutItem *l);