Add mouse event internal members needed by declarative

In order to remove QQuickMouseEventEx we have to be able to store
touch-related data, like capabilities and velocity, also in mouse
events. However they should not be exposed through the public API in
any way. (at least not in 5.0)

Change-Id: I7774b9ea00074950208559463249fbdcaeeaefbf
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Laszlo Agocs 2012-05-22 10:44:48 +03:00 committed by Qt by Nokia
parent b1f12913a6
commit 0390b02a7f
4 changed files with 35 additions and 3 deletions

View File

@ -161,7 +161,7 @@ QInputEvent::~QInputEvent()
*/
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
: QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons)
: QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
{
s = QCursor::pos();
}
@ -188,7 +188,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers)
: QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons)
: QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0)
{}
/*!
@ -211,7 +211,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &scre
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers)
: QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons)
: QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
{}
/*!

View File

@ -119,6 +119,10 @@ protected:
QPointF l, w, s;
Qt::MouseButton b;
Qt::MouseButtons mouseState;
int caps;
QVector2D velocity;
friend class QGuiApplicationPrivate;
};
class Q_GUI_EXPORT QHoverEvent : public QInputEvent

View File

@ -2387,6 +2387,29 @@ void QGuiApplicationPrivate::q_updateFocusObject(QObject *object)
emit q->focusObjectChanged(object);
}
int QGuiApplicationPrivate::mouseEventCaps(QMouseEvent *event)
{
return event->caps;
}
QVector2D QGuiApplicationPrivate::mouseEventVelocity(QMouseEvent *event)
{
return event->velocity;
}
void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity)
{
event->caps = caps;
event->velocity = velocity;
}
void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other)
{
event->caps = other->caps;
event->velocity = other->velocity;
}
#include "moc_qguiapplication.cpp"
QT_END_NAMESPACE

View File

@ -212,6 +212,11 @@ public:
};
QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
static int mouseEventCaps(QMouseEvent *event);
static QVector2D mouseEventVelocity(QMouseEvent *event);
static void setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity);
static void setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other);
const QDrawHelperGammaTables *gammaTables();
// hook reimplemented in QApplication to apply the QStyle function on the QIcon