forgotten to commit before: migrate to the new api

svn path=/trunk/KDE/kdelibs/; revision=1035760
This commit is contained in:
Marco Martin 2009-10-15 20:12:01 +00:00
parent cceef16789
commit 451cf321a2
3 changed files with 15 additions and 32 deletions

View File

@ -430,8 +430,7 @@ void ScrollWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Animator::self()->stopItemMovement(d->animId); Animator::self()->stopItemMovement(d->animId);
} }
d->mouseMoveEvent(event); event->ignore();
QGraphicsWidget::mouseMoveEvent(event);
} }
void ScrollWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) void ScrollWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
@ -439,14 +438,11 @@ void ScrollWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (d->animId) { if (d->animId) {
Animator::self()->stopItemMovement(d->animId); Animator::self()->stopItemMovement(d->animId);
} }
event->accept();
d->mousePressEvent(event);
} }
void ScrollWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void ScrollWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
d->mouseReleaseEvent(event); event->ignore();
} }
void ScrollWidget::wheelEvent(QGraphicsSceneWheelEvent *event) void ScrollWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
@ -455,8 +451,6 @@ void ScrollWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
Animator::self()->stopItemMovement(d->animId); Animator::self()->stopItemMovement(d->animId);
} }
event->accept();
d->wheelReleaseEvent( event );
} }
bool ScrollWidget::eventFilter(QObject *watched, QEvent *event) bool ScrollWidget::eventFilter(QObject *watched, QEvent *event)

View File

@ -47,10 +47,7 @@ class WebViewPrivate : public KineticScrolling
public: public:
WebViewPrivate(WebView *parent) WebViewPrivate(WebView *parent)
: q(parent), : q(parent),
dragToScroll(false), dragToScroll(false)
dragging(false),
dragTimeout(false),
dragTimeoutTimer(0)
{ {
} }
@ -63,9 +60,7 @@ public:
QWebPage *page; QWebPage *page;
bool loaded; bool loaded;
bool dragToScroll; bool dragToScroll;
bool dragging; QPointF lastScrollPosition;
bool dragTimeout;
QTimer *dragTimeoutTimer;
}; };
WebView::WebView(QGraphicsItem *parent) WebView::WebView(QGraphicsItem *parent)
@ -237,9 +232,9 @@ void WebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
if (event->pos().x() <= (d->page->mainFrame()->contentsSize().width() - if (d->dragToScroll) {
d->page->mainFrame()->scrollBarMaximum(Qt::Horizontal))) return;
d->mouseMoveEvent(event); }
QMouseEvent me(QEvent::MouseMove, event->pos().toPoint(), event->button(), QMouseEvent me(QEvent::MouseMove, event->pos().toPoint(), event->button(),
event->buttons(), event->modifiers()); event->buttons(), event->modifiers());
@ -271,14 +266,14 @@ void WebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
d->lastScrollPosition = scrollPosition();
setFocus(); setFocus();
QMouseEvent me(QEvent::MouseButtonPress, event->pos().toPoint(), QMouseEvent me(QEvent::MouseButtonPress, event->pos().toPoint(),
event->button(), event->buttons(), event->modifiers()); event->button(), event->buttons(), event->modifiers());
d->page->event(&me); d->page->event(&me);
if (me.isAccepted()) { if (me.isAccepted() && !d->dragToScroll) {
event->accept(); event->accept();
d->mousePressEvent(event);
} }
} }
@ -304,14 +299,14 @@ void WebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
event->accept();
d->mouseReleaseEvent(event);
QMouseEvent me(QEvent::MouseButtonRelease, event->pos().toPoint(), QMouseEvent me(QEvent::MouseButtonRelease, event->pos().toPoint(),
event->button(),event->buttons(), event->modifiers()); event->button(),event->buttons(), event->modifiers());
d->page->event(&me);
if (me.isAccepted()) { if (!d->dragToScroll || (scrollPosition() - d->lastScrollPosition).manhattanLength() < QApplication::startDragDistance()) {
d->page->event(&me);
}
if (me.isAccepted() && !d->dragToScroll) {
event->accept(); event->accept();
} }
} }
@ -349,8 +344,7 @@ void WebView::wheelEvent(QGraphicsSceneWheelEvent *event)
event->modifiers(), event->orientation()); event->modifiers(), event->orientation());
d->page->event(&we); d->page->event(&we);
event->accept(); event->setAccepted(!d->dragToScroll);
d->wheelReleaseEvent(event);
} }
void WebView::keyPressEvent(QKeyEvent * event) void WebView::keyPressEvent(QKeyEvent * event)
@ -492,10 +486,6 @@ void WebViewPrivate::scrollRequested(int dx, int dy, const QRect &scrollRect)
updateRequested(scrollRect); updateRequested(scrollRect);
} }
void WebViewPrivate::dragTimeoutExpired()
{
dragTimeout = true;
}
} // namespace Plasma } // namespace Plasma

View File

@ -201,7 +201,6 @@ class PLASMA_EXPORT WebView : public QGraphicsWidget
Q_PRIVATE_SLOT(d, void loadingFinished(bool success)) Q_PRIVATE_SLOT(d, void loadingFinished(bool success))
Q_PRIVATE_SLOT(d, void updateRequested(const QRect& dirtyRect)) Q_PRIVATE_SLOT(d, void updateRequested(const QRect& dirtyRect))
Q_PRIVATE_SLOT(d, void scrollRequested(int dx, int dy, const QRect &scrollRect)) Q_PRIVATE_SLOT(d, void scrollRequested(int dx, int dy, const QRect &scrollRect))
Q_PRIVATE_SLOT(d, void dragTimeoutExpired())
WebViewPrivate * const d; WebViewPrivate * const d;
friend class WebViewPrivate; friend class WebViewPrivate;