From 6ad3371e9aa9722da628d8cf272eadb87703d933 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sat, 16 Oct 2010 17:41:59 +0000 Subject: [PATCH] scroll around while dragging items on the extender, to make possible drop the item on any point svn path=/trunk/KDE/kdelibs/; revision=1186504 --- extenders/extender.cpp | 9 +++++++++ extenders/extendergroup.cpp | 2 ++ private/extender_p.h | 1 + 3 files changed, 12 insertions(+) diff --git a/extenders/extender.cpp b/extenders/extender.cpp index 22e4add1b..2b55141ab 100644 --- a/extenders/extender.cpp +++ b/extenders/extender.cpp @@ -421,6 +421,8 @@ void Extender::dragMoveEvent(QGraphicsSceneDragDropEvent *event) if (mimeData) { itemHoverMoveEvent(mimeData->extenderItem(), event->pos()); + + d->setPositionFromDragPosition(event->scenePos()); } } } @@ -837,6 +839,13 @@ void ExtenderPrivate::adjustMinimumSize() scrollWidget->setMinimumHeight(qMin((qreal)300, mainWidget->effectiveSizeHint(Qt::MinimumSize).height())); } +void ExtenderPrivate::setPositionFromDragPosition(const QPointF &pos) +{ + const qreal ratio = (q->mapFromScene(pos).y()/scrollWidget->size().height()); + + mainWidget->setPos(mainWidget->pos().x(), 30 + (ratio *(scrollWidget->size().height() - mainWidget->size().height() - 30))); +} + ExtenderGroup *ExtenderPrivate::findGroup(const QString &name) const { foreach (ExtenderItem *item, attachedExtenderItems) { diff --git a/extenders/extendergroup.cpp b/extenders/extendergroup.cpp index 3a2618dea..40d646ab3 100644 --- a/extenders/extendergroup.cpp +++ b/extenders/extendergroup.cpp @@ -266,6 +266,8 @@ void ExtenderGroup::dragMoveEvent(QGraphicsSceneDragDropEvent *event) d->spacerWidget = widget; } d->layout->insertItem(insertIndex, d->spacerWidget); + + extender()->d->setPositionFromDragPosition(event->scenePos()); } } } diff --git a/private/extender_p.h b/private/extender_p.h index 30866b969..85786bc51 100644 --- a/private/extender_p.h +++ b/private/extender_p.h @@ -75,6 +75,7 @@ class ExtenderPrivate void delayItemAddedEvent(); void updateEmptyExtenderLabel(); void adjustMinimumSize(); + void setPositionFromDragPosition(const QPointF &pos); ExtenderGroup *findGroup(const QString &name) const; Extender *q;