From 74e2ce31ffc6448ee0f847a87e70bbdec58c5ec0 Mon Sep 17 00:00:00 2001 From: Bill Egert Date: Wed, 20 Feb 2008 03:00:26 +0000 Subject: [PATCH] Make some better decisions. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=777237 --- layouts/flowlayout.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/layouts/flowlayout.cpp b/layouts/flowlayout.cpp index 4fe4f01b8..1e1e86eac 100644 --- a/layouts/flowlayout.cpp +++ b/layouts/flowlayout.cpp @@ -152,7 +152,7 @@ void FlowLayout::relayout() qreal colWidth = 0; qreal rowHeight = 0; qreal maxItemWidth = 0; - //qreal minItemWidth = 0; + qreal minItemWidth = 0; //qreal maxItemHeight = 0; qreal minItemHeight = 0; int colCnt = 0; @@ -161,8 +161,8 @@ void FlowLayout::relayout() foreach(LayoutItem *item , d->items) { maxItemWidth = (maxItemWidth < item->maximumSize().width()) ? item->maximumSize().width() : maxItemWidth; - //minItemWidth = (minItemWidth < item->minimumSize().width()) ? - // item->minimumSize().width() : minItemWidth; + minItemWidth = (minItemWidth < item->minimumSize().width()) ? + item->minimumSize().width() : minItemWidth; //maxItemHeight = (maxItemHeight < item->maximumSize().height()) ? // item->maximumSize().height() : maxItemHeight; minItemHeight = (minItemHeight < item->minimumSize().height()) ? @@ -172,9 +172,12 @@ void FlowLayout::relayout() const int rowMax = ((minItemHeight != 0) && (minItemHeight != rectHeight)) ? (int)(rectHeight / (minItemHeight + space)) : 1; - if( maxItemWidth == 0) { - kDebug() << "******POSSIBLE DIVIDE BY ZERO: maxItemWidth ********"; - maxItemWidth = 20; + if( maxItemWidth == 0 && minItemWidth != 0 ) { + kDebug() << "******POSSIBLE DIVIDE BY ZERO: maxItemWidth = minItemWidth ********"; + maxItemWidth = minItemWidth + space; + } else if( maxItemWidth == 0 && minItemWidth == 0 ) { + kDebug() << "******POSSIBLE DIVIDE BY ZERO: maxItemWidth = rectWidth ********"; + maxItemWidth = rectWidth + space; } // try to use the maxwidth if there is room