added the function setExpandingBoth(bool) that makes the layout to expand in both directions, useful for instance if you put an horizontal layout into a vertical layout
oh, and fixed a typo in a comment svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=767568
This commit is contained in:
parent
e3bddd25de
commit
c395cc03bb
@ -41,6 +41,7 @@ public:
|
||||
BoxLayout *const q;
|
||||
Direction direction;
|
||||
QList<LayoutItem*> 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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user