summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicssceneevent.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-05 14:49:21 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-05 14:49:21 (GMT)
commit8d8b3e03cfc36c72665494eaa9bb461ff18072a0 (patch)
tree339041f1692b5f0fdef5a1558bd9534980bb2f4b /src/gui/graphicsview/qgraphicssceneevent.cpp
parent12c315f34ca428c3da38716d2c071a8e94f2acf0 (diff)
downloadQt-8d8b3e03cfc36c72665494eaa9bb461ff18072a0.zip
Qt-8d8b3e03cfc36c72665494eaa9bb461ff18072a0.tar.gz
Qt-8d8b3e03cfc36c72665494eaa9bb461ff18072a0.tar.bz2
Some API changes after an API review round
1. Don't have QGraphicsSceneTouchEvent::TouchPoint inherit from QTouchEvent::TouchPoint. The only reason to do this is to support an implementation trick, which can be done another way (see below). This means we have to essentially duplicate the API in the GraphicsScene variant. 2. Don't use a list of pointers to touch points in QTouchEvent and QGraphicsSceneTouchEvent. This means we have to make the TouchPoint classes implicitly shared (and the effect of the previous trick of static_casting the widget touch point to a graphics-scene touch point can be emulated by sharing the d-pointers between the classes). 3. QEvent::RawTouch isn't really an event type, it's a backdoor. Remove it and export the bool qt_translateRawTouchEvent(QList<QTouchEvent::TouchPoint>, QWidget *) function instead. 4. Rename QTouchEvent::TouchPoint::area() to size() (which is more clear as to what the function returns). QGraphicsSceneTouchEvent::TouchPoint gains size(), sceneSize(), and screenSize() functions (the actual translation from screen to scene to item still needs to be implemented).
Diffstat (limited to 'src/gui/graphicsview/qgraphicssceneevent.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp249
1 files changed, 246 insertions, 3 deletions
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index 0104e9c..c1052e3 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -1962,7 +1962,7 @@ public:
Qt::KeyboardModifiers modifiers;
Qt::TouchPointStates touchPointStates;
- QList<QGraphicsSceneTouchEvent::TouchPoint *> touchPoints;
+ QList<QGraphicsSceneTouchEvent::TouchPoint> touchPoints;
};
/*!
@@ -2019,19 +2019,132 @@ void QGraphicsSceneTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPoi
\sa QGraphicsSceneTouchEvent::TouchPoint
*/
-const QList<QGraphicsSceneTouchEvent::TouchPoint *> &QGraphicsSceneTouchEvent::touchPoints() const
+const QList<QGraphicsSceneTouchEvent::TouchPoint> &QGraphicsSceneTouchEvent::touchPoints() const
{
Q_D(const QGraphicsSceneTouchEvent);
return d->touchPoints;
}
/*! \internal */
-void QGraphicsSceneTouchEvent::setTouchPoints(const QList<QGraphicsSceneTouchEvent::TouchPoint *> &touchPoints)
+void QGraphicsSceneTouchEvent::setTouchPoints(const QList<QGraphicsSceneTouchEvent::TouchPoint> &touchPoints)
{
Q_D(QGraphicsSceneTouchEvent);
d->touchPoints = touchPoints;
}
+/*! \internal */
+QGraphicsSceneTouchEvent::TouchPoint::TouchPoint(int id)
+ : d(new QTouchEventTouchPointPrivate(id))
+{ }
+
+/*! \internal */
+QGraphicsSceneTouchEvent::TouchPoint::TouchPoint(const QGraphicsSceneTouchEvent::TouchPoint &other)
+ : d(other.d)
+{
+ d->ref.ref();
+}
+
+/*! \internal */
+QGraphicsSceneTouchEvent::TouchPoint::TouchPoint(QTouchEventTouchPointPrivate *dd)
+ : d(dd)
+{
+ d->ref.ref();
+}
+
+/*! \internal */
+QGraphicsSceneTouchEvent::TouchPoint::~TouchPoint()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ Returns the id number of this touch point.
+
+ Id numbers are globally sequential, starting at zero, meaning the
+ first touch point in the application has id 0, the second has id 1,
+ and so on.
+*/
+int QGraphicsSceneTouchEvent::TouchPoint::id() const
+{
+ return d->id;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setId(int id)
+{
+ if (!d->ref == 1)
+ d = d->detach();
+ d->id = id;
+}
+
+/*!
+ Returns the current state of this touch point.
+*/
+Qt::TouchPointState QGraphicsSceneTouchEvent::TouchPoint::state() const
+{
+ return d->state;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setState(Qt::TouchPointState state)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->state = state;
+}
+
+/*!
+ Returns the position of this touch point, relative to the widget
+ or item that received the event.
+*/
+QPointF QGraphicsSceneTouchEvent::TouchPoint::pos() const
+{
+ return d->pos;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setPos(const QPointF &pos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->pos = pos;
+}
+
+/*!
+ Returns the starting position of this touch point, relative to the
+ widget that received the event.
+*/
+QPointF QGraphicsSceneTouchEvent::TouchPoint::startPos() const
+{
+ return d->startPos;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startPos = startPos;
+}
+
+/*!
+ Returns the position of this touch point from the previous touch
+ event, relative to the widget that received the event.
+*/
+QPointF QGraphicsSceneTouchEvent::TouchPoint::lastPos() const
+{
+ return d->lastPos;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastPos = lastPos;
+}
+
/*!
Returns the current position of this touch point in scene coordinates.
@@ -2045,6 +2158,8 @@ QPointF QGraphicsSceneTouchEvent::TouchPoint::scenePos() const
/*! \internal */
void QGraphicsSceneTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
{
+ if (d->ref != 1)
+ d = d->detach();
d->scenePos = scenePos;
}
@@ -2061,6 +2176,8 @@ QPointF QGraphicsSceneTouchEvent::TouchPoint::startScenePos() const
/*! \internal */
void QGraphicsSceneTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
{
+ if (d->ref != 1)
+ d = d->detach();
d->startScenePos = startScenePos;
}
@@ -2077,9 +2194,135 @@ QPointF QGraphicsSceneTouchEvent::TouchPoint::lastScenePos() const
/*! \internal */
void QGraphicsSceneTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
{
+ if (d->ref != 1)
+ d = d->detach();
d->lastScenePos = lastScenePos;
}
+/*!
+ Returns the screen position of this touch point.
+*/
+QPointF QGraphicsSceneTouchEvent::TouchPoint::screenPos() const
+{
+ return d->screenPos;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->screenPos = screenPos;
+}
+
+/*!
+ Returns the starting screen position of this touch point.
+*/
+QPointF QGraphicsSceneTouchEvent::TouchPoint::startScreenPos() const
+{
+ return d->startScreenPos;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startScreenPos = startScreenPos;
+}
+
+/*!
+ Returns the screen position of this touch point from the previous
+ touch event.
+*/
+QPointF QGraphicsSceneTouchEvent::TouchPoint::lastScreenPos() const
+{
+ return d->lastScreenPos;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastScreenPos = lastScreenPos;
+}
+
+/*!
+ Returns the size of this touch point.
+*/
+QSizeF QGraphicsSceneTouchEvent::TouchPoint::size() const
+{
+ return d->size;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setSize(const QSizeF &size)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->size = size;
+}
+
+/*!
+ Returns the size of this touch point in scene coordinates.
+*/
+QSizeF QGraphicsSceneTouchEvent::TouchPoint::sceneSize() const
+{
+ return d->sceneSize;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setSceneSize(const QSizeF &sceneSize)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->sceneSize = sceneSize;
+}
+
+/*!
+ Returns the size of this touch point in screen coordinates.
+*/
+QSizeF QGraphicsSceneTouchEvent::TouchPoint::screenSize() const
+{
+ return d->screenSize;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setScreenSize(const QSizeF &screenSize)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->screenSize = screenSize;
+}
+
+/*!
+ Returns the pressure of this touch point. The return value is in
+ the range 0.0 to 1.0.
+*/
+qreal QGraphicsSceneTouchEvent::TouchPoint::pressure() const
+{
+ return d->pressure;
+}
+
+/*! \internal */
+void QGraphicsSceneTouchEvent::TouchPoint::setPressure(qreal pressure)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->pressure = pressure;
+}
+
+/*! \internal */
+QGraphicsSceneTouchEvent::TouchPoint &QGraphicsSceneTouchEvent::TouchPoint::operator=(const QGraphicsSceneTouchEvent::TouchPoint &other)
+{
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ return *this;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_GRAPHICSVIEW