From 9554b17ce863d86d69e5740d5f2cfafb2186a051 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Sat, 6 Mar 2010 01:41:18 +0000 Subject: [PATCH] * don't remove items from our scene if they aren't part of our scene (avoid a warning from inside qt) * always reset the borders of dragged extender items when needed * minor cleanup in appletActions svn path=/trunk/KDE/kdelibs/; revision=1099725 --- containment.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/containment.cpp b/containment.cpp index 74c6d0356..6d31d3f00 100644 --- a/containment.cpp +++ b/containment.cpp @@ -53,6 +53,7 @@ #include "containmentactions.h" #include "containmentactionspluginsconfig.h" #include "corona.h" +#include "extender.h" #include "extenderitem.h" #include "svg.h" #include "wallpaper.h" @@ -65,6 +66,7 @@ #include "private/containmentactionspluginsconfig_p.h" #include "private/desktoptoolbox_p.h" #include "private/extenderitemmimedata_p.h" +#include "private/extenderapplet_p.h" #include "private/paneltoolbox_p.h" #include "plasma/plasma.h" @@ -660,11 +662,8 @@ void ContainmentPrivate::containmentActions(KMenu &desktopMenu) void ContainmentPrivate::appletActions(KMenu &desktopMenu, Applet *applet, bool includeApplet) { - QList actions; - if (includeApplet) { - actions = applet->contextualActions(); - foreach (QAction *action, actions) { + foreach (QAction *action, applet->contextualActions()) { if (action) { desktopMenu.addAction(action); } @@ -960,6 +959,7 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit) applet->flushPendingConstraintsEvents(); } } + if (!delayInit) { applet->d->scheduleModificationNotification(); } @@ -1270,9 +1270,17 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS const ExtenderItemMimeData *extenderData = qobject_cast(mimeData); if (extenderData) { ExtenderItem *item = extenderData->extenderItem(); - QRectF geometry(pos, item->size()); + QRectF geometry(pos - extenderData->pointerOffset(), item->size()); kDebug() << "desired geometry: " << geometry; - Applet *applet = q->addApplet("internal:extender", QVariantList(), geometry); + Applet *applet = qobject_cast(item->extender() ? item->extender()->applet() : 0); + if (applet) { + qreal left, top, right, bottom; + applet->getContentsMargins(&left, &top, &right, &bottom); + applet->setPos(geometry.topLeft() - QPointF(int(left), int(top))); + applet->show(); + } else { + applet = q->addApplet("internal:extender", QVariantList(), geometry); + } item->setExtender(applet->extender()); } } else if (KUrl::List::canDecode(mimeData)) { @@ -2142,8 +2150,9 @@ void ContainmentPrivate::handleDisappeared(AppletHandle *handle) if (handles.contains(handle->applet())) { handles.remove(handle->applet()); handle->detachApplet(); - if (q->scene()) { - q->scene()->removeItem(handle); + QGraphicsScene *scene = q->scene(); + if (scene && handle->scene() == scene) { + scene->removeItem(handle); } handle->deleteLater(); }