From 7b4de980b83ce27b1e4df327058f4f75beca39d5 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 25 Nov 2008 00:23:43 +0000 Subject: [PATCH] clarify this code a wee bit more and call positionContainments() in all necessary cases svn path=/trunk/KDE/kdelibs/; revision=888637 --- containment.cpp | 16 +++++++++------- private/containment_p.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/containment.cpp b/containment.cpp index 7e8e5e526..c48749d95 100644 --- a/containment.cpp +++ b/containment.cpp @@ -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 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()) { diff --git a/private/containment_p.h b/private/containment_p.h index d7957bc69..9ca819bd8 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -71,7 +71,7 @@ public: bool regionIsEmpty(const QRectF ®ion, Applet *ignoredApplet=0) const; void positionPanel(bool force = false); - void positionContainment(); + void positionContainments(); void setLockToolText(); void handleDisappeared(AppletHandle *handle); void appletDestroyed(QObject*);