summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJani Hautakangas <ext-jani.hautakangas@nokia.com>2009-09-30 08:44:53 (GMT)
committerJani Hautakangas <ext-jani.hautakangas@nokia.com>2009-09-30 08:44:53 (GMT)
commitf4c2e64e4700c54750a82bf5a2d6c575afb1cde6 (patch)
tree471860d7f5f1312ce02f1e671bab10871217b1c1 /tests
parent6889622da4d17e5cd97e483deb780d83e3bb4548 (diff)
parentb35bbc064b967c6ec5522fe4e2e76522e92a0a96 (diff)
downloadQt-f4c2e64e4700c54750a82bf5a2d6c575afb1cde6.zip
Qt-f4c2e64e4700c54750a82bf5a2d6c575afb1cde6.tar.gz
Qt-f4c2e64e4700c54750a82bf5a2d6c575afb1cde6.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp21
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp52
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp5
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp31
-rw-r--r--tests/auto/qlocalsocket/lackey/lackey.pro2
-rw-r--r--tests/auto/qlocalsocket/tst_qlocalsocket.cpp114
-rw-r--r--tests/auto/qmake/testdata/prompt/prompt.pro2
-rw-r--r--tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp6
-rw-r--r--tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp1
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp6
-rw-r--r--tests/auto/qsqldriver/qsqldriver.pro8
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp88
-rw-r--r--tests/auto/qurl/tst_qurl.cpp65
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp1
-rw-r--r--tests/manual/keypadnavigation/keypadnavigation.ui105
-rw-r--r--tests/manual/keypadnavigation/main.cpp114
16 files changed, 541 insertions, 80 deletions
diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
index a388f0a..63bc90c 100644
--- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -823,7 +823,7 @@ void tst_QFileSystemModel::sort()
out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n";
tempFile2.close();
- myModel->setRootPath(QDir::rootPath());
+ myModel->setRootPath("");
myModel->setFilter(QDir::AllEntries | QDir::System | QDir::Hidden);
tree->setSortingEnabled(true);
tree->setModel(myModel);
@@ -846,11 +846,22 @@ void tst_QFileSystemModel::sort()
tree->expand(myModel->index(dirPath, 0));
QTest::qWait(500);
QModelIndex parent = myModel->index(dirPath, 0);
+ QList<QString> expectedOrder;
+ expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + "." << dirPath + QChar('/') + "..";
//File dialog Mode means sub trees are not sorted, only the current root
- if (fileDialogMode)
- QVERIFY(dirPath + QChar('/') + myModel->index(0, 1, parent).data(QFileSystemModel::FileNameRole).toString() != tempFile2.fileName());
- else
- QCOMPARE(dirPath + QChar('/') + myModel->index(0, 1, parent).data(QFileSystemModel::FileNameRole).toString(), tempFile2.fileName());
+ if (fileDialogMode) {
+ QList<QString> actualRows;
+ for(int i = 0; i < myModel->rowCount(parent); ++i)
+ {
+ actualRows << dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString();
+ }
+ QVERIFY(actualRows != expectedOrder);
+ } else {
+ for(int i = 0; i < myModel->rowCount(parent); ++i)
+ {
+ QVERIFY(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString() == expectedOrder.at(i));
+ }
+ }
delete tree;
delete myModel;
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 2fee98d..9f13aca 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -40,9 +40,10 @@
****************************************************************************/
#include <QtTest/QtTest>
-#include <qgraphicsanchorlayout.h>
-#include <qgraphicswidget.h>
-#include <qgraphicsproxywidget.h>
+#include <QtGui/qgraphicsanchorlayout.h>
+#include <private/qgraphicsanchorlayout_p.h>
+#include <QtGui/qgraphicswidget.h>
+#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qgraphicsview.h>
class tst_QGraphicsAnchorLayout : public QObject {
@@ -142,6 +143,11 @@ static bool checkReverseDirection(QGraphicsWidget *w)
return true;
}
+static bool layoutHasConflict(QGraphicsAnchorLayout *l)
+{
+ return QGraphicsAnchorLayoutPrivate::get(l)->hasConflicts();
+}
+
void tst_QGraphicsAnchorLayout::simple()
{
QGraphicsWidget *w1 = createItem();
@@ -154,8 +160,6 @@ void tst_QGraphicsAnchorLayout::simple()
QGraphicsWidget p;
p.setLayout(l);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 2);
}
@@ -185,8 +189,6 @@ void tst_QGraphicsAnchorLayout::simple_center()
setAnchor(l, b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 3);
QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
@@ -234,8 +236,6 @@ void tst_QGraphicsAnchorLayout::simple_semifloat()
setAnchor(l, a, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 4);
QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
@@ -296,7 +296,6 @@ void tst_QGraphicsAnchorLayout::layoutDirection()
view->show();
QCOMPARE(checkReverseDirection(p), true);
- QVERIFY(l->hasConflicts() == false);
delete p;
delete view;
@@ -340,8 +339,6 @@ void tst_QGraphicsAnchorLayout::diagonal()
l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 5);
QGraphicsWidget p;
@@ -391,7 +388,7 @@ void tst_QGraphicsAnchorLayout::diagonal()
QCOMPARE(checkReverseDirection(&p), true);
c->setMinimumWidth(300);
- QVERIFY(l->hasConflicts());
+ QVERIFY(layoutHasConflict(l));
}
void tst_QGraphicsAnchorLayout::parallel()
@@ -484,8 +481,6 @@ void tst_QGraphicsAnchorLayout::parallel()
QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100));
QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::parallel2()
@@ -510,7 +505,6 @@ void tst_QGraphicsAnchorLayout::parallel2()
l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft);
l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 2);
QGraphicsWidget p;
@@ -592,8 +586,6 @@ void tst_QGraphicsAnchorLayout::snake()
QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0));
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
@@ -627,7 +619,6 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 3);
QGraphicsWidget p;
@@ -731,8 +722,6 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0));
QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
@@ -809,8 +798,6 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QCOMPARE(a->size(), d->size());
QCOMPARE(e->size().width(), 4 * a->size().width());
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::proportionalPreferred()
@@ -873,8 +860,6 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred()
QCOMPARE(a->size().width(), 10 * factor);
QCOMPARE(c->size().width(), 14 * factor);
QCOMPARE(p.size(), QSizeF(12, 400));
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::example()
@@ -928,7 +913,6 @@ void tst_QGraphicsAnchorLayout::example()
l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 7);
QGraphicsWidget p;
@@ -1017,8 +1001,6 @@ void tst_QGraphicsAnchorLayout::setSpacing()
QCOMPARE(b->geometry(), QRectF(24, 0, 20, 20));
QCOMPARE(c->geometry(), QRectF(0, 20, 44, 20));
- QVERIFY(l->hasConflicts() == false);
-
delete p;
delete view;
}
@@ -1103,7 +1085,6 @@ void tst_QGraphicsAnchorLayout::hardComplexS60()
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
QCOMPARE(layoutMaximumSize, QSizeF(240, 40));
- QVERIFY(l->hasConflicts() == false);
delete p;
}
@@ -1166,7 +1147,6 @@ void tst_QGraphicsAnchorLayout::delete_anchor()
QGraphicsWidget *p = new QGraphicsWidget;
p->setLayout(l);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 3);
scene.addItem(p);
@@ -1281,6 +1261,12 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
delete view;
}
+/*!
+ \internal
+
+ Uses private API. (We have decided to pull hasConflicts() out of the API). However, it also
+ tests some tight conditions (almost-in-conflict) that we really want to test.
+*/
void tst_QGraphicsAnchorLayout::conflicts()
{
QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a");
@@ -1311,13 +1297,13 @@ void tst_QGraphicsAnchorLayout::conflicts()
p->setLayout(l);
- QCOMPARE(l->hasConflicts(), true);
+ QCOMPARE(layoutHasConflict(l), true);
a->setMinimumSize(QSizeF(29,10));
- QCOMPARE(l->hasConflicts(), false);
+ QCOMPARE(layoutHasConflict(l), false);
a->setMinimumSize(QSizeF(30,10));
- QCOMPARE(l->hasConflicts(), false);
+ QCOMPARE(layoutHasConflict(l), false);
delete p;
}
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index a6746db..a521b78 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -43,7 +43,8 @@
#include <QtTest/QtTest>
#include <QTest>
#include <QMetaType>
-#include <QGraphicsAnchorLayout>
+#include <QtGui/qgraphicsanchorlayout.h>
+#include <private/qgraphicsanchorlayout_p.h>
#define TEST_COMPLEX_CASES
@@ -60,7 +61,7 @@ public:
bool isValid()
{
- return !hasConflicts();
+ return !QGraphicsAnchorLayoutPrivate::get(this)->hasConflicts();
}
void setAnchor(
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 956faa1..d08e74b 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -62,7 +62,6 @@
#include "../../shared/util.h"
-
//TESTED_CLASS=
//TESTED_FILES=
@@ -307,6 +306,7 @@ private slots:
void task240400_clickOnTextItem();
void task243707_addChildBeforeParent();
void task197802_childrenVisibility();
+ void QTBUG_4233_updateCachedWithSceneRect();
private:
QList<QGraphicsItem *> paintedItems;
@@ -8463,5 +8463,34 @@ void tst_QGraphicsItem::stackBefore()
QCOMPARE(scene.items(QPointF(2, 2), Qt::IntersectsItemBoundingRect, Qt::AscendingOrder), (QList<QGraphicsItem *>() << child2 << child4 << child3 << child1));
}
+void tst_QGraphicsItem::QTBUG_4233_updateCachedWithSceneRect()
+{
+ EventTester *tester = new EventTester;
+ tester->setCacheMode(QGraphicsItem::ItemCoordinateCache);
+
+ QGraphicsScene scene;
+ scene.addItem(tester);
+ scene.setSceneRect(-100, -100, 200, 200); // contains the tester item
+
+ QGraphicsView view(&scene);
+ view.show();
+ QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view);
+
+ QCOMPARE(tester->repaints, 1);
+
+ scene.update(); // triggers "updateAll" optimization
+ qApp->processEvents();
+ qApp->processEvents(); // in 4.6 only one processEvents is necessary
+
+ QCOMPARE(tester->repaints, 1);
+
+ scene.update(); // triggers "updateAll" optimization
+ tester->update();
+ qApp->processEvents();
+ qApp->processEvents(); // in 4.6 only one processEvents is necessary
+
+ QCOMPARE(tester->repaints, 2);
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qlocalsocket/lackey/lackey.pro b/tests/auto/qlocalsocket/lackey/lackey.pro
index efb2f52..8182394 100644
--- a/tests/auto/qlocalsocket/lackey/lackey.pro
+++ b/tests/auto/qlocalsocket/lackey/lackey.pro
@@ -1,4 +1,4 @@
-include(../src/src.pri)
+#include(../src/src.pri)
QT = core script network
diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
index 1180d4d..be39d00 100644
--- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp
@@ -87,6 +87,8 @@ private slots:
void sendData_data();
void sendData();
+ void readBufferOverflow();
+
void fullPath();
void hitMaximumConnections_data();
@@ -102,13 +104,15 @@ private slots:
void longPath();
void waitForDisconnect();
+ void waitForDisconnectByServer();
void removeServer();
void recycleServer();
+ void multiConnect();
+ void writeOnlySocket();
void writeToClientAndDisconnect();
-
void debug();
void bytesWrittenSignal();
@@ -151,7 +155,13 @@ public:
LocalServer() : QLocalServer()
{
connect(this, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
- };
+ }
+
+ bool listen(const QString &name)
+ {
+ removeServer(name);
+ return QLocalServer::listen(name);
+ }
QList<int> hits;
@@ -553,6 +563,40 @@ void tst_QLocalSocket::sendData()
QCOMPARE(spy.count(), (canListen ? 1 : 0));
}
+void tst_QLocalSocket::readBufferOverflow()
+{
+ const int readBufferSize = 128;
+ const int dataBufferSize = readBufferSize * 2;
+ const QString serverName = QLatin1String("myPreciousTestServer");
+ LocalServer server;
+ server.listen(serverName);
+ QVERIFY(server.isListening());
+
+ LocalSocket client;
+ client.setReadBufferSize(readBufferSize);
+ client.connectToServer(serverName);
+
+ bool timedOut = true;
+ QVERIFY(server.waitForNewConnection(3000, &timedOut));
+ QVERIFY(!timedOut);
+
+ QCOMPARE(client.state(), QLocalSocket::ConnectedState);
+ QVERIFY(server.hasPendingConnections());
+
+ QLocalSocket* serverSocket = server.nextPendingConnection();
+ char buffer[dataBufferSize];
+ memset(buffer, 0, dataBufferSize);
+ serverSocket->write(buffer, dataBufferSize);
+ serverSocket->flush();
+
+ QVERIFY(client.waitForReadyRead());
+ QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
+#if defined(QT_LOCALSOCKET_TCP) || defined(Q_OS_SYMBIAN)
+ QTest::qWait(250);
+#endif
+ QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize));
+}
+
// QLocalSocket/Server can take a name or path, check that it works as expected
void tst_QLocalSocket::fullPath()
{
@@ -833,6 +877,25 @@ void tst_QLocalSocket::waitForDisconnect()
QVERIFY(timer.elapsed() < 2000);
}
+void tst_QLocalSocket::waitForDisconnectByServer()
+{
+ QString name = "tst_localsocket";
+ LocalServer server;
+ QVERIFY(server.listen(name));
+ LocalSocket socket;
+ QSignalSpy spy(&socket, SIGNAL(disconnected()));
+ QVERIFY(spy.isValid());
+ socket.connectToServer(name);
+ QVERIFY(socket.waitForConnected(3000));
+ QVERIFY(server.waitForNewConnection(3000));
+ QLocalSocket *serverSocket = server.nextPendingConnection();
+ QVERIFY(serverSocket);
+ serverSocket->close();
+ QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState);
+ QVERIFY(socket.waitForDisconnected(3000));
+ QCOMPARE(spy.count(), 1);
+}
+
void tst_QLocalSocket::removeServer()
{
// this is a hostile takeover, but recovering from a crash results in the same
@@ -874,6 +937,53 @@ void tst_QLocalSocket::recycleServer()
QVERIFY(server.nextPendingConnection() != 0);
}
+void tst_QLocalSocket::multiConnect()
+{
+ QLocalServer server;
+ QLocalSocket client1;
+ QLocalSocket client2;
+ QLocalSocket client3;
+
+ QVERIFY(server.listen("multiconnect"));
+
+ client1.connectToServer("multiconnect");
+ client2.connectToServer("multiconnect");
+ client3.connectToServer("multiconnect");
+
+ QVERIFY(client1.waitForConnected(201));
+ QVERIFY(client2.waitForConnected(202));
+ QVERIFY(client3.waitForConnected(203));
+
+ QVERIFY(server.waitForNewConnection(201));
+ QVERIFY(server.nextPendingConnection() != 0);
+ QVERIFY(server.waitForNewConnection(202));
+ QVERIFY(server.nextPendingConnection() != 0);
+ QVERIFY(server.waitForNewConnection(203));
+ QVERIFY(server.nextPendingConnection() != 0);
+}
+
+void tst_QLocalSocket::writeOnlySocket()
+{
+ QLocalServer server;
+#ifdef Q_OS_SYMBIAN
+ unlink("writeOnlySocket");
+#endif
+ QVERIFY(server.listen("writeOnlySocket"));
+
+ QLocalSocket client;
+ client.connectToServer("writeOnlySocket", QIODevice::WriteOnly);
+ QVERIFY(client.waitForConnected());
+#if defined(Q_OS_SYMBIAN)
+ QTest::qWait(250);
+#endif
+ QVERIFY(server.waitForNewConnection());
+ QLocalSocket* serverSocket = server.nextPendingConnection();
+ QVERIFY(serverSocket);
+
+ QCOMPARE(client.bytesAvailable(), qint64(0));
+ QCOMPARE(client.state(), QLocalSocket::ConnectedState);
+}
+
void tst_QLocalSocket::writeToClientAndDisconnect()
{
#ifdef Q_OS_SYMBIAN
diff --git a/tests/auto/qmake/testdata/prompt/prompt.pro b/tests/auto/qmake/testdata/prompt/prompt.pro
index 02db4fe..238022c 100644
--- a/tests/auto/qmake/testdata/prompt/prompt.pro
+++ b/tests/auto/qmake/testdata/prompt/prompt.pro
@@ -1,2 +1,2 @@
-a = $$prompt(Prompteroo)
+# a = $$prompt(Prompteroo)
diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index 86a04d0..cc5104a 100644
--- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -259,6 +259,9 @@ void tst_QNetworkDiskCache::data_data()
// public QIODevice* data(QUrl const& url)
void tst_QNetworkDiskCache::data()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll);
+#endif
QFETCH(QNetworkCacheMetaData, data);
SubQNetworkDiskCache cache;
QUrl url(EXAMPLE_URL);
@@ -335,6 +338,9 @@ void tst_QNetworkDiskCache::setCacheDirectory()
// public void updateMetaData(QNetworkCacheMetaData const& metaData)
void tst_QNetworkDiskCache::updateMetaData()
{
+#ifdef Q_OS_SYMBIAN
+ QSKIP("Due to mmap(...) bug in Open C [Temtrack DEF142242]", SkipAll);
+#endif
QUrl url(EXAMPLE_URL);
SubQNetworkDiskCache cache;
cache.setupWithOne(url);
diff --git a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp
index c305221..94f08d9 100644
--- a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp
+++ b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp
@@ -640,6 +640,7 @@ tst_Suite::tst_Suite()
addExpectedFailure("ecma_3/Unicode/regress-352044-01.js", "issues with Unicode escape sequences in JavaScript source code", willFixInNextReleaseMessage);
addExpectedFailure("ecma_3/Unicode/uc-001.js", "Unicode format-control character test (Category Cf.)", willFixInNextReleaseMessage);
+ addFileExclusion(".+/15\\.9\\.2\\..+", "unstable on slow machines");
addFileExclusion(".+/15\\.9\\.5\\..+", "too slooow");
addFileExclusion("regress-130451.js", "asserts");
addFileExclusion("regress-322135-01.js", "asserts");
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index 6792ebf..6b64e76 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -51,6 +51,10 @@
//TESTED_CLASS=
//TESTED_FILES=
+QT_BEGIN_NAMESPACE
+extern bool qt_script_isJITEnabled();
+QT_END_NAMESPACE
+
class tst_QScriptValue : public QObject
{
Q_OBJECT
@@ -2886,7 +2890,6 @@ void tst_QScriptValue::equals()
{
QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << qobj1 << qobj2);
QVERIFY(ret.isBool());
- QEXPECT_FAIL("", "In JSC back-end, == on QObject wrappers doesn't work", Continue);
QVERIFY(ret.toBool());
ret = compareFun.call(QScriptValue(), QScriptValueList() << qobj1 << qobj3);
QVERIFY(ret.isBool());
@@ -2906,7 +2909,6 @@ void tst_QScriptValue::equals()
{
QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << var1 << var2);
QVERIFY(ret.isBool());
- QEXPECT_FAIL("", "In JSC back-end, == on QVariant wrappers doesn't work", Continue);
QVERIFY(ret.toBool());
}
}
diff --git a/tests/auto/qsqldriver/qsqldriver.pro b/tests/auto/qsqldriver/qsqldriver.pro
index 84f1cb2..7f289a6 100644
--- a/tests/auto/qsqldriver/qsqldriver.pro
+++ b/tests/auto/qsqldriver/qsqldriver.pro
@@ -15,3 +15,11 @@ wince*: {
LIBS += ws2_32.lib
}
}
+
+symbian {
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ sqlite.path = /sys/bin
+ sqlite.sources = sqlite3.dll
+ DEPLOYMENT += sqlite
+ }
+}
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 37b34bf..b808f7f 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -119,6 +119,8 @@ private slots:
void assignProperty();
void assignPropertyWithAnimation();
void postEvent();
+ void cancelDelayedEvent();
+ void postDelayedEventAndStop();
void stateFinished();
void parallelStates();
void parallelRootState();
@@ -1543,8 +1545,8 @@ private:
class StringEventPoster : public QState
{
public:
- StringEventPoster(QStateMachine *machine, const QString &value, QState *parent = 0)
- : QState(parent), m_machine(machine), m_value(value), m_delay(0) {}
+ StringEventPoster(const QString &value, QState *parent = 0)
+ : QState(parent), m_value(value), m_delay(-1) {}
void setString(const QString &value)
{ m_value = value; }
@@ -1554,12 +1556,14 @@ public:
protected:
virtual void onEntry(QEvent *)
{
- m_machine->postEvent(new StringEvent(m_value), m_delay);
+ if (m_delay == -1)
+ machine()->postEvent(new StringEvent(m_value));
+ else
+ machine()->postDelayedEvent(new StringEvent(m_value), m_delay);
}
virtual void onExit(QEvent *) {}
private:
- QStateMachine *m_machine;
QString m_value;
int m_delay;
};
@@ -1573,7 +1577,7 @@ void tst_QStateMachine::postEvent()
QTest::ignoreMessage(QtWarningMsg, "QStateMachine::postEvent: cannot post event when the state machine is not running");
machine.postEvent(&e);
}
- StringEventPoster *s1 = new StringEventPoster(&machine, "a");
+ StringEventPoster *s1 = new StringEventPoster("a");
if (x == 1)
s1->setDelay(100);
QFinalState *s2 = new QFinalState;
@@ -1599,6 +1603,80 @@ void tst_QStateMachine::postEvent()
}
}
+void tst_QStateMachine::cancelDelayedEvent()
+{
+ QStateMachine machine;
+ QTest::ignoreMessage(QtWarningMsg, "QStateMachine::cancelDelayedEvent: the machine is not running");
+ QVERIFY(!machine.cancelDelayedEvent(-1));
+
+ QState *s1 = new QState(&machine);
+ QFinalState *s2 = new QFinalState(&machine);
+ s1->addTransition(new StringTransition("a", s2));
+ machine.setInitialState(s1);
+
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ int id1 = machine.postDelayedEvent(new StringEvent("c"), 50000);
+ QVERIFY(id1 != -1);
+ int id2 = machine.postDelayedEvent(new StringEvent("b"), 25000);
+ QVERIFY(id2 != -1);
+ QVERIFY(id2 != id1);
+ int id3 = machine.postDelayedEvent(new StringEvent("a"), 100);
+ QVERIFY(id3 != -1);
+ QVERIFY(id3 != id2);
+ QVERIFY(machine.cancelDelayedEvent(id1));
+ QVERIFY(!machine.cancelDelayedEvent(id1));
+ QVERIFY(machine.cancelDelayedEvent(id2));
+ QVERIFY(!machine.cancelDelayedEvent(id2));
+
+ QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
+ QTRY_COMPARE(finishedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+}
+
+void tst_QStateMachine::postDelayedEventAndStop()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ QFinalState *s2 = new QFinalState(&machine);
+ s1->addTransition(new StringTransition("a", s2));
+ machine.setInitialState(s1);
+
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ int id1 = machine.postDelayedEvent(new StringEvent("a"), 0);
+ QVERIFY(id1 != -1);
+ QSignalSpy stoppedSpy(&machine, SIGNAL(stopped()));
+ machine.stop();
+ QTRY_COMPARE(stoppedSpy.count(), 1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 2);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ int id2 = machine.postDelayedEvent(new StringEvent("a"), 1000);
+ QVERIFY(id2 != -1);
+ machine.stop();
+ QTRY_COMPARE(stoppedSpy.count(), 2);
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 3);
+ QTestEventLoop::instance().enterLoop(2);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+}
+
void tst_QStateMachine::stateFinished()
{
QStateMachine machine;
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 8899176..fb3cf0e 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -186,6 +186,8 @@ private slots:
void resolvedWithAbsoluteSchemes_data() const;
void binaryData_data();
void binaryData();
+ void fromUserInput_data();
+ void fromUserInput();
void task_199967();
void task_240612();
@@ -3637,6 +3639,69 @@ void tst_QUrl::binaryData()
QCOMPARE(url2, url);
}
+void tst_QUrl::fromUserInput_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QUrl>("url");
+
+ // Null
+ QTest::newRow("null") << QString() << QUrl();
+
+ // File
+ QDirIterator it(QDir::homePath());
+ QString fileString;
+ int c = 0;
+ while (it.hasNext()) {
+ it.next();
+ QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.filePath() << QUrl::fromLocalFile(it.filePath());
+ }
+
+ // basic latin1
+ QTest::newRow("unicode-0") << QString::fromUtf8("\xC3\xA5.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xC3\xA5.com/").toUtf8(), QUrl::TolerantMode);
+ // unicode
+ QTest::newRow("unicode-1") << QString::fromUtf8("\xCE\xBB.com/") << QUrl::fromEncoded(QString::fromUtf8("http://\xCE\xBB.com/").toUtf8(), QUrl::TolerantMode);
+
+ // no scheme
+ QTest::newRow("add scheme-0") << "webkit.org" << QUrl("http://webkit.org");
+ QTest::newRow("add scheme-1") << "www.webkit.org" << QUrl("http://www.webkit.org");
+ QTest::newRow("add scheme-2") << "ftp.webkit.org" << QUrl("ftp://ftp.webkit.org");
+ QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit");
+
+ // QUrl's tolerant parser should already handle this
+ QTest::newRow("not-encoded-0") << "http://webkit.org/test page.html" << QUrl("http://webkit.org/test%20page.html");
+
+ // Make sure the :80, i.e. port doesn't screw anything up
+ QUrl portUrl("http://webkit.org");
+ portUrl.setPort(80);
+ QTest::newRow("port-0") << "webkit.org:80" << portUrl;
+ QTest::newRow("port-1") << "http://webkit.org:80" << portUrl;
+
+ // mailto doesn't have a ://, but is valid
+ QUrl mailto("somebody@somewhere.net");
+ mailto.setScheme("mailto");
+ QTest::newRow("mailto") << "mailto:somebody@somewhere.net" << mailto;
+
+ // misc
+ QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost");
+ QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80");
+ QTest::newRow("spaces-0") << " http://webkit.org/test page.html " << QUrl("http://webkit.org/test%20page.html");
+ QTest::newRow("trash-0") << "webkit.org/test?someData=42%&someOtherData=abcde#anchor" << QUrl::fromEncoded("http://webkit.org/test?someData=42%25&someOtherData=abcde#anchor");
+
+ // FYI: The scheme in the resulting url user
+ QUrl authUrl("user:pass@domain.com");
+ QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl;
+}
+
+// public static QUrl guessUrlFromString(QString const& string)
+void tst_QUrl::fromUserInput()
+{
+ QFETCH(QString, string);
+ QFETCH(QUrl, url);
+
+ QUrl guessedUrl = QUrl::fromUserInput(string);
+ QCOMPARE(guessedUrl, url);
+}
+
void tst_QUrl::task_199967()
{
{
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 4cf9e8f..ab7ea78 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -6392,6 +6392,7 @@ private:
void tst_QWidget::render()
{
+ return;
QCalendarWidget source;
// disable anti-aliasing to eliminate potential differences when subpixel antialiasing
// is enabled on the screen
diff --git a/tests/manual/keypadnavigation/keypadnavigation.ui b/tests/manual/keypadnavigation/keypadnavigation.ui
index e0db662..039889b 100644
--- a/tests/manual/keypadnavigation/keypadnavigation.ui
+++ b/tests/manual/keypadnavigation/keypadnavigation.ui
@@ -1058,6 +1058,79 @@ As a reward you can try out the QDial, below.</string>
</item>
</layout>
</widget>
+ <widget class="QWidget" name="m_pageDialogs">
+ <layout class="QVBoxLayout" name="verticalLayout_13">
+ <item>
+ <widget class="QPushButton" name="m_buttonGetOpenFileName">
+ <property name="text">
+ <string>getOpenFileName()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetSaveFileName">
+ <property name="text">
+ <string>getSaveFileName()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetExistingDirectory">
+ <property name="text">
+ <string>getExistingDirectory()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetColor">
+ <property name="text">
+ <string>getColor()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetFont">
+ <property name="text">
+ <string>getFont()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonQuestion">
+ <property name="text">
+ <string>question()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonAboutQt">
+ <property name="text">
+ <string>aboutQt()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="m_buttonGetItem">
+ <property name="text">
+ <string>getItem()</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>104</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
@@ -1080,6 +1153,7 @@ As a reward you can try out the QDial, below.</string>
<addaction name="m_actionLayoutTwoDimensional"/>
<addaction name="m_actionLayoutSliderMagic"/>
<addaction name="m_actionLayoutChaos"/>
+ <addaction name="m_actionLayoutDialogs"/>
</widget>
<widget class="QMenu" name="menuNavigation_mode">
<property name="title">
@@ -1144,14 +1218,22 @@ As a reward you can try out the QDial, below.</string>
<string>CursorForceVisible</string>
</property>
</action>
+ <action name="m_actionLayoutDialogs">
+ <property name="text">
+ <string>Dialogs</string>
+ </property>
+ <property name="toolTip">
+ <string>m_actionLayoutDialogs</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
- <tabstop>lineEdit</tabstop>
- <tabstop>horizontalSlider</tabstop>
- <tabstop>lineEdit_4</tabstop>
- <tabstop>horizontalSlider_2</tabstop>
- <tabstop>dateEdit</tabstop>
+ <tabstop>m_buttonGetOpenFileName</tabstop>
+ <tabstop>m_buttonGetSaveFileName</tabstop>
+ <tabstop>m_buttonGetExistingDirectory</tabstop>
+ <tabstop>m_buttonGetColor</tabstop>
+ <tabstop>m_buttonGetFont</tabstop>
<tabstop>comboBox</tabstop>
<tabstop>plainTextEdit</tabstop>
<tabstop>pushButton</tabstop>
@@ -1169,7 +1251,6 @@ As a reward you can try out the QDial, below.</string>
<tabstop>toolButton_3</tabstop>
<tabstop>horizontalSlider_6</tabstop>
<tabstop>horizontalSlider_5</tabstop>
- <tabstop>scrollArea_3</tabstop>
<tabstop>lineEdit_13</tabstop>
<tabstop>toolButton_31</tabstop>
<tabstop>lineEdit_14</tabstop>
@@ -1202,7 +1283,17 @@ As a reward you can try out the QDial, below.</string>
<tabstop>toolButton_16</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>scrollArea_2</tabstop>
- <tabstop>scrollArea</tabstop>
+ <tabstop>horizontalSlider_4</tabstop>
+ <tabstop>horizontalSlider_3</tabstop>
+ <tabstop>tabWidget_2</tabstop>
+ <tabstop>toolButton_2</tabstop>
+ <tabstop>toolButton_7</tabstop>
+ <tabstop>toolButton_13</tabstop>
+ <tabstop>lineEdit_4</tabstop>
+ <tabstop>lineEdit</tabstop>
+ <tabstop>horizontalSlider</tabstop>
+ <tabstop>horizontalSlider_2</tabstop>
+ <tabstop>dateEdit</tabstop>
</tabstops>
<resources/>
<connections>
diff --git a/tests/manual/keypadnavigation/main.cpp b/tests/manual/keypadnavigation/main.cpp
index 0e4bf31..d1cc8a7 100644
--- a/tests/manual/keypadnavigation/main.cpp
+++ b/tests/manual/keypadnavigation/main.cpp
@@ -53,29 +53,57 @@ public:
{
ui->setupUi(this);
- connect(ui->m_actionLayoutVerticalSimple, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutVerticalSimple, ui->m_pageVerticalSimple);
- connect(ui->m_actionLayoutVerticalComplex, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutVerticalComplex, ui->m_pageVerticalComplex);
- connect(ui->m_actionLayoutTwoDimensional, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutTwoDimensional, ui->m_pageTwoDimensional);
- connect(ui->m_actionLayoutSliderMagic, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutSliderMagic, ui->m_pageSliderMagic);
- connect(ui->m_actionLayoutChaos, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
- m_layoutSignalMapper.setMapping(ui->m_actionLayoutChaos, ui->m_pageChaos);
+ const struct {
+ QObject *action;
+ QWidget *page;
+ } layoutMappings[] = {
+ {ui->m_actionLayoutVerticalSimple, ui->m_pageVerticalSimple},
+ {ui->m_actionLayoutVerticalComplex, ui->m_pageVerticalComplex},
+ {ui->m_actionLayoutTwoDimensional, ui->m_pageTwoDimensional},
+ {ui->m_actionLayoutSliderMagic, ui->m_pageSliderMagic},
+ {ui->m_actionLayoutChaos, ui->m_pageChaos},
+ {ui->m_actionLayoutDialogs, ui->m_pageDialogs}
+ };
+ for (int i = 0; i < int(sizeof layoutMappings / sizeof layoutMappings[0]); ++i) {
+ connect(layoutMappings[i].action, SIGNAL(triggered()), &m_layoutSignalMapper, SLOT(map()));
+ m_layoutSignalMapper.setMapping(layoutMappings[i].action, layoutMappings[i].page);
+ }
connect(&m_layoutSignalMapper, SIGNAL(mapped(QWidget*)), ui->m_stackWidget, SLOT(setCurrentWidget(QWidget*)));
- connect(ui->m_actionModeNone, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeNone, int(Qt::NavigationModeNone));
- connect(ui->m_actionModeKeypadTabOrder, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeKeypadTabOrder, int(Qt::NavigationModeKeypadTabOrder));
- connect(ui->m_actionModeKeypadDirectional, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeKeypadDirectional, int(Qt::NavigationModeKeypadDirectional));
- connect(ui->m_actionModeCursorAuto, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeCursorAuto, int(Qt::NavigationModeCursorAuto));
- connect(ui->m_actionModeCursorForceVisible, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
- m_modeSignalMapper.setMapping(ui->m_actionModeCursorForceVisible, int(Qt::NavigationModeCursorForceVisible));
+ const struct {
+ QObject *action;
+ Qt::NavigationMode mode;
+ } modeMappings[] = {
+ {ui->m_actionModeNone, Qt::NavigationModeNone},
+ {ui->m_actionModeKeypadTabOrder, Qt::NavigationModeKeypadTabOrder},
+ {ui->m_actionModeKeypadDirectional, Qt::NavigationModeKeypadDirectional},
+ {ui->m_actionModeCursorAuto, Qt::NavigationModeCursorAuto},
+ {ui->m_actionModeCursorForceVisible, Qt::NavigationModeCursorForceVisible}
+ };
+ for (int i = 0; i < int(sizeof modeMappings / sizeof modeMappings[0]); ++i) {
+ connect(modeMappings[i].action, SIGNAL(triggered()), &m_modeSignalMapper, SLOT(map()));
+ m_modeSignalMapper.setMapping(modeMappings[i].action, int(modeMappings[i].mode));
+ }
connect(&m_modeSignalMapper, SIGNAL(mapped(int)), SLOT(setNavigationMode(int)));
+
+ const struct {
+ QObject *button;
+ Dialog dialog;
+ } openDialogMappings[] = {
+ {ui->m_buttonGetOpenFileName, DialogGetOpenFileName},
+ {ui->m_buttonGetSaveFileName, DialogGetSaveFileName},
+ {ui->m_buttonGetExistingDirectory, DialogGetExistingDirectory},
+ {ui->m_buttonGetColor, DialogGetColor},
+ {ui->m_buttonGetFont, DialogGetFont},
+ {ui->m_buttonQuestion, DialogQuestion},
+ {ui->m_buttonAboutQt, DialogAboutQt},
+ {ui->m_buttonGetItem, DialogGetItem}
+ };
+ for (int i = 0; i < int(sizeof openDialogMappings / sizeof openDialogMappings[0]); ++i) {
+ connect(openDialogMappings[i].button, SIGNAL(clicked()), &m_dialogSignalMapper, SLOT(map()));
+ m_dialogSignalMapper.setMapping(openDialogMappings[i].button, int(openDialogMappings[i].dialog));
+ }
+ connect(&m_dialogSignalMapper, SIGNAL(mapped(int)), SLOT(openDialog(int)));
}
~KeypadNavigation()
@@ -83,16 +111,60 @@ public:
delete ui;
}
-public slots:
+protected slots:
void setNavigationMode(int mode)
{
QApplication::setNavigationMode(Qt::NavigationMode(mode));
}
+ void openDialog(int dialog)
+ {
+ switch (Dialog(dialog)) {
+ case DialogGetOpenFileName:
+ QFileDialog::getOpenFileName(this, QLatin1String("getOpenFileName"));
+ break;
+ case DialogGetSaveFileName:
+ QFileDialog::getSaveFileName(this, QLatin1String("getSaveFileName"));
+ break;
+ case DialogGetExistingDirectory:
+ QFileDialog::getExistingDirectory(this, QLatin1String("getExistingDirectory"));
+ break;
+ case DialogGetColor:
+ QColorDialog::getColor(QColor(Qt::green), this, QLatin1String("getColor"));
+ break;
+ case DialogGetFont:
+ QFontDialog::getFont(0, this);
+ break;
+ case DialogQuestion:
+ QMessageBox::question(this, QLatin1String("question"), QLatin1String("¿Hola, que tal?"));
+ break;
+ case DialogAboutQt:
+ QMessageBox::aboutQt(this);
+ break;
+ case DialogGetItem:
+ QInputDialog::getItem(this, QLatin1String("getItem"), QLatin1String("Choose a color"), QColor::colorNames());
+ break;
+ default:
+ break;
+ }
+ }
+
private:
+ enum Dialog {
+ DialogGetOpenFileName,
+ DialogGetSaveFileName,
+ DialogGetExistingDirectory,
+ DialogGetColor,
+ DialogGetFont,
+ DialogQuestion,
+ DialogAboutQt,
+ DialogGetItem
+ };
+
Ui_KeypadNavigation *ui;
QSignalMapper m_layoutSignalMapper;
QSignalMapper m_modeSignalMapper;
+ QSignalMapper m_dialogSignalMapper;
};
int main(int argc, char *argv[])