summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-19 01:43:01 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-19 01:43:01 (GMT)
commit9b4dad87830200f7a2d33c51c2e0488a632b57b5 (patch)
treef888cd49424364df347e0c8a5abb05a542c5034a /src/declarative/graphicsitems
parent4e9a4ff3f191094b27a5ab4ef56fcd078a0bc124 (diff)
parent118890afb8b0a56d702d0822891d6417665ab515 (diff)
downloadQt-9b4dad87830200f7a2d33c51c2e0488a632b57b5.zip
Qt-9b4dad87830200f7a2d33c51c2e0488a632b57b5.tar.gz
Qt-9b4dad87830200f7a2d33c51c2e0488a632b57b5.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeevents_p_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp24
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p.h8
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p_p.h2
4 files changed, 35 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeevents_p_p.h b/src/declarative/graphicsitems/qdeclarativeevents_p_p.h
index 65ac8de..0e0329e 100644
--- a/src/declarative/graphicsitems/qdeclarativeevents_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeevents_p_p.h
@@ -115,6 +115,10 @@ public:
bool wasHeld() const { return _wasHeld; }
bool isClick() const { return _isClick; }
+ // only for internal usage
+ void setX(int x) { _x = x; }
+ void setY(int y) { _y = y; }
+
bool isAccepted() { return _accepted; }
void setAccepted(bool accepted) { _accepted = accepted; }
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index a6cc75e..52dbc42 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -466,6 +466,9 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
d->moved = true;
}
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
+ emit mousePosChanged(&me);
+ me.setX(d->lastPos.x());
+ me.setY(d->lastPos.y());
emit positionChanged(&me);
}
@@ -518,6 +521,9 @@ void QDeclarativeMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
} else {
d->lastPos = event->pos();
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, d->lastButtons, d->lastModifiers, false, d->longPress);
+ emit mousePosChanged(&me);
+ me.setX(d->lastPos.x());
+ me.setY(d->lastPos.y());
emit positionChanged(&me);
}
}
@@ -561,6 +567,18 @@ void QDeclarativeMouseArea::timerEvent(QTimerEvent *event)
}
}
+void QDeclarativeMouseArea::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ Q_D(QDeclarativeMouseArea);
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+
+ if (d->lastScenePos.isNull)
+ d->lastScenePos = mapToScene(d->lastPos);
+ else if (newGeometry.x() != oldGeometry.x() || newGeometry.y() != oldGeometry.y())
+ d->lastPos = mapFromScene(d->lastScenePos);
+}
+
/*!
\qmlproperty bool MouseArea::hoverEnabled
This property holds whether hover events are handled.
@@ -648,9 +666,13 @@ bool QDeclarativeMouseArea::setPressed(bool p)
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress);
if (d->pressed) {
emit pressed(&me);
- emit positionChanged(&me);
+ me.setX(d->lastPos.x());
+ me.setY(d->lastPos.y());
+ emit mousePosChanged(&me);
} else {
emit released(&me);
+ me.setX(d->lastPos.x());
+ me.setY(d->lastPos.y());
if (isclick && !d->longPress)
emit clicked(&me);
}
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
index 58faac1..cfd5fc7 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h
@@ -108,8 +108,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeMouseArea : public QDeclarativeItem
{
Q_OBJECT
- Q_PROPERTY(qreal mouseX READ mouseX NOTIFY positionChanged)
- Q_PROPERTY(qreal mouseY READ mouseY NOTIFY positionChanged)
+ Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mousePosChanged)
+ Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mousePosChanged)
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)
@@ -144,6 +144,7 @@ Q_SIGNALS:
void enabledChanged();
void acceptedButtonsChanged();
void positionChanged(QDeclarativeMouseEvent *mouse);
+ void mousePosChanged(QDeclarativeMouseEvent *mouse);
void pressed(QDeclarativeMouseEvent *mouse);
void pressAndHold(QDeclarativeMouseEvent *mouse);
@@ -167,6 +168,9 @@ protected:
bool sceneEvent(QEvent *);
void timerEvent(QTimerEvent *event);
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+
private:
void handlePress();
void handleRelease();
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
index 9068c7c..4973957 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
@@ -81,6 +81,7 @@ public:
void saveEvent(QGraphicsSceneMouseEvent *event) {
lastPos = event->pos();
+ lastScenePos = event->scenePos();
lastButton = event->button();
lastButtons = event->buttons();
lastModifiers = event->modifiers();
@@ -105,6 +106,7 @@ public:
qreal startX;
qreal startY;
QPointF lastPos;
+ QDeclarativeNullableValue<QPointF> lastScenePos;
Qt::MouseButton lastButton;
Qt::MouseButtons lastButtons;
Qt::KeyboardModifiers lastModifiers;