LayoutAnimator indirectly calls relayout() so calling startAnimation() in

relayout() is almost an infinite loop. Instead, only call startAnimation()
when an item has actually been added or removed.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=748736
This commit is contained in:
Jason Stubbs 2007-12-15 09:08:09 +00:00
parent ec76079031
commit 933932ddb4
2 changed files with 11 additions and 5 deletions

View File

@ -309,6 +309,7 @@ void BoxLayout::insertItem(int index, LayoutItem *item)
} }
updateGeometry(); updateGeometry();
startAnimation();
} }
void BoxLayout::addItem(LayoutItem *item) void BoxLayout::addItem(LayoutItem *item)
@ -334,6 +335,7 @@ void BoxLayout::removeItem(LayoutItem *item)
} }
updateGeometry(); updateGeometry();
startAnimation();
} }
int BoxLayout::indexOf(LayoutItem *l) const int BoxLayout::indexOf(LayoutItem *l) const
@ -357,6 +359,8 @@ LayoutItem *BoxLayout::takeAt(int i)
} }
return d->children.takeAt(i); return d->children.takeAt(i);
// FIXME: This is never reached. Should it be called? Should
// startAnimation() also be called?
updateGeometry(); updateGeometry();
} }
@ -442,8 +446,6 @@ void BoxLayout::relayout()
pos = d->layoutItem(margined, d->children[i], pos , sizes[i]); pos = d->layoutItem(margined, d->children[i], pos , sizes[i]);
} }
startAnimation();
} }

View File

@ -61,13 +61,15 @@ void FlowLayout::addItem(LayoutItem* item)
return; return;
} }
item->setManagingLayout(this);
d->items << item; d->items << item;
if (animator()) { if (animator()) {
animator()->setCurrentState(item,LayoutAnimator::InsertedState); animator()->setCurrentState(item,LayoutAnimator::InsertedState);
} }
item->setManagingLayout(this); updateGeometry();
startAnimation();
} }
void FlowLayout::removeItem(LayoutItem* item) void FlowLayout::removeItem(LayoutItem* item)
{ {
@ -81,6 +83,9 @@ void FlowLayout::removeItem(LayoutItem* item)
if (animator()) { if (animator()) {
animator()->setCurrentState(item,LayoutAnimator::RemovedState); animator()->setCurrentState(item,LayoutAnimator::RemovedState);
} }
updateGeometry();
startAnimation();
} }
int FlowLayout::indexOf(LayoutItem* item) const int FlowLayout::indexOf(LayoutItem* item) const
{ {
@ -119,6 +124,7 @@ LayoutItem* FlowLayout::takeAt(int i)
} }
return d->items.takeAt(i); return d->items.takeAt(i);
// FIXME: Should updateGeometry() and startAnimation() be called?
} }
template <class T> template <class T>
@ -215,8 +221,6 @@ void FlowLayout::relayout()
else else
item->setGeometry( newGeometry ); item->setGeometry( newGeometry );
} }
startAnimation();
} }
Qt::Orientations FlowLayout::expandingDirections() const Qt::Orientations FlowLayout::expandingDirections() const