aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickmultipointhandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-04-01 22:47:12 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-04-15 07:48:02 +0000
commite6e63e749088d3a6057bcb18f0f241ab1eb603f6 (patch)
tree24187c8f5aac1cf19d6561deda580ec125bf0a56 /src/quick/handlers/qquickmultipointhandler.cpp
parent48f9dbf06a8fc8530edeb74ff93282b7cbb570d2 (diff)
QQuickMultiPointHandler::moveTarget(): work with interceptors
As with WheelHandler, DragHandler also needs to allow the target movements to be constrained with interceptors like BoundaryRule. Also do a null pointer check in moveTarget(): we haven't needed it before, but we are becoming more open to subclassing, so need to prevent user foot-shooting. Change-Id: I6b39b6dd2ca8245c56ecb3812e6de9624b36fa50 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickmultipointhandler.cpp')
-rw-r--r--src/quick/handlers/qquickmultipointhandler.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp
index ceadbf3ada..5c10ecce75 100644
--- a/src/quick/handlers/qquickmultipointhandler.cpp
+++ b/src/quick/handlers/qquickmultipointhandler.cpp
@@ -384,8 +384,13 @@ bool QQuickMultiPointHandler::grabPoints(QVector<QQuickEventPoint *> points)
void QQuickMultiPointHandler::moveTarget(QPointF pos)
{
Q_D(QQuickMultiPointHandler);
- target()->setPosition(pos);
- d->centroid.m_position = target()->mapFromScene(d->centroid.m_scenePosition);
+ if (QQuickItem *t = target()) {
+ d->xMetaProperty().write(t, pos.x());
+ d->yMetaProperty().write(t, pos.y());
+ d->centroid.m_position = t->mapFromScene(d->centroid.m_scenePosition);
+ } else {
+ qWarning() << "moveTarget: target is null";
+ }
}
QQuickMultiPointHandlerPrivate::QQuickMultiPointHandlerPrivate(int minPointCount, int maxPointCount)
@@ -395,4 +400,24 @@ QQuickMultiPointHandlerPrivate::QQuickMultiPointHandlerPrivate(int minPointCount
{
}
+QMetaProperty &QQuickMultiPointHandlerPrivate::xMetaProperty() const
+{
+ Q_Q(const QQuickMultiPointHandler);
+ if (!xProperty.isValid() && q->target()) {
+ const QMetaObject *targetMeta = q->target()->metaObject();
+ xProperty = targetMeta->property(targetMeta->indexOfProperty("x"));
+ }
+ return xProperty;
+}
+
+QMetaProperty &QQuickMultiPointHandlerPrivate::yMetaProperty() const
+{
+ Q_Q(const QQuickMultiPointHandler);
+ if (!yProperty.isValid() && q->target()) {
+ const QMetaObject *targetMeta = q->target()->metaObject();
+ yProperty = targetMeta->property(targetMeta->indexOfProperty("y"));
+ }
+ return yProperty;
+}
+
QT_END_NAMESPACE