* record where the mouse was in drag

* get the parenting right, prevents crashes
BUG:229566

svn path=/trunk/KDE/kdelibs/; revision=1099727
This commit is contained in:
Aaron J. Seigo 2010-03-06 01:43:44 +00:00
parent f261f87e6f
commit f9027d26fa
2 changed files with 13 additions and 12 deletions

View File

@ -566,7 +566,7 @@ void ExtenderPrivate::addExtenderItem(ExtenderItem *item, const QPointF &pos)
void ExtenderPrivate::removeExtenderItem(ExtenderItem *item)
{
attachedExtenderItems.removeOne(item);
attachedExtenderItems.removeAll(item);
//collapse the popupapplet if the last item is removed.
if (!q->attachedItems().count()) {

View File

@ -263,10 +263,11 @@ void ExtenderItem::setExtender(Extender *extender, const QPointF &pos)
//and notify the applet of the item being detached, after the config has been moved.
emit d->extender->itemDetached(this);
setParentItem(extender);
setParent(extender);
d->extender = extender;
//change parent.
setParentItem(extender);
extender->d->addExtenderItem(this, pos);
//cancel the timer.
@ -465,6 +466,7 @@ void ExtenderItem::returnToSource()
if (!d || !d->sourceApplet) {
return;
}
if (d->sourceApplet->d) {
setExtender(d->sourceApplet->extender());
}
@ -601,6 +603,7 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
//create the necesarry mimedata.
ExtenderItemMimeData *mimeData = new ExtenderItemMimeData();
mimeData->setExtenderItem(this);
mimeData->setPointerOffset(d->mousePos);
//Hide empty internal extender containers when we drag the last item away. Avoids having
//an ugly empty applet on the desktop temporarily.
@ -610,10 +613,6 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
extenderApplet->formFactor() != Plasma::Vertical) {
kDebug() << "leaving the internal extender container, so hide the applet and it's handle.";
extenderApplet->hide();
AppletHandle *handle = dynamic_cast<AppletHandle*>(extenderApplet->parentItem());
if (handle) {
handle->hide();
}
}
ExtenderGroup *group = qobject_cast<ExtenderGroup*>(this);
@ -632,17 +631,21 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Qt::DropAction action = drag->exec();
corona->removeOffscreenWidget(this);
d->dragStarted = false;
if (!action || !drag->target()) {
//we weren't moved, so reinsert the item in our current layout.
//TODO: make it into a stand-alone window?
d->themeChanged();
d->extender->itemAddedEvent(this, curPos);
if (extenderApplet) {
extenderApplet->show();
}
}
if (isGroup() && !collapsedGroup) {
group->expandGroup();
}
d->dragStarted = false;
}
void ExtenderItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
@ -845,14 +848,12 @@ void ExtenderItemPrivate::themeChanged()
{
if (dragStarted) {
background->setImagePath("opaque/widgets/extender-background");
} else {
background->setImagePath("widgets/extender-background");
}
if (dragStarted) {
background->setEnabledBorders(FrameSvg::AllBorders);
} else {
background->setImagePath("widgets/extender-background");
background->setEnabledBorders(extender->enabledBordersForItem(q));
}
background->getMargins(bgLeft, bgTop, bgRight, bgBottom);
dragger->setImagePath("widgets/extender-dragger");