clarify this code a wee bit more and call positionContainments() in all necessary cases

svn path=/trunk/KDE/kdelibs/; revision=888637
This commit is contained in:
Aaron J. Seigo 2008-11-25 00:23:43 +00:00
parent ad6d7b11e4
commit 7b4de980b8
2 changed files with 10 additions and 8 deletions

View File

@ -1129,16 +1129,15 @@ QVariant Containment::itemChange(GraphicsItemChange change, const QVariant &valu
{
//FIXME if the applet is moved to another containment we need to unfocus it
if (isContainment() &&
(change == QGraphicsItem::ItemSceneHasChanged ||
change == QGraphicsItem::ItemPositionHasChanged) && !ContainmentPrivate::s_positioning) {
if (isContainment() && !ContainmentPrivate::s_positioning &&
(change == QGraphicsItem::ItemSceneHasChanged || change == QGraphicsItem::ItemPositionHasChanged)) {
switch (containmentType()) {
case PanelContainment:
case CustomPanelContainment:
d->positionPanel();
break;
default:
d->positionContainment();
d->positionContainments();
break;
}
}
@ -1593,6 +1592,7 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
positionPanel();
break;
default:
positionContainments();
break;
}
}
@ -1697,13 +1697,15 @@ bool containmentSortByPosition(const Containment *c1, const Containment *c2)
return c1->id() < c2->id();
}
void ContainmentPrivate::positionContainment()
void ContainmentPrivate::positionContainments()
{
Corona *c = q->corona();
if (!c) {
if (!c || ContainmentPrivate::s_positioning) {
return;
}
ContainmentPrivate::s_positioning = true;
//TODO: we should avoid running this too often; consider compressing requests
// with a timer.
QList<Containment*> containments = c->containments();
@ -1721,6 +1723,7 @@ void ContainmentPrivate::positionContainment()
}
if (containments.isEmpty()) {
ContainmentPrivate::s_positioning = false;
return;
}
@ -1732,7 +1735,6 @@ void ContainmentPrivate::positionContainment()
int y = 0;
int rowHeight = 0;
//int count = 0;
ContainmentPrivate::s_positioning = true;
//kDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++" << containments.count();
while (it.hasNext()) {

View File

@ -71,7 +71,7 @@ public:
bool regionIsEmpty(const QRectF &region, Applet *ignoredApplet=0) const;
void positionPanel(bool force = false);
void positionContainment();
void positionContainments();
void setLockToolText();
void handleDisappeared(AppletHandle *handle);
void appletDestroyed(QObject*);