From: Michael Brasser Date: Tue, 26 Jul 2011 01:47:19 +0000 (+1000) Subject: Remove onMousePositionChanged signal. X-Git-Tag: qt-v5.0.0-alpha1~2077 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df5c836fe9753e81cda4a30fa27ce7af5e6f9a5f;p=profile%2Fivi%2Fqtdeclarative.git Remove onMousePositionChanged signal. This signal was meant to be "private" (not directly used from QML). Provide separate signals for onMouseXChanged and onMouseYChanged. Task-number: QTBUG-18656 Change-Id: Iefc3d78e270db9c037bbb1b890925b4841f2d5fa Reviewed-by: Martin Jones Reviewed-on: http://codereview.qt.nokia.com/2142 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- diff --git a/src/declarative/items/qsgevents_p_p.h b/src/declarative/items/qsgevents_p_p.h index 02835de..0aa95c0 100644 --- a/src/declarative/items/qsgevents_p_p.h +++ b/src/declarative/items/qsgevents_p_p.h @@ -119,6 +119,7 @@ public: // only for internal usage void setX(int x) { _x = x; } void setY(int y) { _y = y; } + void setPosition(const QPointF &point) { _x = point.x(); _y = point.y(); } bool isAccepted() { return _accepted; } void setAccepted(bool accepted) { _accepted = accepted; } diff --git a/src/declarative/items/qsgmousearea.cpp b/src/declarative/items/qsgmousearea.cpp index f65fbba..c4b7fc0 100644 --- a/src/declarative/items/qsgmousearea.cpp +++ b/src/declarative/items/qsgmousearea.cpp @@ -586,9 +586,10 @@ void QSGMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } } QSGMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress); - emit mousePositionChanged(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); + emit mouseXChanged(&me); + me.setPosition(d->lastPos); + emit mouseYChanged(&me); + me.setPosition(d->lastPos); emit positionChanged(&me); if(!event->isAccepted() && d->forwardToList.count()) @@ -663,7 +664,10 @@ void QSGMouseArea::hoverEnterEvent(QHoverEvent *event) d->lastModifiers = event->modifiers(); setHovered(true); QSGMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, d->lastModifiers, false, false); - emit mousePositionChanged(&me); + emit mouseXChanged(&me); + me.setPosition(d->lastPos); + emit mouseYChanged(&me); + me.setPosition(d->lastPos); } } @@ -676,9 +680,10 @@ void QSGMouseArea::hoverMoveEvent(QHoverEvent *event) d->lastPos = event->posF(); d->lastModifiers = event->modifiers(); QSGMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, d->lastModifiers, false, false); - emit mousePositionChanged(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); + emit mouseXChanged(&me); + me.setPosition(d->lastPos); + emit mouseYChanged(&me); + me.setPosition(d->lastPos); emit positionChanged(&me); } } @@ -893,14 +898,14 @@ bool QSGMouseArea::setPressed(bool p) if (d->pressed) { if (!d->doubleClick) emit pressed(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); - emit mousePositionChanged(&me); + me.setPosition(d->lastPos); + emit mouseXChanged(&me); + me.setPosition(d->lastPos); + emit mouseYChanged(&me); emit pressedChanged(); } else { emit released(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); + me.setPosition(d->lastPos); emit pressedChanged(); if (isclick && !d->longPress && !d->doubleClick){ me.setAccepted(d->isClickConnected()); diff --git a/src/declarative/items/qsgmousearea_p.h b/src/declarative/items/qsgmousearea_p.h index 7d1b095..df553e2 100644 --- a/src/declarative/items/qsgmousearea_p.h +++ b/src/declarative/items/qsgmousearea_p.h @@ -151,8 +151,8 @@ class Q_AUTOTEST_EXPORT QSGMouseArea : public QSGItem { Q_OBJECT - Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mousePositionChanged) - Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mousePositionChanged) + Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mouseXChanged) + Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mouseYChanged) Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged) Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) @@ -198,7 +198,8 @@ Q_SIGNALS: void acceptedButtonsChanged(); void hoverEnabledChanged(); void positionChanged(QSGMouseEvent *mouse); - void mousePositionChanged(QSGMouseEvent *mouse); + void mouseXChanged(QSGMouseEvent *mouse); + void mouseYChanged(QSGMouseEvent *mouse); void preventStealingChanged(); void pressed(QSGMouseEvent *mouse); diff --git a/tests/auto/declarative/qsgmousearea/data/updateMousePosOnResize.qml b/tests/auto/declarative/qsgmousearea/data/updateMousePosOnResize.qml index ad52ef3..55af864 100644 --- a/tests/auto/declarative/qsgmousearea/data/updateMousePosOnResize.qml +++ b/tests/auto/declarative/qsgmousearea/data/updateMousePosOnResize.qml @@ -29,7 +29,12 @@ Rectangle { anchors.fill = parent } onPositionChanged: { emitPositionChanged = true } - onMousePositionChanged: { + onMouseXChanged: { + if (mouse.x != mouseX || mouse.y != mouseY) + mouseMatchesPos = false + x2 = mouseX; y2 = mouseY + } + onMouseYChanged: { if (mouse.x != mouseX || mouse.y != mouseY) mouseMatchesPos = false x2 = mouseX; y2 = mouseY