be sure to always have a containment!

BUG:206379

svn path=/trunk/KDE/kdelibs/; revision=1045316
This commit is contained in:
Aaron J. Seigo 2009-11-05 19:17:00 +00:00
parent f0f6b91bd5
commit 7acbfbc47f

View File

@ -514,21 +514,18 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
// see which containment it belongs to // see which containment it belongs to
Corona * corona = qobject_cast<Corona*>(scene()); Corona * corona = qobject_cast<Corona*>(scene());
if (corona) { if (corona) {
QList<Containment*> containments = corona->containments(); foreach (Containment *containment, corona->containments()) {
for (int i = 0; i < containments.size(); ++i) {
QPointF pos; QPointF pos;
QGraphicsView *v; QGraphicsView *v = containment->view();
v = containments[i]->view();
if (v) { if (v) {
pos = v->mapToScene( pos = v->mapToScene(v->mapFromGlobal(event->screenPos() - m_mousePos));
v->mapFromGlobal(event->screenPos() - m_mousePos));
if (containments[i]->sceneBoundingRect().contains(pos)) { if (containment->sceneBoundingRect().contains(pos)) {
//kDebug() << "new containment = " << containments[i]; //kDebug() << "new containment = " << containments[i];
//kDebug() << "rect = " << containments[i]->sceneBoundingRect(); //kDebug() << "rect = " << containments[i]->sceneBoundingRect();
// add the applet to the new containment and take it from the old one // add the applet to the new containment and take it from the old one
//kDebug() << "moving to other containment with position" << pos;; //kDebug() << "moving to other containment with position" << pos;;
switchContainment(containments[i], pos); switchContainment(containment, pos);
break; break;
} }
} }
@ -603,11 +600,13 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos()); Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
if (v && v != m_currentView) { if (v && v != m_currentView) {
Containment *c = v->containment(); Containment *c = v->containment();
QPoint pos = v->mapFromGlobal(event->screenPos()); if (c) {
//we actually have been dropped on another containment, so QPoint pos = v->mapFromGlobal(event->screenPos());
//move there: we have a screenpos, we need a scenepos //we actually have been dropped on another containment, so
//FIXME how reliable is this transform? //move there: we have a screenpos, we need a scenepos
switchContainment(c, v->mapToScene(pos)); //FIXME how reliable is this transform?
switchContainment(c, v->mapToScene(pos));
}
} }
} }