* 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
This commit is contained in:
Aaron J. Seigo 2010-03-06 01:41:18 +00:00
parent 28e876bc0c
commit 9554b17ce8

View File

@ -53,6 +53,7 @@
#include "containmentactions.h" #include "containmentactions.h"
#include "containmentactionspluginsconfig.h" #include "containmentactionspluginsconfig.h"
#include "corona.h" #include "corona.h"
#include "extender.h"
#include "extenderitem.h" #include "extenderitem.h"
#include "svg.h" #include "svg.h"
#include "wallpaper.h" #include "wallpaper.h"
@ -65,6 +66,7 @@
#include "private/containmentactionspluginsconfig_p.h" #include "private/containmentactionspluginsconfig_p.h"
#include "private/desktoptoolbox_p.h" #include "private/desktoptoolbox_p.h"
#include "private/extenderitemmimedata_p.h" #include "private/extenderitemmimedata_p.h"
#include "private/extenderapplet_p.h"
#include "private/paneltoolbox_p.h" #include "private/paneltoolbox_p.h"
#include "plasma/plasma.h" #include "plasma/plasma.h"
@ -660,11 +662,8 @@ void ContainmentPrivate::containmentActions(KMenu &desktopMenu)
void ContainmentPrivate::appletActions(KMenu &desktopMenu, Applet *applet, bool includeApplet) void ContainmentPrivate::appletActions(KMenu &desktopMenu, Applet *applet, bool includeApplet)
{ {
QList<QAction*> actions;
if (includeApplet) { if (includeApplet) {
actions = applet->contextualActions(); foreach (QAction *action, applet->contextualActions()) {
foreach (QAction *action, actions) {
if (action) { if (action) {
desktopMenu.addAction(action); desktopMenu.addAction(action);
} }
@ -960,6 +959,7 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
applet->flushPendingConstraintsEvents(); applet->flushPendingConstraintsEvents();
} }
} }
if (!delayInit) { if (!delayInit) {
applet->d->scheduleModificationNotification(); applet->d->scheduleModificationNotification();
} }
@ -1270,9 +1270,17 @@ void ContainmentPrivate::dropData(QPointF scenePos, QPoint screenPos, QGraphicsS
const ExtenderItemMimeData *extenderData = qobject_cast<const ExtenderItemMimeData*>(mimeData); const ExtenderItemMimeData *extenderData = qobject_cast<const ExtenderItemMimeData*>(mimeData);
if (extenderData) { if (extenderData) {
ExtenderItem *item = extenderData->extenderItem(); ExtenderItem *item = extenderData->extenderItem();
QRectF geometry(pos, item->size()); QRectF geometry(pos - extenderData->pointerOffset(), item->size());
kDebug() << "desired geometry: " << geometry; kDebug() << "desired geometry: " << geometry;
Applet *applet = q->addApplet("internal:extender", QVariantList(), geometry); Applet *applet = qobject_cast<ExtenderApplet *>(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()); item->setExtender(applet->extender());
} }
} else if (KUrl::List::canDecode(mimeData)) { } else if (KUrl::List::canDecode(mimeData)) {
@ -2142,8 +2150,9 @@ void ContainmentPrivate::handleDisappeared(AppletHandle *handle)
if (handles.contains(handle->applet())) { if (handles.contains(handle->applet())) {
handles.remove(handle->applet()); handles.remove(handle->applet());
handle->detachApplet(); handle->detachApplet();
if (q->scene()) { QGraphicsScene *scene = q->scene();
q->scene()->removeItem(handle); if (scene && handle->scene() == scene) {
scene->removeItem(handle);
} }
handle->deleteLater(); handle->deleteLater();
} }