From 7d566bc4eb5b5e47b48f28012fed24109a8dd735 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 1 Sep 2009 15:52:10 +1000 Subject: Remove unused member variables from QmlEnginePrivate --- src/declarative/qml/qmlengine.cpp | 9 +-------- src/declarative/qml/qmlengine_p.h | 4 ---- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 1640dcb..652144d 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -107,7 +107,7 @@ QScriptValue desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e) } QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) -: rootContext(0), currentBindContext(0), currentExpression(0), +: rootContext(0), currentExpression(0), isDebugging(false), contextClass(0), objectClass(0), valueTypeClass(0), nodeListClass(0), namedNodeMapClass(0), scriptEngine(this), rootComponent(0), networkAccessManager(0), typeManager(e), uniqueId(1) @@ -199,13 +199,6 @@ void QmlEnginePrivate::init() } } -QmlContext *QmlEnginePrivate::setCurrentBindContext(QmlContext *c) -{ - QmlContext *old = currentBindContext; - currentBindContext = c; - return old; -} - QmlEnginePrivate::CapturedProperty::CapturedProperty(const QmlMetaProperty &p) : object(p.object()), coreIndex(p.coreIndex()), notifyIndex(p.property().notifySignalIndex()) { diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index b3c6279..b595e7c 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -114,7 +114,6 @@ public: QPODVector capturedProperties; QmlContext *rootContext; - QmlContext *currentBindContext; // ### Remove me QmlExpression *currentExpression; bool isDebugging; #ifdef QT_SCRIPTTOOLS_LIB @@ -128,9 +127,6 @@ public: QScriptClass *nodeListClass; QScriptClass *namedNodeMapClass; - QmlContext *setCurrentBindContext(QmlContext *); - QStack activeContexts; // ### Remove me - struct QmlScriptEngine : public QScriptEngine { QmlScriptEngine(QmlEnginePrivate *priv) -- cgit v0.12 From 5ef36ea88e15bb4a12575c6639b1d9e6c3be9de6 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 2 Sep 2009 10:57:30 +1000 Subject: Add TextInput key handling test --- .../declarative/qfxtextinput/data/navigation.qml | 23 +++++++ .../auto/declarative/qfxtextinput/qfxtextinput.pro | 6 ++ .../declarative/qfxtextinput/tst_qfxtextinput.cpp | 78 ++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 tests/auto/declarative/qfxtextinput/data/navigation.qml create mode 100644 tests/auto/declarative/qfxtextinput/qfxtextinput.pro create mode 100644 tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp diff --git a/tests/auto/declarative/qfxtextinput/data/navigation.qml b/tests/auto/declarative/qfxtextinput/data/navigation.qml new file mode 100644 index 0000000..c1a6162 --- /dev/null +++ b/tests/auto/declarative/qfxtextinput/data/navigation.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +Rectangle { + property var myInput: Input + + width: 800; height: 600; color: "blue" + + Item { + id: FirstItem + KeyNavigation.right: Input + } + + TextInput { id: Input; focus: true; + KeyNavigation.left: FirstItem + KeyNavigation.right: LastItem + KeyNavigation.up: FirstItem + KeyNavigation.down: LastItem + } + Item { + id: LastItem + KeyNavigation.left: Input + } +} diff --git a/tests/auto/declarative/qfxtextinput/qfxtextinput.pro b/tests/auto/declarative/qfxtextinput/qfxtextinput.pro new file mode 100644 index 0000000..396e66d --- /dev/null +++ b/tests/auto/declarative/qfxtextinput/qfxtextinput.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +SOURCES += tst_qfxtextinput.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp new file mode 100644 index 0000000..852a868 --- /dev/null +++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include +#include + +class tst_qfxtextinput : public QObject + +{ + Q_OBJECT +public: + tst_qfxtextinput(); + +private slots: + void navigation(); + +private: + void simulateKey(QFxView *, int key); + QFxView *createView(const QString &filename); + + QmlEngine engine; +}; + +tst_qfxtextinput::tst_qfxtextinput() +{ +} + +/* +TextInput element should only handle left/right keys until the cursor reaches +the extent of the text, then they should ignore the keys. +*/ +void tst_qfxtextinput::navigation() +{ + QFxView *canvas = createView(SRCDIR "/data/navigation.qml"); + canvas->execute(); + canvas->show(); + + QVERIFY(canvas->root() != 0); + + QFxItem *input = qobject_cast(qvariant_cast(canvas->root()->property("myInput"))); + + QVERIFY(input != 0); + QVERIFY(input->hasFocus() == true); + simulateKey(canvas, Qt::Key_Left); + QVERIFY(input->hasFocus() == false); + simulateKey(canvas, Qt::Key_Right); + QVERIFY(input->hasFocus() == true); + simulateKey(canvas, Qt::Key_Right); + QVERIFY(input->hasFocus() == false); + simulateKey(canvas, Qt::Key_Left); + QVERIFY(input->hasFocus() == true); +} + +void tst_qfxtextinput::simulateKey(QFxView *view, int key) +{ + QKeyEvent press(QKeyEvent::KeyPress, key, 0); + QKeyEvent release(QKeyEvent::KeyRelease, key, 0); + + QApplication::sendEvent(view, &press); + QApplication::sendEvent(view, &release); +} + +QFxView *tst_qfxtextinput::createView(const QString &filename) +{ + QFxView *canvas = new QFxView(0); + + QFile file(filename); + file.open(QFile::ReadOnly); + QString xml = file.readAll(); + canvas->setQml(xml, filename); + + return canvas; +} + +QTEST_MAIN(tst_qfxtextinput) + +#include "tst_qfxtextinput.moc" -- cgit v0.12