diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-11 12:00:50 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-11 12:00:50 (GMT) |
commit | ecc7f07e612bf156afb7fa2dbcbd2288b9b32e79 (patch) | |
tree | 88bbdcb558ef7337d3d3621b3b706f004505c569 /src/gui/kernel/qevent.cpp | |
parent | 666299f9074235185aa7372729c84a2639224601 (diff) | |
download | Qt-ecc7f07e612bf156afb7fa2dbcbd2288b9b32e79.zip Qt-ecc7f07e612bf156afb7fa2dbcbd2288b9b32e79.tar.gz Qt-ecc7f07e612bf156afb7fa2dbcbd2288b9b32e79.tar.bz2 |
remove duplicated code and API (merge QTouchEvent and QGraphicsSceneTouchEvent)
the API for these 2 classes is identical, the implementation is almost
identical, they share the same data structures, so bite the bullet and
merge them.
this means we go back to using screenPos() instead of globalPos()
again
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 242 |
1 files changed, 169 insertions, 73 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7a86dbf..a55d7e2 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -85,6 +85,13 @@ QInputEvent::~QInputEvent() \sa QApplication::keyboardModifiers() */ +/*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers) + + \internal + + Sets the keyboard modifiers flags for this event. +*/ + /*! \class QMouseEvent \ingroup events @@ -3744,21 +3751,34 @@ QTouchEvent::QTouchEvent(QEvent::Type type, QTouchEvent::~QTouchEvent() { } +/*! \fn QWidget *QTouchEvent::widget() const + + Returns the widget on which the event occurred. +*/ + + /*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const Returns a bitwise OR of all the touch point states for this event. */ -/*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates) +/*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const + + Returns the list of touch points contained in the touch event. +*/ + +/*! \fn void QTouchEvent::setWidget(QWidget *widget) \internal - Sets a bitwise OR of all the touch point states for this event. + Sets the widget for this event. */ -/*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::TouchPoints() const +/*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates) - Returns the list of touch points contained in the touch event. + \internal + + Sets a bitwise OR of all the touch point states for this event. */ /*! \fn void QTouchEvent::setTouchPoints(QList<QTouchEvent::TouchPoint> &touchPoints) @@ -3808,14 +3828,6 @@ int QTouchEvent::TouchPoint::id() const return d->id; } -/*! \internal */ -void QTouchEvent::TouchPoint::setId(int id) -{ - if (d->ref != 1) - d = d->detach(); - d->id = id; -} - /*! Returns the current state of this touch point. */ @@ -3824,29 +3836,29 @@ Qt::TouchPointState QTouchEvent::TouchPoint::state() const return d->state; } -/*! \internal */ -void QTouchEvent::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 QTouchEvent::TouchPoint::pos() const { - return d->pos; + return d->rect.center(); } -/*! \internal */ -void QTouchEvent::TouchPoint::setPos(const QPointF &pos) +/*! + Returns the scene position of this touch point. +*/ +QPointF QTouchEvent::TouchPoint::scenePos() const { - if (d->ref != 1) - d = d->detach(); - d->pos = pos; + return d->sceneRect.center(); +} + +/*! + Returns the screen position of this touch point. +*/ +QPointF QTouchEvent::TouchPoint::screenPos() const +{ + return d->screenRect.center(); } /*! @@ -3858,12 +3870,20 @@ QPointF QTouchEvent::TouchPoint::startPos() const return d->startPos; } -/*! \internal */ -void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos) +/*! + Returns the starting scene position of this touch point. +*/ +QPointF QTouchEvent::TouchPoint::startScenePos() const { - if (d->ref != 1) - d = d->detach(); - d->startPos = startPos; + return d->startScenePos; +} + +/*! + Returns the starting screen position of this touch point. +*/ +QPointF QTouchEvent::TouchPoint::startScreenPos() const +{ + return d->startScreenPos; } /*! @@ -3875,70 +3895,144 @@ QPointF QTouchEvent::TouchPoint::lastPos() const return d->lastPos; } +/*! + Returns the scene position of this touch point from the previous + touch event. +*/ +QPointF QTouchEvent::TouchPoint::lastScenePos() const +{ + return d->lastScenePos; +} + +/*! + Returns the screen position of this touch point from the previous + touch event. +*/ +QPointF QTouchEvent::TouchPoint::lastScreenPos() const +{ + return d->lastScreenPos; +} + +/*! + Returns the rect for this touch point. The rect is centered around the point returned by pos(). + Note this function returns an empty rect if the device does not report touch point sizes. +*/ +QRectF QTouchEvent::TouchPoint::rect() const +{ + return d->screenRect; +} + +/*! + Returns the rect for this touch point in scene coordinates. +*/ +QRectF QTouchEvent::TouchPoint::sceneRect() const +{ + return d->sceneRect; +} + +/*! + Returns the rect for this touch point in screen coordinates. +*/ +QRectF QTouchEvent::TouchPoint::screenRect() const +{ + return d->screenRect; +} + +/*! + Returns the pressure of this touch point. The return value is in + the range 0.0 to 1.0. +*/ +qreal QTouchEvent::TouchPoint::pressure() const +{ + return d->pressure; +} + /*! \internal */ -void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos) +void QTouchEvent::TouchPoint::setId(int id) { if (d->ref != 1) d = d->detach(); - d->lastPos = lastPos; + d->id = id; } -/*! - Returns the screen position of this touch point. -*/ -QPointF QTouchEvent::TouchPoint::globalPos() const +/*! \internal */ +void QTouchEvent::TouchPoint::setState(Qt::TouchPointState state) { - return d->screenPos; + if (d->ref != 1) + d = d->detach(); + d->state = state; } /*! \internal */ -void QTouchEvent::TouchPoint::setGlobalPos(const QPointF &globalPos) +void QTouchEvent::TouchPoint::setPos(const QPointF &pos) { if (d->ref != 1) d = d->detach(); - d->screenPos = globalPos; + d->rect.moveCenter(pos); } -/*! - Returns the starting screen position of this touch point. -*/ -QPointF QTouchEvent::TouchPoint::startGlobalPos() const +/*! \internal */ +void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos) { - return d->startScreenPos; + if (d->ref != 1) + d = d->detach(); + d->sceneRect.moveCenter(scenePos); } /*! \internal */ -void QTouchEvent::TouchPoint::setStartGlobalPos(const QPointF &startGlobalPos) +void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos) { if (d->ref != 1) d = d->detach(); - d->startScreenPos = startGlobalPos; + d->screenRect.moveCenter(screenPos); } -/*! - Returns the screen position of this touch point from the previous - touch event. -*/ -QPointF QTouchEvent::TouchPoint::lastGlobalPos() const +/*! \internal */ +void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos) { - return d->lastScreenPos; + if (d->ref != 1) + d = d->detach(); + d->startPos = startPos; } /*! \internal */ -void QTouchEvent::TouchPoint::setLastGlobalPos(const QPointF &lastGlobalPos) +void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos) { if (d->ref != 1) d = d->detach(); - d->lastScreenPos = lastGlobalPos; + d->startScenePos = startScenePos; } -/*! - Returns the rect for this touch point. The rect is centered around the point returned by pos(). - Note this function returns an empty rect if the device does not report touch point sizes. -*/ -QRectF QTouchEvent::TouchPoint::rect() const +/*! \internal */ +void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos) { - return d->screenRect; + if (d->ref != 1) + d = d->detach(); + d->startScreenPos = startScreenPos; +} + +/*! \internal */ +void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos) +{ + if (d->ref != 1) + d = d->detach(); + d->lastPos = lastPos; +} + +/*! \internal */ +void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos) +{ + if (d->ref != 1) + d = d->detach(); + d->lastScenePos = lastScenePos; +} + +/*! \internal */ +void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos) +{ + if (d->ref != 1) + d = d->detach(); + d->lastScreenPos = lastScreenPos; } /*! \internal */ @@ -3946,16 +4040,23 @@ void QTouchEvent::TouchPoint::setRect(const QRectF &rect) { if (d->ref != 1) d = d->detach(); - d->screenRect = rect; + d->rect = rect; } -/*! - Returns the pressure of this touch point. The return value is in - the range 0.0 to 1.0. -*/ -qreal QTouchEvent::TouchPoint::pressure() const +/*! \internal */ +void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect) { - return d->pressure; + if (d->ref != 1) + d = d->detach(); + d->sceneRect = sceneRect; +} + +/*! \internal */ +void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect) +{ + if (d->ref != 1) + d = d->detach(); + d->screenRect = screenRect; } /*! \internal */ @@ -3976,9 +4077,4 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T return *this; } -QTouchEventTouchPointPrivate *QTouchEventTouchPointPrivate::get(const QTouchEvent::TouchPoint &tp) -{ - return tp.d; -} - QT_END_NAMESPACE |