register/unregoster as drag handles is deprecated now since it's automatic

svn path=/trunk/KDE/kdelibs/; revision=1104888
This commit is contained in:
Marco Martin 2010-03-18 20:22:03 +00:00
parent 3c0cffc506
commit 26a4b3f20d
2 changed files with 11 additions and 62 deletions

View File

@ -488,11 +488,6 @@ public:
} }
} }
void cleanupDragHandles(QObject *destroyed)
{
dragHandles.remove(static_cast<QGraphicsWidget *>(destroyed));
}
void stopAnimations() void stopAnimations()
{ {
flickAnimationX->stop(); flickAnimationX->stop();
@ -867,7 +862,6 @@ public:
QWeakPointer<QGraphicsWidget> widgetToBeVisible; QWeakPointer<QGraphicsWidget> widgetToBeVisible;
QRectF rectToBeVisible; QRectF rectToBeVisible;
QPointF dragHandleClicked; QPointF dragHandleClicked;
QSet<QGraphicsWidget *>dragHandles;
bool dragging; bool dragging;
QTimer *adjustScrollbarsTimer; QTimer *adjustScrollbarsTimer;
static const int borderSize = 4; static const int borderSize = 4;
@ -1005,30 +999,12 @@ void ScrollWidget::ensureItemVisible(QGraphicsItem *item)
void ScrollWidget::registerAsDragHandle(QGraphicsWidget *item) void ScrollWidget::registerAsDragHandle(QGraphicsWidget *item)
{ {
if (!d->widget || !item || d->dragHandles.contains(item)) {
return; return;
}
QGraphicsItem *parentOfItem = item->parentItem();
while (parentOfItem != d->widget.data()) {
if (!parentOfItem) {
return;
}
parentOfItem = parentOfItem->parentItem();
}
connect(item, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupDragHandles(QObject *)));
item->installEventFilter(this);
d->dragHandles.insert(item);
} }
void ScrollWidget::unregisterAsDragHandle(QGraphicsWidget *item) void ScrollWidget::unregisterAsDragHandle(QGraphicsWidget *item)
{ {
if (item) { return;
item->removeEventFilter(this);
d->dragHandles.remove(item);
}
} }
QRectF ScrollWidget::viewportGeometry() const QRectF ScrollWidget::viewportGeometry() const
@ -1165,39 +1141,6 @@ bool ScrollWidget::eventFilter(QObject *watched, QEvent *event)
d->verticalScrollBar->setValue(-d->widget.data()->pos().y()/10); d->verticalScrollBar->setValue(-d->widget.data()->pos().y()/10);
d->horizontalScrollBar->blockSignals(false); d->horizontalScrollBar->blockSignals(false);
d->verticalScrollBar->blockSignals(false); d->verticalScrollBar->blockSignals(false);
} else if (d->dragHandles.contains(static_cast<QGraphicsWidget *>(watched))) {
if (event->type() == QEvent::GraphicsSceneMousePress ||
event->type() == QEvent::GraphicsSceneMouseMove ||
event->type() == QEvent::GraphicsSceneMouseRelease) {
QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(event);
qreal dragDistance = (d->dragHandleClicked - me->scenePos()).manhattanLength();
if (event->type() == QEvent::GraphicsSceneMousePress) {
d->dragHandleClicked = me->scenePos();
}
d->dragging = (d->dragging || dragDistance > (KGlobalSettings::dndEventDelay()));
if (scene() && event->type() != QEvent::GraphicsSceneMouseMove) {
scene()->sendEvent(this, event);
}
if (!d->dragging) {
return false;
}
if (scene() && event->type() == QEvent::GraphicsSceneMouseMove) {
scene()->sendEvent(this, event);
}
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
d->dragging = false;
return true;
}
}
} }
return false; return false;

View File

@ -155,18 +155,25 @@ public:
* The item will still receive mouse clicks if the mouse didn't move * The item will still receive mouse clicks if the mouse didn't move
* between press and release. * between press and release.
* *
* This function is no more necessary, since it's the authomatic behaviour
* for all children items, the implementation has now no effect
*
* @param item the drag handle item. widget() must be an ancestor if it in * @param item the drag handle item. widget() must be an ancestor if it in
* the parent hierarchy. if item doesn't accept mose press events * the parent hierarchy. if item doesn't accept mose press events
* it's not necessary to call this function. * it's not necessary to call this function.
* @since 4.4 * @since 4.4
*/ */
Q_INVOKABLE void registerAsDragHandle(QGraphicsWidget *item); KDE_DEPRECATED Q_INVOKABLE void registerAsDragHandle(QGraphicsWidget *item);
/** /**
* Unregister the given item as drag handle (if it was registered) * Unregister the given item as drag handle (if it was registered)
*
* This function is no more necessary, since it's the authomatic behaviour
* for all children items, the implementation has now no effect
*
* @since 4.4 * @since 4.4
*/ */
Q_INVOKABLE void unregisterAsDragHandle(QGraphicsWidget *item); KDE_DEPRECATED Q_INVOKABLE void unregisterAsDragHandle(QGraphicsWidget *item);
/** /**
* The geometry of the viewport. * The geometry of the viewport.
@ -235,7 +242,6 @@ private:
Q_PRIVATE_SLOT(d, void horizontalScroll(int value)) Q_PRIVATE_SLOT(d, void horizontalScroll(int value))
Q_PRIVATE_SLOT(d, void makeRectVisible()) Q_PRIVATE_SLOT(d, void makeRectVisible())
Q_PRIVATE_SLOT(d, void makeItemVisible()) Q_PRIVATE_SLOT(d, void makeItemVisible())
Q_PRIVATE_SLOT(d, void cleanupDragHandles(QObject *destroyed))
Q_PRIVATE_SLOT(d, void adjustScrollbars()) Q_PRIVATE_SLOT(d, void adjustScrollbars())
Q_PRIVATE_SLOT(d, void fixupX()) Q_PRIVATE_SLOT(d, void fixupX())
Q_PRIVATE_SLOT(d, void fixupY()) Q_PRIVATE_SLOT(d, void fixupY())