add support for fixed-size columns. default behavious remains to average item widths.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=733293
This commit is contained in:
parent
845139ae0a
commit
d83f52e2db
@ -34,8 +34,10 @@ using namespace Plasma;
|
|||||||
class FlowLayout::Private
|
class FlowLayout::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Private() : columnWidth( -1 ) {}
|
||||||
QList<LayoutItem*> items;
|
QList<LayoutItem*> items;
|
||||||
QRectF geometry;
|
QRectF geometry;
|
||||||
|
qreal columnWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
FlowLayout::FlowLayout(LayoutItem* parent)
|
FlowLayout::FlowLayout(LayoutItem* parent)
|
||||||
@ -128,7 +130,11 @@ void FlowLayout::setGeometry(const QRectF& geo)
|
|||||||
// Also include the spacing either side of each item as part of the
|
// Also include the spacing either side of each item as part of the
|
||||||
// average width, this provides the spacing between the items and
|
// average width, this provides the spacing between the items and
|
||||||
// also allows some tolerance for small differences in item widths
|
// also allows some tolerance for small differences in item widths
|
||||||
const qreal averageWidth = totalWidth / d->items.count() + 2*spacing();
|
qreal averageWidth;
|
||||||
|
if( d->columnWidth == -1 )
|
||||||
|
averageWidth = totalWidth / d->items.count() + 2*spacing();
|
||||||
|
else
|
||||||
|
averageWidth = d->columnWidth;
|
||||||
|
|
||||||
const int columnCount = (int)(geometry.width() / averageWidth);
|
const int columnCount = (int)(geometry.width() / averageWidth);
|
||||||
|
|
||||||
@ -201,3 +207,12 @@ Qt::Orientations FlowLayout::expandingDirections() const
|
|||||||
return Qt::Vertical | Qt::Horizontal;
|
return Qt::Vertical | Qt::Horizontal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal FlowLayout::columnWidth() const
|
||||||
|
{
|
||||||
|
return d->columnWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlowLayout::setColumnWidth( const qreal width )
|
||||||
|
{
|
||||||
|
d->columnWidth = width;
|
||||||
|
}
|
||||||
|
@ -52,6 +52,8 @@ public:
|
|||||||
virtual QRectF geometry() const;
|
virtual QRectF geometry() const;
|
||||||
virtual void setGeometry(const QRectF& geometry);
|
virtual void setGeometry(const QRectF& geometry);
|
||||||
virtual Qt::Orientations expandingDirections() const;
|
virtual Qt::Orientations expandingDirections() const;
|
||||||
|
virtual void setColumnWidth( const qreal width );
|
||||||
|
virtual qreal columnWidth() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
Loading…
Reference in New Issue
Block a user