summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-09-21 09:23:51 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-21 13:46:08 +0200
commitbc60b6787c791be0168820c42febfdb57b5070e0 (patch)
treeab4f5214d855841e4fefb9d97d2d10cc2269952e /src
parent294a3e7b4797f508ebe629000ee2b2b7c7bd7302 (diff)
testlib: Separate the gui- and widgets-specific api
Group the widgets-specific ("legacy") api under as few ifdefs as possible. (The diff can look confusing; rest assured that this change "only" moves entire functions around in the files.) Change-Id: I27bdec7d1c96d0b040dc22a8fed17e4e47766276 Reviewed-on: http://codereview.qt-project.org/5290 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Matthew Cattell <matthew.cattell@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qtestkeyboard.h174
-rw-r--r--src/testlib/qtestmouse.h117
-rw-r--r--src/testlib/qtesttouch.h42
3 files changed, 159 insertions, 174 deletions
diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h
index 86d56c8710..51e0908e6f 100644
--- a/src/testlib/qtestkeyboard.h
+++ b/src/testlib/qtestkeyboard.h
@@ -68,6 +68,88 @@ namespace QTest
{
enum KeyAction { Press, Release, Click };
+ static void simulateEvent(QWindow *window, bool press, int code,
+ Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
+ {
+ QEvent::Type type;
+ type = press ? QEvent::KeyPress : QEvent::KeyRelease;
+ QWindowSystemInterface::handleKeyEvent(window, type, code, modifier, text, repeat, delay);
+ }
+
+ static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
+ QString text, Qt::KeyboardModifiers modifier, int delay=-1)
+ {
+ QTEST_ASSERT(qApp);
+ QTEST_ASSERT(window);
+
+ if (action == Click) {
+ sendKeyEvent(Press, window, code, text, modifier, delay);
+ sendKeyEvent(Release, window, code, text, modifier, delay);
+ return;
+ }
+
+ bool repeat = false;
+
+ if (action == Press) {
+ if (modifier & Qt::ShiftModifier)
+ simulateEvent(window, true, Qt::Key_Shift, 0, QString(), false, delay);
+
+ if (modifier & Qt::ControlModifier)
+ simulateEvent(window, true, Qt::Key_Control, modifier & Qt::ShiftModifier, QString(), false, delay);
+
+ if (modifier & Qt::AltModifier)
+ simulateEvent(window, true, Qt::Key_Alt,
+ modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
+ if (modifier & Qt::MetaModifier)
+ simulateEvent(window, true, Qt::Key_Meta, modifier & (Qt::ShiftModifier
+ | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
+ simulateEvent(window, true, code, modifier, text, repeat, delay);
+ } else if (action == Release) {
+ simulateEvent(window, false, code, modifier, text, repeat, delay);
+
+ if (modifier & Qt::MetaModifier)
+ simulateEvent(window, false, Qt::Key_Meta, modifier, QString(), false, delay);
+ if (modifier & Qt::AltModifier)
+ simulateEvent(window, false, Qt::Key_Alt, modifier &
+ (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
+
+ if (modifier & Qt::ControlModifier)
+ simulateEvent(window, false, Qt::Key_Control,
+ modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
+
+ if (modifier & Qt::ShiftModifier)
+ simulateEvent(window, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay);
+ }
+ }
+
+ // Convenience function
+ static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
+ char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
+ {
+ QString text;
+ if (ascii)
+ text = QString(QChar::fromLatin1(ascii));
+ sendKeyEvent(action, window, code, text, modifier, delay);
+ }
+
+ inline static void keyEvent(KeyAction action, QWindow *window, char ascii,
+ Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
+ { sendKeyEvent(action, window, asciiToKey(ascii), ascii, modifier, delay); }
+ inline static void keyEvent(KeyAction action, QWindow *window, Qt::Key key,
+ Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
+ { sendKeyEvent(action, window, key, keyToAscii(key), modifier, delay); }
+
+ inline static void keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
+ { keyEvent(Click, window, key, modifier, delay); }
+ inline static void keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
+ { keyEvent(Click, window, key, modifier, delay); }
+ inline static void keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
+ { keyEvent(Release, window, key, modifier, delay); }
+ inline static void keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
+ { keyEvent(Press, window, key, modifier, delay); }
+ inline static void keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
+ { keyEvent(Press, window, key, modifier, delay); }
+
#ifdef QT_WIDGETS_LIB
static void simulateEvent(QWidget *widget, bool press, int code,
Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
@@ -85,17 +167,7 @@ namespace QTest
if (!qApp->notify(widget, &a))
QTest::qWarn("Keyboard event not accepted by receiving widget");
}
-#endif
- //QWindow overload
- static void simulateEvent(QWindow *window, bool press, int code,
- Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
- {
- QEvent::Type type;
- type = press ? QEvent::KeyPress : QEvent::KeyRelease;
- QWindowSystemInterface::handleKeyEvent(window, type, code, modifier, text, repeat, delay);
- }
-#ifdef QT_WIDGETS_LIB
static void sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code,
QString text, Qt::KeyboardModifiers modifier, int delay=-1)
{
@@ -159,55 +231,7 @@ namespace QTest
simulateEvent(widget, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay);
}
}
-#endif
- //QWindow overload
- static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
- QString text, Qt::KeyboardModifiers modifier, int delay=-1)
- {
- QTEST_ASSERT(qApp);
- QTEST_ASSERT(window);
-
- if (action == Click) {
- sendKeyEvent(Press, window, code, text, modifier, delay);
- sendKeyEvent(Release, window, code, text, modifier, delay);
- return;
- }
-
- bool repeat = false;
- if (action == Press) {
- if (modifier & Qt::ShiftModifier)
- simulateEvent(window, true, Qt::Key_Shift, 0, QString(), false, delay);
-
- if (modifier & Qt::ControlModifier)
- simulateEvent(window, true, Qt::Key_Control, modifier & Qt::ShiftModifier, QString(), false, delay);
-
- if (modifier & Qt::AltModifier)
- simulateEvent(window, true, Qt::Key_Alt,
- modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
- if (modifier & Qt::MetaModifier)
- simulateEvent(window, true, Qt::Key_Meta, modifier & (Qt::ShiftModifier
- | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
- simulateEvent(window, true, code, modifier, text, repeat, delay);
- } else if (action == Release) {
- simulateEvent(window, false, code, modifier, text, repeat, delay);
-
- if (modifier & Qt::MetaModifier)
- simulateEvent(window, false, Qt::Key_Meta, modifier, QString(), false, delay);
- if (modifier & Qt::AltModifier)
- simulateEvent(window, false, Qt::Key_Alt, modifier &
- (Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier), QString(), false, delay);
-
- if (modifier & Qt::ControlModifier)
- simulateEvent(window, false, Qt::Key_Control,
- modifier & (Qt::ShiftModifier | Qt::ControlModifier), QString(), false, delay);
-
- if (modifier & Qt::ShiftModifier)
- simulateEvent(window, false, Qt::Key_Shift, modifier & Qt::ShiftModifier, QString(), false, delay);
- }
- }
-
-#ifdef QT_WIDGETS_LIB
// Convenience function
static void sendKeyEvent(KeyAction action, QWidget *widget, Qt::Key code,
char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
@@ -217,35 +241,14 @@ namespace QTest
text = QString(QChar::fromLatin1(ascii));
sendKeyEvent(action, widget, code, text, modifier, delay);
}
-#endif
- // QWindow convenience function
- static void sendKeyEvent(KeyAction action, QWindow *window, Qt::Key code,
- char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
- {
- QString text;
- if (ascii)
- text = QString(QChar::fromLatin1(ascii));
- sendKeyEvent(action, window, code, text, modifier, delay);
- }
-#ifdef QT_WIDGETS_LIB
inline static void keyEvent(KeyAction action, QWidget *widget, char ascii,
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
{ sendKeyEvent(action, widget, asciiToKey(ascii), ascii, modifier, delay); }
inline static void keyEvent(KeyAction action, QWidget *widget, Qt::Key key,
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
{ sendKeyEvent(action, widget, key, keyToAscii(key), modifier, delay); }
-#endif
- //Support QWindow
- inline static void keyEvent(KeyAction action, QWindow *window, char ascii,
- Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
- { sendKeyEvent(action, window, asciiToKey(ascii), ascii, modifier, delay); }
- inline static void keyEvent(KeyAction action, QWindow *window, Qt::Key key,
- Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
- { sendKeyEvent(action, window, key, keyToAscii(key), modifier, delay); }
- ///////////////
-#ifdef QT_WIDGETS_LIB
inline static void keyClicks(QWidget *widget, const QString &sequence,
Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
{
@@ -265,18 +268,7 @@ namespace QTest
{ keyEvent(Release, widget, key, modifier, delay); }
inline static void keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
{ keyEvent(Click, widget, key, modifier, delay); }
-#endif
- //Support QWindow
- inline static void keyClick(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
- { keyEvent(Click, window, key, modifier, delay); }
- inline static void keyClick(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
- { keyEvent(Click, window, key, modifier, delay); }
- inline static void keyRelease(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
- { keyEvent(Release, window, key, modifier, delay); }
- inline static void keyPress(QWindow *window, char key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
- { keyEvent(Press, window, key, modifier, delay); }
- inline static void keyPress(QWindow *window, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
- { keyEvent(Press, window, key, modifier, delay); }
+#endif // QT_WIDGETS_LIB
}
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index b032c376f8..a199a2d2ae 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -68,46 +68,55 @@ namespace QTest
{
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove };
-#ifdef QT_WIDGETS_LIB
- static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button,
+ static void mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button,
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
{
- QTEST_ASSERT(widget);
+ QTEST_ASSERT(window);
extern int Q_TESTLIB_EXPORT defaultMouseDelay();
+ static Qt::MouseButton lastButton = Qt::NoButton;
+
if (delay == -1 || delay < defaultMouseDelay())
delay = defaultMouseDelay();
if (delay > 0)
QTest::qWait(delay);
if (pos.isNull())
- pos = widget->rect().center();
+ pos = window->geometry().center();
if (action == MouseClick) {
- mouseEvent(MousePress, widget, button, stateKey, pos);
- mouseEvent(MouseRelease, widget, button, stateKey, pos);
+ mouseEvent(MousePress, window, button, stateKey, pos);
+ mouseEvent(MouseRelease, window, button, stateKey, pos);
return;
}
-
QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
- QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
+
switch (action)
{
case MousePress:
- me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey);
+ QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),button);
+ lastButton = button;
break;
case MouseRelease:
- me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey);
+ QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton);
+ lastButton = Qt::NoButton;
break;
case MouseDClick:
- me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey);
+ QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),button);
+ qWait(10);
+ QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton);
+ qWait(20);
+ QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),button);
+ qWait(10);
+ QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton);
break;
case MouseMove:
- QCursor::setPos(widget->mapToGlobal(pos));
+ QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton);
+ //QCursor::setPos(window->mapToGlobal(pos));
#ifdef QT_MAC_USE_COCOA
QTest::qWait(20);
#else
@@ -117,66 +126,63 @@ namespace QTest
default:
QTEST_ASSERT(false);
}
- QSpontaneKeyEvent::setSpontaneous(&me);
- if (!qApp->notify(widget, &me)) {
- static const char *mouseActionNames[] =
- { "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
- QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
- QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toAscii().data());
- }
-
}
-#endif
- static void mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button,
+ inline void mousePress(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
+ QPoint pos = QPoint(), int delay=-1)
+ { mouseEvent(MousePress, window, button, stateKey, pos, delay); }
+ inline void mouseRelease(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
+ QPoint pos = QPoint(), int delay=-1)
+ { mouseEvent(MouseRelease, window, button, stateKey, pos, delay); }
+ inline void mouseClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
+ QPoint pos = QPoint(), int delay=-1)
+ { mouseEvent(MouseClick, window, button, stateKey, pos, delay); }
+ inline void mouseDClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
+ QPoint pos = QPoint(), int delay=-1)
+ { mouseEvent(MouseDClick, window, button, stateKey, pos, delay); }
+ inline void mouseMove(QWindow *window, QPoint pos = QPoint(), int delay=-1)
+ { mouseEvent(MouseMove, window, Qt::NoButton, 0, pos, delay); }
+
+#ifdef QT_WIDGETS_LIB
+ static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button,
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
{
- QTEST_ASSERT(window);
+ QTEST_ASSERT(widget);
extern int Q_TESTLIB_EXPORT defaultMouseDelay();
- static Qt::MouseButton lastButton = Qt::NoButton;
-
if (delay == -1 || delay < defaultMouseDelay())
delay = defaultMouseDelay();
if (delay > 0)
QTest::qWait(delay);
if (pos.isNull())
- pos = window->geometry().center();
+ pos = widget->rect().center();
if (action == MouseClick) {
- mouseEvent(MousePress, window, button, stateKey, pos);
- mouseEvent(MouseRelease, window, button, stateKey, pos);
+ mouseEvent(MousePress, widget, button, stateKey, pos);
+ mouseEvent(MouseRelease, widget, button, stateKey, pos);
return;
}
+
QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
-
+ QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
switch (action)
{
case MousePress:
- QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),button);
- lastButton = button;
+ me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey);
break;
case MouseRelease:
- QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton);
- lastButton = Qt::NoButton;
+ me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey);
break;
case MouseDClick:
- QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),button);
- qWait(10);
- QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton);
- qWait(20);
- QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),button);
- qWait(10);
- QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),Qt::NoButton);
+ me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey);
break;
case MouseMove:
- QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton);
- //QCursor::setPos(window->mapToGlobal(pos));
+ QCursor::setPos(widget->mapToGlobal(pos));
#ifdef QT_MAC_USE_COCOA
QTest::qWait(20);
#else
@@ -186,9 +192,16 @@ namespace QTest
default:
QTEST_ASSERT(false);
}
+ QSpontaneKeyEvent::setSpontaneous(&me);
+ if (!qApp->notify(widget, &me)) {
+ static const char *mouseActionNames[] =
+ { "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
+ QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
+ QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toAscii().data());
+ }
+
}
-#ifdef QT_WIDGETS_LIB
inline void mousePress(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
QPoint pos = QPoint(), int delay=-1)
{ mouseEvent(MousePress, widget, button, stateKey, pos, delay); }
@@ -203,23 +216,7 @@ namespace QTest
{ mouseEvent(MouseDClick, widget, button, stateKey, pos, delay); }
inline void mouseMove(QWidget *widget, QPoint pos = QPoint(), int delay=-1)
{ mouseEvent(MouseMove, widget, Qt::NoButton, 0, pos, delay); }
-#endif
-
- //Support QWindow
- inline void mousePress(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
- QPoint pos = QPoint(), int delay=-1)
- { mouseEvent(MousePress, window, button, stateKey, pos, delay); }
- inline void mouseRelease(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
- QPoint pos = QPoint(), int delay=-1)
- { mouseEvent(MouseRelease, window, button, stateKey, pos, delay); }
- inline void mouseClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
- QPoint pos = QPoint(), int delay=-1)
- { mouseEvent(MouseClick, window, button, stateKey, pos, delay); }
- inline void mouseDClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
- QPoint pos = QPoint(), int delay=-1)
- { mouseEvent(MouseDClick, window, button, stateKey, pos, delay); }
- inline void mouseMove(QWindow *window, QPoint pos = QPoint(), int delay=-1)
- { mouseEvent(MouseMove, window, Qt::NoButton, 0, pos, delay); }
+#endif // QT_WIDGETS_LIB
}
QT_END_NAMESPACE
diff --git a/src/testlib/qtesttouch.h b/src/testlib/qtesttouch.h
index 4562cd4c73..b5333f1114 100644
--- a/src/testlib/qtesttouch.h
+++ b/src/testlib/qtesttouch.h
@@ -79,61 +79,57 @@ namespace QTest
commit();
points.clear();
}
-#ifdef QT_WIDGETS_LIB
- QTouchEventSequence& press(int touchId, const QPoint &pt, QWidget *widget = 0)
+ QTouchEventSequence& press(int touchId, const QPoint &pt, QWindow *window = 0)
{
QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(widget, pt));
+ p.setScreenPos(mapToScreen(window, pt));
p.setState(Qt::TouchPointPressed);
return *this;
}
-#endif
- QTouchEventSequence& press(int touchId, const QPoint &pt, QWindow *window = 0)
+ QTouchEventSequence& move(int touchId, const QPoint &pt, QWindow *window = 0)
{
QTouchEvent::TouchPoint &p = point(touchId);
p.setScreenPos(mapToScreen(window, pt));
- p.setState(Qt::TouchPointPressed);
+ p.setState(Qt::TouchPointMoved);
return *this;
}
-
-#ifdef QT_WIDGETS_LIB
- QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = 0)
+ QTouchEventSequence& release(int touchId, const QPoint &pt, QWindow *window = 0)
{
QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(widget, pt));
- p.setState(Qt::TouchPointMoved);
+ p.setScreenPos(mapToScreen(window, pt));
+ p.setState(Qt::TouchPointReleased);
return *this;
}
-#endif
- QTouchEventSequence& move(int touchId, const QPoint &pt, QWindow *window = 0)
+ QTouchEventSequence& stationary(int touchId)
{
QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(window, pt));
- p.setState(Qt::TouchPointMoved);
+ p.setState(Qt::TouchPointStationary);
return *this;
}
+
#ifdef QT_WIDGETS_LIB
- QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = 0)
+ QTouchEventSequence& press(int touchId, const QPoint &pt, QWidget *widget = 0)
{
QTouchEvent::TouchPoint &p = point(touchId);
p.setScreenPos(mapToScreen(widget, pt));
- p.setState(Qt::TouchPointReleased);
+ p.setState(Qt::TouchPointPressed);
return *this;
}
-#endif
- QTouchEventSequence& release(int touchId, const QPoint &pt, QWindow *window = 0)
+ QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = 0)
{
QTouchEvent::TouchPoint &p = point(touchId);
- p.setScreenPos(mapToScreen(window, pt));
- p.setState(Qt::TouchPointReleased);
+ p.setScreenPos(mapToScreen(widget, pt));
+ p.setState(Qt::TouchPointMoved);
return *this;
}
- QTouchEventSequence& stationary(int touchId)
+ QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = 0)
{
QTouchEvent::TouchPoint &p = point(touchId);
- p.setState(Qt::TouchPointStationary);
+ p.setScreenPos(mapToScreen(widget, pt));
+ p.setState(Qt::TouchPointReleased);
return *this;
}
+#endif
private:
#ifdef QT_WIDGETS_LIB