rendered paste bodyIndex: applethandle.cpp
===================================================================
--- applethandle.cpp (revision 737961)
+++ applethandle.cpp (working copy)
@@ -27,6 +27,7 @@
#include <cmath>
#include "containment.h"
+#include "corona.h"
#include "applet.h"
namespace Plasma
@@ -235,6 +236,33 @@
if (m_pressedButton==MoveButton) {
QPointF delta = event->pos()-event->lastPos();
setPos(pos()+delta);
+ // test for containment change
+ if (!m_containment->sceneBoundingRect().contains(event->scenePos())) {
+ // see which containment it belongs to
+ Corona * corona = qobject_cast<Corona*>(scene());
+ if (corona != NULL) {
+ QList<Containment*> containments = corona->containments();
+ for (int i = 0; i < containments.size(); ++i) {
+ if (containments[i]->sceneBoundingRect().contains(event->scenePos())) {
+ // add the applet to the new containment
+ // and take it from the old one
+ QPointF scenePosition = scenePos();
+ kDebug() << "moving to other containment with position" << event->pos() << event->scenePos();
+ kDebug() << "position before reparenting" << pos() << scenePos();
+ m_containment = containments[i];
+ setParentItem(containments[i]);
+ update();
+ kDebug() << "position after reparenting" << pos() << scenePos();
+ //setPos(m_containment->mapFromScene(scenePosition));
+ //setPos(m_containment->mapFromScene(event->scenePos()));
+ kDebug() << "position after setting the position" << pos() << scenePos();
+ kDebug() << "applet z-value: " << zValue();
+ kDebug() << "containment z-value: " << m_containment->zValue();
+ break;
+ }
+ }
+ }
+ }
} else if (m_pressedButton==RotateButton) {
if (_k_distanceForPoint(event->pos()-event->lastPos()) <= 1.0) {
return;