From 19d11751da73fded31605bb80f70642faf4095c5 Mon Sep 17 00:00:00 2001 From: Perttu Pohjonen <perttu.pohjonen@nokia.com> Date: Mon, 7 Mar 2011 08:49:00 +0200 Subject: Unsuccessful unlocking of QNetworkConfigurationPrivate mutex Above mentioned mutex is locked twice: first in caller function and second time in called function. Called function unlocks mutex and emits signal clearly unaware that the mutex is actually still locked. I changed the mutex to be unlocked before the function is called. Task-number: QTBUG-15108 Reviewed-by: Ville Pernu (cherry picked from commit c15560fbe2a1762117395c5ecaaecfa5ab8dce6f) --- src/plugins/bearer/symbian/symbianengine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index bcf7dd9..edf4b89 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -829,6 +829,7 @@ void SymbianEngine::updateStatesToSnaps() discovered = true; } } + snapConfigLocker.unlock(); if (active) { changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); } else if (discovered) { -- cgit v0.12 From 0e32d0575aa92b6d92999fa661d36fd40c1fee66 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas <jani.hautakangas@nokia.com> Date: Thu, 10 Mar 2011 17:50:12 +0200 Subject: Fix for major regression in OpenVG clipping OpenVG paint engine didn't reset it's mask fallback state correctly when engine was resetted. Task-number: QTBUG-17966 Reviewed-by: Jason Barron (cherry picked from commit 2ecb0ea77c04424f6f557ca8a13c1d86666763df) --- src/openvg/qpaintengine_vg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index c2a4c9b..ec2936e 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -2333,6 +2333,7 @@ bool QVGPaintEngine::isDefaultClipRect(const QRect& rect) void QVGPaintEngine::clipEnabledChanged() { #if defined(QVG_SCISSOR_CLIP) + vgSeti(VG_MASKING, VG_FALSE); // disable mask fallback updateScissor(); #else Q_D(QVGPaintEngine); -- cgit v0.12 From 71acbd0ff1c926c9a508b879f0ca365d17cc4987 Mon Sep 17 00:00:00 2001 From: Cristiano di Flora <cristiano.di-flora@nokia.com> Date: Thu, 24 Feb 2011 03:23:28 +0200 Subject: Fix QTBUG-17627: build break in mobility bearer applications Task-Number: QTBUG-17627 (cherry picked from commit f86e014bb6f2754bfed33106021a809ca8c2ce73) --- src/network/bearer/qnetworksession.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h index 52db88f..e491d50 100644 --- a/src/network/bearer/qnetworksession.h +++ b/src/network/bearer/qnetworksession.h @@ -141,13 +141,12 @@ private: #ifndef QT_MOBILITY_BEARER QT_END_NAMESPACE +Q_DECLARE_METATYPE(QNetworkSession::State) +Q_DECLARE_METATYPE(QNetworkSession::SessionError) #else QTM_END_NAMESPACE #endif -Q_DECLARE_METATYPE(QNetworkSession::State) -Q_DECLARE_METATYPE(QNetworkSession::SessionError) - QT_END_HEADER #endif // QT_NO_BEARERMANAGEMENT -- cgit v0.12 From e733cce50b5c49b3ace52b8b5a2266e57ad769e5 Mon Sep 17 00:00:00 2001 From: Timo Turunen <timo.p.turunen@nokia.com> Date: Fri, 11 Mar 2011 16:38:58 +0200 Subject: Bump Qt version to 4.7.3 Reviewed-by: Trust Me (cherry picked from commit e90cff53cdd7bf0bdfed1f2e8efb90539c6f33ba) Conflicts: tools/qdoc3/test/qt-project.qdocconf --- dist/changes-4.7.3 | 0 src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri | 4 ++-- src/corelib/global/qglobal.h | 4 ++-- src/plugins/qpluginbase.pri | 2 +- src/qbase.pri | 2 +- tests/auto/mediaobject/dummy/dummy.pro | 2 +- tests/auto/selftests/expected_cmptest.txt | 2 +- tests/auto/selftests/expected_crashes_3.txt | 2 +- tests/auto/selftests/expected_longstring.txt | 2 +- tests/auto/selftests/expected_maxwarnings.txt | 2 +- tests/auto/selftests/expected_skip.txt | 2 +- tools/assistant/tools/assistant/doc/assistant.qdocconf | 4 ++-- tools/qdoc3/doc/files/qt.qdocconf | 8 ++++---- tools/qdoc3/test/assistant.qdocconf | 4 ++-- tools/qdoc3/test/designer.qdocconf | 4 ++-- tools/qdoc3/test/linguist.qdocconf | 4 ++-- tools/qdoc3/test/qdeclarative.qdocconf | 8 ++++---- tools/qdoc3/test/qmake.qdocconf | 4 ++-- tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf | 8 ++++---- tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf | 8 ++++---- 20 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 dist/changes-4.7.3 diff --git a/dist/changes-4.7.3 b/dist/changes-4.7.3 new file mode 100644 index 0000000..e69de29 diff --git a/src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri b/src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri index b98617f..07754a7 100644 --- a/src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri +++ b/src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri @@ -1,5 +1,5 @@ -QT_WEBKIT_VERSION = 4.7.2 +QT_WEBKIT_VERSION = 4.7.3 QT_WEBKIT_MAJOR_VERSION = 4 QT_WEBKIT_MINOR_VERSION = 7 -QT_WEBKIT_PATCH_VERSION = 2 +QT_WEBKIT_PATCH_VERSION = 3 QT_CONFIG += webkit diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index e13a0fc..d374f09 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -44,11 +44,11 @@ #include <stddef.h> -#define QT_VERSION_STR "4.7.2" +#define QT_VERSION_STR "4.7.3" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x040702 +#define QT_VERSION 0x040703 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index 7cbffe0..3de5fdf 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -1,6 +1,6 @@ TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.7.2 + VERSION=4.7.3 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/src/qbase.pri b/src/qbase.pri index 75da3dc..babea56 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -4,7 +4,7 @@ INCLUDEPATH *= $$QMAKE_INCDIR_QT/$$TARGET #just for today to have some compat isEmpty(QT_ARCH):!isEmpty(ARCH):QT_ARCH=$$ARCH #another compat that will rot for change #215700 TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.7.2 + VERSION=4.7.3 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/tests/auto/mediaobject/dummy/dummy.pro b/tests/auto/mediaobject/dummy/dummy.pro index 88b864b..c81411c 100644 --- a/tests/auto/mediaobject/dummy/dummy.pro +++ b/tests/auto/mediaobject/dummy/dummy.pro @@ -1,7 +1,7 @@ TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.6.4 + VERSION=4.7.3 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/tests/auto/selftests/expected_cmptest.txt b/tests/auto/selftests/expected_cmptest.txt index fccaca3..d70815d 100644 --- a/tests/auto/selftests/expected_cmptest.txt +++ b/tests/auto/selftests/expected_cmptest.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_Cmptest ********* -Config: Using QTest library 4.7.2, Qt 4.7.2 +Config: Using QTest library 4.7.3, Qt 4.7.3 PASS : tst_Cmptest::initTestCase() PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_pointerfuncs() diff --git a/tests/auto/selftests/expected_crashes_3.txt b/tests/auto/selftests/expected_crashes_3.txt index 2558f68..2aea62c 100644 --- a/tests/auto/selftests/expected_crashes_3.txt +++ b/tests/auto/selftests/expected_crashes_3.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_Crashes ********* -Config: Using QTest library 4.7.2, Qt 4.7.2 +Config: Using QTest library 4.7.3, Qt 4.7.3 PASS : tst_Crashes::initTestCase() QFATAL : tst_Crashes::crash() Received signal 11 FAIL! : tst_Crashes::crash() Received a fatal error. diff --git a/tests/auto/selftests/expected_longstring.txt b/tests/auto/selftests/expected_longstring.txt index c56244b..1fe012f 100644 --- a/tests/auto/selftests/expected_longstring.txt +++ b/tests/auto/selftests/expected_longstring.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_LongString ********* -Config: Using QTest library 4.7.2, Qt 4.7.2 +Config: Using QTest library 4.7.3, Qt 4.7.3 PASS : tst_LongString::initTestCase() FAIL! : tst_LongString::failWithLongString() Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. diff --git a/tests/auto/selftests/expected_maxwarnings.txt b/tests/auto/selftests/expected_maxwarnings.txt index 7846435..cdd6ee8 100644 --- a/tests/auto/selftests/expected_maxwarnings.txt +++ b/tests/auto/selftests/expected_maxwarnings.txt @@ -1,5 +1,5 @@ ********* Start testing of MaxWarnings ********* -Config: Using QTest library 4.7.2, Qt 4.7.2 +Config: Using QTest library 4.7.3, Qt 4.7.3 PASS : MaxWarnings::initTestCase() QWARN : MaxWarnings::warn() 0 QWARN : MaxWarnings::warn() 1 diff --git a/tests/auto/selftests/expected_skip.txt b/tests/auto/selftests/expected_skip.txt index 5c9e497..490c140 100644 --- a/tests/auto/selftests/expected_skip.txt +++ b/tests/auto/selftests/expected_skip.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_Skip ********* -Config: Using QTest library 4.7.2, Qt 4.7.2 +Config: Using QTest library 4.7.3, Qt 4.7.3 PASS : tst_Skip::initTestCase() SKIP : tst_Skip::test() skipping all Loc: [/home/user/depot/qt-git/mainline/tests/auto/selftests/skip/tst_skip.cpp(68)] diff --git a/tools/assistant/tools/assistant/doc/assistant.qdocconf b/tools/assistant/tools/assistant/doc/assistant.qdocconf index 57abeae..575b1e5 100644 --- a/tools/assistant/tools/assistant/doc/assistant.qdocconf +++ b/tools/assistant/tools/assistant/doc/assistant.qdocconf @@ -10,7 +10,7 @@ description = "Qt Assistant" HTML.{postheader,address} = "" HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \ "<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \ - "<td width=\"30%\" align=\"left\">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ + "<td width=\"30%\" align=\"left\">Copyright © 2011 Nokia Corporation and/or its subsidiary(-ies)</td>\n" \ "<td width=\"40%\" align=\"center\">Trademarks</td>\n" \ - "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.7.2</div></td>\n" \ + "<td width=\"30%\" align=\"right\"><div align=\"right\">Qt 4.7.3</div></td>\n" \ "</tr></table></div></address>" diff --git a/tools/qdoc3/doc/files/qt.qdocconf b/tools/qdoc3/doc/files/qt.qdocconf index 44cfbc1..9b16233 100644 --- a/tools/qdoc3/doc/files/qt.qdocconf +++ b/tools/qdoc3/doc/files/qt.qdocconf @@ -22,7 +22,7 @@ edition.DesktopLight.groups = -graphicsview-api qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.472 +qhp.Qt.namespace = com.trolltech.qt.473 qhp.Qt.virtualFolder = qdoc qhp.Qt.indexTitle = Qt Reference Documentation qhp.Qt.indexRoot = @@ -36,9 +36,9 @@ qhp.Qt.extraFiles = classic.css \ images/dynamiclayouts-example.png \ images/stylesheet-coffee-plastique.png -qhp.Qt.filterAttributes = qt 4.7.2 qtrefdoc -qhp.Qt.customFilters.Qt.name = Qt 4.7.2 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.2 +qhp.Qt.filterAttributes = qt 4.7.3 qtrefdoc +qhp.Qt.customFilters.Qt.name = Qt 4.7.3 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.3 qhp.Qt.subprojects = classes overviews examples qhp.Qt.subprojects.classes.title = Classes qhp.Qt.subprojects.classes.indexTitle = Qt's Classes diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf index 0e9a2a8..74ab67b 100644 --- a/tools/qdoc3/test/assistant.qdocconf +++ b/tools/qdoc3/test/assistant.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Assistant qhp.Assistant.file = assistant.qhp -qhp.Assistant.namespace = com.trolltech.assistant.472 +qhp.Assistant.namespace = com.trolltech.assistant.473 qhp.Assistant.virtualFolder = qdoc qhp.Assistant.indexTitle = Qt Assistant Manual qhp.Assistant.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.Assistant.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Assistant.filterAttributes = qt 4.7.2 tools assistant +qhp.Assistant.filterAttributes = qt 4.7.3 tools assistant qhp.Assistant.customFilters.Assistant.name = Qt Assistant Manual qhp.Assistant.customFilters.Assistant.filterAttributes = qt tools assistant qhp.Assistant.subprojects = manual examples diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf index 637399b..42dbc20 100644 --- a/tools/qdoc3/test/designer.qdocconf +++ b/tools/qdoc3/test/designer.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Designer qhp.Designer.file = designer.qhp -qhp.Designer.namespace = com.trolltech.designer.472 +qhp.Designer.namespace = com.trolltech.designer.473 qhp.Designer.virtualFolder = qdoc qhp.Designer.indexTitle = Qt Designer Manual qhp.Designer.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.Designer.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Designer.filterAttributes = qt 4.7.2 tools designer +qhp.Designer.filterAttributes = qt 4.7.3 tools designer qhp.Designer.customFilters.Designer.name = Qt Designer Manual qhp.Designer.customFilters.Designer.filterAttributes = qt tools designer qhp.Designer.subprojects = manual examples diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf index 8ee298e..7c01023 100644 --- a/tools/qdoc3/test/linguist.qdocconf +++ b/tools/qdoc3/test/linguist.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Linguist qhp.Linguist.file = linguist.qhp -qhp.Linguist.namespace = com.trolltech.linguist.472 +qhp.Linguist.namespace = com.trolltech.linguist.473 qhp.Linguist.virtualFolder = qdoc qhp.Linguist.indexTitle = Qt Linguist Manual qhp.Linguist.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.Linguist.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Linguist.filterAttributes = qt 4.7.2 tools linguist +qhp.Linguist.filterAttributes = qt 4.7.3 tools linguist qhp.Linguist.customFilters.Linguist.name = Qt Linguist Manual qhp.Linguist.customFilters.Linguist.filterAttributes = qt tools linguist qhp.Linguist.subprojects = manual examples diff --git a/tools/qdoc3/test/qdeclarative.qdocconf b/tools/qdoc3/test/qdeclarative.qdocconf index e68a935..12c939c 100644 --- a/tools/qdoc3/test/qdeclarative.qdocconf +++ b/tools/qdoc3/test/qdeclarative.qdocconf @@ -21,7 +21,7 @@ edition.DesktopLight.groups = -graphicsview-api qhp.projects = Qml qhp.Qml.file = qml.qhp -qhp.Qml.namespace = com.trolltech.qml.472 +qhp.Qml.namespace = com.trolltech.qml.473 qhp.Qml.virtualFolder = qdoc qhp.Qml.indexTitle = Qml Reference @@ -61,9 +61,9 @@ qhp.Qml.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.Qml.filterAttributes = qt 4.7.2 qtrefdoc -qhp.Qml.customFilters.Qt.name = Qt 4.7.2 -qhp.Qml.customFilters.Qt.filterAttributes = qt 4.7.2 +qhp.Qml.filterAttributes = qt 4.7.3 qtrefdoc +qhp.Qml.customFilters.Qt.name = Qt 4.7.3 +qhp.Qml.customFilters.Qt.filterAttributes = qt 4.7.3 qhp.Qml.subprojects = classes qhp.Qml.subprojects.classes.title = Elements qhp.Qml.subprojects.classes.indexTitle = Qml Elements diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf index b5bc96c..b7d1299 100644 --- a/tools/qdoc3/test/qmake.qdocconf +++ b/tools/qdoc3/test/qmake.qdocconf @@ -13,7 +13,7 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = qmake qhp.qmake.file = qmake.qhp -qhp.qmake.namespace = com.trolltech.qmake.472 +qhp.qmake.namespace = com.trolltech.qmake.473 qhp.qmake.virtualFolder = qdoc qhp.qmake.indexTitle = QMake Manual qhp.qmake.extraFiles = images/bg_l.png \ @@ -50,7 +50,7 @@ qhp.qmake.extraFiles = images/bg_l.png \ style/style_ie8.css \ style/style.css -qhp.qmake.filterAttributes = qt 4.7.2 tools qmake +qhp.qmake.filterAttributes = qt 4.7.3 tools qmake qhp.qmake.customFilters.qmake.name = qmake Manual qhp.qmake.customFilters.qmake.filterAttributes = qt tools qmake qhp.qmake.subprojects = manual diff --git a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf index 24696d5..a4d0653 100644 --- a/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf @@ -17,15 +17,15 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.472 +qhp.Qt.namespace = com.trolltech.qt.473 qhp.Qt.virtualFolder = qdoc qhp.Qt.title = Qt qhp.Qt.indexTitle = Qt qhp.Qt.selectors = fake:example -qhp.Qt.filterAttributes = qt 4.7.2 qtrefdoc ja_JP -qhp.Qt.customFilters.Qt.name = Qt 4.7.2 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.2 +qhp.Qt.filterAttributes = qt 4.7.3 qtrefdoc ja_JP +qhp.Qt.customFilters.Qt.name = Qt 4.7.3 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.3 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf index 7789bf7..818b5c5 100644 --- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf @@ -17,15 +17,15 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.472 +qhp.Qt.namespace = com.trolltech.qt.473 qhp.Qt.virtualFolder = qdoc qhp.Qt.title = 教程 qhp.Qt.indexTitle = 教程 qhp.Qt.selectors = fake:example -qhp.Qt.filterAttributes = qt 4.7.2 qtrefdoc zh_CN -qhp.Qt.customFilters.Qt.name = Qt 4.7.2 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.2 +qhp.Qt.filterAttributes = qt 4.7.3 qtrefdoc zh_CN +qhp.Qt.customFilters.Qt.name = Qt 4.7.3 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.3 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML -- cgit v0.12 From 186096455ed3dd5bc27b272ff8959a5a38ec5100 Mon Sep 17 00:00:00 2001 From: Timo Turunen <timo.p.turunen@nokia.com> Date: Mon, 14 Mar 2011 13:26:53 +0200 Subject: QDeclarativeDebug: Export needed symbols on Symbian Allow applications to link against the QDeclarativeDebugService API. This is needed for on-device debugging of QML. (The removal of the symbols was a regression in 4.7.2). Task-number: QTBUG-17503 Reviewed-by: Tom Sutcliffe (cherry picked from commit fbf73dec65df9c27a3a09ca9b436f5f8cb9f1b0e) Conflicts: src/s60installs/bwins/QtDeclarativeu.def --- .../debugger/qdeclarativedebugservice_p.h | 2 +- src/s60installs/bwins/QtDeclarativeu.def | 48 +++++++++++----------- src/s60installs/eabi/QtDeclarativeu.def | 44 ++++++++++---------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h index 449cb65..271b3c9 100644 --- a/src/declarative/debugger/qdeclarativedebugservice_p.h +++ b/src/declarative/debugger/qdeclarativedebugservice_p.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeDebugServicePrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugService : public QObject +class Q_DECLARATIVE_EXPORT QDeclarativeDebugService : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeDebugService) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index b5da47d..6cc24d8 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -3,7 +3,7 @@ EXPORTS ?setStored@QMetaPropertyBuilder@@QAEX_N@Z @ 2 NONAME ABSENT ; void QMetaPropertyBuilder::setStored(bool) ?trUtf8@QDeclarativeExpression@@SA?AVQString@@PBD0H@Z @ 3 NONAME ; class QString QDeclarativeExpression::trUtf8(char const *, char const *, int) ?qt_metacast@QDeclarativeComponent@@UAEPAXPBD@Z @ 4 NONAME ; void * QDeclarativeComponent::qt_metacast(char const *) - ?name@QDeclarativeDebugService@@QBE?AVQString@@XZ @ 5 NONAME ABSENT ; class QString QDeclarativeDebugService::name(void) const + ?name@QDeclarativeDebugService@@QBE?AVQString@@XZ @ 5 NONAME ; class QString QDeclarativeDebugService::name(void) const ?debugId@QDeclarativeDebugObjectReference@@QBEHXZ @ 6 NONAME ABSENT ; int QDeclarativeDebugObjectReference::debugId(void) const ?addPluginPath@QDeclarativeEngine@@QAEXABVQString@@@Z @ 7 NONAME ; void QDeclarativeEngine::addPluginPath(class QString const &) ?name@QMetaPropertyBuilder@@QBE?AVQByteArray@@XZ @ 8 NONAME ABSENT ; class QByteArray QMetaPropertyBuilder::name(void) const @@ -11,7 +11,7 @@ EXPORTS ?propertyOffset@QDeclarativeOpenMetaObjectType@@QBEHXZ @ 10 NONAME ABSENT ; int QDeclarativeOpenMetaObjectType::propertyOffset(void) const ??0QDeclarativeText@@QAE@PAVQDeclarativeItem@@@Z @ 11 NONAME ABSENT ; QDeclarativeText::QDeclarativeText(class QDeclarativeItem *) ?propertyTypeName@QDeclarativeProperty@@QBEPBDXZ @ 12 NONAME ; char const * QDeclarativeProperty::propertyTypeName(void) const - ?getStaticMetaObject@QDeclarativeDebugService@@SAABUQMetaObject@@XZ @ 13 NONAME ABSENT ; struct QMetaObject const & QDeclarativeDebugService::getStaticMetaObject(void) + ?getStaticMetaObject@QDeclarativeDebugService@@SAABUQMetaObject@@XZ @ 13 NONAME ; struct QMetaObject const & QDeclarativeDebugService::getStaticMetaObject(void) ?setLeft@QDeclarativeAnchors@@QAEXABVQDeclarativeAnchorLine@@@Z @ 14 NONAME ABSENT ; void QDeclarativeAnchors::setLeft(class QDeclarativeAnchorLine const &) ?qt_metacall@QDeclarativeExpression@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 15 NONAME ; int QDeclarativeExpression::qt_metacall(enum QMetaObject::Call, int, void * *) ?staticMetaObject@QDeclarativePen@@2UQMetaObject@@B @ 16 NONAME ABSENT ; struct QMetaObject const QDeclarativePen::staticMetaObject @@ -145,7 +145,7 @@ EXPORTS ?isConnected@QDeclarativeDebugClient@@QBE_NXZ @ 144 NONAME ABSENT ; bool QDeclarativeDebugClient::isConnected(void) const ?enabled@QDeclarativeBinding@@QBE_NXZ @ 145 NONAME ABSENT ; bool QDeclarativeBinding::enabled(void) const ?setSource@QDeclarativeView@@QAEXABVQUrl@@@Z @ 146 NONAME ; void QDeclarativeView::setSource(class QUrl const &) - ??_EQDeclarativeDebugService@@UAE@I@Z @ 147 NONAME ABSENT ; QDeclarativeDebugService::~QDeclarativeDebugService(unsigned int) + ??_EQDeclarativeDebugService@@UAE@I@Z @ 147 NONAME ; QDeclarativeDebugService::~QDeclarativeDebugService(unsigned int) ??0QDeclarativeDomDynamicProperty@@QAE@ABV0@@Z @ 148 NONAME ABSENT ; QDeclarativeDomDynamicProperty::QDeclarativeDomDynamicProperty(class QDeclarativeDomDynamicProperty const &) ?className@QDeclarativeDebugObjectReference@@QBE?AVQString@@XZ @ 149 NONAME ABSENT ; class QString QDeclarativeDebugObjectReference::className(void) const ?indexOfSlot@QMetaObjectBuilder@@QAEHABVQByteArray@@@Z @ 150 NONAME ABSENT ; int QMetaObjectBuilder::indexOfSlot(class QByteArray const &) @@ -294,7 +294,7 @@ EXPORTS ?attachedPropertiesType@QDeclarativeType@@QBEPBUQMetaObject@@XZ @ 293 NONAME ABSENT ; struct QMetaObject const * QDeclarativeType::attachedPropertiesType(void) const ?setName@QDeclarativeState@@QAEXABVQString@@@Z @ 294 NONAME ; void QDeclarativeState::setName(class QString const &) ?setReversed@QDeclarativeTransition@@QAEX_N@Z @ 295 NONAME ; void QDeclarativeTransition::setReversed(bool) - ?idForObject@QDeclarativeDebugService@@SAHPAVQObject@@@Z @ 296 NONAME ABSENT ; int QDeclarativeDebugService::idForObject(class QObject *) + ?idForObject@QDeclarativeDebugService@@SAHPAVQObject@@@Z @ 296 NONAME ; int QDeclarativeDebugService::idForObject(class QObject *) ?qt_metacall@QDeclarativeDebugWatch@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 297 NONAME ABSENT ; int QDeclarativeDebugWatch::qt_metacall(enum QMetaObject::Call, int, void * *) ?fromState@QDeclarativeTransition@@QBE?AVQString@@XZ @ 298 NONAME ; class QString QDeclarativeTransition::fromState(void) const ??1QDeclarativeExpression@@UAE@XZ @ 299 NONAME ; QDeclarativeExpression::~QDeclarativeExpression(void) @@ -332,7 +332,7 @@ EXPORTS ??0QDeclarativeCustomParserNode@@QAE@ABV0@@Z @ 331 NONAME ; QDeclarativeCustomParserNode::QDeclarativeCustomParserNode(class QDeclarativeCustomParserNode const &) ??1QDeclarativeImageProvider@@UAE@XZ @ 332 NONAME ; QDeclarativeImageProvider::~QDeclarativeImageProvider(void) ?sync@QDeclarativeListModel@@QAEXXZ @ 333 NONAME ABSENT ; void QDeclarativeListModel::sync(void) - ?objectForId@QDeclarativeDebugService@@SAPAVQObject@@H@Z @ 334 NONAME ABSENT ; class QObject * QDeclarativeDebugService::objectForId(int) + ?objectForId@QDeclarativeDebugService@@SAPAVQObject@@H@Z @ 334 NONAME ; class QObject * QDeclarativeDebugService::objectForId(int) ?hasFocus@QDeclarativeItem@@QBE_NXZ @ 335 NONAME ; bool QDeclarativeItem::hasFocus(void) const ??1QDeclarativeExtensionPlugin@@UAE@XZ @ 336 NONAME ; QDeclarativeExtensionPlugin::~QDeclarativeExtensionPlugin(void) ?qt_metacall@QDeclarativeBehavior@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 337 NONAME ABSENT ; int QDeclarativeBehavior::qt_metacall(enum QMetaObject::Call, int, void * *) @@ -482,7 +482,7 @@ EXPORTS ?pluginPathList@QDeclarativeEngine@@QBE?AVQStringList@@XZ @ 481 NONAME ; class QStringList QDeclarativeEngine::pluginPathList(void) const ?parentContext@QDeclarativeContext@@QBEPAV1@XZ @ 482 NONAME ; class QDeclarativeContext * QDeclarativeContext::parentContext(void) const ?leftMarginChanged@QDeclarativeAnchors@@IAEXXZ @ 483 NONAME ABSENT ; void QDeclarativeAnchors::leftMarginChanged(void) - ?staticMetaObject@QDeclarativeDebugService@@2UQMetaObject@@B @ 484 NONAME ABSENT ; struct QMetaObject const QDeclarativeDebugService::staticMetaObject + ?staticMetaObject@QDeclarativeDebugService@@2UQMetaObject@@B @ 484 NONAME ; struct QMetaObject const QDeclarativeDebugService::staticMetaObject ?topMargin@QDeclarativeAnchors@@QBEMXZ @ 485 NONAME ABSENT ; float QDeclarativeAnchors::topMargin(void) const ??0QDeclarativeDebugExpressionQuery@@AAE@PAVQObject@@@Z @ 486 NONAME ABSENT ; QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(class QObject *) ??0QPacket@@IAE@ABVQByteArray@@@Z @ 487 NONAME ABSENT ; QPacket::QPacket(class QByteArray const &) @@ -559,7 +559,7 @@ EXPORTS ?metaObject@QDeclarativeEngine@@UBEPBUQMetaObject@@XZ @ 558 NONAME ; struct QMetaObject const * QDeclarativeEngine::metaObject(void) const ??_EQDeclarativeDebugContextReference@@QAE@I@Z @ 559 NONAME ABSENT ; QDeclarativeDebugContextReference::~QDeclarativeDebugContextReference(unsigned int) ?propertyWrite@QDeclarativeOpenMetaObject@@MAEXH@Z @ 560 NONAME ABSENT ; void QDeclarativeOpenMetaObject::propertyWrite(int) - ?qt_metacall@QDeclarativeDebugService@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 561 NONAME ABSENT ; int QDeclarativeDebugService::qt_metacall(enum QMetaObject::Call, int, void * *) + ?qt_metacall@QDeclarativeDebugService@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 561 NONAME ; int QDeclarativeDebugService::qt_metacall(enum QMetaObject::Call, int, void * *) ?setVerticalCenterOffset@QDeclarativeAnchors@@QAEXM@Z @ 562 NONAME ABSENT ; void QDeclarativeAnchors::setVerticalCenterOffset(float) ??1QDeclarativeDebugWatch@@UAE@XZ @ 563 NONAME ABSENT ; QDeclarativeDebugWatch::~QDeclarativeDebugWatch(void) ??1QPacketAutoSend@@UAE@XZ @ 564 NONAME ABSENT ; QPacketAutoSend::~QPacketAutoSend(void) @@ -641,7 +641,7 @@ EXPORTS ?d_func@QDeclarativeItem@@AAEPAVQDeclarativeItemPrivate@@XZ @ 640 NONAME ; class QDeclarativeItemPrivate * QDeclarativeItem::d_func(void) ?binding@QDeclarativeDomValueBinding@@QBE?AVQString@@XZ @ 641 NONAME ABSENT ; class QString QDeclarativeDomValueBinding::binding(void) const ?updateAutoState@QDeclarativeStateGroup@@AAE_NXZ @ 642 NONAME ; bool QDeclarativeStateGroup::updateAutoState(void) - ?tr@QDeclarativeDebugService@@SA?AVQString@@PBD0@Z @ 643 NONAME ABSENT ; class QString QDeclarativeDebugService::tr(char const *, char const *) + ?tr@QDeclarativeDebugService@@SA?AVQString@@PBD0@Z @ 643 NONAME ; class QString QDeclarativeDebugService::tr(char const *, char const *) ?tr@QDeclarativeComponent@@SA?AVQString@@PBD0H@Z @ 644 NONAME ; class QString QDeclarativeComponent::tr(char const *, char const *, int) ??1QDeclarativeProperty@@QAE@XZ @ 645 NONAME ; QDeclarativeProperty::~QDeclarativeProperty(void) ?fontChanged@QDeclarativeText@@IAEXABVQFont@@@Z @ 646 NONAME ABSENT ; void QDeclarativeText::fontChanged(class QFont const &) @@ -667,14 +667,14 @@ EXPORTS ?getStaticMetaObject@QDeclarativeListModel@@SAABUQMetaObject@@XZ @ 666 NONAME ABSENT ; struct QMetaObject const & QDeclarativeListModel::getStaticMetaObject(void) ?setStdCppSet@QMetaPropertyBuilder@@QAEX_N@Z @ 667 NONAME ABSENT ; void QMetaPropertyBuilder::setStdCppSet(bool) ??0QDeclarativeItemPrivate@@QAE@XZ @ 668 NONAME ; QDeclarativeItemPrivate::QDeclarativeItemPrivate(void) - ??0QDeclarativeDebugService@@QAE@ABVQString@@PAVQObject@@@Z @ 669 NONAME ABSENT ; QDeclarativeDebugService::QDeclarativeDebugService(class QString const &, class QObject *) + ??0QDeclarativeDebugService@@QAE@ABVQString@@PAVQObject@@@Z @ 669 NONAME ; QDeclarativeDebugService::QDeclarativeDebugService(class QString const &, class QObject *) ?load@QDeclarativePixmap@@QAEXPAVQDeclarativeEngine@@ABVQUrl@@_N@Z @ 670 NONAME ; void QDeclarativePixmap::load(class QDeclarativeEngine *, class QUrl const &, bool) ??_EQPacketAutoSend@@UAE@I@Z @ 671 NONAME ABSENT ; QPacketAutoSend::~QPacketAutoSend(unsigned int) ?saveValueType@QDeclarativePropertyPrivate@@SA?AVQByteArray@@PBUQMetaObject@@H0H@Z @ 672 NONAME ABSENT ; class QByteArray QDeclarativePropertyPrivate::saveValueType(struct QMetaObject const *, int, struct QMetaObject const *, int) ?resetHeight@QDeclarativeItem@@QAEXXZ @ 673 NONAME ; void QDeclarativeItem::resetHeight(void) ?setVAlign@QDeclarativeText@@QAEXW4VAlignment@1@@Z @ 674 NONAME ABSENT ; void QDeclarativeText::setVAlign(enum QDeclarativeText::VAlignment) - ??1QDeclarativeDebugService@@UAE@XZ @ 675 NONAME ABSENT ; QDeclarativeDebugService::~QDeclarativeDebugService(void) - ?trUtf8@QDeclarativeDebugService@@SA?AVQString@@PBD0H@Z @ 676 NONAME ABSENT ; class QString QDeclarativeDebugService::trUtf8(char const *, char const *, int) + ??1QDeclarativeDebugService@@UAE@XZ @ 675 NONAME ; QDeclarativeDebugService::~QDeclarativeDebugService(void) + ?trUtf8@QDeclarativeDebugService@@SA?AVQString@@PBD0H@Z @ 676 NONAME ; class QString QDeclarativeDebugService::trUtf8(char const *, char const *, int) ?elideMode@QDeclarativeText@@QBE?AW4TextElideMode@1@XZ @ 677 NONAME ABSENT ; enum QDeclarativeText::TextElideMode QDeclarativeText::elideMode(void) const ?baseUrl@QDeclarativeContext@@QBE?AVQUrl@@XZ @ 678 NONAME ; class QUrl QDeclarativeContext::baseUrl(void) const ?qt_metacall@QDeclarativeDebugRootContextQuery@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 679 NONAME ABSENT ; int QDeclarativeDebugRootContextQuery::qt_metacall(enum QMetaObject::Call, int, void * *) @@ -849,7 +849,7 @@ EXPORTS ??1QDeclarativeBehavior@@UAE@XZ @ 848 NONAME ABSENT ; QDeclarativeBehavior::~QDeclarativeBehavior(void) ?qmlInfo@@YA?AVQDeclarativeInfo@@PBVQObject@@@Z @ 849 NONAME ; class QDeclarativeInfo qmlInfo(class QObject const *) ?qt_metacall@QDeclarativeDebugClient@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 850 NONAME ABSENT ; int QDeclarativeDebugClient::qt_metacall(enum QMetaObject::Call, int, void * *) - ?d_func@QDeclarativeDebugService@@ABEPBVQDeclarativeDebugServicePrivate@@XZ @ 851 NONAME ABSENT ; class QDeclarativeDebugServicePrivate const * QDeclarativeDebugService::d_func(void) const + ?d_func@QDeclarativeDebugService@@ABEPBVQDeclarativeDebugServicePrivate@@XZ @ 851 NONAME ; class QDeclarativeDebugServicePrivate const * QDeclarativeDebugService::d_func(void) const ??1QDeclarativeDebugQuery@@UAE@XZ @ 852 NONAME ABSENT ; QDeclarativeDebugQuery::~QDeclarativeDebugQuery(void) ?data_append@QDeclarativeItemPrivate@@SAXPAV?$QDeclarativeListProperty@VQObject@@@@PAVQObject@@@Z @ 853 NONAME ; void QDeclarativeItemPrivate::data_append(class QDeclarativeListProperty<class QObject> *, class QObject *) ?tr@QDeclarativeState@@SA?AVQString@@PBD0@Z @ 854 NONAME ; class QString QDeclarativeState::tr(char const *, char const *) @@ -1120,7 +1120,7 @@ EXPORTS ?expression@QDeclarativeDebugExpressionQuery@@QBE?AVQVariant@@XZ @ 1119 NONAME ABSENT ; class QVariant QDeclarativeDebugExpressionQuery::expression(void) const ??4QDeclarativeDomList@@QAEAAV0@ABV0@@Z @ 1120 NONAME ABSENT ; class QDeclarativeDomList & QDeclarativeDomList::operator=(class QDeclarativeDomList const &) ?qt_metacall@QDeclarativeComponent@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1121 NONAME ; int QDeclarativeComponent::qt_metacall(enum QMetaObject::Call, int, void * *) - ?tr@QDeclarativeDebugService@@SA?AVQString@@PBD0H@Z @ 1122 NONAME ABSENT ; class QString QDeclarativeDebugService::tr(char const *, char const *, int) + ?tr@QDeclarativeDebugService@@SA?AVQString@@PBD0H@Z @ 1122 NONAME ; class QString QDeclarativeDebugService::tr(char const *, char const *, int) ?staticMetaObject@QDeclarativeEngine@@2UQMetaObject@@B @ 1123 NONAME ; struct QMetaObject const QDeclarativeEngine::staticMetaObject ?staticMetaObject@QDeclarativeStateOperation@@2UQMetaObject@@B @ 1124 NONAME ; struct QMetaObject const QDeclarativeStateOperation::staticMetaObject ?actions@QDeclarativeStateOperation@@UAE?AV?$QList@VQDeclarativeAction@@@@XZ @ 1125 NONAME ; class QList<class QDeclarativeAction> QDeclarativeStateOperation::actions(void) @@ -1145,7 +1145,7 @@ EXPORTS ?sourceFile@QDeclarativeExpression@@QBE?AVQString@@XZ @ 1144 NONAME ; class QString QDeclarativeExpression::sourceFile(void) const ??_EQDeclarativeAnchors@@UAE@I@Z @ 1145 NONAME ABSENT ; QDeclarativeAnchors::~QDeclarativeAnchors(unsigned int) ?removeNotifySignal@QMetaPropertyBuilder@@QAEXXZ @ 1146 NONAME ABSENT ; void QMetaPropertyBuilder::removeNotifySignal(void) - ?trUtf8@QDeclarativeDebugService@@SA?AVQString@@PBD0@Z @ 1147 NONAME ABSENT ; class QString QDeclarativeDebugService::trUtf8(char const *, char const *) + ?trUtf8@QDeclarativeDebugService@@SA?AVQString@@PBD0@Z @ 1147 NONAME ; class QString QDeclarativeDebugService::trUtf8(char const *, char const *) ?setImportPathList@QDeclarativeEngine@@QAEXABVQStringList@@@Z @ 1148 NONAME ; void QDeclarativeEngine::setImportPathList(class QStringList const &) ?enabledChanged@QDeclarativeDebugService@@MAEX_N@Z @ 1149 NONAME ABSENT ; void QDeclarativeDebugService::enabledChanged(bool) ?addWatch@QDeclarativeEngineDebug@@QAEPAVQDeclarativeDebugWatch@@ABVQDeclarativeDebugObjectReference@@PAVQObject@@@Z @ 1150 NONAME ABSENT ; class QDeclarativeDebugWatch * QDeclarativeEngineDebug::addWatch(class QDeclarativeDebugObjectReference const &, class QObject *) @@ -1176,7 +1176,7 @@ EXPORTS ?paint@QDeclarativeRectangle@@UAEXPAVQPainter@@PBVQStyleOptionGraphicsItem@@PAVQWidget@@@Z @ 1175 NONAME ABSENT ; void QDeclarativeRectangle::paint(class QPainter *, class QStyleOptionGraphicsItem const *, class QWidget *) ??6QDeclarativeState@@QAEAAV0@PAVQDeclarativeStateOperation@@@Z @ 1176 NONAME ; class QDeclarativeState & QDeclarativeState::operator<<(class QDeclarativeStateOperation *) ?destroy@QDeclarativeAbstractBinding@@UAEXXZ @ 1177 NONAME ABSENT ; void QDeclarativeAbstractBinding::destroy(void) - ?qt_metacast@QDeclarativeDebugService@@UAEPAXPBD@Z @ 1178 NONAME ABSENT ; void * QDeclarativeDebugService::qt_metacast(char const *) + ?qt_metacast@QDeclarativeDebugService@@UAEPAXPBD@Z @ 1178 NONAME ; void * QDeclarativeDebugService::qt_metacast(char const *) ?qt_metacast@QDeclarativeValueType@@UAEPAXPBD@Z @ 1179 NONAME ABSENT ; void * QDeclarativeValueType::qt_metacast(char const *) ?childAt@QDeclarativeItem@@QBEPAV1@MM@Z @ 1180 NONAME ; class QDeclarativeItem * QDeclarativeItem::childAt(float, float) const ?paintedWidth@QDeclarativeText@@QBEMXZ @ 1181 NONAME ABSENT ; float QDeclarativeText::paintedWidth(void) const @@ -1297,7 +1297,7 @@ EXPORTS ?value@QDeclarativeOpenMetaObject@@QBE?AVQVariant@@H@Z @ 1296 NONAME ABSENT ; class QVariant QDeclarativeOpenMetaObject::value(int) const ?tr@QDeclarativeDebugRootContextQuery@@SA?AVQString@@PBD0H@Z @ 1297 NONAME ABSENT ; class QString QDeclarativeDebugRootContextQuery::tr(char const *, char const *, int) ?setFromState@QDeclarativeTransition@@QAEXABVQString@@@Z @ 1298 NONAME ; void QDeclarativeTransition::setFromState(class QString const &) - ?metaObject@QDeclarativeDebugService@@UBEPBUQMetaObject@@XZ @ 1299 NONAME ABSENT ; struct QMetaObject const * QDeclarativeDebugService::metaObject(void) const + ?metaObject@QDeclarativeDebugService@@UBEPBUQMetaObject@@XZ @ 1299 NONAME ; struct QMetaObject const * QDeclarativeDebugService::metaObject(void) const ?state@QDeclarativeDebugQuery@@QBE?AW4State@1@XZ @ 1300 NONAME ABSENT ; enum QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state(void) const ?setBottom@QDeclarativeScaleGrid@@QAEXH@Z @ 1301 NONAME ABSENT ; void QDeclarativeScaleGrid::setBottom(int) ?topMarginChanged@QDeclarativeAnchors@@IAEXXZ @ 1302 NONAME ABSENT ; void QDeclarativeAnchors::topMarginChanged(void) @@ -1305,7 +1305,7 @@ EXPORTS ?position@QDeclarativeDomObject@@QBEHXZ @ 1304 NONAME ABSENT ; int QDeclarativeDomObject::position(void) const ?update@QDeclarativeBinding@@UAEXV?$QFlags@W4WriteFlag@QDeclarativePropertyPrivate@@@@@Z @ 1305 NONAME ABSENT ; void QDeclarativeBinding::update(class QFlags<enum QDeclarativePropertyPrivate::WriteFlag>) ?tr@QDeclarativeBehavior@@SA?AVQString@@PBD0@Z @ 1306 NONAME ABSENT ; class QString QDeclarativeBehavior::tr(char const *, char const *) - ?isDebuggingEnabled@QDeclarativeDebugService@@SA_NXZ @ 1307 NONAME ABSENT ; bool QDeclarativeDebugService::isDebuggingEnabled(void) + ?isDebuggingEnabled@QDeclarativeDebugService@@SA_NXZ @ 1307 NONAME ; bool QDeclarativeDebugService::isDebuggingEnabled(void) ?tr@QDeclarativeText@@SA?AVQString@@PBD0H@Z @ 1308 NONAME ABSENT ; class QString QDeclarativeText::tr(char const *, char const *, int) ?reset@QDeclarativeProperty@@QBE_NXZ @ 1309 NONAME ; bool QDeclarativeProperty::reset(void) const ?objectDebugId@QDeclarativeDebugWatch@@QBEHXZ @ 1310 NONAME ABSENT ; int QDeclarativeDebugWatch::objectDebugId(void) const @@ -1344,7 +1344,7 @@ EXPORTS ?maximumPacketSize@QPacketProtocol@@QBEHXZ @ 1343 NONAME ABSENT ; int QPacketProtocol::maximumPacketSize(void) const ??_EQDeclarativeDebuggerStatus@@UAE@I@Z @ 1344 NONAME ABSENT ; QDeclarativeDebuggerStatus::~QDeclarativeDebuggerStatus(unsigned int) ?error@QDeclarativeCustomParser@@IAEXABVQString@@@Z @ 1345 NONAME ; void QDeclarativeCustomParser::error(class QString const &) - ?messageReceived@QDeclarativeDebugService@@MAEXABVQByteArray@@@Z @ 1346 NONAME ABSENT ; void QDeclarativeDebugService::messageReceived(class QByteArray const &) + ?messageReceived@QDeclarativeDebugService@@MAEXABVQByteArray@@@Z @ 1346 NONAME ; void QDeclarativeDebugService::messageReceived(class QByteArray const &) ??0QDeclarativeParserStatus@@QAE@XZ @ 1347 NONAME ; QDeclarativeParserStatus::QDeclarativeParserStatus(void) ?isNumber@Variant@QDeclarativeParser@@QBE_NXZ @ 1348 NONAME ; bool QDeclarativeParser::Variant::isNumber(void) const ?getStaticMetaObject@QDeclarativeEngineDebug@@SAABUQMetaObject@@XZ @ 1349 NONAME ABSENT ; struct QMetaObject const & QDeclarativeEngineDebug::getStaticMetaObject(void) @@ -1475,7 +1475,7 @@ EXPORTS ?packetWritten@QPacketProtocol@@IAEXXZ @ 1474 NONAME ABSENT ; void QPacketProtocol::packetWritten(void) ?getStaticMetaObject@QDeclarativeDebugObjectQuery@@SAABUQMetaObject@@XZ @ 1475 NONAME ABSENT ; struct QMetaObject const & QDeclarativeDebugObjectQuery::getStaticMetaObject(void) ?isSignalProperty@QDeclarativeProperty@@QBE_NXZ @ 1476 NONAME ; bool QDeclarativeProperty::isSignalProperty(void) const - ?d_func@QDeclarativeDebugService@@AAEPAVQDeclarativeDebugServicePrivate@@XZ @ 1477 NONAME ABSENT ; class QDeclarativeDebugServicePrivate * QDeclarativeDebugService::d_func(void) + ?d_func@QDeclarativeDebugService@@AAEPAVQDeclarativeDebugServicePrivate@@XZ @ 1477 NONAME ; class QDeclarativeDebugServicePrivate * QDeclarativeDebugService::d_func(void) ?qmlTypeNames@QDeclarativeMetaType@@SA?AV?$QList@VQByteArray@@@@XZ @ 1478 NONAME ABSENT ; class QList<class QByteArray> QDeclarativeMetaType::qmlTypeNames(void) ?componentComplete@QDeclarativeItem@@MAEXXZ @ 1479 NONAME ; void QDeclarativeItem::componentComplete(void) ?creationContext@QDeclarativeComponent@@QBEPAVQDeclarativeContext@@XZ @ 1480 NONAME ; class QDeclarativeContext * QDeclarativeComponent::creationContext(void) const @@ -1575,7 +1575,7 @@ EXPORTS ?keyCount@QMetaEnumBuilder@@QBEHXZ @ 1574 NONAME ABSENT ; int QMetaEnumBuilder::keyCount(void) const ??1QDeclarativeDomProperty@@QAE@XZ @ 1575 NONAME ABSENT ; QDeclarativeDomProperty::~QDeclarativeDomProperty(void) ?url@QDeclarativePixmap@@QBEABVQUrl@@XZ @ 1576 NONAME ; class QUrl const & QDeclarativePixmap::url(void) const - ?sendMessage@QDeclarativeDebugService@@QAEXABVQByteArray@@@Z @ 1577 NONAME ABSENT ; void QDeclarativeDebugService::sendMessage(class QByteArray const &) + ?sendMessage@QDeclarativeDebugService@@QAEXABVQByteArray@@@Z @ 1577 NONAME ; void QDeclarativeDebugService::sendMessage(class QByteArray const &) ?context@QDeclarativeScriptString@@QBEPAVQDeclarativeContext@@XZ @ 1578 NONAME ; class QDeclarativeContext * QDeclarativeScriptString::context(void) const ?queryObject@QDeclarativeEngineDebug@@QAEPAVQDeclarativeDebugObjectQuery@@ABVQDeclarativeDebugObjectReference@@PAVQObject@@@Z @ 1579 NONAME ABSENT ; class QDeclarativeDebugObjectQuery * QDeclarativeEngineDebug::queryObject(class QDeclarativeDebugObjectReference const &, class QObject *) ?tr@QDeclarativePropertyMap@@SA?AVQString@@PBD0H@Z @ 1580 NONAME ; class QString QDeclarativePropertyMap::tr(char const *, char const *, int) @@ -1608,7 +1608,7 @@ EXPORTS ??_EQDeclarativeComponent@@UAE@I@Z @ 1607 NONAME ; QDeclarativeComponent::~QDeclarativeComponent(unsigned int) ?get@QDeclarativeItemPrivate@@SAPAV1@PAVQDeclarativeItem@@@Z @ 1608 NONAME ; class QDeclarativeItemPrivate * QDeclarativeItemPrivate::get(class QDeclarativeItem *) ?staticMetaObject@QDeclarativeView@@2UQMetaObject@@B @ 1609 NONAME ; struct QMetaObject const QDeclarativeView::staticMetaObject - ?objectToString@QDeclarativeDebugService@@SA?AVQString@@PAVQObject@@@Z @ 1610 NONAME ABSENT ; class QString QDeclarativeDebugService::objectToString(class QObject *) + ?objectToString@QDeclarativeDebugService@@SA?AVQString@@PAVQObject@@@Z @ 1610 NONAME ; class QString QDeclarativeDebugService::objectToString(class QObject *) ?defaultValue@QDeclarativeDomDynamicProperty@@QBE?AVQDeclarativeDomProperty@@XZ @ 1611 NONAME ABSENT ; class QDeclarativeDomProperty QDeclarativeDomDynamicProperty::defaultValue(void) const ?relatedMetaObject@QMetaObjectBuilder@@QBEPBUQMetaObject@@H@Z @ 1612 NONAME ABSENT ; struct QMetaObject const * QMetaObjectBuilder::relatedMetaObject(int) const ?addKey@QMetaEnumBuilder@@QAEHABVQByteArray@@H@Z @ 1613 NONAME ABSENT ; int QMetaEnumBuilder::addKey(class QByteArray const &, int) @@ -1633,7 +1633,7 @@ EXPORTS ?tr@QDeclarativeView@@SA?AVQString@@PBD0@Z @ 1632 NONAME ; class QString QDeclarativeView::tr(char const *, char const *) ?qt_metacall@QPacketProtocol@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1633 NONAME ABSENT ; int QPacketProtocol::qt_metacall(enum QMetaObject::Call, int, void * *) ??0QDeclarativeItem@@QAE@PAV0@@Z @ 1634 NONAME ; QDeclarativeItem::QDeclarativeItem(class QDeclarativeItem *) - ?hasDebuggingClient@QDeclarativeDebugService@@SA_NXZ @ 1635 NONAME ABSENT ; bool QDeclarativeDebugService::hasDebuggingClient(void) + ?hasDebuggingClient@QDeclarativeDebugService@@SA_NXZ @ 1635 NONAME ; bool QDeclarativeDebugService::hasDebuggingClient(void) ?staticMetaObject@QDeclarativeContext@@2UQMetaObject@@B @ 1636 NONAME ; struct QMetaObject const QDeclarativeContext::staticMetaObject ?setContextForObject@QDeclarativeEngine@@SAXPAVQObject@@PAVQDeclarativeContext@@@Z @ 1637 NONAME ; void QDeclarativeEngine::setContextForObject(class QObject *, class QDeclarativeContext *) ?baselineOffsetChanged@QDeclarativeItem@@IAEXM@Z @ 1638 NONAME ; void QDeclarativeItem::baselineOffsetChanged(float) @@ -1733,7 +1733,7 @@ EXPORTS ?start@QDeclarativeTimer@@QAEXXZ @ 1732 NONAME ABSENT ; void QDeclarativeTimer::start(void) ?transition@QDeclarativeAbstractAnimation@@UAEXAAV?$QList@VQDeclarativeAction@@@@AAV?$QList@VQDeclarativeProperty@@@@W4TransitionDirection@1@@Z @ 1733 NONAME ABSENT ; void QDeclarativeAbstractAnimation::transition(class QList<class QDeclarativeAction> &, class QList<class QDeclarativeProperty> &, enum QDeclarativeAbstractAnimation::TransitionDirection) ?componentComplete@QDeclarativeAbstractAnimation@@UAEXXZ @ 1734 NONAME ABSENT ; void QDeclarativeAbstractAnimation::componentComplete(void) - ?statusChanged@QDeclarativeDebugService@@MAEXW4Status@1@@Z @ 1735 NONAME ABSENT ; void QDeclarativeDebugService::statusChanged(enum QDeclarativeDebugService::Status) + ?statusChanged@QDeclarativeDebugService@@MAEXW4Status@1@@Z @ 1735 NONAME ; void QDeclarativeDebugService::statusChanged(enum QDeclarativeDebugService::Status) ?runningChanged@QDeclarativeAbstractAnimation@@IAEX_N@Z @ 1736 NONAME ABSENT ; void QDeclarativeAbstractAnimation::runningChanged(bool) ?trUtf8@QDeclarativeAbstractAnimation@@SA?AVQString@@PBD0H@Z @ 1737 NONAME ABSENT ; class QString QDeclarativeAbstractAnimation::trUtf8(char const *, char const *, int) ??_EQDeclarativeBasePositioner@@UAE@I@Z @ 1738 NONAME ABSENT ; QDeclarativeBasePositioner::~QDeclarativeBasePositioner(unsigned int) @@ -1813,7 +1813,7 @@ EXPORTS ?setTarget@QDeclarativeAbstractAnimation@@EAEXABVQDeclarativeProperty@@@Z @ 1812 NONAME ABSENT ; void QDeclarativeAbstractAnimation::setTarget(class QDeclarativeProperty const &) ?alwaysRunToEnd@QDeclarativeAbstractAnimation@@QBE_NXZ @ 1813 NONAME ABSENT ; bool QDeclarativeAbstractAnimation::alwaysRunToEnd(void) const ?tr@QDeclarativeTimer@@SA?AVQString@@PBD0H@Z @ 1814 NONAME ABSENT ; class QString QDeclarativeTimer::tr(char const *, char const *, int) - ?status@QDeclarativeDebugService@@QBE?AW4Status@1@XZ @ 1815 NONAME ABSENT ; enum QDeclarativeDebugService::Status QDeclarativeDebugService::status(void) const + ?status@QDeclarativeDebugService@@QBE?AW4Status@1@XZ @ 1815 NONAME ; enum QDeclarativeDebugService::Status QDeclarativeDebugService::status(void) const ?intervalChanged@QDeclarativeTimer@@IAEXXZ @ 1816 NONAME ABSENT ; void QDeclarativeTimer::intervalChanged(void) ?isPaused@QDeclarativeAbstractAnimation@@QBE_NXZ @ 1817 NONAME ABSENT ; bool QDeclarativeAbstractAnimation::isPaused(void) const ?getStaticMetaObject@QDeclarativeAbstractAnimation@@SAABUQMetaObject@@XZ @ 1818 NONAME ABSENT ; struct QMetaObject const & QDeclarativeAbstractAnimation::getStaticMetaObject(void) diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 1ed68a8..b4f54d8 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -761,20 +761,20 @@ EXPORTS _ZN24QDeclarativeCustomParser5errorERK28QDeclarativeCustomParserNodeRK7QString @ 760 NONAME _ZN24QDeclarativeCustomParser5errorERK32QDeclarativeCustomParserPropertyRK7QString @ 761 NONAME _ZN24QDeclarativeCustomParser5errorERK7QString @ 762 NONAME - _ZN24QDeclarativeDebugService11idForObjectEP7QObject @ 763 NONAME ABSENT - _ZN24QDeclarativeDebugService11objectForIdEi @ 764 NONAME ABSENT - _ZN24QDeclarativeDebugService11qt_metacallEN11QMetaObject4CallEiPPv @ 765 NONAME ABSENT - _ZN24QDeclarativeDebugService11qt_metacastEPKc @ 766 NONAME ABSENT - _ZN24QDeclarativeDebugService11sendMessageERK10QByteArray @ 767 NONAME ABSENT + _ZN24QDeclarativeDebugService11idForObjectEP7QObject @ 763 NONAME + _ZN24QDeclarativeDebugService11objectForIdEi @ 764 NONAME + _ZN24QDeclarativeDebugService11qt_metacallEN11QMetaObject4CallEiPPv @ 765 NONAME + _ZN24QDeclarativeDebugService11qt_metacastEPKc @ 766 NONAME + _ZN24QDeclarativeDebugService11sendMessageERK10QByteArray @ 767 NONAME _ZN24QDeclarativeDebugService14enabledChangedEb @ 768 NONAME ABSENT - _ZN24QDeclarativeDebugService14objectToStringEP7QObject @ 769 NONAME ABSENT - _ZN24QDeclarativeDebugService15messageReceivedERK10QByteArray @ 770 NONAME ABSENT - _ZN24QDeclarativeDebugService16staticMetaObjectE @ 771 NONAME DATA 16 ABSENT - _ZN24QDeclarativeDebugService18hasDebuggingClientEv @ 772 NONAME ABSENT - _ZN24QDeclarativeDebugService18isDebuggingEnabledEv @ 773 NONAME ABSENT - _ZN24QDeclarativeDebugService19getStaticMetaObjectEv @ 774 NONAME ABSENT - _ZN24QDeclarativeDebugServiceC1ERK7QStringP7QObject @ 775 NONAME ABSENT - _ZN24QDeclarativeDebugServiceC2ERK7QStringP7QObject @ 776 NONAME ABSENT + _ZN24QDeclarativeDebugService14objectToStringEP7QObject @ 769 NONAME + _ZN24QDeclarativeDebugService15messageReceivedERK10QByteArray @ 770 NONAME + _ZN24QDeclarativeDebugService16staticMetaObjectE @ 771 NONAME DATA 16 + _ZN24QDeclarativeDebugService18hasDebuggingClientEv @ 772 NONAME + _ZN24QDeclarativeDebugService18isDebuggingEnabledEv @ 773 NONAME + _ZN24QDeclarativeDebugService19getStaticMetaObjectEv @ 774 NONAME + _ZN24QDeclarativeDebugServiceC1ERK7QStringP7QObject @ 775 NONAME + _ZN24QDeclarativeDebugServiceC2ERK7QStringP7QObject @ 776 NONAME _ZN24QDeclarativeDomComponentC1ERKS_ @ 777 NONAME ABSENT _ZN24QDeclarativeDomComponentC1Ev @ 778 NONAME ABSENT _ZN24QDeclarativeDomComponentC2ERKS_ @ 779 NONAME ABSENT @@ -1425,8 +1425,8 @@ EXPORTS _ZNK23QDeclarativePropertyMapixERK7QString @ 1424 NONAME _ZNK24QDeclarativeCustomParser11resolveTypeERK10QByteArray @ 1425 NONAME _ZNK24QDeclarativeCustomParser12evaluateEnumERK10QByteArray @ 1426 NONAME - _ZNK24QDeclarativeDebugService10metaObjectEv @ 1427 NONAME ABSENT - _ZNK24QDeclarativeDebugService4nameEv @ 1428 NONAME ABSENT + _ZNK24QDeclarativeDebugService10metaObjectEv @ 1427 NONAME + _ZNK24QDeclarativeDebugService4nameEv @ 1428 NONAME _ZNK24QDeclarativeDebugService9isEnabledEv @ 1429 NONAME ABSENT _ZNK24QDeclarativeDomComponent13componentRootEv @ 1430 NONAME ABSENT _ZNK24QDeclarativeScriptString11scopeObjectEv @ 1431 NONAME @@ -1554,7 +1554,7 @@ EXPORTS _ZTI23QDeclarativeItemPrivate @ 1553 NONAME _ZTI23QDeclarativePropertyMap @ 1554 NONAME _ZTI24QDeclarativeCustomParser @ 1555 NONAME - _ZTI24QDeclarativeDebugService @ 1556 NONAME ABSENT + _ZTI24QDeclarativeDebugService @ 1556 NONAME _ZTI24QDeclarativeParserStatus @ 1557 NONAME _ZTI25QDeclarativeImageProvider @ 1558 NONAME _ZTI26QDeclarativeDebuggerStatus @ 1559 NONAME ABSENT @@ -1604,7 +1604,7 @@ EXPORTS _ZTV23QDeclarativeItemPrivate @ 1603 NONAME _ZTV23QDeclarativePropertyMap @ 1604 NONAME _ZTV24QDeclarativeCustomParser @ 1605 NONAME - _ZTV24QDeclarativeDebugService @ 1606 NONAME ABSENT + _ZTV24QDeclarativeDebugService @ 1606 NONAME _ZTV24QDeclarativeParserStatus @ 1607 NONAME _ZTV25QDeclarativeImageProvider @ 1608 NONAME _ZTV26QDeclarativeDebuggerStatus @ 1609 NONAME ABSENT @@ -1777,10 +1777,10 @@ EXPORTS _ZN23QDeclarativeDebugClientD1Ev @ 1776 NONAME ABSENT _ZN23QDeclarativeDebugClientD2Ev @ 1777 NONAME ABSENT _ZN23QDeclarativeEngineDebug13statusChangedENS_6StatusE @ 1778 NONAME ABSENT - _ZN24QDeclarativeDebugService13statusChangedENS_6StatusE @ 1779 NONAME ABSENT - _ZN24QDeclarativeDebugServiceD0Ev @ 1780 NONAME ABSENT - _ZN24QDeclarativeDebugServiceD1Ev @ 1781 NONAME ABSENT - _ZN24QDeclarativeDebugServiceD2Ev @ 1782 NONAME ABSENT + _ZN24QDeclarativeDebugService13statusChangedENS_6StatusE @ 1779 NONAME + _ZN24QDeclarativeDebugServiceD0Ev @ 1780 NONAME + _ZN24QDeclarativeDebugServiceD1Ev @ 1781 NONAME + _ZN24QDeclarativeDebugServiceD2Ev @ 1782 NONAME _ZN26QDeclarativeBasePositioner10addChangedEv @ 1783 NONAME ABSENT _ZN26QDeclarativeBasePositioner10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 1784 NONAME ABSENT _ZN26QDeclarativeBasePositioner10setSpacingEi @ 1785 NONAME ABSENT @@ -1851,7 +1851,7 @@ EXPORTS _ZNK17QDeclarativeTimer9isRunningEv @ 1850 NONAME ABSENT _ZNK23QDeclarativeDebugClient6statusEv @ 1851 NONAME ABSENT _ZNK23QDeclarativeEngineDebug6statusEv @ 1852 NONAME ABSENT - _ZNK24QDeclarativeDebugService6statusEv @ 1853 NONAME ABSENT + _ZNK24QDeclarativeDebugService6statusEv @ 1853 NONAME _ZNK26QDeclarativeBasePositioner10metaObjectEv @ 1854 NONAME ABSENT _ZNK26QDeclarativeBasePositioner3addEv @ 1855 NONAME ABSENT _ZNK26QDeclarativeBasePositioner4moveEv @ 1856 NONAME ABSENT -- cgit v0.12 From cc016cc9cfba9b35a852399603c6d3f99e31af58 Mon Sep 17 00:00:00 2001 From: Sami Merila <sami.merila@nokia.com> Date: Mon, 14 Mar 2011 12:06:04 +0200 Subject: QS60Style: QTreeView::indexRowSizeHint returns incorrect value Fix for http://bugreports.qt.nokia.com/browse/QTBUG-17786. QS60Style tries to work around the hardcoded margin that the QCommonStyle adds to menu items (line 4782 in my QCommonStyle.cpp). Unfortunately regular itemview items are handled in the same code branch in QS60Style, so the class incorrectly reduces the itemview height 8 pixels. The reduction should only happen with menu items. Task-number: QTBUG-17786 Reviewed-by: Laszlo Agocs (cherry picked from commit 8b7c98123eadf9263c6bde4b1263bd64fc388c8d) --- src/gui/styles/qs60style.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index c949326..d0ca407 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2643,10 +2643,13 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); //native items have small empty areas at the beginning and end of menu item sz.setWidth(sz.width() + 2 * pixelMetric(PM_MenuHMargin) + 2 * QS60StylePrivate::pixelMetric(PM_FrameCornerWidth)); - if (QS60StylePrivate::isTouchSupported()) + if (QS60StylePrivate::isTouchSupported()) { //Make itemview easier to use in touch devices + sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); //QCommonStyle does not adjust height with horizontal margin, it only adjusts width - sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin) - 8); //QCommonstyle adds 8 to height that this style handles through PM values + if (ct == CT_MenuItem) + sz.setHeight(sz.height() - 8); //QCommonstyle adds 8 to height that this style handles through PM values + } break; #ifndef QT_NO_COMBOBOX case CT_ComboBox: { -- cgit v0.12 From 3fa85afd04ba67c762ca7489c63b4bfc4a6deac0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.p.agocs@nokia.com> Date: Mon, 14 Mar 2011 13:53:44 +0200 Subject: Fix qgraphicstransform autotest for Symbian, where qreal is float. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-17907 Reviewed-by: Samuel Rødal (cherry picked from commit 99aa67f649c44dda8c0da639b4925dbb0e4c9b70) --- tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index fe66ffa..c8de7fd 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -163,10 +163,11 @@ static inline bool fuzzyCompare(qreal p1, qreal p2) { // increase delta on small machines using float instead of double if (sizeof(qreal) == sizeof(float)) - return (qAbs(p1 - p2) <= 0.00002f * qMin(qAbs(p1), qAbs(p2))); + return (qAbs(p1 - p2) <= 0.00003f * qMin(qAbs(p1), qAbs(p2))); else return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2))); } + static bool fuzzyCompare(const QTransform& t1, const QTransform& t2) { return fuzzyCompare(t1.m11(), t2.m11()) && @@ -180,6 +181,15 @@ static bool fuzzyCompare(const QTransform& t1, const QTransform& t2) fuzzyCompare(t1.m33(), t2.m33()); } +static inline bool fuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2) +{ + bool ok = true; + for (int y = 0; y < 4; ++y) + for (int x = 0; x < 4; ++x) + ok &= fuzzyCompare(m1(y, x), m2(y, x)); + return ok; +} + void tst_QGraphicsTransform::rotation() { QGraphicsRotation rotation; @@ -267,7 +277,7 @@ void tst_QGraphicsTransform::rotation3d() // because the deg2rad value in QTransform is not accurate // enough to match what QMatrix4x4 is doing. } else { - QVERIFY(qFuzzyCompare(t, r)); + QVERIFY(fuzzyCompare(t, r)); } //now let's check that a null vector will not change the transform -- cgit v0.12 From a92f15eaae6981bf420477e4736f169b4224a6c4 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.p.agocs@nokia.com> Date: Wed, 16 Mar 2011 13:52:28 +0200 Subject: Fix for wrong dpi metrics for raster pixmaps on Symbian. The original implementation relied on SizeInTwips() for the underlying bitmap which unfortunately returns 0, leading to incorrect results from QPixmap::logicalDpiX/Y(). This caused issues in text rendering onto pixmaps (QTBUG-17628). This fix changes QS60PixmapData to use a slightly different metrics() implementation (the one VG and GL PixmapData are using). Task-number: QTBUG-18154 Reviewed-by: Jani Hautakangas (cherry picked from commit 48629ab39aa4e20b21a359dc251569a98606983d) --- src/gui/image/qpixmap_s60.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 2bde2e5..0de99f8 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -599,6 +599,9 @@ bool QS60PixmapData::scroll(int dx, int dy, const QRect &rect) return res; } +Q_GUI_EXPORT int qt_defaultDpiX(); +Q_GUI_EXPORT int qt_defaultDpiY(); + int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const { if (!cfbsBitmap) @@ -609,28 +612,18 @@ int QS60PixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const return cfbsBitmap->SizeInPixels().iWidth; case QPaintDevice::PdmHeight: return cfbsBitmap->SizeInPixels().iHeight; - case QPaintDevice::PdmWidthMM: { - TInt twips = cfbsBitmap->SizeInTwips().iWidth; - return (int)(twips * (25.4/KTwipsPerInch)); - } - case QPaintDevice::PdmHeightMM: { - TInt twips = cfbsBitmap->SizeInTwips().iHeight; - return (int)(twips * (25.4/KTwipsPerInch)); - } + case QPaintDevice::PdmWidthMM: + return qRound(cfbsBitmap->SizeInPixels().iWidth * 25.4 / qt_defaultDpiX()); + case QPaintDevice::PdmHeightMM: + return qRound(cfbsBitmap->SizeInPixels().iHeight * 25.4 / qt_defaultDpiY()); case QPaintDevice::PdmNumColors: return TDisplayModeUtils::NumDisplayModeColors(cfbsBitmap->DisplayMode()); case QPaintDevice::PdmDpiX: - case QPaintDevice::PdmPhysicalDpiX: { - TReal inches = cfbsBitmap->SizeInTwips().iWidth / (TReal)KTwipsPerInch; - TInt pixels = cfbsBitmap->SizeInPixels().iWidth; - return pixels / inches; - } + case QPaintDevice::PdmPhysicalDpiX: + return qt_defaultDpiX(); case QPaintDevice::PdmDpiY: - case QPaintDevice::PdmPhysicalDpiY: { - TReal inches = cfbsBitmap->SizeInTwips().iHeight / (TReal)KTwipsPerInch; - TInt pixels = cfbsBitmap->SizeInPixels().iHeight; - return pixels / inches; - } + case QPaintDevice::PdmPhysicalDpiY: + return qt_defaultDpiY(); case QPaintDevice::PdmDepth: return TDisplayModeUtils::NumDisplayModeBitsPerPixel(cfbsBitmap->DisplayMode()); default: -- cgit v0.12 From 7f76be56573f47fc163fa5556061a890cf0c338f Mon Sep 17 00:00:00 2001 From: Timo Turunen <timo.p.turunen@nokia.com> Date: Tue, 22 Mar 2011 15:21:10 +0200 Subject: Changes for 4.7.3 Reviewed-by: Trust Me (cherry picked from commit 5054d7ecdb3bd3fc1c5bf77a99b1675c26ba9795) --- dist/changes-4.7.3 | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/dist/changes-4.7.3 b/dist/changes-4.7.3 index e69de29..fa8a71e 100644 --- a/dist/changes-4.7.3 +++ b/dist/changes-4.7.3 @@ -0,0 +1,47 @@ +Qt 4.7.3 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 4.7.0. For more details, +refer to the online documentation included in this distribution. The +documentation is also available online: + +http://qt.nokia.com/doc/4.7 + +The Qt version 4.7 series is binary compatible with the 4.6.x series. +Applications compiled for 4.6 will continue to run with 4.7. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker or the Merge Request queue +of the public source repository. + +Qt Bug Tracker: http://bugreports.qt.nokia.com +Merge Request: http://qt.gitorious.org + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +Qt for Symbian +-------------- + +- Bearer Management +* [QTBUG-15108] Deadlock between SymbianEngine mutex and +QNetworkConfigurationPrivate mutex in the symbian bearer code +* [QTBUG-17627] qnetworksession.h Q_DECLARE_METATYPE breaks building +QtMobility QtBearer depending applications + +- GraphicsView +* [QTBUG-17966] Major regression in QGraphicsView OpenVG backend + +- Declarative +* [QTBUG-17503] Export qml debugging symbols on Symbian + +- Widgets +* [QTBUG-17786] BC between Qt 4.7.3 and 4.6.3 QTreeView::indexRowSizeHint +doesn't return correct value on Symbian for row when QPushButton widget is +inserted in the treeview + +- Painting +* [QTBUG-17907] tst_QGraphicsTransform::rotation3d test case from +tests/auto/qgraphicstransfor is failed for some rotation angle on +Symbian^3 devices +* [QTBUG-18154] Symbian's QPixmap::logicalDpi[X\Y]() incorrectly +returns MAXINT -- cgit v0.12 From 1f6c02c290b3330c7c784c83b1c0f8a94155f9e5 Mon Sep 17 00:00:00 2001 From: Peter Hartmann <peter.hartmann@nokia.com> Date: Fri, 25 Mar 2011 15:17:16 +0100 Subject: QSslSocket: add test for blacklisted certificates Reviewed-by: Richard J. Moore Task-number: QTBUG-18338 (cherry picked from commit 764e060a389a18a5804d23c528abdaebcee3ca13) --- .../auto/qsslsocket/certs/fake-login.live.com.key | 15 ++++++++ .../auto/qsslsocket/certs/fake-login.live.com.pem | 19 ++++++++++ tests/auto/qsslsocket/tst_qsslsocket.cpp | 43 ++++++++++++++++++++-- 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qsslsocket/certs/fake-login.live.com.key create mode 100644 tests/auto/qsslsocket/certs/fake-login.live.com.pem diff --git a/tests/auto/qsslsocket/certs/fake-login.live.com.key b/tests/auto/qsslsocket/certs/fake-login.live.com.key new file mode 100644 index 0000000..692a7bd --- /dev/null +++ b/tests/auto/qsslsocket/certs/fake-login.live.com.key @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQDOtxdvMa0VHUQYG5q7Tsi1Jj4qKEJppyZEkmuRXOi0fDbd1SwE +bwHrLGMvDO6OMrYBbq3WDNrtnIfF9CvzUOEch+gjr4hEVQqecU5fb45Wor7yNel3 +/C/gxfbzuXHrsj/gUjNghL2i10+c2NW+hUo/sWO6OusaBT6d6s7ee+YBcQIDAQAB +AoGAb8cVhu0HuLkgjyCuJMbPRRUu3ED02Iin6sB6JhplQuNAD+grayJTmUVhRJnr +jTziqhedLHe7Em1oBaSo92MutfMpXvWiccSlbNygI61VgmrJpVB+qIN5H9cQc9ql +Zymc+nIPa1+i5rsrOzlpUytTh7AsbZ27QG4tQXR/kQejEiECQQD6BgTxBeT8D7x9 +DuukoBaSCkLwx7U7P1NXx15EI3lA1nO51t6UHfvk/jGPp8Sl4wv4alJ7AQxr5uQ/ +vC3kzA/1AkEA06gNu10se8pe3n8qL2RRt+FmVjHkQdD9Mm2Dx9oWCs2A4wOSOrlo +6/nKYF1CaQNYn9HgsNbHVEUpnICVO18qDQJBALEw/uOJ1+TDikPfBSWgxx4s45Ad +GNWqZXh6NNZ5hX9r/IwiOZAjR9fcRmeW8IjYRi2BvH6sGY+HDRAWXzgdXtkCQCma +dOiJTf8fLjqp4E7kdzOfuI/kyqstOze4Uxjrgz2oW1dEEnA8laUcumzqp+0gXUE8 +7d+UuCWWWrGKjMrYz9kCQQDh5E5+b6Djn082Jo6gvyuXWC5eXju6IdmihlJ2SMzD +s2y3IDjOUtTeQQRDymLneteMz0ha79KeUp6VnAvZCOVe +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/qsslsocket/certs/fake-login.live.com.pem b/tests/auto/qsslsocket/certs/fake-login.live.com.pem new file mode 100644 index 0000000..429f951 --- /dev/null +++ b/tests/auto/qsslsocket/certs/fake-login.live.com.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRALC3Ez7Qlvm1b66RyHS9OsAwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMObG9naW4ubGl2ZS5jb20w +HhcNMTEwMzI1MTMyODUwWhcNMTEwNDI0MTMyODUwWjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw5sb2dpbi5saXZlLmNvbTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEAzrcXbzGtFR1EGBuau07ItSY+KihCaacmRJJrkVzotHw23dUs +BG8B6yxjLwzujjK2AW6t1gza7ZyHxfQr81DhHIfoI6+IRFUKnnFOX2+OVqK+8jXp +d/wv4MX287lx67I/4FIzYIS9otdPnNjVvoVKP7FjujrrGgU+nerO3nvmAXECAwEA +AaOByzCByDAdBgNVHQ4EFgQUpSOEcmtkQITvBdM2IDfcXnJ0FCAwgZgGA1UdIwSB +kDCBjYAUpSOEcmtkQITvBdM2IDfcXnJ0FCChYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDmxvZ2luLmxpdmUuY29tghEAsLcTPtCW+bVvrpHIdL06 +wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAD+2HT4GSHHKCdbl9VkX +zsl+D+drMm2b0ksxz9SgPihP7aW50EEIJDEEihNMTa27mhpeOXHc/sLqDi4ECUao +/0Ns/5uoVuAIrAKCydmtPsonVFh9XWjyrfUzPOHAc9p2bmJ1i9a3kTsLB6jlrVDO +VufGzsowHlHZ0TtKf5omojU5 +-----END CERTIFICATE----- diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 569a593..aa695e7 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -183,6 +183,7 @@ private slots: void ignoreSslErrorsListWithSlot(); void readFromClosedSocket(); void writeBigChunk(); + void blacklist(); void setEmptyDefaultConfiguration(); static void exitLoop() @@ -868,8 +869,13 @@ class SslServer : public QTcpServer { Q_OBJECT public: - SslServer() : socket(0) { } + SslServer(const QString &keyFile = SRCDIR "certs/fluke.key", const QString &certFile = SRCDIR "certs/fluke.cert") + : socket(0), + m_keyFile(keyFile), + m_certFile(certFile) { } QSslSocket *socket; + QString m_keyFile; + QString m_certFile; protected: void incomingConnection(int socketDescriptor) @@ -877,13 +883,13 @@ protected: socket = new QSslSocket(this); connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); - QFile file(SRCDIR "certs/fluke.key"); + QFile file(m_keyFile); QVERIFY(file.open(QIODevice::ReadOnly)); QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); QVERIFY(!key.isNull()); socket->setPrivateKey(key); - QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(m_certFile); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -1837,6 +1843,37 @@ void tst_QSslSocket::writeBigChunk() socket->close(); } +void tst_QSslSocket::blacklist() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SslServer server(SRCDIR "certs/fake-login.live.com.key", SRCDIR "certs/fake-login.live.com.pem"); + QSslSocket *receiver = new QSslSocket(this); + connect(receiver, SIGNAL(readyRead()), SLOT(exitLoop())); + + // connect two sockets to each other: + QVERIFY(server.listen(QHostAddress::LocalHost)); + receiver->connectToHost("127.0.0.1", server.serverPort()); + QVERIFY(receiver->waitForConnected(5000)); + QVERIFY(server.waitForNewConnection(0)); + + QSslSocket *sender = server.socket; + QVERIFY(sender); + QVERIFY(sender->state() == QAbstractSocket::ConnectedState); + receiver->setObjectName("receiver"); + sender->setObjectName("sender"); + receiver->ignoreSslErrors(); + receiver->startClientEncryption(); + + connect(receiver, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(exitLoop())); + connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop())); + enterLoop(1); + QCOMPARE(receiver->error(), QAbstractSocket::SslHandshakeFailedError); + QCOMPARE(receiver->errorString(), QString("The peer certificate is blacklisted")); +} + void tst_QSslSocket::setEmptyDefaultConfiguration() { // used to produce a crash in QSslConfigurationPrivate::deepCopyDefaultConfiguration, QTBUG-13265 -- cgit v0.12 From b3f64f1b4eb949bd639c4a088121a4c5ad2eb743 Mon Sep 17 00:00:00 2001 From: Peter Hartmann <peter.hartmann@nokia.com> Date: Fri, 25 Mar 2011 13:45:24 +0100 Subject: QSslSocket internals: abort on encountering blacklisted certificates tested manually with "openssl s_server -cert blacklisted.pem -key key.pem" and connecting a QSslSocket. Reviewed-by: Markus Goetz Task-number: QTBUG-18338 (cherry picked from commit b87528a71b66e786c11804d7b79e408aae612748) --- src/network/ssl/qsslsocket_openssl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 7395c0a..0024ee6 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -1183,6 +1183,13 @@ bool QSslSocketBackendPrivate::startHandshake() X509 *x509 = q_SSL_get_peer_certificate(ssl); configuration.peerCertificate = QSslCertificatePrivate::QSslCertificate_from_X509(x509); q_X509_free(x509); + if (QSslCertificatePrivate::isBlacklisted(configuration.peerCertificate)) { + q->setErrorString(QSslSocket::tr("The peer certificate is blacklisted")); + q->setSocketError(QAbstractSocket::SslHandshakeFailedError); + emit q->error(QAbstractSocket::SslHandshakeFailedError); + plainSocket->disconnectFromHost(); + return false; + } // Start translating errors. QList<QSslError> errors; -- cgit v0.12 From c9511d642e7ab38ad2a47ba834580cfbda43ab65 Mon Sep 17 00:00:00 2001 From: Timo Turunen <timo.p.turunen@nokia.com> Date: Mon, 28 Mar 2011 20:01:19 +0300 Subject: QSslCertificate: fix test for blacklisted certs on Windows Apparently the wildcard matching and the SRCDIR hack don't go well together. Reviewed-by: Markus Goetz Task-number: QTBUG-18338 (cherry picked from commit aeabe790203e7dcb1786e0dad7b4608f1e45b7d5) Conflicts: tests/auto/qsslcertificate/tst_qsslcertificate.cpp --- tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index ccc6af9..a8c5a4d 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -817,6 +817,15 @@ void tst_QSslCertificate::largeExpirationDate() // QTBUG-12489 QCOMPARE(cert.expiryDate().toUTC(), QDateTime(QDate(2051, 8, 29), QTime(9, 53, 41), Qt::UTC)); } +void tst_QSslCertificate::blacklistedCertificates() +{ + QList<QSslCertificate> blacklistedCerts = QSslCertificate::fromPath("more-certificates/blacklisted*.pem", QSsl::Pem, QRegExp::Wildcard); + QVERIFY2(blacklistedCerts.count() > 0, "Please run this test from the source directory"); + for (int a = 0; a < blacklistedCerts.count(); a++) { + QVERIFY(! blacklistedCerts.at(a).isValid()); + } +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslCertificate) -- cgit v0.12 From 43a8e3115fc9d13c2da2f32c3d2aafcfe0c6e543 Mon Sep 17 00:00:00 2001 From: Timo Turunen <timo.p.turunen@nokia.com> Date: Mon, 28 Mar 2011 20:24:32 +0300 Subject: QSslCertificate: report fraudulent certificates as invalid There are some fraudulent certificates in the wild that are not valid; this patch introduces a blacklist of serial numbers of those certificates. Reviewed-by: Richard J. Moore Reviewed-by: Markus Goetz Task-number: QTBUG-18338 (cherry picked from commit 04e074e8d7c097295505e63565abdc7ca2b49f7b) Conflicts: tests/auto/qsslcertificate/tst_qsslcertificate.cpp --- src/network/ssl/qsslcertificate.cpp | 34 +++++++++++++++++++--- src/network/ssl/qsslcertificate_p.h | 1 + .../more-certificates/blacklisted1.pem | 19 ++++++++++++ .../more-certificates/blacklisted2.pem | 19 ++++++++++++ .../more-certificates/blacklisted3.pem | 19 ++++++++++++ .../more-certificates/blacklisted4.pem | 19 ++++++++++++ .../more-certificates/blacklisted5.pem | 19 ++++++++++++ .../more-certificates/blacklisted6.pem | 19 ++++++++++++ .../more-certificates/blacklisted7.pem | 19 ++++++++++++ .../more-certificates/blacklisted8.pem | 19 ++++++++++++ .../more-certificates/blacklisted9.pem | 19 ++++++++++++ tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 2 ++ 12 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted1.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted2.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted3.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted4.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted5.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted6.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted7.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted8.pem create mode 100644 tests/auto/qsslcertificate/more-certificates/blacklisted9.pem diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 3053351..1bcc3c9 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -219,17 +219,19 @@ bool QSslCertificate::isNull() const Returns true if this certificate is valid; otherwise returns false. - Note: Currently, this function only checks that the current + Note: Currently, this function checks that the current data-time is within the date-time range during which the - certificate is considered valid. No other checks are - currently performed. + certificate is considered valid, and checks that the + certificate is not in a blacklist of fraudulent certificates. \sa isNull() */ bool QSslCertificate::isValid() const { const QDateTime currentTime = QDateTime::currentDateTime(); - return currentTime >= d->notValidBefore && currentTime <= d->notValidAfter; + return currentTime >= d->notValidBefore && + currentTime <= d->notValidAfter && + ! QSslCertificatePrivate::isBlacklisted(*this); } /*! @@ -798,6 +800,30 @@ QList<QSslCertificate> QSslCertificatePrivate::certificatesFromDer(const QByteAr return certificates; } +// These certificates are known to be fraudulent and were created during the comodo +// compromise. See http://www.comodo.com/Comodo-Fraud-Incident-2011-03-23.html +static const char *certificate_blacklist[] = { + "04:7e:cb:e9:fc:a5:5f:7b:d0:9e:ae:36:e1:0c:ae:1e", + "f5:c8:6a:f3:61:62:f1:3a:64:f5:4f:6d:c9:58:7c:06", + "d7:55:8f:da:f5:f1:10:5b:b2:13:28:2b:70:77:29:a3", + "39:2a:43:4f:0e:07:df:1f:8a:a3:05:de:34:e0:c2:29", + "3e:75:ce:d4:6b:69:30:21:21:88:30:ae:86:a8:2a:71", + "e9:02:8b:95:78:e4:15:dc:1a:71:0a:2b:88:15:44:47", + "92:39:d5:34:8f:40:d1:69:5a:74:54:70:e1:f2:3f:43", + "b0:b7:13:3e:d0:96:f9:b5:6f:ae:91:c8:74:bd:3a:c0", + "d8:f3:5f:4e:b7:87:2b:2d:ab:06:92:e3:15:38:2f:b0", + 0 +}; + +bool QSslCertificatePrivate::isBlacklisted(const QSslCertificate &certificate) +{ + for (int a = 0; certificate_blacklist[a] != 0; a++) { + if (certificate.serialNumber() == certificate_blacklist[a]) + return true; + } + return false; +} + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const QSslCertificate &certificate) { diff --git a/src/network/ssl/qsslcertificate_p.h b/src/network/ssl/qsslcertificate_p.h index 1f99b09..4dd0e75 100644 --- a/src/network/ssl/qsslcertificate_p.h +++ b/src/network/ssl/qsslcertificate_p.h @@ -96,6 +96,7 @@ public: static QSslCertificate QSslCertificate_from_X509(X509 *x509); static QList<QSslCertificate> certificatesFromPem(const QByteArray &pem, int count = -1); static QList<QSslCertificate> certificatesFromDer(const QByteArray &der, int count = -1); + static bool isBlacklisted(const QSslCertificate &certificate); friend class QSslSocketBackendPrivate; diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem new file mode 100644 index 0000000..3945aea --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted1.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAnigAwIBAgIQBH7L6fylX3vQnq424QyuHjANBgkqhkiG9w0BAQUFADBf +MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 +ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20w +HhcNMTEwMzI0MTMwNjI1WhcNMTEwNDIzMTMwNjI1WjBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEB +BQADgY0AMIGJAoGBAOeAGV2FbGnT4rLjTvCNEEDjj0/iIUATa6RT8WKF2PVaOzbE +oceiODx6hTStvBnCgs+h/d3eVKgp+uAyBde5sW/HlOwHrNgKF3ZDvxegzIOEHaVI +ndNtBpFS3UyOEkO0NxfioBatNRYpeTRU/DVmazu3yvzgrV1V2mDsrNngVWxJAgMB +AAGjgcswgcgwHQYDVR0OBBYEFHcF1eqRpm7B78aY8ZjseN6zSYbvMIGYBgNVHSME +gZAwgY2AFHcF1eqRpm7B78aY8ZjseN6zSYbvoWOkYTBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9tYWlsLmdvb2dsZS5jb22CEAR+y+n8pV970J6uNuEM +rh4wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBEb1iF+EbhAJli5Sj2 ++iEdJ5xMP8R6FtgqAYknqXD8+tyEyXxJXdN186qdAWuTD9N22AUqi61BPWxUkufW +xH8FYMEHdFCkitvYE0321+GT5pJz6ON/d5Co+wusumt7T5oSjzj8Ax9V+nmo3Nkb +dSANM4/Lnc6moijcpJZq+GC1ng== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem new file mode 100644 index 0000000..4b8d059 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted2.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRAPXIavNhYvE6ZPVPbclYfAYwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOd3d3Lmdvb2dsZS5jb20w +HhcNMTEwMzI0MTMwNzExWhcNMTEwNDIzMTMwNzExWjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw53d3cuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEAy1fNDFl65Njfcd1EUJeaxvyiKln+JKlqUmk1x4mrE1BQoa0C +QZaiXAF21rDhivWejZWBiEQ4IWbg3b12ANY74G1KqAfLC4BNKS9UP94hy18vezRA +pFc+m/HAClwc8AdACpl8eZpQW8cMgdvnMBMZTrQkgV0JYykX+uDD9Tb+QNUCAwEA +AaOByzCByDAdBgNVHQ4EFgQUSelG6IVRj2ZQbp049zkQ0X/Po9wwgZgGA1UdIwSB +kDCBjYAUSelG6IVRj2ZQbp049zkQ0X/Po9yhYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDnd3dy5nb29nbGUuY29tghEA9chq82Fi8Tpk9U9tyVh8 +BjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBALQyDC/AMQMNj2fa6E8L +umILCklWJwG1K1p/1bUAgm0CB8zm94n1xrh/ZK4+HS+k2a9OQmvLRbFyJn8Wua8p +3UU0267UNkCanA1FKHuO3Mo18wLvjMLWjjCQ4g1C9IvJx6P+8EFDQFG+MJBV/w2k +gJXXVl3q1T1dvahIgfav9QBL +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem new file mode 100644 index 0000000..e47ece6 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted3.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDETCCAnqgAwIBAgIRANdVj9r18RBbshMoK3B3KaMwDQYJKoZIhvcNAQEFBQAw +XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29t +MB4XDTExMDMyNDEzMDg0MloXDTExMDQyMzEzMDg0MlowXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQCosFLKRvGtxjvdAjWdEAHYycFTa4VtdpXmCNhNHf2xbeLn +xzde10KjEe44pQxNI+UUD1rJkyuH6wUfloyefn0D2Mu+MvusmvOEzFosa4EDbK9s +BAAlsSiyJgrp/GgbEPq/XOl4XJRBIVP1WC6LllduNbskFCipDqS+HQwifXmmwQID +AQABo4HMMIHJMB0GA1UdDgQWBBSEgWnsoYtd5GEx/MGJvKxuIuROJzCBmQYDVR0j +BIGRMIGOgBSEgWnsoYtd5GEx/MGJvKxuIuROJ6FjpGEwXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4ueWFob28uY29tghEA11WP2vXxEFuyEygr +cHcpozAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAKNpIrzTOxIykKZt +EE6HU2nW1lrWUkIMjwjL8ntw7QI4JLMDN1ADVIxWaGTeQ+U/eXFou6dDNAYVAijK +ONDXgOItxW2YvSw0wOZsZj6INX2x88/0yRH+19TqaL/r+Y1D1h/0zefkHgfXufnY +Ex7BHju/rGBTp6R1mr+Tlh1tewva +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem new file mode 100644 index 0000000..64c7d41 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted4.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAnigAwIBAgIQOSpDTw4H3x+KowXeNODCKTANBgkqhkiG9w0BAQUFADBf +MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 +ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w +HhcNMTEwMzI0MTMwOTE1WhcNMTEwNDIzMTMwOTE1WjBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB +BQADgY0AMIGJAoGBANO2gz9x2H92xz5OvZSEul9gHxqqd+kdjeoS2exyvjC9wzqb +gYXqNmAsbtNp4WmieEQFd0riCAEkIAn8JpHTCsMHN4rHhS+W+4D5a/drI2jfnZEF +orNYJG1PHSQV/rvh6d7wkVdT+0SYOjrFTAA2biGWaK3W9ztf2yX577w+uQtBAgMB +AAGjgcswgcgwHQYDVR0OBBYEFJjDp8Prs7oReRmskIeFixp0vDkGMIGYBgNVHSME +gZAwgY2AFJjDp8Prs7oReRmskIeFixp0vDkGoWOkYTBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CEDkqQ08OB98fiqMF3jTg +wikwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAZyo0Q3leeM1+lxeCd +Wp0ZYHMSW11ANc6nuMWOmJC+nIQGlyGiP3IqeUvIfekwboV638bahVPwcl2HYWsS +/l01Bgyd25Zn6VTQBfMK01dILyxscjVwdHuojzYBN05sl+qkVoqQr5EroQQbgDc9 +6I88p6Kjajv3IusCwfK6wlqISw== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem new file mode 100644 index 0000000..c7ddbf2 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted5.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDzCCAnigAwIBAgIQPnXO1GtpMCEhiDCuhqgqcTANBgkqhkiG9w0BAQUFADBf +MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 +ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20w +HhcNMTEwMzI0MTMwOTQ4WhcNMTEwNDIzMTMwOTQ4WjBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb20wgZ8wDQYJKoZIhvcNAQEB +BQADgY0AMIGJAoGBALkiHG9TgTw/00CMW8D23NBDAa3331AL5kTkAaXbAWg2R/1o +yKQfXq3hgHbyWGPccUT+tU6FmaBf3bIndLK7iGx81RGzGgXeoQ5mpgnJ50iCeW73 +G99VlVwutPia7d9qqui84YdcG9t+P2Fuxv+xRqAB6lKOaa4qTPIbH50PgwOvAgMB +AAGjgcswgcgwHQYDVR0OBBYEFBWJrs8bnZ5fikfaLbTxK0ssj69MMIGYBgNVHSME +gZAwgY2AFBWJrs8bnZ5fikfaLbTxK0ssj69MoWOkYTBfMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRgwFgYDVQQDEw9sb2dpbi55YWhvby5jb22CED51ztRraTAhIYgwroao +KnEwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCIfqqs1a7RzdmV8U00 +v/xAsxscKvQvmu6BK+HwvY5iL2pSwXTYgRLJLoj5QGOd3mmgOFsyW3BPSCP1+fVE +M1ROhU2u8wHub+hGGds18Fx6F4yZjdh8pNUoOUR9A0Ym+VDJr2p50oUNTTy0RbH8 +9ns/gbemx84cjF9DD2G5stQhYg== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem new file mode 100644 index 0000000..bc2be2a --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted6.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDETCCAnqgAwIBAgIRAOkCi5V45BXcGnEKK4gVREcwDQYJKoZIhvcNAQEFBQAw +XzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29t +MB4XDTExMDMyNDEzMTAxNloXDTExMDQyMzEzMTAxNlowXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tMIGfMA0GCSqGSIb3DQEB +AQUAA4GNADCBiQKBgQDFq06qqRl86pP7GRX3m7FMMSaSU6zlNGAo+WPoRfYAzB6x +5KpvlfxMCo3T/nWtInX3Bw9TBWCZSweQ2GEjggO0irjw5UX3MiToLxK+rwzWztm9 +H3LBxTWR0cOOa78kRFvNQ1onvNHbs8fJzXjG7b2IJDOIwG1HAT1LK80oPXZc1wID +AQABo4HMMIHJMB0GA1UdDgQWBBTiGNxw0ImW/wfW0mD3eA65PY5CAzCBmQYDVR0j +BIGRMIGOgBTiGNxw0ImW/wfW0mD3eA65PY5CA6FjpGEwXzELMAkGA1UEBhMCQVUx +EzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMg +UHR5IEx0ZDEYMBYGA1UEAxMPbG9naW4uc2t5cGUuY29tghEA6QKLlXjkFdwacQor +iBVERzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAHdb1QY/oxuro/4x +GX9jbm930ysoeXkWZSKVtVxoxrPIferu8jVpb1SLRjGcMnmjJoNWNFpvnbZgoYei +f3wdSWun7ndyQBh61k8eM7UABDOUXUHOsHuHj7s1koMKtet4gykmMfd6VxBkwBvN +ZXOll4X+TKe8nrxbnGUByIwQaRM+ +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem new file mode 100644 index 0000000..19d4353 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted7.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDGjCCAoOgAwIBAgIRAJI51TSPQNFpWnRUcOHyP0MwDQYJKoZIhvcNAQEFBQAw +YjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEu +b3JnMB4XDTExMDMyNDEzMTA0NFoXDTExMDQyMzEzMTA0NFowYjELMAkGA1UEBhMC +QVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdp +dHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnMIGfMA0GCSqG +SIb3DQEBAQUAA4GNADCBiQKBgQC1lsoAcZTwF8Pf0E9do5avLdobB/O7EhhrCMs2 +/EMO07aIlrLwl3UP/Fmu/cAkKuX8Mx+Eif9x+XT3ZqGKGYKiqPTJcNfeZvgwbn0j +wXDtEo4DuURrwtBU9okS+v4dF6F4RtHQKAGcsXoOjhR7ah71kve+PG2GG0sJ167V +klK1xwIDAQABo4HPMIHMMB0GA1UdDgQWBBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxjCB +nAYDVR0jBIGUMIGRgBRgGDJ4Qp0WFyLIzm4Nz5wgqDSSxqFmpGQwYjELMAkGA1UE +BhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdp +ZGdpdHMgUHR5IEx0ZDEbMBkGA1UEAxMSYWRkb25zLm1vemlsbGEub3JnghEAkjnV +NI9A0WladFRw4fI/QzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACeE +DHMQ+LWEuoa/6z2EgrgM1k9rvBbUtCR+rjTuyzVW4OLXdpiVwZPOAiKphpq7q8Sb +TQ3zwsCoPLLJk5VolwcPfcD8Y2/tYK3NCYl+HzGxxnzPDFVaZM5Jh8RI861Hc00D +hVoQaptPK/V/lr0KEevqjhusAdFZbwlWA923zASa +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem new file mode 100644 index 0000000..aedf3f7 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted8.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRALC3Ez7Qlvm1b66RyHS9OsAwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMObG9naW4ubGl2ZS5jb20w +HhcNMTEwMzI0MTMxMTA2WhcNMTEwNDIzMTMxMTA2WjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw5sb2dpbi5saXZlLmNvbTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEA3OVNj9ijzMewvDeZYzgCWoKtyjclyIHxrQfHZpcexaKbxUap +1MtF6L0ayjtRWpiBYuPteUSy/Ja4Oh6zZz8K6z5rVgXhmy3xPIYuOoWaTKEOhb0Z +oHTBtGh8aWWai1XWw37HIm2FP8cmfgdH4lZwVvpTZIUxYidsyqyjB9IrhiMCAwEA +AaOByzCByDAdBgNVHQ4EFgQU4CcQcIvEhJC0tqHlNFMkv6MlDN4wgZgGA1UdIwSB +kDCBjYAU4CcQcIvEhJC0tqHlNFMkv6MlDN6hYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDmxvZ2luLmxpdmUuY29tghEAsLcTPtCW+bVvrpHIdL06 +wDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAMNzIStXDNSNQ8ayxrcj +4RrUMsHWUG/6XPrgfYqCP5TfPGAa5qBfNb9LfUbiS4b0flJVN1RlHVwwRo0yf9v4 +LGg0dSuPQAOWlLeUR1GminO1jHZw7E4dYfR7QEmiiOgaQU+CbxLsf5vCaKInN9Gu +jv/5xytVCbMoLoZ4EBVb0tka +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem new file mode 100644 index 0000000..d179b29 --- /dev/null +++ b/tests/auto/qsslcertificate/more-certificates/blacklisted9.pem @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDDjCCAnegAwIBAgIRANjzX063hystqwaS4xU4L7AwDQYJKoZIhvcNAQEFBQAw +XjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGElu +dGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEXMBUGA1UEAxMOZ2xvYmFsIHRydXN0ZWUw +HhcNMTEwMzI0MTMxMTM3WhcNMTEwNDIzMTMxMTM3WjBeMQswCQYDVQQGEwJBVTET +MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ +dHkgTHRkMRcwFQYDVQQDEw5nbG9iYWwgdHJ1c3RlZTCBnzANBgkqhkiG9w0BAQEF +AAOBjQAwgYkCgYEArHCVym7AEZDBhDkrUSG3Q94a+caNcCk5fE6ltZHiZHv096xr +cixHYvSGvms780bkI+oot2xI/e9awwkV+7VjWNvr0HrajzBWeimwk+myjP+3ddMY +Kmr0eI6bmvmPHtOFJE5Ar8/62FwD0wlLogRIx56JtXcCpkiUQktJVPz2gtMCAwEA +AaOByzCByDAdBgNVHQ4EFgQUUJwC/qSGBmcB+DVrd43ovRLdLmQwgZgGA1UdIwSB +kDCBjYAUUJwC/qSGBmcB+DVrd43ovRLdLmShYqRgMF4xCzAJBgNVBAYTAkFVMRMw +EQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0 +eSBMdGQxFzAVBgNVBAMTDmdsb2JhbCB0cnVzdGVlghEA2PNfTreHKy2rBpLjFTgv +sDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBACAYxI+r3+JNelL6SBB0 +Pda3LkbCm+schP64NBYDdGl2Kus2b2QZ83T7xENBFEhyNoXvc6pRI4/Oh6JDxmG1 +7WmqOVStS/4JeAu6ygiyI1ImRKq2/MvJx/kaKh6IiXanB5nW1U+fhDV6kMOEfpwV +i6FBibpHboPQoqzPPRe7qHSL +-----END CERTIFICATE----- diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index a8c5a4d..aadfb5e 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -111,6 +111,8 @@ private slots: void nulInSan(); void largeSerialNumber(); void largeExpirationDate(); + void blacklistedCertificates(); + // ### add tests for certificate bundles (multiple certificates concatenated into a single // structure); both PEM and DER formatted #endif -- cgit v0.12 From abc6e08c72427feea29c9826f72990f2c4e2565f Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen <miikka.heikkinen@digia.com> Date: Mon, 28 Mar 2011 15:55:28 +0300 Subject: Show softkeys when opening a dialog that has a fullscreen parent. Now shows the CBA for each window that defines softkeys even if topmost parent is fullscreen. Task-number: QTBUG-4953 Reviewed-by: Sami Merila (cherry picked from commit 5a6acc0ba1ed3b056f4c7a9c37481f4cb347a352) --- src/gui/kernel/qapplication_s60.cpp | 39 ++++++++++++++++++++++++-------- src/gui/kernel/qwidget_s60.cpp | 44 ++++++++++++++++++++++++++++--------- 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index dd403d8..57dc218 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1243,15 +1243,36 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) qwidget->d_func()->setWindowIcon_sys(true); qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); #ifdef Q_WS_S60 - // If widget is fullscreen/minimized, hide status pane and button container otherwise show them. - QWidget *const window = qwidget->window(); - if (!window->parentWidget()) { // Only top level native windows have control over cba/status pane - const bool decorationsVisible = !(window->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); - const bool statusPaneVisibility = decorationsVisible; - const bool isFullscreen = window->windowState() & Qt::WindowFullScreen; - const bool cbaVisibilityHint = window->windowFlags() & Qt::WindowSoftkeysVisibleHint; - const bool buttonGroupVisibility = (decorationsVisible || (isFullscreen && cbaVisibilityHint)); - S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); + if (qwidget->isWindow()) { + QWidget *const window = qwidget->window(); + QWidget *parentWindow = window->parentWidget(); + if (parentWindow) { + while (parentWindow->parentWidget()) + parentWindow = parentWindow->parentWidget(); + } else { + parentWindow = window; + } + + const bool parentDecorationsVisible = !(parentWindow->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); + const bool parentIsFullscreen = parentWindow->windowState() & Qt::WindowFullScreen; + const bool parentCbaVisibilityHint = parentWindow->windowFlags() & Qt::WindowSoftkeysVisibleHint; + bool buttonGroupVisibility = (parentDecorationsVisible || (parentIsFullscreen && parentCbaVisibilityHint)); + + // For non-toplevel normal and maximized windows, show cba if window has softkey + // actions even if topmost parent is not showing cba. Do the same for fullscreen + // windows that request it. + if (!buttonGroupVisibility + && window->parentWidget() + && !(window->windowState() & Qt::WindowMinimized) + && ((window->windowFlags() & Qt::WindowSoftkeysVisibleHint) || !(window->windowState() & Qt::WindowFullScreen))) { + for (int i = 0; i < window->actions().size(); ++i) { + if (window->actions().at(i)->softKeyRole() != QAction::NoSoftKey) { + buttonGroupVisibility = true; + break; + } + } + } + S60->setStatusPaneAndButtonGroupVisibility(parentDecorationsVisible, buttonGroupVisibility); } #endif } else if (QApplication::activeWindow() == qwidget->window()) { diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 1e0f1c1..d2bd614 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1184,17 +1184,41 @@ void QWidget::setWindowState(Qt::WindowStates newstate) } #ifdef Q_WS_S60 - bool decorationsVisible(false); - if (!parentWidget()) { // Only top level native windows have control over cba/status pane - // Hide window decoration when switching to fullscreen / minimized otherwise show decoration. - // The window decoration visibility has to be changed before doing actual window state - // change since in that order the availableGeometry will return directly the right size and - // we will avoid unnecessary redraws - decorationsVisible = !(newstate & (Qt::WindowFullScreen | Qt::WindowMinimized)); - const bool statusPaneVisibility = decorationsVisible; - const bool buttonGroupVisibility = (decorationsVisible || (isFullscreen && cbaRequested)); - S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); + // Hide window decoration when switching to fullscreen / minimized otherwise show decoration. + // The window decoration visibility has to be changed before doing actual window state + // change since in that order the availableGeometry will return directly the right size and + // we will avoid unnecessary redraws + Qt::WindowStates comparisonState = newstate; + QWidget *parentWindow = parentWidget(); + if (parentWindow) { + while (parentWindow->parentWidget()) + parentWindow = parentWindow->parentWidget(); + comparisonState = parentWindow->windowState(); + } else { + parentWindow = this; + } + + const bool decorationsVisible = !(comparisonState & (Qt::WindowFullScreen | Qt::WindowMinimized)); + const bool parentIsFullscreen = comparisonState & Qt::WindowFullScreen; + const bool parentCbaVisibilityHint = parentWindow->windowFlags() & Qt::WindowSoftkeysVisibleHint; + bool buttonGroupVisibility = (decorationsVisible || (parentIsFullscreen && parentCbaVisibilityHint)); + + // For non-toplevel normal and maximized windows, show cba if window has softkey + // actions even if topmost parent is not showing cba. Do the same for fullscreen + // windows that request it. + if (!buttonGroupVisibility + && parentWidget() + && !(newstate & Qt::WindowMinimized) + && ((windowFlags() & Qt::WindowSoftkeysVisibleHint) || !(newstate & Qt::WindowFullScreen))) { + for (int i = 0; i < actions().size(); ++i) { + if (actions().at(i)->softKeyRole() != QAction::NoSoftKey) { + buttonGroupVisibility = true; + break; + } + } } + S60->setStatusPaneAndButtonGroupVisibility(decorationsVisible, buttonGroupVisibility); + #endif // Q_WS_S60 // Ensure the initial size is valid, since we store it as normalGeometry below. -- cgit v0.12 From a5f89cb5e52554b59b308ca0ceed76873f833c46 Mon Sep 17 00:00:00 2001 From: Timo Turunen <timo.p.turunen@nokia.com> Date: Mon, 28 Mar 2011 21:18:40 +0300 Subject: Update changes for 4.7.3 Reviewed-by: Trust Me (cherry picked from commit 45c4c792c48605de4cbc28637a39bce5a65b1613) --- dist/changes-4.7.3 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dist/changes-4.7.3 b/dist/changes-4.7.3 index fa8a71e..1ff23c6 100644 --- a/dist/changes-4.7.3 +++ b/dist/changes-4.7.3 @@ -16,6 +16,16 @@ Qt Bug Tracker: http://bugreports.qt.nokia.com Merge Request: http://qt.gitorious.org **************************************************************************** +* Library * +**************************************************************************** + +QtNetwork +--------- + +- SSL +* [QTBUG-18338] blacklist fraudulent SSL certificates + +**************************************************************************** * Platform Specific Changes * **************************************************************************** @@ -38,6 +48,8 @@ QtMobility QtBearer depending applications * [QTBUG-17786] BC between Qt 4.7.3 and 4.6.3 QTreeView::indexRowSizeHint doesn't return correct value on Symbian for row when QPushButton widget is inserted in the treeview +* [QTBUG-4953] QMessageBox can not be closed/dismissed on touch phones if any +widget is fullscreen - Painting * [QTBUG-17907] tst_QGraphicsTransform::rotation3d test case from -- cgit v0.12 From f55d5a5a3c2842d4e5f66cc86219cea56f2a4612 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 6 Apr 2011 17:18:09 +1000 Subject: Fix missing equality and inequality operator docs for QPointer. Task-number: QTBUG-18565 Reviewed-by: Rohan McGovern --- src/corelib/kernel/qpointer.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp index 7d63088..73f695b 100644 --- a/src/corelib/kernel/qpointer.cpp +++ b/src/corelib/kernel/qpointer.cpp @@ -183,6 +183,7 @@ /*! \fn bool operator==(const T *o, const QPointer<T> &p) + \relates QPointer Equality operator. Returns true if \a o and the guarded pointer \a p are pointing to the same object, otherwise @@ -191,6 +192,7 @@ */ /*! \fn bool operator==(const QPointer<T> &p, const T *o) + \relates QPointer Equality operator. Returns true if \a o and the guarded pointer \a p are pointing to the same object, otherwise @@ -199,6 +201,7 @@ */ /*! \fn bool operator==(T *o, const QPointer<T> &p) + \relates QPointer Equality operator. Returns true if \a o and the guarded pointer \a p are pointing to the same object, otherwise @@ -207,6 +210,7 @@ */ /*! \fn bool operator==(const QPointer<T> &p, T *o) + \relates QPointer Equality operator. Returns true if \a o and the guarded pointer \a p are pointing to the same object, otherwise @@ -215,6 +219,7 @@ */ /*! \fn bool operator==(const QPointer<T> &p1, const QPointer<T> &p2) + \relates QPointer Equality operator. Returns true if the guarded pointers \a p1 and \a p2 are pointing to the same object, otherwise @@ -225,6 +230,7 @@ /*! \fn bool operator!=(const T *o, const QPointer<T> &p) + \relates QPointer Inequality operator. Returns true if \a o and the guarded pointer \a p are not pointing to the same object, otherwise @@ -232,6 +238,7 @@ */ /*! \fn bool operator!=(const QPointer<T> &p, const T *o) + \relates QPointer Inequality operator. Returns true if \a o and the guarded pointer \a p are not pointing to the same object, otherwise @@ -239,6 +246,7 @@ */ /*! \fn bool operator!=(T *o, const QPointer<T> &p) + \relates QPointer Inequality operator. Returns true if \a o and the guarded pointer \a p are not pointing to the same object, otherwise @@ -246,6 +254,7 @@ */ /*! \fn bool operator!=(const QPointer<T> &p, T *o) + \relates QPointer Inequality operator. Returns true if \a o and the guarded pointer \a p are not pointing to the same object, otherwise @@ -253,6 +262,7 @@ */ /*! \fn bool operator!=(const QPointer<T> &p1, const QPointer<T> &p2) + \relates QPointer Inequality operator. Returns true if the guarded pointers \a p1 and \a p2 are not pointing to the same object, otherwise -- cgit v0.12 From 78722d6b6e9ba0f6de1a4eba232aad2f96a339f2 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 11 Apr 2011 12:43:28 +1000 Subject: Remove autotest code related to old Qt versions Reviewed-by: Rohan McGovern --- tests/auto/qbuttongroup/tst_qbuttongroup.cpp | 10 +--------- tests/auto/qeasingcurve/tst_qeasingcurve.cpp | 6 ------ tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 4 +--- tests/auto/selftests/tst_selftests.cpp | 14 -------------- tests/auto/symbols/tst_symbols.cpp | 4 ---- 5 files changed, 2 insertions(+), 36 deletions(-) diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp index a809101..34be20c 100644 --- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp @@ -98,10 +98,7 @@ private slots: void task106609(); - // fixed for Qt 4.6.0 -#if QT_VERSION >= 0x040600 void autoIncrementId(); -#endif void task209485_removeFromGroupInEventHandler_data(); void task209485_removeFromGroupInEventHandler(); @@ -338,10 +335,7 @@ void tst_QButtonGroup::testSignals() QCOMPARE(clickedSpy.count(), 1); QCOMPARE(clickedIdSpy.count(), 1); - int expectedId = -1; -#if QT_VERSION >= 0x040600 - expectedId = -2; -#endif + int expectedId = -2; QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId); QCOMPARE(pressedSpy.count(), 1); @@ -500,7 +494,6 @@ void tst_QButtonGroup::task209485_removeFromGroupInEventHandler() QCOMPARE(spy1.count() + spy2.count(), signalCount); } -#if QT_VERSION >= 0x040600 void tst_QButtonGroup::autoIncrementId() { QDialog dlg(0); @@ -529,7 +522,6 @@ void tst_QButtonGroup::autoIncrementId() dlg.show(); } -#endif QTEST_MAIN(tst_QButtonGroup) #include "tst_qbuttongroup.moc" diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp index 327b6f3..f10d35b 100644 --- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp @@ -42,10 +42,6 @@ #include <QtTest/QtTest> -#if QT_VERSION < 0x040200 -QTEST_NOOP_MAIN -#else - #include <qeasingcurve.h> //TESTED_CLASS= @@ -578,5 +574,3 @@ void tst_QEasingCurve::metaTypes() QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" - -#endif //QT_VERSION diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index e7c8175..bb04621 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -698,7 +698,7 @@ void tst_QSharedPointer::noSharedPointerFromWeakQObject() QSharedPointer<QObject> strong = weak.toStrongRef(); QVERIFY(strong.isNull()); - // is something went wrong, we'll probably crash here + // if something went wrong, we'll probably crash here } void tst_QSharedPointer::weakQObjectFromSharedPointer() @@ -1747,7 +1747,6 @@ void tst_QSharedPointer::invalidConstructs_data() "QSharedPointer<Data> b;\n" "if (a + b) return;"; -#if QT_VERSION >= 0x040600 // two objects with the same pointer QTest::newRow("same-pointer") << &QTest::QExternalTest::tryRunFail @@ -1761,7 +1760,6 @@ void tst_QSharedPointer::invalidConstructs_data() << "Data *aData = new Data;\n" "QSharedPointer<Data> ptr1 = QSharedPointer<Data>(aData);" "ptr1 = QSharedPointer<Data>(aData);"; -#endif // any type of cast for unrelated types: // (we have no reinterpret_cast) diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 0d27d38..1c01c5f 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -515,8 +515,6 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) } bool ok; -#if QT_VERSION >= 0x040700 - // Qt 4.7 uses floating point double total = sTotal.toDouble(&ok); if (!ok) { if (error) *error = sTotal + " is not a valid number"; @@ -527,18 +525,6 @@ BenchmarkResult BenchmarkResult::parse(QString const& line, QString* error) if (error) *error = sIterations + " is not a valid number"; return out; } -#else - qlonglong total = sTotal.toLongLong(&ok); - if (!ok) { - if (error) *error = sTotal + " is not a valid integer"; - return out; - } - qlonglong iterations = sIterations.toLongLong(&ok); - if (!ok) { - if (error) *error = sIterations + " is not a valid integer"; - return out; - } -#endif out.unit = unit; out.total = total; diff --git a/tests/auto/symbols/tst_symbols.cpp b/tests/auto/symbols/tst_symbols.cpp index db1cbea..6f21c71 100644 --- a/tests/auto/symbols/tst_symbols.cpp +++ b/tests/auto/symbols/tst_symbols.cpp @@ -169,11 +169,7 @@ void tst_Symbols::globalObjects() } if (isFailed) { -#if QT_VERSION >= 0x040600 QVERIFY2(!isFailed, "Libraries contain static global objects. See Debug output above."); -#else - QSKIP("Libraries contains static global objects. See Debug output above. [These errors cannot be fixed in 4.5 in time]", SkipSingle); -#endif } } -- cgit v0.12 From 3475168550c1a804f04f2a4edfeb30c04cd36551 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 12 Apr 2011 14:53:36 +1000 Subject: Reduce usage of Q_ASSERT in autotests. Using Q_ASSERT does nothing in release-mode builds, and in debug builds it causes tests to terminate prematurely. It is much better to use QVERIFY or QCOMPARE. Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../qdeclarativedebug/tst_qdeclarativedebug.cpp | 40 +++--- .../tst_qdeclarativedebugclient.cpp | 2 +- .../tst_qdeclarativedebugservice.cpp | 2 +- .../tst_qdeclarativefontloader.cpp | 10 +- tests/auto/modeltest/modeltest.cpp | 139 ++++++++++----------- tests/auto/q3listview/tst_q3listview.cpp | 2 +- tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp | 10 +- tests/auto/qbuffer/tst_qbuffer.cpp | 3 +- tests/auto/qchar/tst_qchar.cpp | 4 +- tests/auto/qcompleter/tst_qcompleter.cpp | 2 - tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp | 2 +- tests/auto/qdbusthreading/tst_qdbusthreading.cpp | 2 +- tests/auto/qdirmodel/tst_qdirmodel.cpp | 6 +- tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 2 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 2 +- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 2 +- tests/auto/qinputdialog/tst_qinputdialog.cpp | 18 +-- tests/auto/qlocale/tst_qlocale.cpp | 4 +- tests/auto/qmessagebox/tst_qmessagebox.cpp | 49 ++++---- tests/auto/qpixmap/tst_qpixmap.cpp | 4 +- tests/auto/qprocess/tst_qprocess.cpp | 2 +- .../tst_qscriptvalueiterator.cpp | 4 +- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 22 ++-- tests/auto/qsplitter/tst_qsplitter.cpp | 6 +- tests/auto/qsqldatabase/tst_qsqldatabase.cpp | 4 +- tests/auto/qstring/tst_qstring.cpp | 30 ++--- .../tst_qtextboundaryfinder.cpp | 18 +-- tests/auto/qtextcodec/tst_qtextcodec.cpp | 8 +- tests/auto/qwidget/tst_qwidget.cpp | 3 +- tests/auto/xmlpatternsxqts/tst_suitetest.cpp | 2 +- 30 files changed, 197 insertions(+), 207 deletions(-) diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index 6bcb4eb..7237553 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -81,7 +81,7 @@ private: void recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const; void recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const; void compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const; - + QDeclarativeDebugConnection *m_conn; QDeclarativeEngineDebug *m_dbg; QDeclarativeEngine *m_engine; @@ -123,7 +123,7 @@ QDeclarativeDebugObjectReference tst_QDeclarativeDebug::findRootObject(int conte { QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); waitForQuery(q_engines); - + if (q_engines->engines().count() == 0) return QDeclarativeDebugObjectReference(); QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); @@ -353,7 +353,7 @@ void tst_QDeclarativeDebug::initTestCase() for (int i=0; i<qml.count(); i++) { QDeclarativeComponent component(m_engine); component.setData(qml[i], QUrl::fromLocalFile("")); - Q_ASSERT(component.isReady()); // fails if bad syntax + QVERIFY(component.isReady()); // fails if bad syntax m_components << qobject_cast<QDeclarativeItem*>(component.create()); } m_rootItem = qobject_cast<QDeclarativeItem*>(m_components.first()); @@ -367,7 +367,7 @@ void tst_QDeclarativeDebug::initTestCase() QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established"); bool ok = m_conn->waitForConnected(); - Q_ASSERT(ok); + QVERIFY(ok); QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); m_dbg = new QDeclarativeEngineDebug(m_conn, this); QTRY_VERIFY(m_dbg->status() == QDeclarativeEngineDebug::Enabled); @@ -424,7 +424,7 @@ void tst_QDeclarativeDebug::watch_property() QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width"); QDeclarativeDebugPropertyWatch *watch; - + QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0); watch = unconnected->addWatch(prop, this); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead); @@ -435,7 +435,7 @@ void tst_QDeclarativeDebug::watch_property() QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)))); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive); delete watch; - + watch = m_dbg->addWatch(prop, this); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting); QCOMPARE(watch->objectDebugId(), obj.debugId()); @@ -467,12 +467,12 @@ void tst_QDeclarativeDebug::watch_object() { QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); waitForQuery(q_engines); - - Q_ASSERT(q_engines->engines().count() > 0); + + QVERIFY(q_engines->engines().count() > 0); QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); - Q_ASSERT(q_context->rootContext().objects().count() > 0); + QVERIFY(q_context->rootContext().objects().count() > 0); QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this); waitForQuery(q_obj); @@ -489,7 +489,7 @@ void tst_QDeclarativeDebug::watch_object() QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead); delete watch; delete unconnected; - + watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this); QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)))); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive); @@ -543,7 +543,7 @@ void tst_QDeclarativeDebug::watch_expression() QFETCH(int, incrementCount); int origWidth = m_rootItem->property("width").toInt(); - + QDeclarativeDebugObjectReference obj = findRootObject(); QDeclarativeDebugObjectExpressionWatch *watch; @@ -553,12 +553,12 @@ void tst_QDeclarativeDebug::watch_expression() QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead); delete watch; delete unconnected; - + watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), expr, this); QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)))); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive); delete watch; - + watch = m_dbg->addWatch(obj, expr, this); QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting); QCOMPARE(watch->objectDebugId(), obj.debugId()); @@ -588,7 +588,7 @@ void tst_QDeclarativeDebug::watch_expression() delete watch; // restore original value and verify spy doesn't get a signal since watch has been removed - m_rootItem->setProperty("width", origWidth); + m_rootItem->setProperty("width", origWidth); QTest::qWait(100); QCOMPARE(spy.count(), expectedSpyCount); @@ -659,7 +659,7 @@ void tst_QDeclarativeDebug::queryRootContexts() int engineId = q_engines->engines()[0].debugId(); QDeclarativeDebugRootContextQuery *q_context; - + QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0); q_context = unconnected->queryRootContexts(engineId, this); QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error); @@ -698,7 +698,7 @@ void tst_QDeclarativeDebug::queryObject() QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); waitForQuery(q_engines); - + QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0]; @@ -772,7 +772,7 @@ void tst_QDeclarativeDebug::queryExpressionResult() QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); waitForQuery(q_engines); // check immediate deletion is ok - + QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); waitForQuery(q_context); int objectId = q_context->rootContext().objects()[0].debugId(); @@ -784,7 +784,7 @@ void tst_QDeclarativeDebug::queryExpressionResult() QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error); delete q_expr; delete unconnected; - + q_expr = m_dbg->queryExpressionResult(objectId, expr, this); delete q_expr; @@ -923,7 +923,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference() QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this); waitForQuery(query); QDeclarativeDebugObjectReference obj = query->object(); - delete query; + delete query; QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale"); QVERIFY(ref.objectDebugId() > 0); @@ -932,7 +932,7 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference() QVERIFY(!ref.valueTypeName().isEmpty()); QVERIFY(!ref.binding().isEmpty()); QVERIFY(ref.hasNotifySignal()); - + QDeclarativeDebugPropertyReference copy(ref); QDeclarativeDebugPropertyReference copyAssign; copyAssign = ref; diff --git a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp index c182893..59214d1 100644 --- a/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp +++ b/tests/auto/declarative/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp @@ -88,7 +88,7 @@ void tst_QDeclarativeDebugClient::initTestCase() QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established"); bool ok = m_conn->waitForConnected(); - Q_ASSERT(ok); + QVERIFY(ok); QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); QTRY_COMPARE(client.status(), QDeclarativeDebugClient::Enabled); diff --git a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp index 0911a83..a61f4a8 100644 --- a/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp +++ b/tests/auto/declarative/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp @@ -87,7 +87,7 @@ void tst_QDeclarativeDebugService::initTestCase() QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established"); bool ok = m_conn->waitForConnected(); - Q_ASSERT(ok); + QVERIFY(ok); QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient()); } diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp index e684bbe..2f0992c 100644 --- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -55,13 +55,13 @@ #endif class tst_qdeclarativefontloader : public QObject - { Q_OBJECT public: tst_qdeclarativefontloader(); private slots: + void init(); void noFont(); void namedFont(); void localFont(); @@ -71,8 +71,6 @@ private slots: void failWebFont(); void changeFont(); -private slots: - private: QDeclarativeEngine engine; TestHTTPServer server; @@ -82,7 +80,11 @@ tst_qdeclarativefontloader::tst_qdeclarativefontloader() : server(SERVER_PORT) { server.serveDirectory(SRCDIR "/data"); - Q_ASSERT(server.isValid()); +} + +void tst_qdeclarativefontloader::init() +{ + QVERIFY(server.isValid()); } void tst_qdeclarativefontloader::noFont() diff --git a/tests/auto/modeltest/modeltest.cpp b/tests/auto/modeltest/modeltest.cpp index 98d707c..5ef27f9 100644 --- a/tests/auto/modeltest/modeltest.cpp +++ b/tests/auto/modeltest/modeltest.cpp @@ -45,8 +45,6 @@ #include "modeltest.h" #include <QtTest/QtTest> -#undef Q_ASSERT -#define Q_ASSERT QVERIFY Q_DECLARE_METATYPE ( QModelIndex ) @@ -118,15 +116,15 @@ void ModelTest::runAllTests() */ void ModelTest::nonDestructiveBasicTest() { - Q_ASSERT ( model->buddy ( QModelIndex() ) == QModelIndex() ); + QVERIFY( model->buddy ( QModelIndex() ) == QModelIndex() ); model->canFetchMore ( QModelIndex() ); - Q_ASSERT ( model->columnCount ( QModelIndex() ) >= 0 ); - Q_ASSERT ( model->data ( QModelIndex() ) == QVariant() ); + QVERIFY( model->columnCount ( QModelIndex() ) >= 0 ); + QVERIFY( model->data ( QModelIndex() ) == QVariant() ); fetchingMore = true; model->fetchMore ( QModelIndex() ); fetchingMore = false; Qt::ItemFlags flags = model->flags ( QModelIndex() ); - Q_ASSERT ( flags == Qt::ItemIsDropEnabled || flags == 0 ); + QVERIFY( flags == Qt::ItemIsDropEnabled || flags == 0 ); model->hasChildren ( QModelIndex() ); model->hasIndex ( 0, 0 ); model->headerData ( 0, Qt::Horizontal ); @@ -135,8 +133,8 @@ void ModelTest::nonDestructiveBasicTest() QVariant cache; model->match ( QModelIndex(), -1, cache ); model->mimeTypes(); - Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() ); - Q_ASSERT ( model->rowCount() >= 0 ); + QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() ); + QVERIFY( model->rowCount() >= 0 ); QVariant variant; model->setData ( QModelIndex(), variant, -1 ); model->setHeaderData ( -1, Qt::Horizontal, QVariant() ); @@ -158,17 +156,17 @@ void ModelTest::rowCount() // check top row QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); int rows = model->rowCount ( topIndex ); - Q_ASSERT ( rows >= 0 ); + QVERIFY( rows >= 0 ); if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( topIndex ) == true ); + QVERIFY( model->hasChildren ( topIndex ) ); QModelIndex secondLevelIndex = model->index ( 0, 0, topIndex ); if ( secondLevelIndex.isValid() ) { // not the top level // check a row count where parent is valid rows = model->rowCount ( secondLevelIndex ); - Q_ASSERT ( rows >= 0 ); + QVERIFY( rows >= 0 ); if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( secondLevelIndex ) == true ); + QVERIFY( model->hasChildren ( secondLevelIndex ) ); } // The models rowCount() is tested more extensively in checkChildren(), @@ -182,12 +180,12 @@ void ModelTest::columnCount() { // check top row QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); - Q_ASSERT ( model->columnCount ( topIndex ) >= 0 ); + QVERIFY( model->columnCount ( topIndex ) >= 0 ); // check a column count where parent is valid QModelIndex childIndex = model->index ( 0, 0, topIndex ); if ( childIndex.isValid() ) - Q_ASSERT ( model->columnCount ( childIndex ) >= 0 ); + QVERIFY( model->columnCount ( childIndex ) >= 0 ); // columnCount() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -200,19 +198,19 @@ void ModelTest::hasIndex() { // qDebug() << "hi"; // Make sure that invalid values returns an invalid index - Q_ASSERT ( model->hasIndex ( -2, -2 ) == false ); - Q_ASSERT ( model->hasIndex ( -2, 0 ) == false ); - Q_ASSERT ( model->hasIndex ( 0, -2 ) == false ); + QVERIFY( !model->hasIndex ( -2, -2 ) ); + QVERIFY( !model->hasIndex ( -2, 0 ) ); + QVERIFY( !model->hasIndex ( 0, -2 ) ); int rows = model->rowCount(); int columns = model->columnCount(); // check out of bounds - Q_ASSERT ( model->hasIndex ( rows, columns ) == false ); - Q_ASSERT ( model->hasIndex ( rows + 1, columns + 1 ) == false ); + QVERIFY( !model->hasIndex ( rows, columns ) ); + QVERIFY( !model->hasIndex ( rows + 1, columns + 1 ) ); if ( rows > 0 ) - Q_ASSERT ( model->hasIndex ( 0, 0 ) == true ); + QVERIFY( model->hasIndex ( 0, 0 ) ); // hasIndex() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -225,9 +223,9 @@ void ModelTest::index() { // qDebug() << "i"; // Make sure that invalid values returns an invalid index - Q_ASSERT ( model->index ( -2, -2 ) == QModelIndex() ); - Q_ASSERT ( model->index ( -2, 0 ) == QModelIndex() ); - Q_ASSERT ( model->index ( 0, -2 ) == QModelIndex() ); + QVERIFY( model->index ( -2, -2 ) == QModelIndex() ); + QVERIFY( model->index ( -2, 0 ) == QModelIndex() ); + QVERIFY( model->index ( 0, -2 ) == QModelIndex() ); int rows = model->rowCount(); int columns = model->columnCount(); @@ -236,13 +234,13 @@ void ModelTest::index() return; // Catch off by one errors - Q_ASSERT ( model->index ( rows, columns ) == QModelIndex() ); - Q_ASSERT ( model->index ( 0, 0 ).isValid() == true ); + QVERIFY( model->index ( rows, columns ) == QModelIndex() ); + QVERIFY( model->index ( 0, 0 ).isValid() ); // Make sure that the same index is *always* returned QModelIndex a = model->index ( 0, 0 ); QModelIndex b = model->index ( 0, 0 ); - Q_ASSERT ( a == b ); + QVERIFY( a == b ); // index() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -256,7 +254,7 @@ void ModelTest::parent() // qDebug() << "p"; // Make sure the model wont crash and will return an invalid QModelIndex // when asked for the parent of an invalid index. - Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() ); + QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() ); if ( model->rowCount() == 0 ) return; @@ -269,13 +267,13 @@ void ModelTest::parent() // Common error test #1, make sure that a top level index has a parent // that is a invalid QModelIndex. QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); - Q_ASSERT ( model->parent ( topIndex ) == QModelIndex() ); + QVERIFY( model->parent ( topIndex ) == QModelIndex() ); // Common error test #2, make sure that a second level index has a parent // that is the first level index. if ( model->rowCount ( topIndex ) > 0 ) { QModelIndex childIndex = model->index ( 0, 0, topIndex ); - Q_ASSERT ( model->parent ( childIndex ) == topIndex ); + QVERIFY( model->parent ( childIndex ) == topIndex ); } // Common error test #3, the second column should NOT have the same children @@ -285,7 +283,7 @@ void ModelTest::parent() if ( model->rowCount ( topIndex1 ) > 0 ) { QModelIndex childIndex = model->index ( 0, 0, topIndex ); QModelIndex childIndex1 = model->index ( 0, 0, topIndex1 ); - Q_ASSERT ( childIndex != childIndex1 ); + QVERIFY( childIndex != childIndex1 ); } // Full test, walk n levels deep through the model making sure that all @@ -325,47 +323,47 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) int columns = model->columnCount ( parent ); if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( parent ) ); + QVERIFY( model->hasChildren ( parent ) ); // Some further testing against rows(), columns(), and hasChildren() - Q_ASSERT ( rows >= 0 ); - Q_ASSERT ( columns >= 0 ); + QVERIFY( rows >= 0 ); + QVERIFY( columns >= 0 ); if ( rows > 0 ) - Q_ASSERT ( model->hasChildren ( parent ) == true ); + QVERIFY( model->hasChildren ( parent ) ); //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows // << "columns:" << columns << "parent column:" << parent.column(); - Q_ASSERT ( model->hasIndex ( rows + 1, 0, parent ) == false ); + QVERIFY( !model->hasIndex ( rows + 1, 0, parent ) ); for ( int r = 0; r < rows; ++r ) { if ( model->canFetchMore ( parent ) ) { fetchingMore = true; model->fetchMore ( parent ); fetchingMore = false; } - Q_ASSERT ( model->hasIndex ( r, columns + 1, parent ) == false ); + QVERIFY( !model->hasIndex ( r, columns + 1, parent ) ); for ( int c = 0; c < columns; ++c ) { - Q_ASSERT ( model->hasIndex ( r, c, parent ) == true ); + QVERIFY( model->hasIndex ( r, c, parent ) ); QModelIndex index = model->index ( r, c, parent ); // rowCount() and columnCount() said that it existed... - Q_ASSERT ( index.isValid() == true ); + QVERIFY( index.isValid() ); // index() should always return the same index when called twice in a row QModelIndex modifiedIndex = model->index ( r, c, parent ); - Q_ASSERT ( index == modifiedIndex ); + QVERIFY( index == modifiedIndex ); // Make sure we get the same index if we request it twice in a row QModelIndex a = model->index ( r, c, parent ); QModelIndex b = model->index ( r, c, parent ); - Q_ASSERT ( a == b ); + QVERIFY( a == b ); // Some basic checking on the index that is returned - Q_ASSERT ( index.model() == model ); - Q_ASSERT ( index.row() == r ); - Q_ASSERT ( index.column() == c ); + QVERIFY( index.model() == model ); + QCOMPARE( index.row(), r ); + QCOMPARE( index.column(), c ); // While you can technically return a QVariant usually this is a sign - // of an bug in data() Disable if this really is ok in your model. -// Q_ASSERT ( model->data ( index, Qt::DisplayRole ).isValid() == true ); + // of a bug in data(). Disable if this really is ok in your model. +// QVERIFY( model->data ( index, Qt::DisplayRole ).isValid() ); // If the next test fails here is some somewhat useful debug you play with. @@ -380,8 +378,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) } // Check that we can get back our real parent. -// qDebug() << model->parent ( index ) << parent ; - Q_ASSERT ( model->parent ( index ) == parent ); + QCOMPARE( model->parent ( index ), parent ); // recursively go down the children if ( model->hasChildren ( index ) && currentDepth < 10 ) { @@ -391,7 +388,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) // make sure that after testing the children that the index doesn't change. QModelIndex newerIndex = model->index ( r, c, parent ); - Q_ASSERT ( index == newerIndex ); + QVERIFY( index == newerIndex ); } } } @@ -402,68 +399,68 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) void ModelTest::data() { // Invalid index should return an invalid qvariant - Q_ASSERT ( !model->data ( QModelIndex() ).isValid() ); + QVERIFY( !model->data ( QModelIndex() ).isValid() ); if ( model->rowCount() == 0 ) return; // A valid index should have a valid QVariant data - Q_ASSERT ( model->index ( 0, 0 ).isValid() ); + QVERIFY( model->index ( 0, 0 ).isValid() ); // shouldn't be able to set data on an invalid index - Q_ASSERT ( model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) == false ); + QVERIFY( !model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) ); // General Purpose roles that should return a QString QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole ); if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert<QString> ( variant ) ); + QVERIFY( qVariantCanConvert<QString> ( variant ) ); } variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole ); if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert<QString> ( variant ) ); + QVERIFY( qVariantCanConvert<QString> ( variant ) ); } variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole ); if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert<QString> ( variant ) ); + QVERIFY( qVariantCanConvert<QString> ( variant ) ); } // General Purpose roles that should return a QSize variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole ); if ( variant.isValid() ) { - Q_ASSERT ( qVariantCanConvert<QSize> ( variant ) ); + QVERIFY( qVariantCanConvert<QSize> ( variant ) ); } // General Purpose roles that should return a QFont QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole ); if ( fontVariant.isValid() ) { - Q_ASSERT ( qVariantCanConvert<QFont> ( fontVariant ) ); + QVERIFY( qVariantCanConvert<QFont> ( fontVariant ) ); } // Check that the alignment is one we know about QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole ); if ( textAlignmentVariant.isValid() ) { int alignment = textAlignmentVariant.toInt(); - Q_ASSERT ( alignment == ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) ); + QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) ); } // General Purpose roles that should return a QColor QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole ); if ( colorVariant.isValid() ) { - Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) ); + QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) ); } colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole ); if ( colorVariant.isValid() ) { - Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) ); + QVERIFY( qVariantCanConvert<QColor> ( colorVariant ) ); } // Check that the "check state" is one we know about. QVariant checkStateVariant = model->data ( model->index ( 0, 0 ), Qt::CheckStateRole ); if ( checkStateVariant.isValid() ) { int state = checkStateVariant.toInt(); - Q_ASSERT ( state == Qt::Unchecked || - state == Qt::PartiallyChecked || - state == Qt::Checked ); + QVERIFY( state == Qt::Unchecked || + state == Qt::PartiallyChecked || + state == Qt::Checked ); } } @@ -494,7 +491,7 @@ void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, in void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) { Changing c = insert.pop(); - Q_ASSERT ( c.parent == parent ); + QVERIFY( c.parent == parent ); // qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize // << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent ); @@ -504,8 +501,8 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) // } // qDebug(); - Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) ); - Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); + QVERIFY( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) ); + QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); if (c.next != model->data(model->index(end + 1, 0, c.parent))) { qDebug() << start << end; @@ -514,7 +511,7 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent)); } - Q_ASSERT ( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) ); + QVERIFY( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) ); } void ModelTest::layoutAboutToBeChanged() @@ -527,7 +524,7 @@ void ModelTest::layoutChanged() { for ( int i = 0; i < changing.count(); ++i ) { QPersistentModelIndex p = changing[i]; - Q_ASSERT ( p == model->index ( p.row(), p.column(), p.parent() ) ); + QVERIFY( p == model->index ( p.row(), p.column(), p.parent() ) ); } changing.clear(); } @@ -557,10 +554,10 @@ void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end ) { qDebug() << "rr" << parent << start << end; Changing c = remove.pop(); - Q_ASSERT ( c.parent == parent ); - Q_ASSERT ( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) ); - Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); - Q_ASSERT ( c.next == model->data ( model->index ( start, 0, c.parent ) ) ); + QVERIFY( c.parent == parent ); + QVERIFY( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) ); + QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); + QVERIFY( c.next == model->data ( model->index ( start, 0, c.parent ) ) ); } diff --git a/tests/auto/q3listview/tst_q3listview.cpp b/tests/auto/q3listview/tst_q3listview.cpp index 601d74f..c1b3950 100644 --- a/tests/auto/q3listview/tst_q3listview.cpp +++ b/tests/auto/q3listview/tst_q3listview.cpp @@ -678,7 +678,7 @@ void tst_Q3ListView::selections_mouseClick() for (i = 0; i < items.count(); ++i) { Q3ListViewItem *item = items.at(i); - Q_ASSERT(item); + QVERIFY(item); if ( item->isSelected() ) { QVERIFY( selectedItems.contains( i ) ); } else { diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp index 6f3722d..838fd22 100644 --- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp +++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp @@ -251,7 +251,7 @@ void tst_Q3SqlCursor::copyConstructor() } QSqlRecord* rec = cur2.primeUpdate(); - Q_ASSERT( rec ); + QVERIFY( rec ); QCOMPARE( (int)rec->count(), 4 ); int i = 0; @@ -398,7 +398,7 @@ void tst_Q3SqlCursor::batchInsert() int i = 0; for ( ; i < 100; ++i ) { QSqlRecord* irec = cur.primeInsert(); - Q_ASSERT( irec ); + QVERIFY( irec ); irec->setValue( "id", i ); irec->setValue( "t_varchar", "blah" ); irec->setValue( "t_char", "blah" ); @@ -412,7 +412,7 @@ void tst_Q3SqlCursor::batchInsert() for ( ; i < 200; ++i ) { QSqlRecord* irec = cur.primeInsert(); - Q_ASSERT( irec ); + QVERIFY( irec ); irec->setValue( "id", i ); irec->setValue( "t_varchar", "blah" ); irec->setValue( "t_char", "blah" ); @@ -699,7 +699,7 @@ void tst_Q3SqlCursor::updateNoPK() Q3SqlCursor cur(qTableName("qtestPK", __FILE__), true, db); QSqlRecord* rec = cur.primeInsert(); - Q_ASSERT(rec); + QVERIFY(rec); rec->setNull(0); rec->setNull(1); rec->setNull(2); @@ -724,7 +724,7 @@ void tst_Q3SqlCursor::updateNoPK() } rec = cur.primeUpdate(); - Q_ASSERT(rec); + QVERIFY(rec); rec->setValue(0, 1); rec->setNull(1); rec->setNull(2); diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp index 3e3cc73..5d6b84f 100644 --- a/tests/auto/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/qbuffer/tst_qbuffer.cpp @@ -309,8 +309,7 @@ void tst_QBuffer::seekTest() // (see Task 184730) { char c; - const int offset = 1; - Q_ASSERT(offset > 0); // any positive integer will do + const int offset = 1; // any positive integer will do const qint64 pos = buf.size() + offset; QVERIFY(buf.seek(pos)); QCOMPARE(buf.pos(), pos); diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp index 45dd7eb..911a30c 100644 --- a/tests/auto/qchar/tst_qchar.cpp +++ b/tests/auto/qchar/tst_qchar.cpp @@ -548,14 +548,14 @@ void tst_QChar::normalization_data() QList<QByteArray> l = line.split(';'); - Q_ASSERT(l.size() == 5); + QCOMPARE(l.size(), 5); QStringList columns; for (int i = 0; i < 5; ++i) { columns.append(QString()); QList<QByteArray> c = l.at(i).split(' '); - Q_ASSERT(!c.isEmpty()); + QVERIFY(!c.isEmpty()); for (int j = 0; j < c.size(); ++j) { bool ok; diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 932c19e..afcc433 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -1248,9 +1248,7 @@ public: void tst_QCompleter::task189564_omitNonSelectableItems() { const QString prefix("a"); - Q_ASSERT(!prefix.isEmpty()); const int n = 5; - Q_ASSERT(n > 0); QStringList strings; for (int i = 0; i < n; ++i) diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp index c8c3b90..98632ae 100644 --- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp @@ -2751,7 +2751,7 @@ void tst_QDateTimeEdit::setCurrentSection() QFETCH(QList<int>, setCurrentSections); QFETCH(QList<int>, expectedCursorPositions); - Q_ASSERT(setCurrentSections.size() == expectedCursorPositions.size()); + QCOMPARE(setCurrentSections.size(), expectedCursorPositions.size()); testWidget->setDisplayFormat(format); testWidget->setDateTime(dateTime); #ifdef Q_WS_MAC diff --git a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp index bfb806b..142b6c2 100644 --- a/tests/auto/qdbusthreading/tst_qdbusthreading.cpp +++ b/tests/auto/qdbusthreading/tst_qdbusthreading.cpp @@ -592,7 +592,7 @@ void tst_QDBusThreading::callbackInAnotherAuxThread() // wait for the event loop sem1.release(); sem2.acquire(); - Q_ASSERT(loop); + QVERIFY(loop); // create the second thread new Thread; diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp index 38a6b8a..a6985a4 100644 --- a/tests/auto/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp @@ -641,10 +641,10 @@ void tst_QDirModel::filter() QDirModel model; model.setNameFilters(QStringList() << "*.nada"); QModelIndex index = model.index(SRCDIR "test"); - Q_ASSERT(model.rowCount(index) == 0); + QCOMPARE(model.rowCount(index), 0); QModelIndex index2 = model.index(SRCDIR "test/file01.tst"); - Q_ASSERT(!index2.isValid()); - Q_ASSERT(model.rowCount(index) == 0); + QVERIFY(!index2.isValid()); + QCOMPARE(model.rowCount(index), 0); } void tst_QDirModel::task244669_remove() diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 5e9f130..dc3ca52 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -812,7 +812,7 @@ void tst_QFileDialog2::task239706_editableFilterCombo() break; } } - Q_ASSERT(filterCombo); + QVERIFY(filterCombo); filterCombo->setEditable(true); QTest::mouseClick(filterCombo, Qt::LeftButton); QTest::keyPress(filterCombo, Qt::Key_X); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 168f75e..269b576 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -10655,7 +10655,7 @@ void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations() QTRY_VERIFY(view.repaints > 0); QGraphicsItemCache *itemCache = QGraphicsItemPrivate::get(item)->extraItemCache(); - Q_ASSERT(itemCache); + QVERIFY(itemCache); QPixmapCache::Key currentKey = itemCache->deviceData.value(view.viewport()).key; // Trigger an update and verify that the cache is unchanged. diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 9ff086c..0927577 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -3594,7 +3594,7 @@ void tst_QGraphicsScene::task160653_selectionChanged() item->flags() | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable); item->setSelected(true); } - Q_ASSERT(scene.items().size() > 1); + QVERIFY(scene.items().size() > 1); QCOMPARE(scene.items().size(), scene.selectedItems().size()); QSignalSpy spy(&scene, SIGNAL(selectionChanged())); diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp index 1d13eb6..e0317df 100644 --- a/tests/auto/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp @@ -193,12 +193,12 @@ void testGetNumeric(QInputDialog *dialog, SpinBoxType * = 0, ValueType * = 0) void testGetText(QInputDialog *dialog) { QLineEdit *ledit = qFindChild<QLineEdit *>(dialog); - Q_ASSERT(ledit); + QVERIFY(ledit); QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog); - Q_ASSERT(bbox); + QVERIFY(bbox); QPushButton *okButton = bbox->button(QDialogButtonBox::Ok); - Q_ASSERT(okButton); + QVERIFY(okButton); QVERIFY(ledit->hasAcceptableInput()); QCOMPARE(ledit->selectedText(), ledit->text()); @@ -211,12 +211,12 @@ void testGetText(QInputDialog *dialog) void testGetItem(QInputDialog *dialog) { QComboBox *cbox = qFindChild<QComboBox *>(dialog); - Q_ASSERT(cbox); + QVERIFY(cbox); QDialogButtonBox *bbox = qFindChild<QDialogButtonBox *>(dialog); - Q_ASSERT(bbox); + QVERIFY(bbox); QPushButton *okButton = bbox->button(QDialogButtonBox::Ok); - Q_ASSERT(okButton); + QVERIFY(okButton); QVERIFY(okButton->isEnabled()); const int origIndex = cbox->currentIndex(); @@ -249,7 +249,7 @@ void tst_QInputDialog::timerEvent(QTimerEvent *event) { killTimer(event->timerId()); QInputDialog *dialog = qFindChild<QInputDialog *>(parent); - Q_ASSERT(dialog); + QVERIFY(dialog); if (testFunc) testFunc(dialog); dialog->done(doneCode); // cause static function call to return @@ -270,7 +270,7 @@ void tst_QInputDialog::getInteger() { QFETCH(int, min); QFETCH(int, max); - Q_ASSERT(min < max); + QVERIFY(min < max); parent = new QWidget; doneCode = QDialog::Accepted; testFunc = &tst_QInputDialog::testFuncGetInteger; @@ -310,7 +310,7 @@ void tst_QInputDialog::getDouble() QFETCH(double, min); QFETCH(double, max); QFETCH(int, decimals); - Q_ASSERT(min < max && decimals >= 0 && decimals <= 13); + QVERIFY(min < max && decimals >= 0 && decimals <= 13); parent = new QWidget; doneCode = QDialog::Accepted; testFunc = &tst_QInputDialog::testFuncGetDouble; diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index 16846de..4f0de4c 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -317,7 +317,7 @@ void tst_QLocale::ctor() TEST_CTOR("en_GB@.bla", English, UnitedKingdom) TEST_CTOR("en_GB@bla", English, UnitedKingdom) - Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal); + QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal); TEST_CTOR("no", Norwegian, Norway) TEST_CTOR("nb", Norwegian, Norway) TEST_CTOR("nn", NorwegianNynorsk, Norway) @@ -397,7 +397,7 @@ void tst_QLocale::emptyCtor() TEST_CTOR("en_GB@bla", "en_GB") TEST_CTOR("de", "de_DE") - Q_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal); + QVERIFY(QLocale::Norwegian == QLocale::NorwegianBokmal); TEST_CTOR("no", "nb_NO") TEST_CTOR("nb", "nb_NO") TEST_CTOR("nn", "nn_NO") diff --git a/tests/auto/qmessagebox/tst_qmessagebox.cpp b/tests/auto/qmessagebox/tst_qmessagebox.cpp index c11e76c..ed121ce 100644 --- a/tests/auto/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/qmessagebox/tst_qmessagebox.cpp @@ -609,48 +609,43 @@ void tst_QMessageBox::testSymbols() button = QMessageBox::FlagMask; mb1.setText("Foo"); - QString text = mb1.text(); - Q_ASSERT(text == "Foo"); + QCOMPARE(mb1.text(), "Foo"); icon = mb1.icon(); - Q_ASSERT(icon == QMessageBox::NoIcon); + QVERIFY(icon == QMessageBox::NoIcon); mb1.setIcon(QMessageBox::Question); - Q_ASSERT(mb1.icon() == QMessageBox::Question); + QVERIFY(mb1.icon() == QMessageBox::Question); QPixmap iconPixmap = mb1.iconPixmap(); mb1.setIconPixmap(iconPixmap); - Q_ASSERT(mb1.icon() == QMessageBox::NoIcon); + QVERIFY(mb1.icon() == QMessageBox::NoIcon); - QString bt0 = mb1.buttonText(QMessageBox::Ok); - QString bt1 = mb1.buttonText(QMessageBox::Cancel); - QString bt2 = mb1.buttonText(QMessageBox::Ok | QMessageBox::Default); - - Q_ASSERT(bt0 == "OK"); - Q_ASSERT(bt1.isEmpty()); - Q_ASSERT(bt2.isEmpty()); + QCOMPARE(mb1.buttonText(QMessageBox::Ok), "OK"); + QCOMPARE(mb1.buttonText(QMessageBox::Cancel), QString()); + QCOMPARE(mb1.buttonText(QMessageBox::Ok | QMessageBox::Default), QString()); mb2.setButtonText(QMessageBox::Cancel, "Foo"); mb2.setButtonText(QMessageBox::Ok, "Bar"); mb2.setButtonText(QMessageBox::Ok | QMessageBox::Default, "Baz"); - Q_ASSERT(mb2.buttonText(QMessageBox::Cancel).isEmpty()); - Q_ASSERT(mb2.buttonText(QMessageBox::Ok) == "Bar"); + QCOMPARE(mb2.buttonText(QMessageBox::Cancel), QString()); + QCOMPARE(mb2.buttonText(QMessageBox::Ok), "Bar"); - Q_ASSERT(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes")); - Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty()); - Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty()); + QVERIFY(mb3b.buttonText(QMessageBox::Yes).endsWith("Yes")); + QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString()); + QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString()); mb3b.setButtonText(QMessageBox::Yes, "Blah"); mb3b.setButtonText(QMessageBox::YesAll, "Zoo"); mb3b.setButtonText(QMessageBox::Ok, "Zoo"); - Q_ASSERT(mb3b.buttonText(QMessageBox::Yes) == "Blah"); - Q_ASSERT(mb3b.buttonText(QMessageBox::YesAll).isEmpty()); - Q_ASSERT(mb3b.buttonText(QMessageBox::Ok).isEmpty()); + QCOMPARE(mb3b.buttonText(QMessageBox::Yes), "Blah"); + QCOMPARE(mb3b.buttonText(QMessageBox::YesAll), QString()); + QCOMPARE(mb3b.buttonText(QMessageBox::Ok), QString()); - Q_ASSERT(mb1.textFormat() == Qt::AutoText); + QCOMPARE(mb1.textFormat(), Qt::AutoText); mb1.setTextFormat(Qt::PlainText); - Q_ASSERT(mb1.textFormat() == Qt::PlainText); + QCOMPARE(mb1.textFormat(), Qt::PlainText); CONVENIENCE_FUNC_SYMS(information); CONVENIENCE_FUNC_SYMS_EXTRA(information); @@ -660,7 +655,7 @@ void tst_QMessageBox::testSymbols() CONVENIENCE_FUNC_SYMS(critical); QSize sizeHint = mb1.sizeHint(); - Q_ASSERT(sizeHint.width() > 20 && sizeHint.height() > 20); + QVERIFY(sizeHint.width() > 20 && sizeHint.height() > 20); #ifdef QT3_SUPPORT //test QT3_SUPPORT stuff @@ -672,8 +667,8 @@ void tst_QMessageBox::testSymbols() QPixmap pm = QMessageBox::standardIcon(QMessageBox::Question, Qt::GUIStyle(1)); QPixmap pm2 = QMessageBox::standardIcon(QMessageBox::Question); - Q_ASSERT(pm.toImage() == iconPixmap.toImage()); - Q_ASSERT(pm2.toImage() == iconPixmap.toImage()); + QVERIFY(pm.toImage() == iconPixmap.toImage()); + QVERIFY(pm2.toImage() == iconPixmap.toImage()); int ret1 = QMessageBox::message("title", "text"); int ret2 = QMessageBox::message("title", "text", "OK"); @@ -692,10 +687,10 @@ void tst_QMessageBox::testSymbols() Q_UNUSED(ret5); QPixmap pm3 = QMessageBox::standardIcon(QMessageBox::NoIcon); - Q_ASSERT(pm3.isNull()); + QVERIFY(pm3.isNull()); pm3 = QMessageBox::standardIcon(QMessageBox::Information); - Q_ASSERT(!pm3.isNull()); + QVERIFY(!pm3.isNull()); #endif //QT3_SUPPORT QMessageBox::about(&mb1, "title", "text"); diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 4d032e8..198a275 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -1696,8 +1696,8 @@ void tst_QPixmap::fromImageReaderAnimatedGif() QImageReader referenceReader(path); QImageReader pixmapReader(path); - Q_ASSERT(referenceReader.canRead()); - Q_ASSERT(referenceReader.imageCount() > 1); + QVERIFY(referenceReader.canRead()); + QVERIFY(referenceReader.imageCount() > 1); for (int i = 0; i < referenceReader.imageCount(); ++i) { QImage refImage = referenceReader.read(); diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index 2a8874e..3e0c3ff 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -668,7 +668,7 @@ void tst_QProcess::exitStatus() QSKIP("This test opens a crash dialog on Windows", SkipSingle); #endif - Q_ASSERT(processList.count() == exitStatus.count()); + QCOMPARE(exitStatus.count(), processList.count()); for (int i = 0; i < processList.count(); ++i) { process->start(processList.at(i)); QVERIFY(process->waitForStarted(5000)); diff --git a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp index 03e5c0f..1d4745e 100644 --- a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp +++ b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp @@ -106,7 +106,7 @@ void tst_QScriptValueIterator::iterateForward() QFETCH(QStringList, propertyNames); QFETCH(QStringList, propertyValues); QMap<QString, QString> pmap; - Q_ASSERT(propertyNames.size() == propertyValues.size()); + QVERIFY(propertyNames.size() == propertyValues.size()); QScriptEngine engine; QScriptValue object = engine.newObject(); @@ -165,7 +165,7 @@ void tst_QScriptValueIterator::iterateBackward() QFETCH(QStringList, propertyNames); QFETCH(QStringList, propertyValues); QMap<QString, QString> pmap; - Q_ASSERT(propertyNames.size() == propertyValues.size()); + QVERIFY(propertyNames.size() == propertyValues.size()); QScriptEngine engine; QScriptValue object = engine.newObject(); diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index bb04621..f25f8e8 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -283,8 +283,8 @@ void tst_QSharedPointer::operators() QSharedPointer<char> p1; QSharedPointer<char> p2(new char); qptrdiff diff = p2.data() - p1.data(); - Q_ASSERT(p1.data() != p2.data()); - Q_ASSERT(diff != 0); + QVERIFY(p1.data() != p2.data()); + QVERIFY(diff != 0); // operator- QCOMPARE(p2 - p1.data(), diff); @@ -867,8 +867,8 @@ void tst_QSharedPointer::differentPointers() { DiffPtrDerivedData *aData = new DiffPtrDerivedData; Data *aBase = aData; - Q_ASSERT(aData == aBase); - Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); + QVERIFY(aData == aBase); + QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); QSharedPointer<Data> baseptr = QSharedPointer<Data>(aData); QSharedPointer<DiffPtrDerivedData> ptr = qSharedPointerCast<DiffPtrDerivedData>(baseptr); @@ -885,8 +885,8 @@ void tst_QSharedPointer::differentPointers() { DiffPtrDerivedData *aData = new DiffPtrDerivedData; Data *aBase = aData; - Q_ASSERT(aData == aBase); - Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); + QVERIFY(aData == aBase); + QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); QSharedPointer<DiffPtrDerivedData> ptr = QSharedPointer<DiffPtrDerivedData>(aData); QSharedPointer<Data> baseptr = ptr; @@ -908,8 +908,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers() { VirtualDerived *aData = new VirtualDerived; Data *aBase = aData; - Q_ASSERT(aData == aBase); - Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); + QVERIFY(aData == aBase); + QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData); QSharedPointer<Data> baseptr = qSharedPointerCast<Data>(ptr); @@ -928,8 +928,8 @@ void tst_QSharedPointer::virtualBaseDifferentPointers() { VirtualDerived *aData = new VirtualDerived; Data *aBase = aData; - Q_ASSERT(aData == aBase); - Q_ASSERT(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); + QVERIFY(aData == aBase); + QVERIFY(*reinterpret_cast<quintptr *>(&aData) != *reinterpret_cast<quintptr *>(&aBase)); QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>(aData); QSharedPointer<Data> baseptr = ptr; @@ -1605,7 +1605,7 @@ void hashAndMapTest() QVERIFY(it != c.find(Key())); if (Ordered) { - Q_ASSERT(k0 < k1); + QVERIFY(k0 < k1); it = c.begin(); QCOMPARE(it.key(), k0); diff --git a/tests/auto/qsplitter/tst_qsplitter.cpp b/tests/auto/qsplitter/tst_qsplitter.cpp index 0482661..60be944 100644 --- a/tests/auto/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/qsplitter/tst_qsplitter.cpp @@ -1340,14 +1340,14 @@ void tst_QSplitter::task187373_addAbstractScrollAreas() QFETCH(QString, className); QFETCH(bool, addInConstructor); QFETCH(bool, addOutsideConstructor); - Q_ASSERT(addInConstructor || addOutsideConstructor); + QVERIFY(addInConstructor || addOutsideConstructor); QSplitter *splitter = new QSplitter; splitter->show(); - Q_ASSERT(splitter->isVisible()); + QVERIFY(splitter->isVisible()); QAbstractScrollArea *w = task187373_createScrollArea(splitter, className, addInConstructor); - Q_ASSERT(w); + QVERIFY(w); if (addOutsideConstructor) splitter->addWidget(w); diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp index 4462659..185e046 100644 --- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp @@ -767,7 +767,7 @@ void tst_QSqlDatabase::checkValues(const FieldDef fieldDefs[], QSqlDatabase db) Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); QVERIFY_SQL(cur, select()); QSqlRecord* rec = cur.primeInsert(); - Q_ASSERT(rec); + QVERIFY(rec); rec->setValue("id", pkey++); int i = 0; for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { @@ -828,7 +828,7 @@ void tst_QSqlDatabase::checkNullValues(const FieldDef fieldDefs[], QSqlDatabase Q3SqlCursor cur(qTableName("qtestfields", __FILE__), true, db); QVERIFY_SQL(cur, select()); QSqlRecord* rec = cur.primeInsert(); - Q_ASSERT(rec); + QVERIFY(rec); rec->setValue("id", pkey++); int i = 0; for (i = 0; !fieldDefs[ i ].typeName.isNull(); ++i) { diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index abc8d9a..ad7515b 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -3415,9 +3415,9 @@ void tst_QString::fromLatin1Roundtrip() QFETCH(QString, unicode); // QtTest safety check: - Q_ASSERT(latin1.isNull() == unicode.isNull()); - Q_ASSERT(latin1.isEmpty() == unicode.isEmpty()); - Q_ASSERT(latin1.length() == unicode.length()); + QCOMPARE(latin1.isNull(), unicode.isNull()); + QCOMPARE(latin1.isEmpty(), unicode.isEmpty()); + QCOMPARE(latin1.length(), unicode.length()); if (!latin1.isEmpty()) while (latin1.length() < 128) { @@ -3470,12 +3470,12 @@ void tst_QString::toLatin1Roundtrip() QFETCH(QString, unicodedst); // QtTest safety check: - Q_ASSERT(latin1.isNull() == unicodesrc.isNull()); - Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty()); - Q_ASSERT(latin1.length() == unicodesrc.length()); - Q_ASSERT(latin1.isNull() == unicodedst.isNull()); - Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty()); - Q_ASSERT(latin1.length() == unicodedst.length()); + QCOMPARE(latin1.isNull(), unicodesrc.isNull()); + QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty()); + QCOMPARE(latin1.length(), unicodesrc.length()); + QCOMPARE(latin1.isNull(), unicodedst.isNull()); + QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty()); + QCOMPARE(latin1.length(), unicodedst.length()); if (!latin1.isEmpty()) while (latin1.length() < 128) { @@ -3505,12 +3505,12 @@ void tst_QString::stringRef_toLatin1Roundtrip() QFETCH(QString, unicodedst); // QtTest safety check: - Q_ASSERT(latin1.isNull() == unicodesrc.isNull()); - Q_ASSERT(latin1.isEmpty() == unicodesrc.isEmpty()); - Q_ASSERT(latin1.length() == unicodesrc.length()); - Q_ASSERT(latin1.isNull() == unicodedst.isNull()); - Q_ASSERT(latin1.isEmpty() == unicodedst.isEmpty()); - Q_ASSERT(latin1.length() == unicodedst.length()); + QCOMPARE(latin1.isNull(), unicodesrc.isNull()); + QCOMPARE(latin1.isEmpty(), unicodesrc.isEmpty()); + QCOMPARE(latin1.length(), unicodesrc.length()); + QCOMPARE(latin1.isNull(), unicodedst.isNull()); + QCOMPARE(latin1.isEmpty(), unicodedst.isEmpty()); + QCOMPARE(latin1.length(), unicodedst.length()); if (!latin1.isEmpty()) while (latin1.length() < 128) { diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index 6157004..1da0bde 100644 --- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -123,14 +123,14 @@ void tst_QTextBoundaryFinder::graphemeBoundaries() if (test.at(pos).unicode() == 0xf7) breakPositions.append(strPos); else - Q_ASSERT(test.at(pos).unicode() == 0xd7); + QVERIFY(test.at(pos).unicode() == 0xd7); ++pos; if (pos < test.length()) { - Q_ASSERT(pos < test.length() - 4); + QVERIFY(pos < test.length() - 4); QString hex = test.mid(pos, 4); bool ok = true; testString.append(QChar(hex.toInt(&ok, 16))); - Q_ASSERT(ok); + QVERIFY(ok); pos += 4; } ++strPos; @@ -176,14 +176,14 @@ void tst_QTextBoundaryFinder::wordBoundaries() if (test.at(pos).unicode() == 0xf7) breakPositions.append(strPos); else - Q_ASSERT(test.at(pos).unicode() == 0xd7); + QVERIFY(test.at(pos).unicode() == 0xd7); ++pos; if (pos < test.length()) { - Q_ASSERT(pos < test.length() - 4); + QVERIFY(pos < test.length() - 4); QString hex = test.mid(pos, 4); bool ok = true; testString.append(QChar(hex.toInt(&ok, 16))); - Q_ASSERT(ok); + QVERIFY(ok); pos += 4; } ++strPos; @@ -228,14 +228,14 @@ void tst_QTextBoundaryFinder::sentenceBoundaries() if (test.at(pos).unicode() == 0xf7) breakPositions.append(strPos); else - Q_ASSERT(test.at(pos).unicode() == 0xd7); + QVERIFY(test.at(pos).unicode() == 0xd7); ++pos; if (pos < test.length()) { - Q_ASSERT(pos < test.length() - 4); + QVERIFY(pos < test.length() - 4); QString hex = test.mid(pos, 4); bool ok = true; testString.append(QChar(hex.toInt(&ok, 16))); - Q_ASSERT(ok); + QVERIFY(ok); pos += 4; } ++strPos; diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index 43656c8..d122b0b 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -428,7 +428,7 @@ void tst_QTextCodec::flagCodepointFFFF() const QString input(ch); QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8 - Q_ASSERT(codec); + QVERIFY(codec); const QByteArray asDecoded(codec->fromUnicode(input)); QCOMPARE(asDecoded, QByteArray("?")); @@ -465,7 +465,7 @@ void tst_QTextCodec::flagF7808080() const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8 - Q_ASSERT(codec); + QVERIFY(codec); //QVERIFY(!codec->canEncode(QChar(0x1C0000))); @@ -482,7 +482,7 @@ void tst_QTextCodec::flagEFBFBF() const invalidInput[2] = char(0xBF); const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8 - Q_ASSERT(codec); + QVERIFY(codec); { //QVERIFY(!codec->canEncode(QChar(0xFFFF))); @@ -1627,7 +1627,7 @@ void tst_QTextCodec::utf8bom() QFETCH(QString, result); QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8 - Q_ASSERT(codec); + QVERIFY(codec); QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result); diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 35014c9..64d543f 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -7220,8 +7220,7 @@ void tst_QWidget::render_systemClip2() QFETCH(bool, usePaintEvent); QFETCH(QColor, expectedColor); - Q_ASSERT_X(expectedColor != QColor(Qt::red), Q_FUNC_INFO, - "Qt::red is the reference color for the image, pick another color"); + QVERIFY2(expectedColor != QColor(Qt::red), "Qt::red is the reference color for the image, pick another color"); class MyWidget : public QWidget { diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp index 62cc4bb..ff6121f 100644 --- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp +++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp @@ -108,7 +108,7 @@ void tst_SuiteTest::runTestSuite() const /* Run the tests, and serialize the result(as according to XQTSResult.xsd) to standard out. */ TestSuiteResult *const result = ts->runSuite(); - Q_ASSERT(result); + QVERIFY(result); QFile out(m_candidateBaseline); QVERIFY(out.open(QIODevice::WriteOnly)); -- cgit v0.12 From 1750a4351a8125756bf38a53d6d8312993c7d85e Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 15 Apr 2011 14:15:49 +1000 Subject: Remove Q_ASSERT calls that wrap side-effecting code. In release mode builds, code inside Q_ASSERT macros is not executed, so putting code with side-effects inside Q_ASSERT is not a good idea. Task-number: QTBUG-17582 Change-Id: I1a5d8ccce666ee7b7f120bf9cbb49e30dac9add4 Reviewed-by: Rohan McGovern --- tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 2dbed3b..50c634f 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -185,16 +185,22 @@ QString tst_qmlvisual::toTestScript(const QString &file, Mode mode) if (platformsuffix && (mode == UpdatePlatformVisuals || QFile::exists(testdata+QLatin1String(platformsuffix)+QDir::separator()+testname+".qml"))) { QString platformdir = testdata + QLatin1String(platformsuffix); if (mode == UpdatePlatformVisuals) { - Q_ASSERT(QDir().mkpath(platformdir)); + if (!QDir().mkpath(platformdir)) { + qFatal("Cannot make path %s", qPrintable(platformdir)); + } // Copy from base QDir dir(testdata,testname+".*"); dir.setFilter(QDir::Files); QFileInfoList list = dir.entryInfoList(); for (int i = 0; i < list.size(); ++i) { QFile in(list.at(i).filePath()); - Q_ASSERT(in.open(QIODevice::ReadOnly)); + if (!in.open(QIODevice::ReadOnly)) { + qFatal("Cannot open file %s: %s", qPrintable(in.fileName()), qPrintable(in.errorString())); + } QFile out(platformdir + QDir::separator() + list.at(i).fileName()); - Q_ASSERT(out.open(QIODevice::WriteOnly)); + if (!out.open(QIODevice::WriteOnly)) { + qFatal("Cannot open file %s: %s", qPrintable(out.fileName()), qPrintable(out.errorString())); + } out.write(in.readAll()); } } -- cgit v0.12 From d6bd4db2db6dbefec327e226bf54a69a20690a45 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 15 Apr 2011 15:25:45 +1000 Subject: Remove redundant Q_ASSERT from qmlvisual autotest. Change-Id: I5c413793ee6322b5be1ae52658362803dc4c2010 Task-number: QTBUG-17582 Reviewed-by: Alan Alpert --- tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 50c634f..61e1883 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -240,8 +240,6 @@ QStringList tst_qmlvisual::findQmlFiles(const QDir &d) void action(Mode mode, const QString &file) { - Q_ASSERT(mode != Test); - QString testdata = tst_qmlvisual::toTestScript(file,mode); QStringList arguments; -- cgit v0.12 From 59a6e6200984ccbb862b8758436a5e88b8c40bbc Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 15 Apr 2011 16:15:39 +1000 Subject: Remove Q_ASSERT from QDeclarativeListModel autotest. Change-Id: Ic15b747fa50bcec54df748b173b299058f69c681 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 45072f3..14af19c 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -114,7 +114,6 @@ int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, if (model->toString(roles[i]) == roleName) return roles[i]; } - Q_ASSERT(false); return -1; } @@ -740,6 +739,7 @@ void tst_qdeclarativelistmodel::get() "}", QUrl()); QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create()); int role = roleFromName(model, roleName); + QVERIFY(role >= 0); QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>))); QDeclarativeExpression expr(eng.rootContext(), model, expression); @@ -801,6 +801,7 @@ void tst_qdeclarativelistmodel::get_worker() model.append(sv); model.append(sv); int role = roleFromName(&model, roleName); + QVERIFY(role >= 0); const char *warning = "<Unknown File>: QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"; if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) @@ -892,6 +893,7 @@ void tst_qdeclarativelistmodel::get_nested() int outerListIndex = testData[i].first; QString outerListRoleName = testData[i].second; int outerListRole = roleFromName(model, outerListRoleName); + QVERIFY(outerListRole >= 0); childModel = qobject_cast<QDeclarativeListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>()); QVERIFY(childModel); @@ -904,6 +906,7 @@ void tst_qdeclarativelistmodel::get_nested() QVERIFY(!expr.hasError()); int role = roleFromName(childModel, roleName); + QVERIFY(role >= 0); QCOMPARE(childModel->data(index, role), roleValue); QCOMPARE(spy.count(), 1); -- cgit v0.12 From ee55dec1efe9c67518bf3e27f81b0696075f7153 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 15 Apr 2011 17:35:13 +1000 Subject: Make tst_exceptionsafety_objects part of the test set. Re-enable this test, with the two test functions that fail on Linux disabled until the failures can be diagnosed. Change-Id: I915e1a0d675cb71a80086e89f9799a4f9f6b600c Reviewed-by: Rohan McGovern --- tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 2 ++ tests/auto/other.pro | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index e7e516e..3e4ccf5 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -352,6 +352,7 @@ void tst_ExceptionSafetyObjects::cleanupTestCase() void tst_ExceptionSafetyObjects::objects() { + QSKIP("This test currently crashes", SkipAll); QFETCH(AbstractTester *, objectCreator); doOOMTest(*objectCreator, 0); @@ -457,6 +458,7 @@ void tst_ExceptionSafetyObjects::widgets_data() void tst_ExceptionSafetyObjects::widgets() { + QSKIP("This test currently crashes", SkipAll); QFETCH(AbstractTester *, widgetCreator); doOOMTest(*widgetCreator, 0, 00000); diff --git a/tests/auto/other.pro b/tests/auto/other.pro index 8819879..4d8ff4e 100644 --- a/tests/auto/other.pro +++ b/tests/auto/other.pro @@ -3,7 +3,7 @@ TEMPLATE=subdirs SUBDIRS=\ -# exceptionsafety_objects \ shouldn't enable it + exceptionsafety_objects \ # baselineexample \ Just an example demonstrating qbaselinetest usage lancelot \ qaccessibility \ -- cgit v0.12 From 069e4441f2e14a82b4ae39601734acb71c909bd9 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 18 Apr 2011 11:11:47 +1000 Subject: Rename test class. Fixes warning from tst_maketestselftest about test class name not matching TARGET. Change-Id: I7a81d87bb64d2902e842d097248e33eacb388746 Reviewed-by: Rohan McGovern --- .../tst_exceptionsafety_objects.cpp | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 3e4ccf5..c78782e 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -60,7 +60,7 @@ QT_USE_NAMESPACE #include "3rdparty/memcheck.h" #endif -class tst_ExceptionSafetyObjects: public QObject +class tst_ExceptionSafety_Objects: public QObject { Q_OBJECT @@ -156,7 +156,7 @@ struct DirCreator : public AbstractTester } }; -void tst_ExceptionSafetyObjects::objects_data() +void tst_ExceptionSafety_Objects::objects_data() { QTest::addColumn<AbstractTester *>("objectCreator"); @@ -274,9 +274,9 @@ public: } }; -QtMsgHandler tst_ExceptionSafetyObjects::testMessageHandler; +QtMsgHandler tst_ExceptionSafety_Objects::testMessageHandler; -void tst_ExceptionSafetyObjects::safeMessageHandler(QtMsgType type, const char *msg) +void tst_ExceptionSafety_Objects::safeMessageHandler(QtMsgType type, const char *msg) { // this temporarily suspends OOM testing while handling a message int currentIndex = mallocFailIndex; @@ -301,7 +301,7 @@ void debugUnexpected() (*defaultUnexpected)(); } -void tst_ExceptionSafetyObjects::initTestCase() +void tst_ExceptionSafety_Objects::initTestCase() { // set handlers for bad exception cases, you might want to step in and breakpoint the default handlers too defaultTerminate = std::set_terminate(&debugTerminate); @@ -345,12 +345,12 @@ void tst_ExceptionSafetyObjects::initTestCase() QCOMPARE(malloc2Failed, 1); } -void tst_ExceptionSafetyObjects::cleanupTestCase() +void tst_ExceptionSafety_Objects::cleanupTestCase() { qInstallMsgHandler(testMessageHandler); } -void tst_ExceptionSafetyObjects::objects() +void tst_ExceptionSafety_Objects::objects() { QSKIP("This test currently crashes", SkipAll); QFETCH(AbstractTester *, objectCreator); @@ -389,7 +389,7 @@ template <> struct WidgetCreator<QDesktopWidget> : public AbstractTester QScopedPointer<QDesktopWidget> ptr(new QDesktopWidget()); } }; -void tst_ExceptionSafetyObjects::widgets_data() +void tst_ExceptionSafety_Objects::widgets_data() { #ifdef Q_OS_SYMBIAN // Initialise the S60 rasteriser, which crashes if started while out of memory @@ -456,7 +456,7 @@ void tst_ExceptionSafetyObjects::widgets_data() NEWROW(QTreeWidget); } -void tst_ExceptionSafetyObjects::widgets() +void tst_ExceptionSafety_Objects::widgets() { QSKIP("This test currently crashes", SkipAll); QFETCH(AbstractTester *, widgetCreator); @@ -722,12 +722,12 @@ static void containerData() QTest::newRow("erase moveable") << static_cast<TestFunction>(containerEraseTest<IntegerMoveable, Container>); } -void tst_ExceptionSafetyObjects::vector_data() +void tst_ExceptionSafety_Objects::vector_data() { containerData<QVector>(); } -void tst_ExceptionSafetyObjects::vector() +void tst_ExceptionSafety_Objects::vector() { QFETCH(TestFunction, testFunction); @@ -738,30 +738,30 @@ void tst_ExceptionSafetyObjects::vector() doOOMTest(testFunction, 0); } -void tst_ExceptionSafetyObjects::list_data() +void tst_ExceptionSafety_Objects::list_data() { containerData<QList>(); } -void tst_ExceptionSafetyObjects::list() +void tst_ExceptionSafety_Objects::list() { QFETCH(TestFunction, testFunction); doOOMTest(testFunction, 0); } -void tst_ExceptionSafetyObjects::linkedList_data() +void tst_ExceptionSafety_Objects::linkedList_data() { containerData<QLinkedList>(); } -void tst_ExceptionSafetyObjects::linkedList() +void tst_ExceptionSafety_Objects::linkedList() { QFETCH(TestFunction, testFunction); doOOMTest(testFunction, 0); } -QTEST_MAIN(tst_ExceptionSafetyObjects) +QTEST_MAIN(tst_ExceptionSafety_Objects) #include "tst_exceptionsafety_objects.moc" #endif // QT_NO_EXCEPTIONS -- cgit v0.12 From ced0a98b5274be6a62ae7e4a0f9fc3161d0e40cb Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 18 Apr 2011 14:27:44 +1000 Subject: Make test compile in namespaced build. Change-Id: I824864b8db755a8dc731e3c9de39e3dd7b16224a Reviewed-by: Rohan McGovern --- tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index c78782e..ab589ed 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -549,7 +549,9 @@ struct IntegerMoveable }; int IntegerMoveable::instanceCount = 0; +QT_BEGIN_NAMESPACE Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE); +QT_END_NAMESPACE template <typename T, template<typename> class Container> void containerInsertTest(QObject*) -- cgit v0.12 From 3788a90338e9328710b9d3335a63fb85ab7d97fc Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 18 Apr 2011 15:38:38 +1000 Subject: Partially re-enable exception safety test Re-enabling for object types that don't crash the test. Change-Id: I8c2f0d02171c973bf1ede227d4139b52cac5939f Reviewed-by: Rohan McGovern --- .../tst_exceptionsafety_objects.cpp | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index ab589ed..cb37049 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -352,7 +352,14 @@ void tst_ExceptionSafety_Objects::cleanupTestCase() void tst_ExceptionSafety_Objects::objects() { - QSKIP("This test currently crashes", SkipAll); + QLatin1String tag = QLatin1String(QTest::currentDataTag()); + if (tag == QLatin1String("QFile") + || tag == QLatin1String("QProcess") + || tag == QLatin1String("QSettings") + || tag == QLatin1String("QThread") + || tag == QLatin1String("QThreadPool")) + QSKIP("This type of object is not currently strongly exception safe", SkipSingle); + QFETCH(AbstractTester *, objectCreator); doOOMTest(*objectCreator, 0); @@ -458,7 +465,42 @@ void tst_ExceptionSafety_Objects::widgets_data() void tst_ExceptionSafety_Objects::widgets() { - QSKIP("This test currently crashes", SkipAll); + QLatin1String tag = QLatin1String(QTest::currentDataTag()); + if (tag == QLatin1String("QColumnView") + || tag == QLatin1String("QComboBox") + || tag == QLatin1String("QCommandLinkButton") + || tag == QLatin1String("QDateEdit") + || tag == QLatin1String("QDateTimeEdit") + || tag == QLatin1String("QDesktopWidget") + || tag == QLatin1String("QDoubleSpinBox") + || tag == QLatin1String("QFontComboBox") + || tag == QLatin1String("QGroupBox") + || tag == QLatin1String("QLineEdit") + || tag == QLatin1String("QListView") + || tag == QLatin1String("QListWidget") + || tag == QLatin1String("QMainWindow") + || tag == QLatin1String("QMenu") + || tag == QLatin1String("QMenuBar") + || tag == QLatin1String("QPlainTextEdit") + || tag == QLatin1String("QProgressBar") + || tag == QLatin1String("QPushButton") + || tag == QLatin1String("QScrollArea") + || tag == QLatin1String("QSpinBox") + || tag == QLatin1String("QStackedWidget") + || tag == QLatin1String("QStatusBar") + || tag == QLatin1String("QTableView") + || tag == QLatin1String("QTableWidget") + || tag == QLatin1String("QTabWidget") + || tag == QLatin1String("QTextBrowser") + || tag == QLatin1String("QTextEdit") + || tag == QLatin1String("QTimeEdit") + || tag == QLatin1String("QToolBar") + || tag == QLatin1String("QToolBox") + || tag == QLatin1String("QTreeView") + || tag == QLatin1String("QTreeWidget") + || tag == QLatin1String("QWorkspace")) + QSKIP("This type of widget is not currently strongly exception safe", SkipSingle); + QFETCH(AbstractTester *, widgetCreator); doOOMTest(*widgetCreator, 0, 00000); -- cgit v0.12 From 01dfb9ca25bfaec5784f404dcd4bf41bbc2b6fcb Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 18 Apr 2011 17:21:03 +1000 Subject: Don't try to run exceptionsafety_objects test by default on windows. This test relies on some API specific to MSVC's debug runtime, which is not always guaranteed to be available. Change-Id: Ib0ae4694ad51f59198dadfce802f0dfdf0522002 Reviewed-by: Rohan McGovern --- tests/auto/other.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/other.pro b/tests/auto/other.pro index 4d8ff4e..89f9e53 100644 --- a/tests/auto/other.pro +++ b/tests/auto/other.pro @@ -3,7 +3,6 @@ TEMPLATE=subdirs SUBDIRS=\ - exceptionsafety_objects \ # baselineexample \ Just an example demonstrating qbaselinetest usage lancelot \ qaccessibility \ @@ -56,6 +55,8 @@ symbian { qs60mainapplication } +!win32-msvc*:!wince*:SUBDIRS += exceptionsafety_objects + # Following tests depends on private API !contains(QT_CONFIG, private_tests): SUBDIRS -= \ qcssparser \ -- cgit v0.12 From 10f3f270c8a319205590ae13bdeab063d5216441 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 18 Apr 2011 18:21:03 +1000 Subject: Cosmetic changes to exceptionsafety_objects test Sort test data alphabetically and remove excess whitespace. Change-Id: I0e244efca9e9adbe747a375a28a63f70992ef4f8 Reviewed-by: Trust Me --- .../tst_exceptionsafety_objects.cpp | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index cb37049..2f094f3 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -164,12 +164,12 @@ void tst_ExceptionSafety_Objects::objects_data() NEWROW(QObject); NEWROW(QBuffer); NEWROW(QFile); + NEWROW(QFSFileEngine); NEWROW(QProcess); NEWROW(QSettings); NEWROW(QThread); NEWROW(QThreadPool); NEWROW(QTranslator); - NEWROW(QFSFileEngine); #define NEWROW2(T, CREATOR) QTest::newRow(#T) << static_cast<AbstractTester *>(new CREATOR) NEWROW2(QBitArray, BitArrayCreator); @@ -177,7 +177,6 @@ void tst_ExceptionSafety_Objects::objects_data() NEWROW2(QCryptographicHash, CryptographicHashCreator); NEWROW2(QDataStream, DataStreamCreator); NEWROW2(QDir, DirCreator); - } // create and destructs an object, and lets each and every allocation @@ -363,7 +362,7 @@ void tst_ExceptionSafety_Objects::objects() QFETCH(AbstractTester *, objectCreator); doOOMTest(*objectCreator, 0); - + delete objectCreator; } @@ -400,9 +399,9 @@ void tst_ExceptionSafety_Objects::widgets_data() { #ifdef Q_OS_SYMBIAN // Initialise the S60 rasteriser, which crashes if started while out of memory - QImage image(20, 20, QImage::Format_RGB32); - QPainter p(&image); - p.drawText(0, 15, "foo"); + QImage image(20, 20, QImage::Format_RGB32); + QPainter p(&image); + p.drawText(0, 15, "foo"); #endif QTest::addColumn<AbstractTester *>("widgetCreator"); @@ -413,23 +412,27 @@ void tst_ExceptionSafety_Objects::widgets_data() NEWROW(QWidget); NEWROW(QButtonGroup); - NEWROW(QDesktopWidget); NEWROW(QCheckBox); + NEWROW(QColumnView); NEWROW(QComboBox); NEWROW(QCommandLinkButton); NEWROW(QDateEdit); NEWROW(QDateTimeEdit); + NEWROW(QDesktopWidget); NEWROW(QDial); NEWROW(QDoubleSpinBox); NEWROW(QFocusFrame); NEWROW(QFontComboBox); NEWROW(QFrame); NEWROW(QGroupBox); - NEWROW(QLCDNumber); NEWROW(QLabel); NEWROW(QLCDNumber); NEWROW(QLineEdit); + NEWROW(QListView); + NEWROW(QListWidget); + NEWROW(QMainWindow); NEWROW(QMenu); + NEWROW(QMenuBar); NEWROW(QPlainTextEdit); NEWROW(QProgressBar); NEWROW(QPushButton); @@ -443,24 +446,18 @@ void tst_ExceptionSafety_Objects::widgets_data() NEWROW(QStackedWidget); NEWROW(QStatusBar); NEWROW(QTabBar); + NEWROW(QTableView); + NEWROW(QTableWidget); NEWROW(QTabWidget); NEWROW(QTextBrowser); NEWROW(QTextEdit); NEWROW(QTimeEdit); + NEWROW(QToolBar); NEWROW(QToolBox); NEWROW(QToolButton); - NEWROW(QStatusBar); - NEWROW(QToolBar); - NEWROW(QMenuBar); - NEWROW(QMainWindow); - NEWROW(QWorkspace); - NEWROW(QColumnView); - NEWROW(QListView); - NEWROW(QListWidget); - NEWROW(QTableView); - NEWROW(QTableWidget); NEWROW(QTreeView); NEWROW(QTreeWidget); + NEWROW(QWorkspace); } void tst_ExceptionSafety_Objects::widgets() -- cgit v0.12 From ed5dd84582881bc30a5ce85902b37aae9c243978 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 12:05:59 +1000 Subject: Remove Q_ASSERT calls from gestures autotest Make the test report a useful warning, rather than terminating with an unintelligible assertion failure, if the GestureState enum is ever extended. Change-Id: Ib876a5f2986cbea4e181678a83a72e0d1444f1ee Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/gestures/tst_gestures.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 7327a49..bff8a04 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -280,7 +280,7 @@ protected: eventsPtr->canceled << g->gestureType(); break; default: - Q_ASSERT(false); + qWarning() << "Unknown GestureState enum value:" << static_cast<int>(g->state()); } } } else if (event->type() == CustomEvent::EventType) { @@ -823,7 +823,7 @@ public: emit gestureCanceled(e->type(), g); break; default: - Q_ASSERT(false); + qWarning() << "Unknown GestureState enum value:" << static_cast<int>(g->state()); } } } else if (event->type() == CustomEvent::EventType) { -- cgit v0.12 From 1191dc0c278ddd22556d6c8e5ea5a898fa7b35f6 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 13:39:35 +1000 Subject: Remove unused functions. Change-Id: I8cae0550c58238bd99bc759c21b022c54fe2de8b Reviewed-by: Trust Me --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 8d9603b..8e68363 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -374,18 +374,6 @@ QAccessible::State state(QWidget * const widget) return state; } -void printState(QWidget * const widget) -{ - qDebug() << "State for" << widget->metaObject()->className() << stateNames(state(widget)); -} - -void printState(QAccessibleInterface * const iface, const int child = 0) -{ - qDebug() << "State for" << iface->object()->metaObject()->className() << "child" << child - << iface->text(QAccessible::Name, child) << stateNames(iface->state(child)); -} - - class QtTestAccessibleWidget: public QWidget { Q_OBJECT -- cgit v0.12 From d8dc5bfdff25d72e8276c6e80080d72315abe7e0 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 13:55:05 +1000 Subject: Remove Q_ASSERT from accessibility autotest Instead of crashing when we can't get a QAccessibleInterface for a widget, output a useful warning and return a value that makes the test fail gracefully. Change-Id: I0b292cdd8f5a59e26bdc9b0b67cea2b58591df7d Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 8e68363..fe0200a 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -368,8 +368,9 @@ static QString stateNames(int state) QAccessible::State state(QWidget * const widget) { QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget); - Q_ASSERT(iface); - QAccessible::State state = iface->state(0); + if (!iface) + qWarning() << "Cannot get QAccessibleInterface for widget"; + QAccessible::State state = (iface ? iface->state(0) : static_cast<QAccessible::State>(0)); delete iface; return state; } -- cgit v0.12 From 1a98c473fbcbb6a9edf1b7e42babbad7d901edb4 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 14:09:44 +1000 Subject: Remove unused function. Change-Id: I197ca88e04a68dca0ea819d6e335a02607e597aa Reviewed-by: Trust Me --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 42 ------------------------ 1 file changed, 42 deletions(-) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index fe0200a..35c9e4d 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -323,48 +323,6 @@ QString eventName(const int ev) } } -static QString stateNames(int state) -{ - QString stateString; - if (state == 0x00000000) stateString += " Normal"; - if (state & 0x00000001) stateString += " Unavailable"; - if (state & 0x00000002) stateString += " Selected"; - if (state & 0x00000004) stateString += " Focused"; - if (state & 0x00000008) stateString += " Pressed"; - if (state & 0x00000010) stateString += " Checked"; - if (state & 0x00000020) stateString += " Mixed"; - if (state & 0x00000040) stateString += " ReadOnly"; - if (state & 0x00000080) stateString += " HotTracked"; - if (state & 0x00000100) stateString += " DefaultButton"; - if (state & 0x00000200) stateString += " Expanded"; - if (state & 0x00000400) stateString += " Collapsed"; - if (state & 0x00000800) stateString += " Busy"; - if (state & 0x00001000) stateString += " Floating"; - if (state & 0x00002000) stateString += " Marqueed"; - if (state & 0x00004000) stateString += " Animated"; - if (state & 0x00008000) stateString += " Invisible"; - if (state & 0x00010000) stateString += " Offscreen"; - if (state & 0x00020000) stateString += " Sizeable"; - if (state & 0x00040000) stateString += " Moveable"; - if (state & 0x00080000) stateString += " SelfVoicing"; - if (state & 0x00100000) stateString += " Focusable"; - if (state & 0x00200000) stateString += " Selectable"; - if (state & 0x00400000) stateString += " Linked"; - if (state & 0x00800000) stateString += " Traversed"; - if (state & 0x01000000) stateString += " MultiSelectable"; - if (state & 0x02000000) stateString += " ExtSelectable"; - if (state & 0x04000000) stateString += " AlertLow"; - if (state & 0x08000000) stateString += " AlertMedium"; - if (state & 0x10000000) stateString += " AlertHigh"; - if (state & 0x20000000) stateString += " Protected"; - if (state & 0x3fffffff) stateString += " Valid"; - - if (stateString.isEmpty()) - stateString = "Unknown state " + QString::number(state); - - return stateString; -} - QAccessible::State state(QWidget * const widget) { QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget); -- cgit v0.12 From cf911bc0d297ed30e615fd115b0d3ae574cb2412 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 15:31:09 +1000 Subject: If accessibility isn't built, don't try to test it Only build the autotest when the feature to be tested is in the Qt build. This is better than building and running an empty test. Change-Id: I67721f5f48296afcca64f761d12325f8e040f2d8 Reviewed-by: Rohan McGovern --- tests/auto/other.pro | 3 +- tests/auto/qaccessibility/qaccessibility.pro | 3 +- tests/auto/qaccessibility/tst_qaccessibility.cpp | 219 +---------------------- 3 files changed, 8 insertions(+), 217 deletions(-) diff --git a/tests/auto/other.pro b/tests/auto/other.pro index 89f9e53..655d666 100644 --- a/tests/auto/other.pro +++ b/tests/auto/other.pro @@ -5,7 +5,6 @@ TEMPLATE=subdirs SUBDIRS=\ # baselineexample \ Just an example demonstrating qbaselinetest usage lancelot \ - qaccessibility \ qalgorithms \ qcombobox \ qcssparser \ @@ -36,6 +35,8 @@ SUBDIRS=\ windowsmobile \ nativeimagehandleprovider +contains(QT_CONFIG, accessibility):SUBDIRS += qaccessibility + contains(QT_CONFIG, OdfWriter):SUBDIRS += qzip qtextodfwriter mac: { SUBDIRS += macgui \ diff --git a/tests/auto/qaccessibility/qaccessibility.pro b/tests/auto/qaccessibility/qaccessibility.pro index a4f606c..71d6f95 100644 --- a/tests/auto/qaccessibility/qaccessibility.pro +++ b/tests/auto/qaccessibility/qaccessibility.pro @@ -1,4 +1,5 @@ load(qttest_p4) +requires(contains(QT_CONFIG,accessibility)) SOURCES += tst_qaccessibility.cpp unix:!mac:LIBS+=-lm @@ -8,4 +9,4 @@ wince*: { accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll accessneeded.path = accessible DEPLOYMENT += accessneeded -} \ No newline at end of file +} diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 35c9e4d..888f449 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -347,7 +347,6 @@ public: } }; -#ifdef QTEST_ACCESSIBILITY class QtTestAccessibleWidgetIface: public QAccessibleWidget { public: @@ -365,7 +364,6 @@ public: return 0; } }; -#endif tst_QAccessibility::tst_QAccessibility() { @@ -377,17 +375,13 @@ tst_QAccessibility::~tst_QAccessibility() void tst_QAccessibility::initTestCase() { -#ifdef QTEST_ACCESSIBILITY QTestAccessibility::initialize(); QAccessible::installFactory(QtTestAccessibleWidgetIface::ifaceFactory); -#endif } void tst_QAccessibility::cleanupTestCase() { -#ifdef QTEST_ACCESSIBILITY QTestAccessibility::cleanup(); -#endif } void tst_QAccessibility::init() @@ -397,7 +391,6 @@ void tst_QAccessibility::init() void tst_QAccessibility::cleanup() { -#ifdef QTEST_ACCESSIBILITY const EventList list = QTestAccessibility::events(); if (!list.isEmpty()) { qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(), @@ -407,14 +400,10 @@ void tst_QAccessibility::cleanup() eventName(list.at(i).event).toAscii().constData(), list.at(i).event, list.at(i).child); } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::eventTest() { -#ifdef QTEST_ACCESSIBILITY QPushButton* button = new QPushButton(0); button->setObjectName(QString("Olaf")); @@ -430,14 +419,10 @@ void tst_QAccessibility::eventTest() QVERIFY_EVENT(button, 0, QAccessible::ObjectHide); delete button; -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::customWidget() { -#ifdef QTEST_ACCESSIBILITY QtTestAccessibleWidget* widget = new QtTestAccessibleWidget(0, "Heinz"); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget); @@ -449,14 +434,10 @@ void tst_QAccessibility::customWidget() delete iface; delete widget; -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::deletedWidget() { -#ifdef QTEST_ACCESSIBILITY QtTestAccessibleWidget *widget = new QtTestAccessibleWidget(0, "Ralf"); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(widget); QVERIFY(iface != 0); @@ -467,9 +448,6 @@ void tst_QAccessibility::deletedWidget() widget = 0; QVERIFY(!iface->isValid()); delete iface; -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } QWidget *tst_QAccessibility::createGUI() @@ -478,7 +456,6 @@ QWidget *tst_QAccessibility::createGUI() qWarning( "Should never get here without Qt3Support"); return 0; #else -# ifdef QTEST_ACCESSIBILITY QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint); QGridLayout *grid = new QGridLayout(toplevel, 2, 2); @@ -550,10 +527,6 @@ QWidget *tst_QAccessibility::createGUI() radioAM->setFocus(); QTestAccessibility::clearEvents(); return toplevel; -# else - Q_ASSERT(0); // this function cannot be called without accessibility support - return 0; -# endif #endif // !QT3_SUPPORT } @@ -562,7 +535,6 @@ void tst_QAccessibility::childAt() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY QWidget *toplevel = createGUI(); QAccessibleInterface *acc_toplevel = QAccessible::queryAccessibleInterface(toplevel); QVERIFY(acc_toplevel); @@ -594,9 +566,6 @@ void tst_QAccessibility::childAt() delete acc_toplevel; delete toplevel; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // !QT3_SUPPORT } @@ -605,7 +574,6 @@ void tst_QAccessibility::childCount() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY QWidget *toplevel = createGUI(); QObject *topLeft = toplevel->child("topLeft"); QObject *topRight = toplevel->child("topRight"); @@ -638,9 +606,6 @@ void tst_QAccessibility::childCount() delete acc_bottomRight; delete toplevel; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // !QT3_SUPPORT } @@ -649,7 +614,6 @@ void tst_QAccessibility::relationTo() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY QWidget *toplevel = createGUI(); toplevel->resize(400,300); QObject *topLeft = toplevel->child("topLeft"); @@ -855,15 +819,11 @@ void tst_QAccessibility::relationTo() delete toplevel; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // !QT3_SUPPORT } void tst_QAccessibility::navigateGeometric() { -#ifdef QTEST_ACCESSIBILITY { static const int skip = 20; //speed the test up significantly static const double step = Q_PI / 180; @@ -959,14 +919,10 @@ void tst_QAccessibility::navigateGeometric() delete w; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::navigateSlider() { -#ifdef QTEST_ACCESSIBILITY { QSlider *slider = new QSlider(0); slider->setObjectName(QString("Slidy")); @@ -993,14 +949,10 @@ void tst_QAccessibility::navigateSlider() delete slider; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::navigateCovered() { -#ifdef QTEST_ACCESSIBILITY { QWidget *w = new QWidget(0); w->setObjectName(QString("Harry")); @@ -1103,14 +1055,10 @@ void tst_QAccessibility::navigateCovered() delete w; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::navigateHierarchy() { -#ifdef QTEST_ACCESSIBILITY { QWidget *w = new QWidget(0); w->setObjectName(QString("Hans")); @@ -1206,9 +1154,6 @@ void tst_QAccessibility::navigateHierarchy() delete w; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } #define QSETCOMPARE(thetypename, elements, otherelements) \ @@ -1219,7 +1164,6 @@ void tst_QAccessibility::navigateControllers() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY { Q3VBox vbox; QSlider slider(&vbox); @@ -1302,9 +1246,6 @@ void tst_QAccessibility::navigateControllers() delete acc_slider; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // !QT3_SUPPORT } @@ -1313,7 +1254,6 @@ void tst_QAccessibility::navigateLabels() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY { Q3VBox vbox; Q3HBox hbox(&vbox); @@ -1435,9 +1375,6 @@ void tst_QAccessibility::navigateLabels() delete acc_lineedit3; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // !QT3_SUPPORT } @@ -1489,7 +1426,6 @@ static QWidget *createWidgets() void tst_QAccessibility::accessibleName() { -#ifdef QTEST_ACCESSIBILITY QWidget *toplevel = createWidgets(); toplevel->show(); #if defined(Q_WS_X11) @@ -1514,9 +1450,6 @@ void tst_QAccessibility::accessibleName() delete toplevel; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::text() @@ -1524,7 +1457,6 @@ void tst_QAccessibility::text() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY QWidget *toplevel = createGUI(); toplevel->show(); #if defined(Q_WS_X11) @@ -1620,10 +1552,6 @@ void tst_QAccessibility::text() delete toplevel; QTestAccessibility::clearEvents(); - -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // !QT3_SUPPORT } @@ -1632,7 +1560,6 @@ void tst_QAccessibility::setText() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY QWidget *toplevel = createGUI(); toplevel->show(); QObject *bottomLeft = toplevel->findChild<QObject *>("bottomLeft"); @@ -1656,16 +1583,11 @@ void tst_QAccessibility::setText() delete acc_lineedit; delete toplevel; QTestAccessibility::clearEvents(); - -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif //QT3_SUPPORT } void tst_QAccessibility::hideShowTest() { -#ifdef QTEST_ACCESSIBILITY QWidget * const window = new QWidget(); QWidget * const child = new QWidget(window); @@ -1692,14 +1614,10 @@ void tst_QAccessibility::hideShowTest() delete window; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::userActionCount() { -#ifdef QTEST_ACCESSIBILITY QWidget widget; QAccessibleInterface *test = QAccessible::queryAccessibleInterface(&widget); @@ -1729,14 +1647,10 @@ void tst_QAccessibility::userActionCount() QCOMPARE(test->userActionCount(1), 0); QCOMPARE(test->userActionCount(-1), 0); delete test; test = 0; -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::actionText() { -#ifdef QTEST_ACCESSIBILITY QWidget widget; widget.show(); @@ -1753,24 +1667,15 @@ void tst_QAccessibility::actionText() QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QString("SetFocus")); delete test; test = 0; - -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::doAction() { -#ifdef QTEST_ACCESSIBILITY QSKIP("TODO: Implement me", SkipAll); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::buttonTest() { -//#ifdef QTEST_ACCESSIBILITY #if 0 QAccessibleInterface *test = 0; Q3VBox vbox; @@ -1949,9 +1854,7 @@ void tst_QAccessibility::buttonTest() test->release(); QTestAccessibility::clearEvents(); - #else -// QSKIP("Test needs accessibility support.", SkipAll); QSKIP("No action interface in Qt 4 yet.", SkipAll); #endif } @@ -1961,7 +1864,6 @@ void tst_QAccessibility::sliderTest() #if !defined(QT3_SUPPORT) QSKIP("This test needs Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY QAccessibleInterface *test = 0; Q3VBox vbox; QLabel labelHorizontal("Horizontal", &vbox); @@ -1990,7 +1892,7 @@ void tst_QAccessibility::sliderTest() QCOMPARE(test->text(QAccessible::Value, 1), QString()); QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal.value())); QCOMPARE(test->text(QAccessible::Value, 3), QString()); -// Skip acton tests. +// Skip action tests. #if 0 QCOMPARE(test->defaultAction(0), QAccessible::SetFocus); QCOMPARE(test->defaultAction(1), QAccessible::Press); @@ -2037,7 +1939,7 @@ void tst_QAccessibility::sliderTest() QCOMPARE(test->text(QAccessible::Value, 1), QString()); QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical.value())); QCOMPARE(test->text(QAccessible::Value, 3), QString()); -// Skip acton tests. +// Skip action tests. #if 0 QCOMPARE(test->defaultAction(0), QAccessible::SetFocus); QCOMPARE(test->defaultAction(1), QAccessible::Press); @@ -2148,17 +2050,12 @@ void tst_QAccessibility::sliderTest() delete sliderInterface; } - QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif //!QT3_SUPPORT } void tst_QAccessibility::scrollBarTest() { -#ifdef QTEST_ACCESSIBILITY // Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the // Invisible state bit set. enum SubControls { LineUp = 1, @@ -2166,7 +2063,7 @@ void tst_QAccessibility::scrollBarTest() Position = 3, PageDown = 4, LineDown = 5 - }; + }; QScrollBar *scrollBar = new QScrollBar(); QAccessibleInterface * const scrollBarInterface = QAccessible::queryAccessibleInterface(scrollBar); @@ -2248,15 +2145,10 @@ void tst_QAccessibility::scrollBarTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif - } void tst_QAccessibility::tabTest() { -#ifdef QTEST_ACCESSIBILITY QTabBar *tabBar = new QTabBar(); tabBar->show(); @@ -2292,14 +2184,10 @@ void tst_QAccessibility::tabTest() delete tabBar; delete interface; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::menuTest() { -#ifdef QTEST_ACCESSIBILITY { QMainWindow mw; mw.resize(300, 200); @@ -2545,14 +2433,10 @@ void tst_QAccessibility::menuTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll); -#endif } void tst_QAccessibility::spinBoxTest() { -#ifdef QTEST_ACCESSIBILITY QSpinBox * const spinBox = new QSpinBox(); spinBox->show(); @@ -2579,14 +2463,10 @@ void tst_QAccessibility::spinBoxTest() QVERIFY(events.contains(expectedEvent)); delete spinBox; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::doubleSpinBoxTest() { -#ifdef QTEST_ACCESSIBILITY QDoubleSpinBox *doubleSpinBox = new QDoubleSpinBox; doubleSpinBox->show(); @@ -2606,14 +2486,10 @@ void tst_QAccessibility::doubleSpinBoxTest() delete doubleSpinBox; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::textEditTest() { -#ifdef QTEST_ACCESSIBILITY { QTextEdit edit; QString text = "hello world\nhow are you today?\n"; @@ -2628,14 +2504,10 @@ void tst_QAccessibility::textEditTest() QCOMPARE(iface->text(QAccessible::Value, 6), QString()); } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::textBrowserTest() { -#ifdef QTEST_ACCESSIBILITY { QTextBrowser textBrowser; QString text = QLatin1String("Hello world\nhow are you today?\n"); @@ -2652,14 +2524,10 @@ void tst_QAccessibility::textBrowserTest() QCOMPARE(interface->text(QAccessible::Value, 6), QString()); } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::listViewTest() { -#if 1 //def QTEST_ACCESSIBILITY { QListView listView; QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&listView); @@ -2725,15 +2593,11 @@ void tst_QAccessibility::listViewTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::mdiAreaTest() { -#ifdef QTEST_ACCESSIBILITY { QMdiArea mdiArea; mdiArea.resize(400,300); @@ -2782,14 +2646,10 @@ void tst_QAccessibility::mdiAreaTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::mdiSubWindowTest() { -#ifdef QTEST_ACCESSIBILITY { QMdiArea mdiArea; mdiArea.show(); @@ -2912,14 +2772,10 @@ void tst_QAccessibility::mdiSubWindowTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::lineEditTest() { -#ifdef QTEST_ACCESSIBILITY QLineEdit *le = new QLineEdit; QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(le); QVERIFY(iface); @@ -2977,14 +2833,10 @@ void tst_QAccessibility::lineEditTest() delete le2; delete toplevel; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::workspaceTest() { -#ifdef QTEST_ACCESSIBILITY { QWorkspace workspace; workspace.resize(400,300); @@ -3038,14 +2890,10 @@ void tst_QAccessibility::workspaceTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::dialogButtonBoxTest() { -#ifdef QTEST_ACCESSIBILITY { QDialogButtonBox box(QDialogButtonBox::Reset | QDialogButtonBox::Help | @@ -3158,14 +3006,10 @@ void tst_QAccessibility::dialogButtonBoxTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::dialTest() { -#ifdef QTEST_ACCESSIBILITY { QDial dial; dial.setValue(20); @@ -3207,28 +3051,20 @@ void tst_QAccessibility::dialTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::rubberBandTest() { -#ifdef QTEST_ACCESSIBILITY QRubberBand rubberBand(QRubberBand::Rectangle); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&rubberBand); QVERIFY(interface); QCOMPARE(interface->role(0), QAccessible::Border); delete interface; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::abstractScrollAreaTest() { -#ifdef QTEST_ACCESSIBILITY { QAbstractScrollArea abstractScrollArea; @@ -3386,14 +3222,10 @@ void tst_QAccessibility::abstractScrollAreaTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::scrollAreaTest() { -#ifdef QTEST_ACCESSIBILITY { QScrollArea scrollArea; scrollArea.show(); @@ -3407,14 +3239,10 @@ void tst_QAccessibility::scrollAreaTest() delete interface; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::tableWidgetTest() { -#ifdef QTEST_ACCESSIBILITY { QWidget *topLevel = new QWidget; QTableWidget *w = new QTableWidget(8,4,topLevel); @@ -3454,10 +3282,6 @@ void tst_QAccessibility::tableWidgetTest() delete topLevel; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif - } class QtTestTableModel: public QAbstractTableModel @@ -3540,7 +3364,6 @@ public: void tst_QAccessibility::tableViewTest() { -#ifdef QTEST_ACCESSIBILITY { QtTestTableModel *model = new QtTestTableModel(3, 4); QTableView *w = new QTableView(); @@ -3620,15 +3443,11 @@ void tst_QAccessibility::tableViewTest() delete model; } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::calendarWidgetTest() { #ifndef QT_NO_CALENDARWIDGET -#ifdef QTEST_ACCESSIBILITY { QCalendarWidget calendarWidget; @@ -3721,17 +3540,12 @@ void tst_QAccessibility::calendarWidgetTest() } QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // QT_NO_CALENDARWIDGET } void tst_QAccessibility::dockWidgetTest() { #ifndef QT_NO_DOCKWIDGET - -#ifdef QTEST_ACCESSIBILITY // Set up a proper main window with two dock widgets QMainWindow *mw = new QMainWindow(); QFrame *central = new QFrame(mw); @@ -3799,19 +3613,14 @@ void tst_QAccessibility::dockWidgetTest() delete dock2; delete mw; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif // QT_NO_DOCKWIDGET } void tst_QAccessibility::pushButtonTest() { #if !defined(QT3_SUPPORT) - qWarning( "Should never get here without Qt3Support"); - return ; + QSKIP( "Should never get here without Qt3Support", SkipAll); #else -#ifdef QTEST_ACCESSIBILITY // Set up a proper main window with two dock widgets QWidget *toplevel = createGUI(); QObject *topRight = toplevel->findChild<QObject *>("topRight"); @@ -3845,15 +3654,11 @@ void tst_QAccessibility::pushButtonTest() delete accToplevel; delete toplevel; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif #endif //QT3_SUPPORT } void tst_QAccessibility::comboBoxTest() { -#ifdef QTEST_ACCESSIBILITY #if defined(Q_OS_WINCE) if (!IsValidCEPlatform()) { QSKIP("Test skipped on Windows Mobile test hardware", SkipAll); @@ -3891,15 +3696,10 @@ void tst_QAccessibility::comboBoxTest() delete w; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif - } void tst_QAccessibility::treeWidgetTest() { -#ifdef QTEST_ACCESSIBILITY QWidget *w = new QWidget; QTreeWidget *tree = new QTreeWidget(w); QHBoxLayout *l = new QHBoxLayout(w); @@ -3957,14 +3757,10 @@ void tst_QAccessibility::treeWidgetTest() delete w; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::labelTest() { -#ifdef QTEST_ACCESSIBILITY QString text = "Hello World"; QLabel *label = new QLabel(text); label->show(); @@ -4003,14 +3799,10 @@ void tst_QAccessibility::labelTest() delete acc_label; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs accessibility support.", SkipAll); -#endif } void tst_QAccessibility::accelerators() { -#ifdef QTEST_ACCESSIBILITY QWidget *window = new QWidget; QHBoxLayout *lay = new QHBoxLayout(window); QLabel *label = new QLabel(tr("&Line edit"), window); @@ -4043,9 +3835,6 @@ void tst_QAccessibility::accelerators() QTest::qWait(100); delete window; QTestAccessibility::clearEvents(); -#else - QSKIP("Test needs Qt >= 0x040000 and accessibility support.", SkipAll); -#endif } -- cgit v0.12 From 3ca51d87296bcb3098d7de14294fef9294fd5ed4 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 16:15:57 +1000 Subject: Ignore expected warning in accessibility autotest Change-Id: I4b614766d2451dde51ab1207267301a2fe7dd0f6 Reviewed-by: Rohan McGovern --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 888f449..ebd01bb 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -3826,6 +3826,8 @@ void tst_QAccessibility::accelerators() QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A")); label->setText(tr("Q &&A")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString()); + + QTest::ignoreMessage(QtWarningMsg, "QKeySequence::mnemonic: \"Q &A&B\" contains multiple occurrences of '&'"); label->setText(tr("Q &A&B")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A")); -- cgit v0.12 From bf1d860143ff40330c6e8f3e2872f2ae812adaa7 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 17:15:24 +1000 Subject: Fix remaining warnings in accessibility autotest Prevent warnings about unhandled accessibility events by managing object lifetimes appropriately. Change-Id: If72a2a6a76527ff746b99634c2d0895354570724 Reviewed-by: Rohan McGovern --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 72 +++++++++++++----------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index ebd01bb..e5e3e77 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -1651,10 +1651,10 @@ void tst_QAccessibility::userActionCount() void tst_QAccessibility::actionText() { - QWidget widget; - widget.show(); + QWidget *widget = new QWidget; + widget->show(); - QAccessibleInterface *test = QAccessible::queryAccessibleInterface(&widget); + QAccessibleInterface *test = QAccessible::queryAccessibleInterface(widget); QVERIFY(test); QVERIFY(test->isValid()); @@ -1666,7 +1666,10 @@ void tst_QAccessibility::actionText() QCOMPARE(test->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("SetFocus")); QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QString("SetFocus")); - delete test; test = 0; + delete test; + delete widget; + + QTestAccessibility::clearEvents(); } void tst_QAccessibility::doAction() @@ -1865,18 +1868,18 @@ void tst_QAccessibility::sliderTest() QSKIP("This test needs Qt3Support", SkipAll); #else QAccessibleInterface *test = 0; - Q3VBox vbox; - QLabel labelHorizontal("Horizontal", &vbox); - QSlider sliderHorizontal(Qt::Horizontal, &vbox); - labelHorizontal.setBuddy(&sliderHorizontal); + Q3VBox *vbox = new Q3VBox; + QLabel *labelHorizontal = new QLabel("Horizontal", vbox); + QSlider *sliderHorizontal = new QSlider(Qt::Horizontal, vbox); + labelHorizontal->setBuddy(sliderHorizontal); - QLabel labelVertical("Vertical", &vbox); - QSlider sliderVertical(Qt::Vertical, &vbox); - labelVertical.setBuddy(&sliderVertical); - vbox.show(); + QLabel *labelVertical = new QLabel("Vertical", vbox); + QSlider *sliderVertical = new QSlider(Qt::Vertical, vbox); + labelVertical->setBuddy(sliderVertical); + vbox->show(); // test horizontal slider - test = QAccessible::queryAccessibleInterface(&sliderHorizontal); + test = QAccessible::queryAccessibleInterface(sliderHorizontal); QVERIFY(test); QCOMPARE(test->childCount(), 3); QCOMPARE(test->role(0), QAccessible::Slider); @@ -1884,13 +1887,13 @@ void tst_QAccessibility::sliderTest() QCOMPARE(test->role(2), QAccessible::Indicator); QCOMPARE(test->role(3), QAccessible::PushButton); - QCOMPARE(test->text(QAccessible::Name, 0), labelHorizontal.text()); + QCOMPARE(test->text(QAccessible::Name, 0), labelHorizontal->text()); QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page left")); QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position")); QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page right")); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.value())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->value())); QCOMPARE(test->text(QAccessible::Value, 1), QString()); - QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal.value())); + QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderHorizontal->value())); QCOMPARE(test->text(QAccessible::Value, 3), QString()); // Skip action tests. #if 0 @@ -1904,26 +1907,26 @@ void tst_QAccessibility::sliderTest() QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease")); QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press")); QVERIFY(test->doAction(QAccessible::Press, 3)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.pageStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep())); QVERIFY(test->doAction(QAccessible::Press, 3)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal.pageStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->pageStep())); QVERIFY(test->doAction(QAccessible::Press, 1)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.pageStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->pageStep())); QVERIFY(test->doAction(QAccessible::Press, 1)); QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0)); QVERIFY(test->doAction(QAccessible::Increase, 2)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.lineStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep())); QVERIFY(test->doAction(QAccessible::Increase, 2)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal.lineStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderHorizontal->lineStep())); QVERIFY(test->doAction(QAccessible::Decrease, 2)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal.lineStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderHorizontal->lineStep())); QVERIFY(test->doAction(QAccessible::Decrease, 2)); QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0)); #endif delete test; // test vertical slider - test = QAccessible::queryAccessibleInterface(&sliderVertical); + test = QAccessible::queryAccessibleInterface(sliderVertical); QVERIFY(test); QCOMPARE(test->childCount(), 3); QCOMPARE(test->role(0), QAccessible::Slider); @@ -1931,13 +1934,13 @@ void tst_QAccessibility::sliderTest() QCOMPARE(test->role(2), QAccessible::Indicator); QCOMPARE(test->role(3), QAccessible::PushButton); - QCOMPARE(test->text(QAccessible::Name, 0), labelVertical.text()); + QCOMPARE(test->text(QAccessible::Name, 0), labelVertical->text()); QCOMPARE(test->text(QAccessible::Name, 1), QSlider::tr("Page up")); QCOMPARE(test->text(QAccessible::Name, 2), QSlider::tr("Position")); QCOMPARE(test->text(QAccessible::Name, 3), QSlider::tr("Page down")); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.value())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->value())); QCOMPARE(test->text(QAccessible::Value, 1), QString()); - QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical.value())); + QCOMPARE(test->text(QAccessible::Value, 2), QString::number(sliderVertical->value())); QCOMPARE(test->text(QAccessible::Value, 3), QString()); // Skip action tests. #if 0 @@ -1951,23 +1954,28 @@ void tst_QAccessibility::sliderTest() QCOMPARE(test->actionText(QAccessible::Decrease, QAccessible::Name, 2), QSlider::tr("Decrease")); QCOMPARE(test->actionText(QAccessible::Press, QAccessible::Name, 3), QSlider::tr("Press")); QVERIFY(test->doAction(QAccessible::Press, 3)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.pageStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep())); QVERIFY(test->doAction(QAccessible::Press, 3)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical.pageStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->pageStep())); QVERIFY(test->doAction(QAccessible::Press, 1)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.pageStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->pageStep())); QVERIFY(test->doAction(QAccessible::Press, 1)); QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0)); QVERIFY(test->doAction(QAccessible::Increase, 2)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.lineStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep())); QVERIFY(test->doAction(QAccessible::Increase, 2)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical.lineStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(2*sliderVertical->lineStep())); QVERIFY(test->doAction(QAccessible::Decrease, 2)); - QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical.lineStep())); + QCOMPARE(test->text(QAccessible::Value, 0), QString::number(sliderVertical->lineStep())); QVERIFY(test->doAction(QAccessible::Decrease, 2)); QCOMPARE(test->text(QAccessible::Value, 0), QString::number(0)); #endif delete test; + delete sliderHorizontal; + delete sliderVertical; + delete labelHorizontal; + delete labelVertical; + delete vbox; // Test that when we hide() a slider, the PageLeft, Indicator, and PageRight also gets the // Invisible state bit set. -- cgit v0.12 From 70f42ced8e01ddf0098b143e5804c22d55ebf16f Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 19 Apr 2011 18:02:33 +1000 Subject: Remove Q_ASSERT from qatomicint/pointer autotests Some code in these tests is not intended to be executed, but rather to detect compiler warnings. Instead of having an obscure fatal error if this code is run in a debug build, it now has a clear fatal error if run in any build. Change-Id: I1c9d27bb14ebf3313865b68e3e57668ba1d14e25 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qatomicint/tst_qatomicint.cpp | 3 +-- tests/auto/qatomicpointer/tst_qatomicpointer.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/auto/qatomicint/tst_qatomicint.cpp b/tests/auto/qatomicint/tst_qatomicint.cpp index 717187a..5ccb997 100644 --- a/tests/auto/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/qatomicint/tst_qatomicint.cpp @@ -116,8 +116,7 @@ tst_QAtomicInt::~tst_QAtomicInt() void tst_QAtomicInt::warningFreeHelper() { - Q_ASSERT(false); - // The code below is bogus, and shouldn't be run. We're looking for warnings, only. + qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only."); QBasicAtomicInt i = Q_BASIC_ATOMIC_INITIALIZER(0); diff --git a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp index af8fabc..05f8294 100644 --- a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp @@ -98,8 +98,7 @@ struct WFHC void tst_QAtomicPointer::warningFreeHelper() { - Q_ASSERT(false); - // The code below is bogus, and shouldn't be run. We're looking for warnings, only. + qFatal("This code is bogus, and shouldn't be run. We're looking for compiler warnings only."); QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0); -- cgit v0.12 From 34c077faae538adc12d4aa28113640570dfc8728 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 20 Apr 2011 11:05:55 +1000 Subject: Remove Q_ASSERT from qcompleter autotest. Replace obscure failure on bad test data in debug builds with an informative warning in all builds. Change-Id: I9001820f34de2f78bf296a2f0e095ce73d9ac4bd Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qcompleter/tst_qcompleter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index afcc433..9cb2468 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -277,7 +277,9 @@ retry: case 'L': row = completer->completionCount() - 1; break; case 'F': row = 0; break; default: - Q_ASSERT(false); + QFAIL(qPrintable(QString( + "Problem with 'step' value in test data: %1 (only P, N, L and F are allowed)." + ).arg(step[i]))); } completer->setCurrentRow(row); } -- cgit v0.12 From 67bc4990f7541cca089882a8c3be1b2b8d98cd4c Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 20 Apr 2011 11:39:14 +1000 Subject: Only ignore warning when it can actually be produced. Fix regression introduced in 3ca51d87296bcb3098d7de14294fef9294fd5ed4. The warning is only generated in builds where QT_NO_DEBUG is not defined. Change-Id: I9aa3db369094f4046062b5dc1dc694342208ee45 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index e5e3e77..2645090 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -3835,7 +3835,9 @@ void tst_QAccessibility::accelerators() label->setText(tr("Q &&A")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString()); +#ifndef QT_NO_DEBUG QTest::ignoreMessage(QtWarningMsg, "QKeySequence::mnemonic: \"Q &A&B\" contains multiple occurrences of '&'"); +#endif label->setText(tr("Q &A&B")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A")); -- cgit v0.12 From a5bd4abed834ce3670b2f28d4f932d612a033b36 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 20 Apr 2011 12:16:58 +1000 Subject: Remove Q_ASSERT from QCompleter autotest If a combobox had no completer, this test would assert in a debug build and crash in a release build. This commit makes the test report a test failure and avoid terminating in all builds. Change-Id: Ib2924412e3d55f10875675cb65079259cd4ef552 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qcompleter/tst_qcompleter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 9cb2468..b0d40d0 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -1278,10 +1278,11 @@ public: { setEditable(true); setInsertPolicy(NoInsert); - Q_ASSERT(completer()); - completer()->setCompletionMode(QCompleter::PopupCompletion); - completer()->setCompletionRole(Qt::DisplayRole); - connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix())); + if (completer()) { + completer()->setCompletionMode(QCompleter::PopupCompletion); + completer()->setCompletionRole(Qt::DisplayRole); + connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix())); + } } private slots: void setCompletionPrefix() { completer()->setCompletionPrefix(lineEdit()->text()); } @@ -1290,6 +1291,7 @@ private slots: void tst_QCompleter::task246056_setCompletionPrefix() { task246056_ComboBox *comboBox = new task246056_ComboBox; + QVERIFY(comboBox->completer()); comboBox->addItem(""); comboBox->addItem("a1"); comboBox->addItem("a2"); -- cgit v0.12 From 5a530f6171a9569d1a35cd8cd1015ec796b048cc Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 20 Apr 2011 15:11:23 +1000 Subject: Remove Q_ASSERT from qcopchannel autotest This code would assert in a debug build and potentially crash in a release build. (The behaviour of QStringList::at() with an out-of-bounds index is undefined.) This commit makes the program exit with a useful error message in all builds. Change-Id: Ia57a2e5693eb25d3eb0b9ba701ed485dfbc1e846 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qcopchannel/testSend/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qcopchannel/testSend/main.cpp b/tests/auto/qcopchannel/testSend/main.cpp index 91628e5..a56883b 100644 --- a/tests/auto/qcopchannel/testSend/main.cpp +++ b/tests/auto/qcopchannel/testSend/main.cpp @@ -49,7 +49,11 @@ int main(int argc, char** argv) #ifdef Q_WS_QWS QApplication app(argc, argv); QStringList args = app.arguments(); - Q_ASSERT(args.count() == 3 || args.count() == 4); + if (args.count() != 3 && args.count() != 4) { + fprintf(stdout,qPrintable(QString("Usage: %1 channel message [data]").arg(args.at(0)))); + fflush(stdout); + return 1; + } QString channelName = args.at(1); QString msg = args.at(2); QByteArray data; -- cgit v0.12 From e754832eff8e1a35fc2681ae69b6e3b1ad666ddb Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 20 Apr 2011 16:03:42 +1000 Subject: Remove Q_ASSERT from datetimeedit autotest The assert and the last four parameters of makeList() are not needed. The function is always used to make lists of three integers and the data are all >= 0. Change-Id: I93ae5a5f541cde2ff61bd9dd21164ed4a9b57403 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp index 98632ae..abbf00d 100644 --- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp @@ -2699,17 +2699,10 @@ void tst_QDateTimeEdit::task98554() QCOMPARE(testWidget->time(), QTime(0, 0, 10, 0)); } -static QList<int> makeList(int val1, int val2 = -1, int val3 = -1, int val4 = -1, int val5 = -1, int val6 = -1, int val7 = -1) +static QList<int> makeList(int val1, int val2, int val3) { QList<int> ret; - Q_ASSERT(val1 >= 0); - ret << val1; - if (val2 < 0) {return ret;} else {ret << val2;} - if (val3 < 0) {return ret;} else {ret << val3;} - if (val4 < 0) {return ret;} else {ret << val4;} - if (val5 < 0) {return ret;} else {ret << val5;} - if (val6 < 0) {return ret;} else {ret << val6;} - if (val7 >= 0) {ret << val2;} + ret << val1 << val2 << val3; return ret; } -- cgit v0.12 From 6181805f9ea66b37ee164bd67bdac2ac9d53fb65 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 20 Apr 2011 16:27:07 +1000 Subject: Remove Q_ASSERT from QDom autotest The Q_ASSERT here should really be a QVERIFY. Expanded the trivial helper function to make it more obvious what the test does. Change-Id: Ia6017fe820a83b4d6101e5edcfcb68993eef233a Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qdom/tst_qdom.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 18aa84a..f3b3e00 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -137,7 +137,6 @@ private slots: private: static QDomDocument generateRequest(); - static QDomDocument doc(const QString &title, const QByteArray &ba); static int hasAttributesHelper( const QDomNode& node ); static bool compareDocuments( const QDomDocument &doc1, const QDomDocument &doc2 ); static bool compareNodes( const QDomNode &node1, const QDomNode &node2, bool deep ); @@ -1591,14 +1590,6 @@ void tst_QDom::reportDuplicateAttributes() const QVERIFY2(!isSuccess, "Duplicate attributes are well-formedness errors, and should be reported as such."); } -QDomDocument tst_QDom::doc(const QString &title, const QByteArray &ba) -{ - QDomDocument doc(title); - const bool ret = doc.setContent(ba, true); - Q_ASSERT(ret); - return doc; -} - void tst_QDom::namespacedAttributes() const { static const char *const xml = @@ -1611,8 +1602,13 @@ void tst_QDom::namespacedAttributes() const " <Title displayLabel='Title' >>>> SIMPLE BASIC OP - SEND - DUT AS SINK</Title>\n" "</xan:td>\n"; - QDomDocument one = doc("document", xml); - QDomDocument two = doc("document2", one.toByteArray(2)); + QDomDocument one("document"); + QString error; + bool docParsed = one.setContent(QByteArray(xml), true, &error); + QVERIFY2(docParsed, qPrintable(error)); + QDomDocument two("document2"); + docParsed = two.setContent(one.toByteArray(2), true, &error); + QVERIFY2(docParsed, qPrintable(error)); QVERIFY(isDeepEqual(one, two)); } -- cgit v0.12 From b1eb564830ff1b754de14919ce5c1547e9758f7c Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 21 Apr 2011 11:15:35 +1000 Subject: Fix logic error in large file autotest The function generating data blocks was filling the block to 16 bytes short of the blockSize, then appending three 8 byte values, causing the block to grow 8 bytes beyond blockSize and then truncating it back to blockSize. This commit makes the code fill the block to 24 bytes short of the blockSize, so that the block will always end up at the correct size and truncation is not needed. Change-Id: I9fe6e6d6cf7bc445513b53e0a910d205c4c8002f Reviewed-by: Rohan McGovern --- tests/auto/qfile/largefile/tst_largefile.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index a9ad017..47f2e73 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -206,14 +206,13 @@ static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 u QByteArray filler("0123456789"); block.append(filler.right(10 - block.size() % 10)); - topUpWith(block, filler, blockSize - 2 * sizeof(qint64)); + topUpWith(block, filler, blockSize - 3 * sizeof(qint64)); appendRaw(block, counter); appendRaw(block, userBits); appendRaw(block, randomBits); - Q_ASSERT( block.size() >= blockSize ); - block.resize(blockSize); + Q_ASSERT( block.size() == blockSize ); ++counter; return block; -- cgit v0.12 From 59634e825f1efa6f32befc8767cafedfeb9b7d59 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 21 Apr 2011 13:00:06 +1000 Subject: Use meaningful variable names Make the meaning of the code more obvious and avoid a compiler warning about the variable "w" being overridden. Change-Id: Ib76d3aa1cae46e263b2ab61b675d9ef74032aacc Reviewed-by: Rohan McGovern --- .../tst_qgraphicsanchorlayout.cpp | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index e7c63d5..67e9b0a 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -132,33 +132,33 @@ static void setAnchor(QGraphicsAnchorLayout *l, anchor->setSpacing(spacing); } -static bool checkReverseDirection(QGraphicsWidget *w) +static bool checkReverseDirection(QGraphicsWidget *widget) { - QGraphicsLayout *l = w->layout(); - Q_ASSERT(l); + QGraphicsLayout *layout = widget->layout(); + Q_ASSERT(layout); qreal left, top, right, bottom; - l->getContentsMargins(&left, &top, &right, &bottom); - w->setLayoutDirection(Qt::LeftToRight); + layout->getContentsMargins(&left, &top, &right, &bottom); + widget->setLayoutDirection(Qt::LeftToRight); QApplication::processEvents(); - const QRectF lg = l->geometry(); + const QRectF layoutGeometry = layout->geometry(); QMap<QGraphicsLayoutItem *, QRectF> geometries; - for (int i = 0; i < l->count(); ++i) { - QGraphicsLayoutItem *w = l->itemAt(i); - geometries.insert(w, w->geometry()); + for (int i = 0; i < layout->count(); ++i) { + QGraphicsLayoutItem *item = layout->itemAt(i); + geometries.insert(item, item->geometry()); } - w->setLayoutDirection(Qt::RightToLeft); + widget->setLayoutDirection(Qt::RightToLeft); QApplication::processEvents(); - lg.adjusted(+right, +top, -left, -bottom); - for (int i = 0; i < l->count(); ++i) { - QGraphicsLayoutItem *w = l->itemAt(i); - const QRectF rtlGeom = w->geometry(); - const QRectF ltrGeom = geometries.value(w); - QRectF expectedGeom = ltrGeom; - expectedGeom.moveRight(lg.right() - (0 + ltrGeom.left())); - if (expectedGeom != rtlGeom) { - qDebug() << "layout->geometry():" << lg - << "expected:" << expectedGeom - << "actual:" << rtlGeom; + layoutGeometry.adjusted(+right, +top, -left, -bottom); + for (int i = 0; i < layout->count(); ++i) { + QGraphicsLayoutItem *item = layout->itemAt(i); + const QRectF rightToLeftGeometry = item->geometry(); + const QRectF leftToRightGeometry = geometries.value(item); + QRectF expectedGeometry = leftToRightGeometry; + expectedGeometry.moveRight(layoutGeometry.right() - leftToRightGeometry.left()); + if (expectedGeometry != rightToLeftGeometry) { + qDebug() << "layout->geometry():" << layoutGeometry + << "expected:" << expectedGeometry + << "actual:" << rightToLeftGeometry; return false; } } -- cgit v0.12 From 60e5ed805af1e11aaec426b823df209b4c895c29 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 21 Apr 2011 14:49:41 +1000 Subject: Only ignore warning when it can actually be produced. Fix regression introduced in 3ca51d87296bcb3098d7de14294fef9294fd5ed4. The warning is only generated in builds where QT_NO_DEBUG is not defined *and* the target is not Mac OS X. Change-Id: I7245f2eab8ea47ab7495fef874b2f8a29186b659 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index 2645090..254fdf7 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -3835,7 +3835,7 @@ void tst_QAccessibility::accelerators() label->setText(tr("Q &&A")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString()); -#ifndef QT_NO_DEBUG +#if !defined(QT_NO_DEBUG) && !defined(Q_WS_MAC) QTest::ignoreMessage(QtWarningMsg, "QKeySequence::mnemonic: \"Q &A&B\" contains multiple occurrences of '&'"); #endif label->setText(tr("Q &A&B")); -- cgit v0.12 From 2c2026df66f237b7313397dd74f6bc3212b94596 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Tue, 26 Apr 2011 12:34:00 +0200 Subject: Set the default graphics system to raster. This change is specific to Mac OS X/Cocoa. Reviewed-by: Lars Knoll --- src/gui/painting/qgraphicssystemfactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp index 62a60d7..6212674 100644 --- a/src/gui/painting/qgraphicssystemfactory.cpp +++ b/src/gui/painting/qgraphicssystemfactory.cpp @@ -74,7 +74,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key) if (system.isEmpty()) { system = QLatin1String("runtime"); } -#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) +#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) || (defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) if (system.isEmpty()) { system = QLatin1String("raster"); } -- cgit v0.12 From 244fedd484b022881b906b1bc794d5af19d02843 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Fri, 29 Apr 2011 12:26:08 +0200 Subject: Change the repaint() to an update(). Forcing to repaint might cause a recursive repaint. Since there is no apparent reason to directly repaint, we just call update(). Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 354f05b..8dc9d2e 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2733,7 +2733,7 @@ QWidget::macCGHandle() const return handle(); } -void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget) +void qt_mac_updateParentUnderAlienWidget(QWidget *alienWidget) { QWidget *nativeParent = alienWidget->nativeParentWidget(); if (!nativeParent) @@ -2741,7 +2741,7 @@ void qt_mac_repaintParentUnderAlienWidget(QWidget *alienWidget) QPoint globalPos = alienWidget->mapToGlobal(QPoint(0, 0)); QRect dirtyRect = QRect(nativeParent->mapFromGlobal(globalPos), alienWidget->size()); - nativeParent->repaint(dirtyRect); + nativeParent->update(dirtyRect); } void QWidget::destroy(bool destroyWindow, bool destroySubWindows) @@ -2752,7 +2752,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) if (!isWindow() && parentWidget()) parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry())); if (!internalWinId()) - qt_mac_repaintParentUnderAlienWidget(this); + qt_mac_updateParentUnderAlienWidget(this); d->deactivateWidgetCleanup(); qt_mac_event_release(this); if(testAttribute(Qt::WA_WState_Created)) { @@ -3683,7 +3683,7 @@ void QWidgetPrivate::hide_sys() [view setHidden:YES]; } else { // INVARIANT: q is alien. Repaint where q is placed instead: - qt_mac_repaintParentUnderAlienWidget(q); + qt_mac_updateParentUnderAlienWidget(q); } #endif } -- cgit v0.12 From 78821cd51c69757a7b4e711c495e702adf97d682 Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Fri, 29 Apr 2011 16:46:33 +0200 Subject: Revert symbol addition in b033bb9 Because it breaks forward compatibility. We will use the original fix in 4.8. In 4.7 we just make sure it doesn't crash in QTextBlock::next(). Reviewed-by: Thiago Macieira --- src/gui/text/qtextobject.cpp | 7 +------ src/gui/text/qtextobject.h | 2 +- src/s60installs/eabi/QtGuiu.def | 1 - tests/auto/qtextblock/tst_qtextblock.cpp | 12 ------------ 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index a403cc5..2a93f67 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -891,11 +891,6 @@ QTextBlockUserData::~QTextBlockUserData() Returns true if this text block is valid; otherwise returns false. */ -bool QTextBlock::isValid() const -{ - return p != 0 && p->blockMap().isValid(n); -} - /*! \fn QTextBlock &QTextBlock::operator=(const QTextBlock &other) @@ -1493,7 +1488,7 @@ QTextBlock::iterator QTextBlock::end() const */ QTextBlock QTextBlock::next() const { - if (!isValid()) + if (!isValid() || !p->blockMap().isValid(n)) return QTextBlock(); return QTextBlock(p, p->blockMap().next(n)); diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index 73aed79..d5c1e8d 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -204,7 +204,7 @@ public: inline QTextBlock(const QTextBlock &o) : p(o.p), n(o.n) {} inline QTextBlock &operator=(const QTextBlock &o) { p = o.p; n = o.n; return *this; } - bool isValid() const; + inline bool isValid() const { return p != 0 && n != 0; } inline bool operator==(const QTextBlock &o) const { return p == o.p && n == o.n; } inline bool operator!=(const QTextBlock &o) const { return p != o.p || n != o.n; } diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 799ac43..fafa07b 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12183,5 +12183,4 @@ EXPORTS _ZN15QGraphicsSystem22releaseCachedResourcesEv @ 12182 NONAME _Z32qt_s60_setPartialScreenInputModeb @ 12183 NONAME _Z29qt_draw_decoration_for_glyphsP8QPainterPKjPK11QFixedPointiP11QFontEngineRK5QFontRK15QTextCharFormat @ 12184 NONAME - _ZNK10QTextBlock7isValidEv @ 12185 NONAME diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp index 748d921..cec3a6a 100644 --- a/tests/auto/qtextblock/tst_qtextblock.cpp +++ b/tests/auto/qtextblock/tst_qtextblock.cpp @@ -76,7 +76,6 @@ private slots: void excludeParagraphSeparatorFragment(); void backwardsBlockIterator(); void previousBlock_qtbug18026(); - void removedBlock_qtbug18500(); private: QTextDocument *doc; @@ -182,16 +181,5 @@ void tst_QTextBlock::previousBlock_qtbug18026() QVERIFY(last.isValid()); } -void tst_QTextBlock::removedBlock_qtbug18500() -{ - cursor.insertText("line 1\nline 2\nline 3 \nline 4\n"); - cursor.setPosition(7); - QTextBlock block = cursor.block(); - cursor.setPosition(21, QTextCursor::KeepAnchor); - - cursor.removeSelectedText(); - QVERIFY(!block.isValid()); -} - QTEST_MAIN(tst_QTextBlock) #include "tst_qtextblock.moc" -- cgit v0.12 From 75d2387fbf005b022437855ab6433790372639f8 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Mon, 2 May 2011 10:52:25 +0200 Subject: Fix the update() autotest for raster. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the CoreGraphics engine, we expect the test to fail with update(), but with the raster engine the behavior is the same across platforms. Hence we don't need a special case for Mac OS X with the raster engine. Reviewed-by: Samuel Rødal --- tests/auto/qwidget/tst_qwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 35014c9..9c2f6ea 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -4738,7 +4738,8 @@ void tst_QWidget::update() QCOMPARE(w.visibleRegion(), expectedVisible); QCOMPARE(w.paintedRegion, expectedVisible); #ifdef QT_MAC_USE_COCOA - QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue); + if (QApplicationPrivate::graphics_system_name != QLatin1String("raster")) + QEXPECT_FAIL(0, "Cocoa compositor says to paint this.", Continue); #endif QCOMPARE(child.numPaintEvents, 0); -- cgit v0.12 From 6db0153cd7e35e4a919a76ae2aadbf2d2510bfb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= <bjorn.nilsen@nokia.com> Date: Mon, 2 May 2011 12:39:45 +0200 Subject: Fixes crash in QWidget::effectiveWinId. Widgets are left in a transitional (and incosistent) state while being re-parented, which caused QWidget::effectiveWinId() to crash in certain circumstances. See patch for more details. Auto test included. Reviewed-by: ogoffart --- src/gui/kernel/qwidget.cpp | 20 ++++++++++++++++++++ src/gui/kernel/qwidget_p.h | 1 + tests/auto/qwidget/tst_qwidget.cpp | 25 +++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index ac35d42..fcb098f 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -292,6 +292,7 @@ QWidgetPrivate::QWidgetPrivate(int version) #ifndef QT_NO_IM , inheritsInputMethodHints(0) #endif + , inSetParent(0) #if defined(Q_WS_X11) , picture(0) #elif defined(Q_WS_WIN) @@ -2563,6 +2564,22 @@ WId QWidget::effectiveWinId() const if (id || !testAttribute(Qt::WA_WState_Created)) return id; QWidget *realParent = nativeParentWidget(); + if (!realParent && d_func()->inSetParent) { + // In transitional state. This is really just a workaround. The real problem + // is that QWidgetPrivate::setParent_sys (platform specific code) first sets + // the window id to 0 (setWinId(0)) before it sets the Qt::WA_WState_Created + // attribute to false. The correct way is to do it the other way around, and + // in that case the Qt::WA_WState_Created logic above will kick in and + // return 0 whenever the widget is in a transitional state. However, changing + // the original logic for all platforms is far more intrusive and might + // break existing applications. + // Note: The widget can only be in a transitional state when changing its + // parent -- everything else is an internal error -- hence explicitly checking + // against 'inSetParent' rather than doing an unconditional return whenever + // 'realParent' is 0 (which may cause strange artifacts and headache later). + return 0; + } + // This widget *must* have a native parent widget. Q_ASSERT(realParent); Q_ASSERT(realParent->internalWinId()); return realParent->internalWinId(); @@ -10041,6 +10058,7 @@ void QWidget::setParent(QWidget *parent) void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) { Q_D(QWidget); + d->inSetParent = true; bool resized = testAttribute(Qt::WA_Resized); bool wasCreated = testAttribute(Qt::WA_WState_Created); QWidget *oldtlw = window(); @@ -10195,6 +10213,8 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) ancestorProxy->d_func()->embedSubWindow(this); } #endif + + d->inSetParent = false; } /*! diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 377e3a7..c9dba29 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -759,6 +759,7 @@ public: #ifndef QT_NO_IM uint inheritsInputMethodHints : 1; #endif + uint inSetParent : 1; // *************************** Platform specific ************************************ #if defined(Q_WS_X11) // <----------------------------------------------------------- X11 diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index bb8b8b4..a851d03 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -345,6 +345,7 @@ private slots: void immediateRepaintAfterInvalidateBuffer(); #endif void effectiveWinId(); + void effectiveWinId2(); void customDpi(); void customDpiProperty(); @@ -8522,6 +8523,30 @@ void tst_QWidget::effectiveWinId() QVERIFY(child.effectiveWinId()); } +void tst_QWidget::effectiveWinId2() +{ + QWidget parent; + + class MyWidget : public QWidget { + bool event(QEvent *e) + { + if (e->type() == QEvent::WinIdChange) { + // Shouldn't crash. + effectiveWinId(); + } + + return QWidget::event(e); + } + }; + + MyWidget child; + child.setParent(&parent); + parent.show(); + + child.setParent(0); + child.setParent(&parent); +} + class CustomWidget : public QWidget { public: -- cgit v0.12 From 2c64404e2edd3b792b8a1d04c773860d40c04c4c Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 21 Apr 2011 15:33:01 +1000 Subject: Remove Q_ASSERTs from qgraphicsanchorlayout1 test Sanity-check the test data when using it rather than when creating it. Change-Id: Ie5d5e1ff3fc439d196096f17cb6f97680927a90c Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../tst_qgraphicsanchorlayout1.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp index a03f7bc..ee25291 100644 --- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp +++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp @@ -2585,15 +2585,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data() sizeHints1.insert( Qt::MinimumSize, 30 ); sizeHints1.insert( Qt::PreferredSize, 35 ); sizeHints1.insert( Qt::MaximumSize, 40 ); - Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); SizeHintArray sizeHints2; sizeHints2.insert( Qt::MinimumSize, 5 ); sizeHints2.insert( Qt::PreferredSize, 35 ); sizeHints2.insert( Qt::MaximumSize, 300 ); - Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); const qreal width1 = 35; const qreal width2 = 100-10-10-10-width1; @@ -2605,15 +2601,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data() sizeHints1.insert( Qt::MinimumSize, 0 ); sizeHints1.insert( Qt::PreferredSize, 20 ); sizeHints1.insert( Qt::MaximumSize, 100 ); - Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); SizeHintArray sizeHints2; sizeHints2.insert( Qt::MinimumSize, 0 ); sizeHints2.insert( Qt::PreferredSize, 50 ); sizeHints2.insert( Qt::MaximumSize, 100 ); - Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); const qreal width1 = 20; const qreal width2 = 100-10-10-10-width1; @@ -2625,15 +2617,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data() sizeHints1.insert( Qt::MinimumSize, 0 ); sizeHints1.insert( Qt::PreferredSize, 40 ); sizeHints1.insert( Qt::MaximumSize, 100 ); - Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); SizeHintArray sizeHints2; sizeHints2.insert( Qt::MinimumSize, 0 ); sizeHints2.insert( Qt::PreferredSize, 60 ); sizeHints2.insert( Qt::MaximumSize, 100 ); - Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); const qreal width1 = 28; // got from manual calculation const qreal width2 = 100-10-10-10-width1; @@ -2645,15 +2633,11 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution_data() sizeHints1.insert( Qt::MinimumSize, 0 ); sizeHints1.insert( Qt::PreferredSize, 10 ); sizeHints1.insert( Qt::MaximumSize, 100 ); - Q_ASSERT( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); SizeHintArray sizeHints2; sizeHints2.insert( Qt::MinimumSize, 0 ); sizeHints2.insert( Qt::PreferredSize, 40 ); sizeHints2.insert( Qt::MaximumSize, 100 ); - Q_ASSERT( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); - Q_ASSERT( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); const qreal width1 = 22; // got from manual calculation const qreal width2 = 100-10-10-10-width1; @@ -2669,6 +2653,12 @@ void tst_QGraphicsAnchorLayout1::testSizeDistribution() QFETCH(qreal, width1); QFETCH(qreal, width2); + // sanity-check the test data - MinimumSize <= PreferredSize <= MaximumSize + QVERIFY( sizeHints1.value( Qt::MinimumSize ) <= sizeHints1.value( Qt::PreferredSize ) ); + QVERIFY( sizeHints1.value( Qt::PreferredSize ) <= sizeHints1.value( Qt::MaximumSize ) ); + QVERIFY( sizeHints2.value( Qt::MinimumSize ) <= sizeHints2.value( Qt::PreferredSize ) ); + QVERIFY( sizeHints2.value( Qt::PreferredSize ) <= sizeHints2.value( Qt::MaximumSize ) ); + // create objects QGraphicsWidget widget; TheAnchorLayout *layout = new TheAnchorLayout; -- cgit v0.12 From 4b5a7eeacee997f0129354c9669b8e0d66ca4efa Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 27 Apr 2011 16:41:16 +1000 Subject: Remove dead code from qscriptenginedebugger test Remove code made obsolete by 2d1839e850ac632a13ff0ac3096d8419bff5082d. Change-Id: Ic889c81f0507eb91028fa6b6c4cbf6ae71a728b0 Reviewed-by: Rohan McGovern --- .../qscriptenginedebugger/tst_qscriptenginedebugger.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp index 70adb58..1a3ad2c 100644 --- a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp +++ b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp @@ -76,9 +76,6 @@ public: tst_QScriptEngineDebugger(); virtual ~tst_QScriptEngineDebugger(); -protected slots: - void recordDebuggerStateAndContinue(); - private slots: void attachAndDetach(); void action(); @@ -89,9 +86,6 @@ private slots: void multithreadedDebugging(); void autoShowStandardWindow(); void standardWindowOwnership(); - -private: - QScriptEngineDebugger::DebuggerState m_recordedDebuggerState; }; tst_QScriptEngineDebugger::tst_QScriptEngineDebugger() @@ -102,14 +96,6 @@ tst_QScriptEngineDebugger::~tst_QScriptEngineDebugger() { } -void tst_QScriptEngineDebugger::recordDebuggerStateAndContinue() -{ - QScriptEngineDebugger *debugger = qobject_cast<QScriptEngineDebugger*>(sender()); - Q_ASSERT(debugger != 0); - m_recordedDebuggerState = debugger->state(); - debugger->action(QScriptEngineDebugger::ContinueAction)->trigger(); -} - void tst_QScriptEngineDebugger::attachAndDetach() { #if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 -- cgit v0.12 From 36e01e698beb8b5703f5d68f5b2eb9494e11a571 Mon Sep 17 00:00:00 2001 From: Tero Toivola <ext-tero.toivola@nokia.com> Date: Tue, 3 May 2011 14:14:40 +0200 Subject: memory leak fix If glyph is not found from glyphSet it is created dynamically and in this case not deleted. Task-number: https://projects.maemo.org/bugzilla/show_bug.cgi?id=244326 Merge-request: 1208 Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com> --- src/gui/text/qfontengine_ft.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index e89b508..9c90964 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1800,10 +1800,12 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr } else { glyphSet = &defaultGlyphSet; } + bool needsDelete = false; Glyph * g = glyphSet->getGlyph(glyph); if (!g) { face = lockFace(); g = loadGlyphMetrics(glyphSet, glyph); + needsDelete = true; } if (g) { @@ -1812,6 +1814,8 @@ glyph_metrics_t QFontEngineFT::boundingBox(glyph_t glyph, const QTransform &matr overall.width = g->width; overall.height = g->height; overall.xoff = g->advance; + if (needsDelete) + delete g; } else { int left = FLOOR(face->glyph->metrics.horiBearingX); int right = CEIL(face->glyph->metrics.horiBearingX + face->glyph->metrics.width); -- cgit v0.12 From 747962e6ec20a59b7e2ed67c5cd685258f199a86 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Tue, 3 May 2011 14:28:56 +0200 Subject: Change the repaint() call to an update(). In show_sys(), if we directly call repaint() this will triggers too many UpdateRequest events. This fixes the qwidget autotest "compatibilityChildInsertedEvents". Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 8dc9d2e..27a1bb6 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3526,8 +3526,8 @@ void QWidgetPrivate::show_sys() // INVARIANT: q is native. Just show the view: [view setHidden:NO]; } else { - // INVARIANT: q is alien. Repaint q instead: - q->repaint(); + // INVARIANT: q is alien. Update q instead: + q->update(); } #endif } -- cgit v0.12 From 2c6af885d959f90b801c74dc5d389a720dc9fd1d Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Tue, 3 May 2011 14:29:36 +0200 Subject: Fix the autotest condition. The previous preprocessor directive was aimed to exclude Mac OS X. With the raster engine, the behavior is unified and we don't need to have a separate path for Mac OS X/Cocoa. The new condition excludes only Mac OS X with a graphics system other than raster or Carbon. Reviewed-by: Jiang Jiang --- tests/auto/qwidget/tst_qwidget.cpp | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 9c2f6ea..e266efb 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -6337,11 +6337,15 @@ void tst_QWidget::compatibilityChildInsertedEvents() expected = EventRecorder::EventList() << qMakePair(&widget, QEvent::PolishRequest) - << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) - << qMakePair(&widget, QEvent::UpdateRequest) -#endif - ; + << qMakePair(&widget, QEvent::Type(QEvent::User + 1)); + +#ifndef QT_MAC_USE_CARBON +#ifdef QT_MAC_USE_COCOA + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) +#endif // QT_MAC_USE_COCOA + expected << qMakePair(&widget, QEvent::UpdateRequest); +#endif // !QT_MAC_USE_CARBON + QCOMPARE(spy.eventList(), expected); } @@ -6433,11 +6437,15 @@ void tst_QWidget::compatibilityChildInsertedEvents() #endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) - << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) - << qMakePair(&widget, QEvent::UpdateRequest) -#endif - ; + << qMakePair(&widget, QEvent::Type(QEvent::User + 2)); + +#ifndef QT_MAC_USE_CARBON +#ifdef QT_MAC_USE_COCOA + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) +#endif // QT_MAC_USE_COCOA + expected << qMakePair(&widget, QEvent::UpdateRequest); +#endif // !QT_MAC_USE_CARBON + QCOMPARE(spy.eventList(), expected); } @@ -6529,11 +6537,15 @@ void tst_QWidget::compatibilityChildInsertedEvents() #endif << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) - << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) || defined(Q_WS_QPA) - << qMakePair(&widget, QEvent::UpdateRequest) -#endif - ; + << qMakePair(&widget, QEvent::Type(QEvent::User + 2)); + +#ifndef QT_MAC_USE_CARBON +#ifdef QT_MAC_USE_COCOA + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) +#endif // QT_MAC_USE_COCOA + expected << qMakePair(&widget, QEvent::UpdateRequest); +#endif // !QT_MAC_USE_CARBON + QCOMPARE(spy.eventList(), expected); } } -- cgit v0.12 From 004653e63b2c20f32750c54a609572329903d8be Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr <ademar.reis@openbossa.org> Date: Fri, 21 Jan 2011 08:19:00 -0600 Subject: QPainterPath: Ignore calls with NaN/Infinite parameters QPainterPath can't handle NaNs/Inf inside coordinates, but instead of safely ignoring or aborting an operation, it shows a warning and keeps going on, with undefined behavior. Sometimes leading to infinite loops, leaks or crashes (see qtwebkit example below). This is particularly bad when QPainterPath is used to render content from untrusted sources (web or user data). As an example, there's a qtwebkit bug where the browser crashes when a particular SVG is loaded: https://bugs.webkit.org/show_bug.cgi?id=51698. Please note that "untrusted sources" doesn't apply only to network sources. This behavior can probably be exploited on applications such as file-browsers with previews enabled. Task-number: QTBUG-16664 Signed-off-by: Ademar de Souza Reis Jr <ademar.reis@openbossa.org> Merge-request: 1026 Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Reviewed-by: Samuel --- src/gui/painting/qpainterpath.cpp | 66 ++++++++++++++++++++-------- tests/auto/qpainterpath/tst_qpainterpath.cpp | 46 +++++++++++++++++++ 2 files changed, 93 insertions(+), 19 deletions(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 0bb2901..4744cb5 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -628,10 +628,14 @@ void QPainterPath::moveTo(const QPointF &p) #ifdef QPP_DEBUG printf("QPainterPath::moveTo() (%.2f,%.2f)\n", p.x(), p.y()); #endif + + if (!qt_is_finite(p.x()) || !qt_is_finite(p.y())) { #ifndef QT_NO_DEBUG - if (qt_is_nan(p.x()) || qt_is_nan(p.y())) - qWarning("QPainterPath::moveTo: Adding point where x or y is NaN, results are undefined"); + qWarning("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call"); #endif + return; + } + ensureData(); detach(); @@ -674,10 +678,14 @@ void QPainterPath::lineTo(const QPointF &p) #ifdef QPP_DEBUG printf("QPainterPath::lineTo() (%.2f,%.2f)\n", p.x(), p.y()); #endif + + if (!qt_is_finite(p.x()) || !qt_is_finite(p.y())) { #ifndef QT_NO_DEBUG - if (qt_is_nan(p.x()) || qt_is_nan(p.y())) - qWarning("QPainterPath::lineTo: Adding point where x or y is NaN, results are undefined"); + qWarning("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call"); #endif + return; + } + ensureData(); detach(); @@ -729,11 +737,15 @@ void QPainterPath::cubicTo(const QPointF &c1, const QPointF &c2, const QPointF & printf("QPainterPath::cubicTo() (%.2f,%.2f), (%.2f,%.2f), (%.2f,%.2f)\n", c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y()); #endif + + if (!qt_is_finite(c1.x()) || !qt_is_finite(c1.y()) || !qt_is_finite(c2.x()) || !qt_is_finite(c2.y()) + || !qt_is_finite(e.x()) || !qt_is_finite(e.y())) { #ifndef QT_NO_DEBUG - if (qt_is_nan(c1.x()) || qt_is_nan(c1.y()) || qt_is_nan(c2.x()) || qt_is_nan(c2.y()) - || qt_is_nan(e.x()) || qt_is_nan(e.y())) - qWarning("QPainterPath::cubicTo: Adding point where x or y is NaN, results are undefined"); + qWarning("QPainterPath::cubicTo: Adding point where x or y is NaN or Inf, ignoring call"); #endif + return; + } + ensureData(); detach(); @@ -782,10 +794,14 @@ void QPainterPath::quadTo(const QPointF &c, const QPointF &e) printf("QPainterPath::quadTo() (%.2f,%.2f), (%.2f,%.2f)\n", c.x(), c.y(), e.x(), e.y()); #endif + + if (!qt_is_finite(c.x()) || !qt_is_finite(c.y()) || !qt_is_finite(e.x()) || !qt_is_finite(e.y())) { #ifndef QT_NO_DEBUG - if (qt_is_nan(c.x()) || qt_is_nan(c.y()) || qt_is_nan(e.x()) || qt_is_nan(e.y())) - qWarning("QPainterPath::quadTo: Adding point where x or y is NaN, results are undefined"); + qWarning("QPainterPath::quadTo: Adding point where x or y is NaN or Inf, ignoring call"); #endif + return; + } + ensureData(); detach(); @@ -849,11 +865,15 @@ void QPainterPath::arcTo(const QRectF &rect, qreal startAngle, qreal sweepLength printf("QPainterPath::arcTo() (%.2f, %.2f, %.2f, %.2f, angle=%.2f, sweep=%.2f\n", rect.x(), rect.y(), rect.width(), rect.height(), startAngle, sweepLength); #endif + + if (!qt_is_finite(rect.x()) && !qt_is_finite(rect.y()) || !qt_is_finite(rect.width()) || !qt_is_finite(rect.height()) + || !qt_is_finite(startAngle) || !qt_is_finite(sweepLength)) { #ifndef QT_NO_DEBUG - if (qt_is_nan(rect.x()) || qt_is_nan(rect.y()) || qt_is_nan(rect.width()) || qt_is_nan(rect.height()) - || qt_is_nan(startAngle) || qt_is_nan(sweepLength)) - qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN, results are undefined"); + qWarning("QPainterPath::arcTo: Adding arc where a parameter is NaN or Inf, ignoring call"); #endif + return; + } + if (rect.isNull()) return; @@ -952,10 +972,13 @@ QPointF QPainterPath::currentPosition() const */ void QPainterPath::addRect(const QRectF &r) { + if (!qt_is_finite(r.x()) || !qt_is_finite(r.y()) || !qt_is_finite(r.width()) || !qt_is_finite(r.height())) { #ifndef QT_NO_DEBUG - if (qt_is_nan(r.x()) || qt_is_nan(r.y()) || qt_is_nan(r.width()) || qt_is_nan(r.height())) - qWarning("QPainterPath::addRect: Adding rect where a parameter is NaN, results are undefined"); + qWarning("QPainterPath::addRect: Adding rect where a parameter is NaN or Inf, ignoring call"); #endif + return; + } + if (r.isNull()) return; @@ -1032,11 +1055,14 @@ void QPainterPath::addPolygon(const QPolygonF &polygon) */ void QPainterPath::addEllipse(const QRectF &boundingRect) { + if (!qt_is_finite(boundingRect.x()) || !qt_is_finite(boundingRect.y()) + || !qt_is_finite(boundingRect.width()) || !qt_is_finite(boundingRect.height())) { #ifndef QT_NO_DEBUG - if (qt_is_nan(boundingRect.x()) || qt_is_nan(boundingRect.y()) - || qt_is_nan(boundingRect.width()) || qt_is_nan(boundingRect.height())) - qWarning("QPainterPath::addEllipse: Adding ellipse where a parameter is NaN, results are undefined"); + qWarning("QPainterPath::addEllipse: Adding ellipse where a parameter is NaN or Inf, ignoring call"); #endif + return; + } + if (boundingRect.isNull()) return; @@ -2358,10 +2384,12 @@ QDataStream &operator>>(QDataStream &s, QPainterPath &p) s >> x; s >> y; Q_ASSERT(type >= 0 && type <= 3); + if (!qt_is_finite(x) || !qt_is_finite(y)) { #ifndef QT_NO_DEBUG - if (qt_is_nan(x) || qt_is_nan(y)) - qWarning("QDataStream::operator>>: Adding a NaN element to path, results are undefined"); + qWarning("QDataStream::operator>>: NaN or Inf element found in path, skipping it"); #endif + continue; + } QPainterPath::Element elm = { x, y, QPainterPath::ElementType(type) }; p.d_func()->elements.append(elm); } diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp index bc3b5d9..e9f09ea 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -101,6 +101,8 @@ private slots: void testToFillPolygons(); + void testNaNandInfinites(); + void closing(); void operators_data(); @@ -1159,6 +1161,50 @@ void tst_QPainterPath::testToFillPolygons() QCOMPARE(polygons.first().count(QPointF(70, 50)), 0); } +void tst_QPainterPath::testNaNandInfinites() +{ + QPainterPath path1; + QPainterPath path2 = path1; + + QPointF p1 = QPointF(qSNaN(), 1); + QPointF p2 = QPointF(qQNaN(), 1); + QPointF p3 = QPointF(qQNaN(), 1); + QPointF pInf = QPointF(qInf(), 1); + + // all these operations with NaN/Inf should be ignored + // can't test operator>> reliably, as we can't create a path with NaN to << later + + path1.moveTo(p1); + path1.moveTo(qSNaN(), qQNaN()); + path1.moveTo(pInf); + + path1.lineTo(p1); + path1.lineTo(qSNaN(), qQNaN()); + path1.lineTo(pInf); + + path1.cubicTo(p1, p2, p3); + path1.cubicTo(p1, QPointF(1, 1), QPointF(2, 2)); + path1.cubicTo(pInf, QPointF(10, 10), QPointF(5, 1)); + + path1.quadTo(p1, p2); + path1.quadTo(QPointF(1, 1), p3); + path1.quadTo(QPointF(1, 1), pInf); + + path1.arcTo(QRectF(p1, p2), 5, 5); + path1.arcTo(QRectF(pInf, QPointF(1, 1)), 5, 5); + + path1.addRect(QRectF(p1, p2)); + path1.addRect(QRectF(pInf, QPointF(1, 1))); + + path1.addEllipse(QRectF(p1, p2)); + path1.addEllipse(QRectF(pInf, QPointF(1, 1))); + + QCOMPARE(path1, path2); + + path1.lineTo(QPointF(1, 1)); + QVERIFY(path1 != path2); +} + void tst_QPainterPath::connectPathDuplicatePoint() { QPainterPath a; -- cgit v0.12 From d1011fc9328fa335bc69a065b29e77ce60608c55 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 10:38:03 +1000 Subject: Remove Q_ASSERT from qgraphicsanchorlayout test Q_ASSERT will only catch a violation of the precondition of the checkReverseDirection function in a debug build. This commit replaces the Q_ASSERT with QVERIFY'ing the precondition (that the widget has a layout) before calling the function. Change-Id: Ibaa2b52b7d67fa20784e0df022e8c8169da0e50e Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp index 67e9b0a..7b33081 100644 --- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -135,7 +135,6 @@ static void setAnchor(QGraphicsAnchorLayout *l, static bool checkReverseDirection(QGraphicsWidget *widget) { QGraphicsLayout *layout = widget->layout(); - Q_ASSERT(layout); qreal left, top, right, bottom; layout->getContentsMargins(&left, &top, &right, &bottom); widget->setLayoutDirection(Qt::LeftToRight); @@ -345,6 +344,7 @@ void tst_QGraphicsAnchorLayout::layoutDirection() p->show(); view->show(); + QVERIFY(p->layout()); QCOMPARE(checkReverseDirection(p), true); if (hasSimplification) { @@ -445,6 +445,7 @@ void tst_QGraphicsAnchorLayout::diagonal() QVERIFY(!usedSimplex(l, Qt::Vertical)); } + QVERIFY(p.layout()); QCOMPARE(checkReverseDirection(&p), true); c->setMinimumWidth(300); @@ -735,6 +736,7 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections() QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0)); QCOMPARE(p.size(), layoutMaximumSize); + QVERIFY(p.layout()); QCOMPARE(checkReverseDirection(&p), true); } -- cgit v0.12 From 012b2d8198b8cfe39a66025334ed9ae2a045a68c Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 10:44:51 +1000 Subject: Remove dead code from qgraphicsgridlayout autotest Change-Id: I230d1ec9dfd5df2a0fac161a03090308b7f07a1e Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../tst_qgraphicsgridlayout.cpp | 33 ---------------------- 1 file changed, 33 deletions(-) diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 837df78..78010e6 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -3018,39 +3018,6 @@ static QSizeF wfh(Qt::SizeHint /*which*/, const QSizeF &constraint) return result; } -static qreal growthFactorBelowPreferredSize(qreal desired, qreal sumAvailable, qreal sumDesired) -{ - Q_ASSERT(sumDesired != 0.0); - return desired * qPow(sumAvailable / sumDesired, desired / sumDesired); -} - -static void expectedWidth(qreal minSize1, qreal prefSize1, - qreal minSize2, qreal prefSize2, - qreal targetSize, qreal *width1, qreal *width2) -{ - qreal sumAvail,factor1,factor2; - // stretch behaviour is different below and above preferred size... - if (targetSize < prefSize1 + prefSize2) { - sumAvail = targetSize - minSize1 - minSize2; - const qreal desired1 = prefSize1 - minSize1; - const qreal desired2 = prefSize2 - minSize2; - const qreal sumDesired = desired1 + desired2; - factor1 = growthFactorBelowPreferredSize(desired1, sumAvail, sumDesired); - factor2 = growthFactorBelowPreferredSize(desired2, sumAvail, sumDesired); - const qreal sumFactors = factor1 + factor2; - *width1 = sumAvail*factor1/sumFactors + minSize1; - *width2 = sumAvail*factor2/sumFactors + minSize2; - } else { - sumAvail = targetSize - prefSize1 - prefSize2; - factor1 = prefSize1; - factor2 = prefSize2; - const qreal sumFactors = factor1 + factor2; - *width1 = sumAvail*factor1/sumFactors + prefSize1; - *width2 = sumAvail*factor2/sumFactors + prefSize2; - } -} - - bool qFuzzyCompare(const QSizeF &a, const QSizeF &b) { return qFuzzyCompare(a.width(), b.width()) && qFuzzyCompare(a.height(), b.height()); -- cgit v0.12 From a388e104febb131cd35438bbb1397eeab41d3ab8 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 10:48:14 +1000 Subject: Remove mention of Q_ASSERT from qheaderview autotest Change-Id: I3a97411c0b53345bffbadb60a3e7caabfb0441d2 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qheaderview/tst_qheaderview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp index 9a25fb6..d877d2f 100644 --- a/tests/auto/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/qheaderview/tst_qheaderview.cpp @@ -1106,7 +1106,7 @@ void tst_QHeaderView::moveAndInsertSection() void tst_QHeaderView::resizeMode() { - // Q_ASSERT's when resizeMode is called with an invalid index + // resizeMode must not be called with an invalid index int last = view->count() - 1; view->setResizeMode(QHeaderView::Interactive); QCOMPARE(view->resizeMode(last), QHeaderView::Interactive); -- cgit v0.12 From 0d773d839e39f4f4bfd0bf9d652e4f2650adfcb0 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 10:52:52 +1000 Subject: Remove Q_ASSERT from qitemmodel autotest Allow createModel() to return a null model on failure (which it already did in release mode builds), but fail the test gracefully instead of crashing when a null model is returned. Change-Id: Iaa0ec31183e0c90fcea512223d01e07ed188a380 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qitemmodel/modelstotest.cpp | 1 - tests/auto/qitemmodel/tst_qitemmodel.cpp | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp index c4c2cbb..cec1703 100644 --- a/tests/auto/qitemmodel/modelstotest.cpp +++ b/tests/auto/qitemmodel/modelstotest.cpp @@ -227,7 +227,6 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType) return widget->model(); } - Q_ASSERT(false); return 0; } diff --git a/tests/auto/qitemmodel/tst_qitemmodel.cpp b/tests/auto/qitemmodel/tst_qitemmodel.cpp index 7e177ba..9482853 100644 --- a/tests/auto/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/qitemmodel/tst_qitemmodel.cpp @@ -199,6 +199,7 @@ void tst_QItemModel::nonDestructiveBasicTest() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); QCOMPARE(currentModel->buddy(QModelIndex()), QModelIndex()); currentModel->canFetchMore(QModelIndex()); @@ -244,6 +245,7 @@ void tst_QItemModel::rowCount() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); QFETCH(bool, isEmpty); if (isEmpty) { @@ -291,6 +293,7 @@ void tst_QItemModel::columnCount() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); QFETCH(bool, isEmpty); if (isEmpty) { @@ -325,6 +328,7 @@ void tst_QItemModel::hasIndex() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); // Make sure that invalid values returns an invalid index QCOMPARE(currentModel->hasIndex(-2, -2), false); @@ -359,6 +363,7 @@ void tst_QItemModel::index() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); // Make sure that invalid values returns an invalid index QCOMPARE(currentModel->index(-2, -2), QModelIndex()); @@ -489,6 +494,7 @@ void tst_QItemModel::parent() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); // Make sure the model wont crash and will return an invalid QModelIndex // when asked for the parent of an invalid index. @@ -538,6 +544,7 @@ void tst_QItemModel::data() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); // Invalid index should return an invalid qvariant QVERIFY(!currentModel->data(QModelIndex()).isValid()); @@ -618,6 +625,7 @@ void tst_QItemModel::setData() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); qRegisterMetaType<QModelIndex>("QModelIndex"); QSignalSpy spy(currentModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &))); QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false); @@ -660,6 +668,7 @@ void tst_QItemModel::setHeaderData() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); QCOMPARE(currentModel->setHeaderData(-1, Qt::Horizontal, QVariant()), false); QCOMPARE(currentModel->setHeaderData(-1, Qt::Vertical, QVariant()), false); @@ -708,6 +717,7 @@ void tst_QItemModel::sort() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); QFETCH(bool, isEmpty); if (isEmpty) @@ -819,6 +829,7 @@ void tst_QItemModel::remove() QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); QFETCH(bool, readOnly); if (readOnly) @@ -1160,6 +1171,7 @@ void tst_QItemModel::insert() { QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); + QVERIFY(currentModel); QFETCH(bool, readOnly); if (readOnly) -- cgit v0.12 From 51b1d8dc20a2557d2002550b03e5b9f37f425fb4 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 11:25:17 +1000 Subject: Remove Q_ASSERT from qitemview autotest Allow createView() to return a null view on failure (which it already did in release mode builds), but fail the test gracefully instead of crashing when a null view is returned. Also reordered the code slightly to put all the QFETCH's together. Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern Change-Id: I3a41c738cb0e4e860db2342b30817a804b20f30d --- tests/auto/qitemview/tst_qitemview.cpp | 25 +++++++++++++++++++------ tests/auto/qitemview/viewstotest.cpp | 1 - 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp index 220a174..c987c8f 100644 --- a/tests/auto/qitemview/tst_qitemview.cpp +++ b/tests/auto/qitemview/tst_qitemview.cpp @@ -297,9 +297,11 @@ void tst_QItemView::nonDestructiveBasicTest() #endif QFETCH(QString, viewType); - view = testViews->createView(viewType); QFETCH(int, vscroll); QFETCH(int, hscroll); + + view = testViews->createView(viewType); + QVERIFY(view); view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); @@ -454,9 +456,11 @@ void tst_QItemView::spider() QSKIP("This test takes too long to execute on IRIX", SkipAll); #endif QFETCH(QString, viewType); - view = testViews->createView(viewType); QFETCH(int, vscroll); QFETCH(int, hscroll); + + view = testViews->createView(viewType); + QVERIFY(view); view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->setModel(treeModel); @@ -489,9 +493,11 @@ void tst_QItemView::resize() // This test needs to be re-thought out, it takes too long and // doesn't really catch theproblem. QFETCH(QString, viewType); - view = testViews->createView(viewType); QFETCH(int, vscroll); QFETCH(int, hscroll); + + view = testViews->createView(viewType); + QVERIFY(view); view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->setModel(treeModel); @@ -517,9 +523,11 @@ void tst_QItemView::visualRect() QSKIP("This test takes too long to execute on IRIX", SkipAll); #endif QFETCH(QString, viewType); - view = testViews->createView(viewType); QFETCH(int, vscroll); QFETCH(int, hscroll); + + view = testViews->createView(viewType); + QVERIFY(view); view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); QCOMPARE(view->visualRect(QModelIndex()), QRect()); @@ -651,9 +659,11 @@ void tst_QItemView::indexAt() QSKIP("This test takes too long to execute on IRIX", SkipAll); #endif QFETCH(QString, viewType); - view = testViews->createView(viewType); QFETCH(int, vscroll); QFETCH(int, hscroll); + + view = testViews->createView(viewType); + QVERIFY(view); view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->show(); @@ -685,9 +695,11 @@ void tst_QItemView::scrollTo() QSKIP("This test takes too long to execute on IRIX", SkipAll); #endif QFETCH(QString, viewType); - view = testViews->createView(viewType); QFETCH(int, vscroll); QFETCH(int, hscroll); + + view = testViews->createView(viewType); + QVERIFY(view); view->setVerticalScrollMode((QAbstractItemView::ScrollMode)vscroll); view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->setModel(treeModel); @@ -735,6 +747,7 @@ void tst_QItemView::moveCursor() #endif QFETCH(QString, viewType); view = testViews->createView(viewType); + QVERIFY(view); if (view->objectName() == "QHeaderView") return; diff --git a/tests/auto/qitemview/viewstotest.cpp b/tests/auto/qitemview/viewstotest.cpp index 3aa355d..5e21daf 100644 --- a/tests/auto/qitemview/viewstotest.cpp +++ b/tests/auto/qitemview/viewstotest.cpp @@ -141,7 +141,6 @@ QAbstractItemView *ViewsToTest::createView(const QString &viewType) view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); view->setSelectionBehavior(QAbstractItemView::SelectItems); } - Q_ASSERT(view); return view; } -- cgit v0.12 From 291f04a4a7be4a975c6b8eaeeed4e0c196e23128 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 11:35:25 +1000 Subject: Change Q_ASSERT to QVERIFY in QMenu test. Change-Id: Ifc08d4eabd8565cfd242ec2e70cf597e92f28fe3 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qmenu/tst_qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 1367e1f..c31361d 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -789,7 +789,7 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition() while (main.columnCount() < 2) { main.addAction(QString("Item %1").arg(i)); ++i; - Q_ASSERT(i<1000); + QVERIFY(i<1000); } main.setActiveAction(menuAction); sub.setActiveAction(subAction); -- cgit v0.12 From 6f082a3fdd368cd7a969b7f324354583d081da82 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 11:44:16 +1000 Subject: Remove Q_ASSERT from QMetaObject autotest. Issue a helpful warning rather than ignoring the error in release mode builds. Change-Id: Iea7bf4d63f8227abaf7dcf1700c5fef62763afad Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qmetaobject/tst_qmetaobject.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index d496c56..5621c47 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -241,7 +241,12 @@ public: QObject *child; public slots: - void on_child1_destroyed(QObject *obj = 0) { ++invokeCount1; Q_ASSERT(obj && obj == child); } + void on_child1_destroyed(QObject *obj = 0) + { + ++invokeCount1; + if (!obj || obj != child) + qWarning() << "on_child1_destroyed invoked with wrong child object"; + } void on_child2_destroyed() { ++invokeCount2; } }; @@ -265,7 +270,12 @@ public: } private slots: - void on_child1_destroyed(QObject *obj) { ++invokeCount1; Q_ASSERT(obj && obj == child); } + void on_child1_destroyed(QObject *obj) + { + ++invokeCount1; + if (!obj || obj != child) + qWarning() << "on_child1_destroyed invoked with wrong child object"; + } void on_child1_destroyed() { ++invokeCount2; } }; -- cgit v0.12 From a3b2fa3f1beffa7709c11522d4e2db9ec8f952e0 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 11:48:40 +1000 Subject: Remove Q_ASSERT's from QMetaType autotest. Instead of asserting in debug mode and doing nothing in release mode, put specific warnings in the test output and fail the test gracefully. Change-Id: I453a0ab7ddef5b2acf55f77f71a59a940d93ae54 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qmetatype/tst_qmetatype.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp index 67bbac2..fcb949f 100644 --- a/tests/auto/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/qmetatype/tst_qmetatype.cpp @@ -113,17 +113,35 @@ protected: #ifdef Q_OS_LINUX pthread_yield(); #endif - Q_ASSERT(QMetaType::isRegistered(tp)); - Q_ASSERT(QMetaType::type(nm) == tp); - Q_ASSERT(QMetaType::typeName(tp) == name); + if (!QMetaType::isRegistered(tp)) { + ++failureCount; + qWarning() << name << "is not a registered metatype"; + } + if (QMetaType::type(nm) != tp) { + ++failureCount; + qWarning() << "Wrong metatype returned for" << name; + } + if (QMetaType::typeName(tp) != name) { + ++failureCount; + qWarning() << "Wrong typeName returned for" << tp; + } void *buf = QMetaType::construct(tp, 0); void *buf2 = QMetaType::construct(tp, buf); - Q_ASSERT(buf); - Q_ASSERT(buf2); + if (!buf) { + ++failureCount; + qWarning() << "Null buffer returned by QMetaType::construct(tp, 0)"; + } + if (!buf2) { + ++failureCount; + qWarning() << "Null buffer returned by QMetaType::construct(tp, buf)"; + } QMetaType::destroy(tp, buf); QMetaType::destroy(tp, buf2); } } +public: + MetaTypeTorturer() : failureCount(0) { } + int failureCount; }; void tst_QMetaType::threadSafety() @@ -139,6 +157,10 @@ void tst_QMetaType::threadSafety() QVERIFY(t1.wait()); QVERIFY(t2.wait()); QVERIFY(t3.wait()); + + QCOMPARE(t1.failureCount, 0); + QCOMPARE(t2.failureCount, 0); + QCOMPARE(t3.failureCount, 0); } namespace TestSpace -- cgit v0.12 From 7bd6ca895e5fa4de197d9d7bf2e7b578c01c3c2a Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 11:59:05 +1000 Subject: Remove Q_ASSERT's from QObject autotest. The Receiver class has two slots that aren't meant to get called during the test (they're there to catch broken parsing of slot names). Rather than asserting when one of them gets called, which does nothing in a release mode build, this commit makes the slots record the number of times they were called (as for the other slots in the test) and fails the test gracefully if either of those slots was called. Change-Id: Ia0393026cb96ffdc6190b5e7bd951f75d231b11e Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qobject/tst_qobject.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index d2307ee..29b07af 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -403,6 +403,8 @@ public: } void reset() { + called_slot10 = 0; + called_slot9 = 0; called_slot8 = 0; called_slot7 = 0; called_slot6 = 0; @@ -421,6 +423,8 @@ public: int called_slot6; int called_slot7; int called_slot8; + int called_slot9; + int called_slot10; bool called(int slot) { switch (slot) { @@ -432,6 +436,8 @@ public: case 6: return called_slot6; case 7: return called_slot7; case 8: return called_slot8; + case 9: return called_slot9; + case 10: return called_slot10; default: return false; } } @@ -449,8 +455,8 @@ public slots: void slotLoopBack() { ++called_slot8; } protected slots: - void o() { Q_ASSERT(0); } - void on() { Q_ASSERT(0); } + void o() { ++called_slot9; } + void on() { ++called_slot10; } signals: void on_Sender_signalLoopBack(); @@ -473,6 +479,8 @@ void tst_QObject::connectByName() QCOMPARE(receiver.called(6), false); QCOMPARE(receiver.called(7), false); QCOMPARE(receiver.called(8), false); + QCOMPARE(receiver.called(9), false); + QCOMPARE(receiver.called(10), false); receiver.reset(); sender.emitSignalWithParams(0); @@ -484,6 +492,8 @@ void tst_QObject::connectByName() QCOMPARE(receiver.called(6), false); QCOMPARE(receiver.called(7), false); QCOMPARE(receiver.called(8), false); + QCOMPARE(receiver.called(9), false); + QCOMPARE(receiver.called(10), false); receiver.reset(); sender.emitSignalWithParams(0, "string"); @@ -495,6 +505,8 @@ void tst_QObject::connectByName() QCOMPARE(receiver.called(6), false); QCOMPARE(receiver.called(7), false); QCOMPARE(receiver.called(8), false); + QCOMPARE(receiver.called(9), false); + QCOMPARE(receiver.called(10), false); receiver.reset(); sender.emitSignalManyParams(1, 2, 3, "string", true); @@ -506,6 +518,8 @@ void tst_QObject::connectByName() QCOMPARE(receiver.called(6), false); QCOMPARE(receiver.called(7), false); QCOMPARE(receiver.called(8), false); + QCOMPARE(receiver.called(9), false); + QCOMPARE(receiver.called(10), false); receiver.reset(); sender.emitSignalManyParams2(1, 2, 3, "string", true); @@ -517,6 +531,8 @@ void tst_QObject::connectByName() QCOMPARE(receiver.called(6), false); QCOMPARE(receiver.called(7), true); QCOMPARE(receiver.called(8), false); + QCOMPARE(receiver.called(9), false); + QCOMPARE(receiver.called(10), false); receiver.reset(); sender.emitSignalLoopBack(); @@ -528,6 +544,8 @@ void tst_QObject::connectByName() QCOMPARE(receiver.called(6), false); QCOMPARE(receiver.called(7), false); QCOMPARE(receiver.called(8), true); + QCOMPARE(receiver.called(9), false); + QCOMPARE(receiver.called(10), false); receiver.reset(); } -- cgit v0.12 From 8b95b4b5c09bf31f813fe39a3eec611c9daddb98 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 12:43:15 +1000 Subject: Remove Q_ASSERT's from qscriptclass autotest Allow the extension() function to return a null QVariant, which will cause the test to fail gracefully. Change-Id: Ide9ef69c48f4bdd5a000f525fe9f395c27854da9 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptclass/tst_qscriptclass.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp index 9ab8318..4d27672 100644 --- a/tests/auto/qscriptclass/tst_qscriptclass.cpp +++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp @@ -369,8 +369,7 @@ QVariant TestClass::extension(Extension extension, { m_lastExtensionType = extension; m_lastExtensionArgument = argument; - if (extension == Callable) { - Q_ASSERT(m_callableMode != NotCallable); + if (extension == Callable && m_callableMode != NotCallable) { QScriptContext *ctx = qvariant_cast<QScriptContext*>(argument); if (m_callableMode == CallableReturnsSum) { qsreal sum = 0; @@ -398,8 +397,7 @@ QVariant TestClass::extension(Extension extension, engine()->newQObject(ctx->thisObject(), engine()); return QVariant(); } - } else if (extension == HasInstance) { - Q_ASSERT(m_hasInstance); + } else if (extension == HasInstance && m_hasInstance) { QScriptValueList args = qvariant_cast<QScriptValueList>(argument); QScriptValue obj = args.at(0); QScriptValue value = args.at(1); -- cgit v0.12 From 3ba55189d9aa7d9d7c2087071dcb4d338c0feab8 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 12:51:47 +1000 Subject: Remove Q_ASSERT from V8 autotest Replace Q_ASSERT with QTest::qVerify, in line with the rest of this test function. Change-Id: Ia39e62efb9945f72a6a93fddddf36488cd456965 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp index b35fd06..0f63675 100644 --- a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp +++ b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp @@ -153,7 +153,7 @@ void tst_QScriptV8TestSuite::runTestFunction(int testIndex) QScriptValue ret = engine.evaluate(contents); if (engine.hasUncaughtException()) { if (!ret.isError()) { - Q_ASSERT(ret.instanceOf(engine.globalObject().property("MjsUnitAssertionError"))); + QTest::qVerify(ret.instanceOf(engine.globalObject().property("MjsUnitAssertionError"))); QString actual = ret.property("actual").toString(); QString expected = ret.property("expected").toString(); int lineNumber = ret.property("lineNumber").toInt32(); -- cgit v0.12 From 5b86c4abc676b36d60e6625e89535e7f4907d2b3 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 12:56:16 +1000 Subject: Remove Q_ASSERT's from qsharedpointer autotest Report a meaningful warning message into the test output rather than aborting in debug mode and doing nothing in release mode. Change-Id: I6883fccbce0139c763f36f6839bb3452d8f69c1c Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qsharedpointer/externaltests.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/auto/qsharedpointer/externaltests.cpp b/tests/auto/qsharedpointer/externaltests.cpp index 1ba03dc..b0490c9 100644 --- a/tests/auto/qsharedpointer/externaltests.cpp +++ b/tests/auto/qsharedpointer/externaltests.cpp @@ -50,6 +50,7 @@ #include <QtCore/QDir> #include <QtCore/QDirIterator> #include <QtCore/QDateTime> +#include <QtCore/QDebug> #ifdef Q_OS_SYMBIAN #define DEFAULT_MAKESPEC "X:/STLsupport/mkspecs/symbian-abld/" @@ -342,7 +343,8 @@ namespace QTest { void QExternalTestPrivate::removeTemporaryDirectory() { - Q_ASSERT(!temporaryDir.isEmpty()); + if (temporaryDir.isEmpty()) + qWarning() << "Temporary directory is expected to be non-empty"; removeRecursive(temporaryDir); temporaryDir.clear(); } @@ -487,7 +489,8 @@ namespace QTest { bool QExternalTestPrivate::createProjectFile() { - Q_ASSERT(!temporaryDir.isEmpty()); + if (temporaryDir.isEmpty()) + qWarning() << "Temporary directory is expected to be non-empty"; QFile projectFile(temporaryDir + QLatin1String("/project.pro")); if (!projectFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { @@ -599,7 +602,9 @@ namespace QTest { bool QExternalTestPrivate::runQmake() { - Q_ASSERT(!temporaryDir.isEmpty()); + if (temporaryDir.isEmpty()) + qWarning() << "Temporary directory is expected to be non-empty"; + if (!createProjectFile()) return false; @@ -633,7 +638,8 @@ namespace QTest { bool QExternalTestPrivate::runMake(Target target) { - Q_ASSERT(!temporaryDir.isEmpty()); + if (temporaryDir.isEmpty()) + qWarning() << "Temporary directory is expected to be non-empty"; QExternalProcess make; make.setWorkingDirectory(temporaryDir); -- cgit v0.12 From b9b3ced2eafe13e491d5af5ad7432733941bfd8d Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 14:45:59 +1000 Subject: Remove Q_ASSERT from qsslsocket autotest. Make the server thread exit early if the socket is invalid. This will make the test fail gracefully instead of crashing. Change-Id: Ia9564c94dd32d65e6e9bdb4a2410f1512409546c Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qsslsocket/tst_qsslsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index ef5833ef..6fbedfa 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -1517,8 +1517,8 @@ protected: // delayed start of encryption QTest::qSleep(100); QSslSocket *socket = server.socket; - Q_ASSERT(socket); - Q_ASSERT(socket->isValid()); + if (!socket || !socket->isValid()) + return; // error socket->ignoreSslErrors(); socket->startServerEncryption(); if (!socket->waitForEncrypted(2000)) -- cgit v0.12 From f01e2a5024db69913aed016e2854b2589ca85080 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 14:56:05 +1000 Subject: Remove Q_ASSERT from qtesselator autotest If the test data is incorrect, print a meaningful warning into the test output instead of deferencing an iterator beyond the last element in the list. Change-Id: I7be4f282639453de6d8240a2f17253025b415337 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtessellator/dataparser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtessellator/dataparser.cpp b/tests/auto/qtessellator/dataparser.cpp index bd17ee2..d6566cb2 100644 --- a/tests/auto/qtessellator/dataparser.cpp +++ b/tests/auto/qtessellator/dataparser.cpp @@ -98,8 +98,12 @@ static QList<QPointF> parsePoints(const QByteArray &line) QList<qreal> nums = parseNumbersList(it); QList<qreal>::const_iterator nitr; for (nitr = nums.begin(); nitr != nums.end(); ++nitr) { - qreal x = *nitr; ++nitr; - Q_ASSERT(nitr != nums.end()); + qreal x = *nitr; + ++nitr; + if (nitr == nums.end()) { + qWarning() << "parsePoints: Even number of co-ordinates required, odd number found: skipping last point"; + break; + } qreal y = *nitr; res.append(QPointF(x, y)); } -- cgit v0.12 From a88dd1c5f62b5ded8ea0d76d185127ef28549c72 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 15:47:55 +1000 Subject: Remove Q_ASSERT from QTextOdfWriter autotest If the <dummy> tag can't be found in the data, return an empty string rather than asserting, so that the test fails gracefully. Change-Id: I536f08c9c3e942817680849d96d035999d4994db Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index 997cd68..ffce9a2 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -114,11 +114,14 @@ QString tst_QTextOdfWriter::getContentFromXml() xmlWriter->writeEndDocument(); buffer->close(); QString stringContent = QString::fromUtf8(buffer->data()); + QString ret; int index = stringContent.indexOf("<dummy"); - Q_ASSERT(index); - index = stringContent.indexOf('>', index); - stringContent = stringContent.mid(index+1, stringContent.length() - index - 10); - return stringContent; + if (index > 0) { + index = stringContent.indexOf('>', index); + if (index > 0) + ret = stringContent.mid(index+1, stringContent.length() - index - 10); + } + return ret; } void tst_QTextOdfWriter::testWriteParagraph_data() -- cgit v0.12 From a8dc321b6669dd263a25a0cb5766e5b7150c6e20 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 15:58:24 +1000 Subject: Remove Q_ASSERT's from QVariant autotest. Print a meaningful warning message instead of aborting in debug mode builds and failing silently in release mode builds. Change-Id: I44143c5fbe6b6af87bdf5bd231cfaf9a3c9c33f8 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qvariant/tst_qvariant.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 62babdb..fef7ec2 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -3232,18 +3232,21 @@ struct MyData { void *ptr; MyData() : ptr(this) {} - ~MyData() { Q_ASSERT(ptr == this); } + ~MyData() + { + if (ptr != this) qWarning("MyData::~MyData(): object has moved"); + } MyData(const MyData& o) : ptr(this) { Q_ASSERT(o.ptr == &o); } MyData &operator=(const MyData &o) { - Q_ASSERT(ptr == this); - Q_ASSERT(o.ptr == &o); + if (ptr != this) qWarning("MyData::operator=(): object has moved"); + if (o.ptr != &o) qWarning("MyData::operator=(): other object has moved"); return *this; } bool operator==(const MyData &o) const { - Q_ASSERT(ptr == this); - Q_ASSERT(o.ptr == &o); + if (ptr != this) qWarning("MyData::operator==(): object has moved"); + if (o.ptr != &o) qWarning("MyData::operator==(): other object has moved"); return true; } }; -- cgit v0.12 From b2db13f245f09f1d14af64d2199284c78cbb5b6e Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 16:04:31 +1000 Subject: Remove mention of Q_ASSERT in comments This will make it easier to check for stray Q_ASSERT's in the future. Change-Id: I5ddafe1bf26819566460920deae8ff448008c93f Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qwidget/tst_qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 64d543f..e8d9719 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -10383,7 +10383,7 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() w.setFocusProxy(fp); QWidget::setTabOrder(&w, fp); - // No Q_ASSERT, then it's allright. + // In debug mode, no assertion failure means it's alright. } void tst_QWidget::movedAndResizedAttributes() -- cgit v0.12 From a54900d2227bfb2021c5d1255817824aff11cf32 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 16:08:25 +1000 Subject: Remove Q_ASSERT's from QWizard autotest Combine the two checking functions (check and checkInvariant) and have the resulting check function return a bool instead of asserting so that the test function can QVERIFY and fail gracefully. Change-Id: Ib069b5424483ba6ffb9caf75036c4f325e9dba51 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qwizard/tst_qwizard.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/auto/qwizard/tst_qwizard.cpp b/tests/auto/qwizard/tst_qwizard.cpp index a813727..61eb8d4 100644 --- a/tests/auto/qwizard/tst_qwizard.cpp +++ b/tests/auto/qwizard/tst_qwizard.cpp @@ -854,25 +854,26 @@ struct MyPage2 : public QWizardPage public: MyPage2() : init(0), cleanup(0), validate(0) {} - void initializePage() { ++init; QWizardPage::initializePage(); checkInvariant(); } - void cleanupPage() { ++cleanup; QWizardPage::cleanupPage(); checkInvariant(); } + void initializePage() { ++init; QWizardPage::initializePage(); } + void cleanupPage() { ++cleanup; QWizardPage::cleanupPage(); } bool validatePage() { ++validate; return QWizardPage::validatePage(); } - void check(int init, int cleanup) - { Q_ASSERT(init == this->init && cleanup == this->cleanup); Q_UNUSED(init); Q_UNUSED(cleanup); } + bool check(int init, int cleanup) + { + return init == this->init + && cleanup == this->cleanup + && (this->init == this->cleanup || this->init - 1 == this->cleanup); + } int init; int cleanup; int validate; - -private: - void checkInvariant() { Q_ASSERT(init == cleanup || init - 1 == cleanup); } }; #define CHECK_PAGE_INIT(i0, c0, i1, c1, i2, c2) \ - page0->check((i0), (c0)); \ - page1->check((i1), (c1)); \ - page2->check((i2), (c2)); + QVERIFY(page0->check((i0), (c0))); \ + QVERIFY(page1->check((i1), (c1))); \ + QVERIFY(page2->check((i2), (c2))); void tst_QWizard::setOption_IndependentPages() { -- cgit v0.12 From fed42f25e129af1f4f2c03a075530ad7111d2fdd Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 16:12:05 +1000 Subject: Remove Q_ASSERT from QThread autotest Report a meaningful fatal error instead of aborting in debug mode builds and failing silently in release mode builds. Change-Id: If9a6c0655e021b3bb6b7d894aefd9bbcc58e4605 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qthread/tst_qthread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index c69052e..4e3d67d 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -207,7 +207,7 @@ public: cond.wait(&mutex, five_minutes); } setTerminationEnabled(true); - Q_ASSERT_X(false, "tst_QThread", "test case hung"); + qFatal("tst_QThread: test case hung"); } }; -- cgit v0.12 From b988b2f9f04ac0ebce7a779cd9bd5d394bfa1c95 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 16:14:03 +1000 Subject: Remove Q_ASSERT from QSharedPointer autotest Report a meaningful fatal error instead of aborting in debug mode builds and failing silently in release mode builds. Change-Id: I0f939dc40810f072a3e24aeba085191793c49ef3 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index f25f8e8..6250219 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -139,7 +139,8 @@ public: virtual ~Data() { - Q_ASSERT_X(generation > 0, "tst_QSharedPointer", "Double deletion!"); + if (generation <= 0) + qFatal("tst_qsharedpointer: Double deletion!"); generation = 0; ++destructorCounter; } -- cgit v0.12 From 22aa68ecec96da4d14a4c9fe2f6e4a337b13b4a3 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 16:17:43 +1000 Subject: Remove Q_ASSERT from QLibrary autotest Report a regular test failure rather than aborting when an unknown operation is requested. Change-Id: I3678f42f9e9f895d8d0d49a768d4c8b575d1863f Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qlibrary/tst_qlibrary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp index c79332d..a8c60c9 100644 --- a/tests/auto/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/qlibrary/tst_qlibrary.cpp @@ -468,7 +468,7 @@ void tst_QLibrary::errorString() } break;} default: - Q_ASSERT(0); + QFAIL(qPrintable(QString("Unknown operation: %1").arg(operation))); break; } QRegExp re(errorString); -- cgit v0.12 From 4f818b8bcf51cf9c654edbf319d90f6c77a09b3e Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 16:39:50 +1000 Subject: Remove Q_ASSERT from QXmlInputSource autotest Report a fatal error in all builds rather than aborting in debug mode builds only. Change-Id: I53b348f077c6533433e32bbebd159066a2bc2c37 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp b/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp index c0029f5..a2c84cf 100644 --- a/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp +++ b/tests/auto/qxmlinputsource/tst_qxmlinputsource.cpp @@ -181,9 +181,7 @@ private slots: { if(bodyLength == -1) { - Q_ASSERT_X(false, Q_FUNC_INFO, - "No length was specified in the header."); - return; + qFatal("No length was specified in the header."); } QDomDocument domDoc; -- cgit v0.12 From d7453aef14b80a5972909ed99f1b4c765b7436a5 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 17:16:52 +1000 Subject: Remove Q_ASSERT from qxmlsimplereader autotest Verify the success of setting the document content in the test function rather than using Q_ASSERT. Change-Id: I25e017e7f92803867a998b4f09ad9f717212a9bc Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../auto/qxmlsimplereader/tst_qxmlsimplereader.cpp | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp index 565df30..0e49304 100644 --- a/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -165,7 +165,7 @@ class tst_QXmlSimpleReader : public QObject void roundtripWithNamespaces() const; private: - static QDomDocument fromByteArray(const QString &title, const QByteArray &ba); + static QDomDocument fromByteArray(const QString &title, const QByteArray &ba, bool *ok); XmlServer *server; }; @@ -730,25 +730,27 @@ void tst_QXmlSimpleReader::reportNamespace_data() const << QString("http://example.com/"); } -QDomDocument tst_QXmlSimpleReader::fromByteArray(const QString &title, const QByteArray &ba) +QDomDocument tst_QXmlSimpleReader::fromByteArray(const QString &title, const QByteArray &ba, bool *ok) { QDomDocument doc(title); - const bool ret = doc.setContent(ba, true); - Q_ASSERT(ret); + *ok = doc.setContent(ba, true); return doc; } void tst_QXmlSimpleReader::roundtripWithNamespaces() const { - QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort); - const char *const expected = "<element b:attr=\"value\" xmlns:a=\"http://www.example.com/A\" xmlns:b=\"http://www.example.com/B\" />\n"; + bool ok; { const char *const xml = "<element xmlns:b=\"http://www.example.com/B\" b:attr=\"value\" xmlns:a=\"http://www.example.com/A\"/>"; - const QDomDocument one(fromByteArray("document", xml)); - const QDomDocument two(fromByteArray("document2", one.toByteArray(2))); + const QDomDocument one(fromByteArray("document", xml, &ok)); + QVERIFY(ok); + const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok)); + QVERIFY(ok); + + QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort); QCOMPARE(expected, one.toByteArray().constData()); QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData()); @@ -758,8 +760,10 @@ void tst_QXmlSimpleReader::roundtripWithNamespaces() const { const char *const xml = "<element b:attr=\"value\" xmlns:b=\"http://www.example.com/B\" xmlns:a=\"http://www.example.com/A\"/>"; - const QDomDocument one(fromByteArray("document", xml)); - const QDomDocument two(fromByteArray("document2", one.toByteArray(2))); + const QDomDocument one(fromByteArray("document", xml, &ok)); + QVERIFY(ok); + const QDomDocument two(fromByteArray("document2", one.toByteArray(2), &ok)); + QVERIFY(ok); QCOMPARE(expected, one.toByteArray().constData()); QCOMPARE(one.toByteArray(2).constData(), two.toByteArray(2).constData()); -- cgit v0.12 From 614474fb3d440eabd3ba7e381d246064ce39f4fa Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 17:30:43 +1000 Subject: Remove unused code from QXmlStream autotest Change-Id: I719e502ef14848a22d41de71245fe6b6758c8d6b Reviewed-by: Rohan McGovern --- tests/auto/qxmlstream/qc14n.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/auto/qxmlstream/qc14n.h b/tests/auto/qxmlstream/qc14n.h index bf80908..99432f3 100644 --- a/tests/auto/qxmlstream/qc14n.h +++ b/tests/auto/qxmlstream/qc14n.h @@ -47,17 +47,9 @@ QT_FORWARD_DECLARE_CLASS(QString) class QC14N { public: - enum Option - { - IgnoreProcessingInstruction, - IgnoreComments - }; - typedef QFlags<Option> Options; - static bool isEqual(QIODevice *const firstDocument, QIODevice *const secondDocument, - QString *const message = 0, - const Options options = Options()); + QString *const message = 0); private: static bool isDifferent(const QXmlStreamReader &r1, @@ -76,8 +68,7 @@ private: */ bool QC14N::isEqual(QIODevice *const firstDocument, QIODevice *const secondDocument, - QString *const message, - const Options options) + QString *const message) { qDebug() << Q_FUNC_INFO; Q_ASSERT_X(firstDocument, Q_FUNC_INFO, @@ -86,10 +77,6 @@ bool QC14N::isEqual(QIODevice *const firstDocument, "A valid QIODevice pointer must be supplied"); Q_ASSERT_X(firstDocument->isReadable(), Q_FUNC_INFO, "The device must be readable."); Q_ASSERT_X(secondDocument->isReadable(), Q_FUNC_INFO, "The device must be readable."); - - Q_ASSERT_X(options == Options(), Q_FUNC_INFO, - "Not yet implemented."); - Q_UNUSED(options); QXmlStreamReader r1(firstDocument); QXmlStreamReader r2(secondDocument); -- cgit v0.12 From 8a1279b0ae180fae94d3da1a4eeb20df5a748d33 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 4 May 2011 10:56:50 +1000 Subject: Remove Q_ASSERT's from qtestlib selftests Report a fatal error in all builds rather than just in debug mode builds. Change-Id: Ie54e55ea2dd13bbb12e4265278db832ac1297c28 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/selftests/alive/qtestalive.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/auto/selftests/alive/qtestalive.cpp b/tests/auto/selftests/alive/qtestalive.cpp index ba42367..e743eae 100644 --- a/tests/auto/selftests/alive/qtestalive.cpp +++ b/tests/auto/selftests/alive/qtestalive.cpp @@ -78,7 +78,8 @@ private: QTestAlivePinger::QTestAlivePinger(QObject *receiver, QObject *parent) : QObject(parent), rec(receiver), currentSequenceId(0), lastSequenceId(0) { - Q_ASSERT(rec); + if (!rec) + qFatal("Null receiver object passed to QTestAlivePinger::QTestAlivePinger()"); timerId = startTimer(850); } @@ -147,8 +148,8 @@ bool QTestAlive::event(QEvent *e) void QTestAlive::run() { - Q_ASSERT_X(QCoreApplication::instance(), "QTestAlive::run()", - "Cannot start QTestAlive without a QCoreApplication instance."); + if (!QCoreApplication::instance()) + qFatal("QTestAlive::run(): Cannot start QTestAlive without a QCoreApplication instance."); QTestAlivePinger p(this); pinger = &p; -- cgit v0.12 From edd9d3f64f1532e39a80a2c7a97a2501391b2316 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 4 May 2011 11:17:49 +1000 Subject: Remove Q_ASSERT's from xmlpatterns autotest Verify initial state in initTestCase() rather than asserting in the test class's constructor. Change-Id: Ic7612a5368e35b2abda96828d2a95690baeaf6a9 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/xmlpatterns/tst_xmlpatterns.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp index 4d59f22..45aa8d6 100644 --- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp +++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp @@ -107,13 +107,13 @@ tst_XmlPatterns::tst_XmlPatterns() : m_generatedTests(0) , m_dontRun(false) { Q_SET_DEFAULT_IAP - - Q_ASSERT(m_normalizeTestName.isValid()); - Q_ASSERT(m_filenameInStderr.isValid()); } void tst_XmlPatterns::initTestCase() { + QVERIFY(m_normalizeTestName.isValid()); + QVERIFY(m_filenameInStderr.isValid()); + QProcess process; process.start(m_command); @@ -121,7 +121,7 @@ void tst_XmlPatterns::initTestCase() { m_dontRun = true; QEXPECT_FAIL("", "The command line tool is not in the path, most likely because Qt " - "has been partically built, such as only the sub-src rule. No tests will be run.", Abort); + "has been partially built, such as only the sub-src rule. No tests will be run.", Abort); QVERIFY(false); } -- cgit v0.12 From 6f791f8ad0b7ef023d91c1609ce076443f335c13 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 4 May 2011 12:26:59 +1000 Subject: Remove Q_ASSERT's from ecmascript test. These Q_ASSERT's were redundant as the test functions that call these functions already verify that "value == 0". Change-Id: Ic23e539c5814153d67fea8156ade0783f91d7b83 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 48466d5..6be0275 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -2149,16 +2149,12 @@ public: ~CppOwnershipReturnValue() { delete value; } Q_INVOKABLE QObject *create() { - Q_ASSERT(value == 0); - value = new QObject; QDeclarativeEngine::setObjectOwnership(value, QDeclarativeEngine::CppOwnership); return value; } Q_INVOKABLE MyQmlObject *createQmlObject() { - Q_ASSERT(value == 0); - MyQmlObject *rv = new MyQmlObject; value = rv; return rv; -- cgit v0.12 From 1ea84cba1f90a9c95c54480117342dba0eae3d2f Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 4 May 2011 12:54:10 +1000 Subject: Remove Q_ASSERT from qdeclarativexmllistmodel test Report a meaningful warning in all builds rather than aborting in debug builds and doing nothing in release builds. Change-Id: I14aa7bc8699f5307e1ec34b18006b9fbbd8aca8e Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index af54008..4ec2783 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -126,7 +126,10 @@ private: QStringList fields = item.split(","); foreach(const QString &field, fields) { QStringList values = field.split("="); - Q_ASSERT(values.count() == 2); + if (values.count() != 2) { + qWarning() << "makeItemXmlAndData: invalid field:" << field; + continue; + } xml += QString("<%1>%2</%1>").arg(values[0], values[1]); if (!modelData) continue; -- cgit v0.12 From c183540c6c244f327ebd834167799072dcc3b72d Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 17:37:05 +1000 Subject: Remove Q_ASSERT's from QXmlStream autotest. Report a fatal error in all builds rather than only in debug mode builds. Change-Id: I6b3a999dd3ccf00ae66a86b43c125d7082cf0ae5 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlstream/tst_qxmlstream.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp index fd2f90e..5324264 100644 --- a/tests/auto/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp @@ -221,8 +221,7 @@ static QString documentElement(const QByteArray &document) reader.readNext(); } - Q_ASSERT_X(false, Q_FUNC_INFO, - qPrintable(QString::fromLatin1("The input %1 didn't contain an element.").arg(QString::fromUtf8(document.constData())))); + qFatal("The input %s didn't contain an element", document.constData()); return QString(); } @@ -461,7 +460,7 @@ public: } else { - Q_ASSERT_X(false, Q_FUNC_INFO, "The input catalog is invalid."); + qFatal("The input catalog is invalid."); return false; } } -- cgit v0.12 From 324b9db856f00a82d7fd3426d9b698211290efaa Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 14:52:57 +1000 Subject: Remove mention of Q_ASSERT in QTableView test. Change-Id: If27cb7031cdde222d1dd988188569dca4b1fb6d9 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtableview/tst_qtableview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 380116d..d715914 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3028,7 +3028,7 @@ void tst_QTableView::spans_data() << 1 << 2; - QTest::newRow("QTBUG-6004: No failing Q_ASSERT, then it passes.") + QTest::newRow("QTBUG-6004: No failing assertion, then it passes.") << 5 << 5 << (SpanList() << QRect(0, 0, 2, 2) << QRect(0, 0, 1, 1)) << false @@ -3036,7 +3036,7 @@ void tst_QTableView::spans_data() << 1 << 1; - QTest::newRow("QTBUG-6004 (follow-up): No failing Q_ASSERT, then it passes.") + QTest::newRow("QTBUG-6004 (follow-up): No failing assertion, then it passes.") << 10 << 10 << (SpanList() << QRect(2, 2, 1, 3) << QRect(2, 2, 1, 1)) << false -- cgit v0.12 From a7acd7e0a09d89647abb9ff91b1bcb55d1a7a849 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 12:06:09 +1000 Subject: Remove Q_ASSERT's from QScriptable autotest The helper class expects a valid script engine to be available and attempted to verify this with Q_ASSERT (which does nothing in release mode) and QVERIFY (which should only be used directly in test functions). This commit makes the helper class avoid using an invalid engine and catches the problem later by verifying that the last script engine used by the scriptable class was valid. Change-Id: I849df32b141b7801b9b5a92f44ff325397e32f2d Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptable/tst_qscriptable.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/auto/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp index f5d36ea..97af050 100644 --- a/tests/auto/qscriptable/tst_qscriptable.cpp +++ b/tests/auto/qscriptable/tst_qscriptable.cpp @@ -137,8 +137,8 @@ int MyScriptable::getArgumentCount() void MyScriptable::foo() { m_lastEngine = engine(); - QVERIFY(engine() != 0); - context()->throwError("MyScriptable.foo"); + if (engine()) + context()->throwError("MyScriptable.foo"); } void MyScriptable::evalIsBar() @@ -164,15 +164,15 @@ void MyScriptable::setOtherEngine() void MyScriptable::setX(int x) { m_lastEngine = engine(); - Q_ASSERT(engine()); - thisObject().setProperty("x", QScriptValue(engine(), x)); + if (engine()) + thisObject().setProperty("x", QScriptValue(engine(), x)); } void MyScriptable::setX(const QString &x) { m_lastEngine = engine(); - Q_ASSERT(engine()); - thisObject().setProperty("x", QScriptValue(engine(), x)); + if (engine()) + thisObject().setProperty("x", QScriptValue(engine(), x)); } void MyScriptable::setX2(int) @@ -291,6 +291,7 @@ void tst_QScriptable::thisObject() "o.setX(123);" "o.__proto__ = Object.prototype;" "o.x"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, 123)), true); } { @@ -298,46 +299,55 @@ void tst_QScriptable::thisObject() "o.setX2(456);" "o.__proto__ = Object.prototype;" "o.x"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, 456)), true); } m_engine.evaluate("o.__proto__ = scriptable"); { QScriptValue ret = m_engine.evaluate("o.isBar()"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, false)), true); } { QScriptValue ret = m_engine.evaluate("o.toString = function() { return 'foo@bar'; }; o.isBar()"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.strictlyEquals(QScriptValue(&m_engine, true)), true); } // property getter { QScriptValue ret = m_engine.evaluate("scriptable.zab"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isQObject(), true); QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable); } { QScriptValue ret = m_engine.evaluate("scriptable[1]"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isQObject(), true); QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable); } { QScriptValue ret = m_engine.evaluate("o.zab"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.toQObject(), (QObject *)0); } // property setter { QScriptValue ret = m_engine.evaluate("scriptable.setZab(null)"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isQObject(), true); QCOMPARE(ret.toQObject(), (QObject *)&m_scriptable); } { QVERIFY(!m_scriptable.oofThisObject().isValid()); m_engine.evaluate("o.oof = 123"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("o"))); } { m_engine.evaluate("scriptable.oof = 123"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("scriptable"))); } @@ -345,13 +355,17 @@ void tst_QScriptable::thisObject() { { QScriptValue ret = m_engine.evaluate("scriptable.sig.connect(o, scriptable.setX)"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(ret.isUndefined()); } QVERIFY(m_engine.evaluate("o.x").strictlyEquals(QScriptValue(&m_engine, 456))); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); m_scriptable.emitSig(654321); QVERIFY(m_engine.evaluate("o.x").strictlyEquals(QScriptValue(&m_engine, 654321))); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); { QScriptValue ret = m_engine.evaluate("scriptable.sig.disconnect(o, scriptable.setX)"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QVERIFY(ret.isUndefined()); } } @@ -383,6 +397,7 @@ void tst_QScriptable::arguments() void tst_QScriptable::throwError() { QScriptValue ret = m_engine.evaluate("scriptable.foo()"); + QCOMPARE(m_scriptable.lastEngine(), &m_engine); QCOMPARE(ret.isError(), true); QCOMPARE(ret.toString(), QString("Error: MyScriptable.foo")); } -- cgit v0.12 From 8e12d9e322ec7d8f7eece09b6f15cba640615f9e Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 15:03:35 +1000 Subject: Remove Q_ASSERT from qtesselator autotest If the test data is incorrect, print a meaningful error message into the test output. Change-Id: I505a86b4411619d3c3be9541c96c082f92589ff7 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtessellator/oldtessellator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qtessellator/oldtessellator.cpp b/tests/auto/qtessellator/oldtessellator.cpp index 78f117f..10b8710 100644 --- a/tests/auto/qtessellator/oldtessellator.cpp +++ b/tests/auto/qtessellator/oldtessellator.cpp @@ -218,7 +218,8 @@ void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pg qreal ymax(INT_MIN/256); //painter.begin(pg, pgSize); - Q_ASSERT(pg[0] == pg[pgSize-1]); + if (pg[0] != pg[pgSize-1]) + qWarning() << Q_FUNC_INFO << "Malformed polygon (first and last points must be identical)"; // generate edge table // qDebug() << "POINTS:"; for (int x = 0; x < pgSize-1; ++x) { -- cgit v0.12 From cb126ff7ad08e9801e2911511aa9aeb728faa8f3 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 15:55:30 +1000 Subject: Remove Q_ASSERT's from QTreeView autotest Issue a meaningful fatal error in preference to aborting in debug mode builds and crashing in release mode builds. Change-Id: I7bb04e1e222fd6167be19b5d88caac27b43d88df Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtreeview/tst_qtreeview.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index c07c471..551b63f 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -2536,7 +2536,7 @@ void tst_QTreeView::sortByColumn() /* This is a model that every time kill() is called it will completely change - all of its nodes for new nodes. It then asserts if you later use a dead node. + all of its nodes for new nodes. It then qFatal's if you later use a dead node. */ class EvilModel: public QAbstractItemModel { @@ -2624,7 +2624,8 @@ public: Node *parentNode = root; if (parent.isValid()) { parentNode = static_cast<Node*>(parent.internalPointer()); - Q_ASSERT(!parentNode->isDead); + if (parentNode->isDead) + qFatal("%s: parentNode is dead!", Q_FUNC_INFO); } return parentNode->children.count(); } @@ -2639,9 +2640,11 @@ public: Node *grandparentNode = static_cast<Node*>(parent.internalPointer()); Node *parentNode = root; if (parent.isValid()) { - Q_ASSERT(!grandparentNode->isDead); + if (grandparentNode->isDead) + qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO); parentNode = grandparentNode->children[parent.row()]; - Q_ASSERT(!parentNode->isDead); + if (parentNode->isDead) + qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO); } return createIndex(row, column, parentNode); } @@ -2661,7 +2664,8 @@ public: Node *parentNode = root; if (idx.isValid()) { parentNode = static_cast<Node*>(idx.internalPointer()); - Q_ASSERT(!parentNode->isDead); + if (parentNode->isDead) + qFatal("%s: grandparentNode is dead!", Q_FUNC_INFO); } return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column()) .arg(parentNode->isDead ? "dead" : "alive"); -- cgit v0.12 From 66aafe42f9076c0d70037ee8fad0e382828ed7bb Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Wed, 4 May 2011 10:36:05 +0200 Subject: Fix ordinal number conflict Caused by previous merge conflict. Should have made it sequential. Reviewed-by: TrustMe --- src/s60installs/eabi/QtGuiu.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 1914e1f..318b394 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12183,5 +12183,5 @@ EXPORTS _ZN15QGraphicsSystem22releaseCachedResourcesEv @ 12182 NONAME _Z32qt_s60_setPartialScreenInputModeb @ 12183 NONAME _Z29qt_draw_decoration_for_glyphsP8QPainterPKjPK11QFixedPointiP11QFontEngineRK5QFontRK15QTextCharFormat @ 12184 NONAME - _ZNK14QVolatileImage14paintingActiveEv @ 12186 NONAME + _ZNK14QVolatileImage14paintingActiveEv @ 12185 NONAME -- cgit v0.12 From 5aa5c2e2935c1829cc6965198968699f17c24ec0 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Date: Wed, 4 May 2011 10:52:20 +0200 Subject: Include pixel size of font in exported HTML from QTextDocument When you copy-pasted rich text in which the font size had been set using setPixelSize() the font size would be mysteriously forgotten. The pixel size property in QTextCharFormat was added ad hoc, and not integrated in the HTML exporter. Task-number: QT-4792 Reviewed-by: Gunnar --- src/gui/text/qtextdocument.cpp | 8 ++++++++ tests/auto/qtextdocument/tst_qtextdocument.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 36f3c6c..9169955 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2099,6 +2099,10 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) html += QLatin1String(" font-size:"); html += QString::number(defaultCharFormat.fontPointSize()); html += QLatin1String("pt;"); + } else if (defaultCharFormat.hasProperty(QTextFormat::FontPixelSize)) { + html += QLatin1String(" font-size:"); + html += QString::number(defaultCharFormat.intProperty(QTextFormat::FontPixelSize)); + html += QLatin1String("px;"); } html += QLatin1String(" font-weight:"); @@ -2179,6 +2183,10 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) html += QLatin1Char(';'); attributesEmitted = true; } + } else if (format.hasProperty(QTextFormat::FontPixelSize)) { + html += QLatin1String(" font-size:"); + html += QString::number(format.intProperty(QTextFormat::FontPixelSize)); + html += QLatin1String("px;"); } if (format.hasProperty(QTextFormat::FontWeight) diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 6675c99..26fa43d 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -180,6 +180,8 @@ private slots: void escape_data(); void escape(); + void copiedFontSize(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); @@ -2734,5 +2736,29 @@ void tst_QTextDocument::escape() QCOMPARE(Qt::escape(original), expected); } +void tst_QTextDocument::copiedFontSize() +{ + QTextDocument documentInput; + QTextDocument documentOutput; + + QFont fontInput; + fontInput.setPixelSize(24); // With pixels font size is not transfered in html + + QTextCursor cursorInput(&documentInput); + QTextCharFormat formatInput = cursorInput.charFormat(); + formatInput.setFont(fontInput); + cursorInput.insertText("Should be the same font", formatInput); + cursorInput.select(QTextCursor::Document); + + QTextDocumentFragment fragmentInput(cursorInput); + QString html = fragmentInput.toHtml(); + + QTextCursor cursorOutput(&documentOutput); + QTextDocumentFragment fragmentOutput = QTextDocumentFragment::fromHtml(html); + cursorOutput.insertFragment(fragmentOutput); + + QCOMPARE(cursorOutput.charFormat().font().pixelSize(), 24); +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" -- cgit v0.12 From 5f241ec1426447380b1e938ac7888fb16cde94f8 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Wed, 4 May 2011 13:02:57 +0100 Subject: Fix QNetworkConfigurationManager usage outside main thread first QNetworkConfigurationManager creates the engines loaded from plugins as objects in the main thread. If a QNetworkConfigurationManager instance is created in a worker thread without any instance previously existing in the main thread, then it is uninitialised until the main thread has run. This causes allConfigurations() to return an empty list if called immediately after instantiation, for example. This fix initialises the plugins using blocking queued connections, which causes the worker thread to block until the initialisation function has been called in the context of the main thread. Deadlock is possible if the main thread is for some reason waiting on the worker thread, but it will not deadlock on QNetworkConfigurationManager's mutex. If this is a problem for an application, it should use QNetworkConfigurationManager from the main thread first to preload the plugins. Task-number: QTBUG-18795 Task-number: QTBUG-18799 Reviewed-by: Cristiano Di Flora --- src/network/bearer/qnetworkconfigmanager_p.cpp | 15 +++++++-- .../tst_qnetworkconfigurationmanager.cpp | 38 ++++++++++++++++++++++ .../tst_qnetworkproxyfactory.cpp | 31 +++++++++++++++++- 3 files changed, 80 insertions(+), 4 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index c321328..f703354 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -392,8 +392,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); - - QMetaObject::invokeMethod(engine, "initialize"); } } @@ -423,8 +421,19 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() startPolling(); } - if (firstUpdate) + if (firstUpdate) { firstUpdate = false; + QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex + Qt::ConnectionType connectionType; + if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) + connectionType = Qt::DirectConnection; + else + connectionType = Qt::BlockingQueuedConnection; + locker.unlock(); + foreach (QBearerEngine* engine, enginesToInitialize) { + QMetaObject::invokeMethod(engine, "initialize", connectionType); + } + } } void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 443fd18..57812d3 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -62,6 +62,7 @@ public slots: void cleanup(); private slots: + void usedInThread(); // this test must be first, or it will falsely pass void allConfigurations(); void defaultConfiguration(); void configurationFromIdentifier(); @@ -329,6 +330,43 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier() QVERIFY(!invalid.isValid()); } +class QNCMTestThread : public QThread +{ +protected: + virtual void run() + { + QNetworkConfigurationManager manager; + preScanConfigs = manager.allConfigurations(); + QSignalSpy spy(&manager, SIGNAL(updateCompleted())); + manager.updateConfigurations(); //initiate scans + QTRY_VERIFY(spy.count() == 1); //wait for scan to complete + configs = manager.allConfigurations(); + } +public: + QList<QNetworkConfiguration> configs; + QList<QNetworkConfiguration> preScanConfigs; +}; + +// regression test for QTBUG-18795 +void tst_QNetworkConfigurationManager::usedInThread() +{ + QNCMTestThread thread; + connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + thread.start(); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(thread.isFinished()); + qDebug() << "prescan:" << thread.preScanConfigs.count(); + qDebug() << "postscan:" << thread.configs.count(); + + QNetworkConfigurationManager manager; + QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations(); + QSignalSpy spy(&manager, SIGNAL(updateCompleted())); + manager.updateConfigurations(); //initiate scans + QTRY_VERIFY(spy.count() == 1); //wait for scan to complete + QList<QNetworkConfiguration> configs = manager.allConfigurations(); + QCOMPARE(thread.configs, configs); + QCOMPARE(thread.preScanConfigs, preScanConfigs); +} QTEST_MAIN(tst_QNetworkConfigurationManager) #include "tst_qnetworkconfigurationmanager.moc" diff --git a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index 10fa7c6..85b1944 100644 --- a/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -41,14 +41,17 @@ #include <QtTest/QTest> +#include <QtTest/QTestEventLoop> #include <qcoreapplication.h> #include <qdebug.h> #include <qnetworkproxy.h> +#include <QThread> class tst_QNetworkProxyFactory : public QObject { Q_OBJECT private slots: + void systemProxyForQueryCalledFromThread(); void systemProxyForQuery() const; private: @@ -96,5 +99,31 @@ void tst_QNetworkProxyFactory::systemProxyForQuery() const QFAIL("One or more system proxy lookup failures occurred."); } +class QSPFQThread : public QThread +{ +protected: + virtual void run() + { + proxies = QNetworkProxyFactory::systemProxyForQuery(query); + } +public: + QNetworkProxyQuery query; + QList<QNetworkProxy> proxies; +}; + +//regression test for QTBUG-18799 +void tst_QNetworkProxyFactory::systemProxyForQueryCalledFromThread() +{ + QUrl url(QLatin1String("http://qt.nokia.com")); + QNetworkProxyQuery query(url); + QSPFQThread thread; + thread.query = query; + connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + thread.start(); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(thread.isFinished()); + QCOMPARE(thread.proxies, QNetworkProxyFactory::systemProxyForQuery(query)); +} + QTEST_MAIN(tst_QNetworkProxyFactory) #include "tst_qnetworkproxyfactory.moc" -- cgit v0.12 From e1cd594cf2daa6667b411aa639f4ec1195b7e067 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Wed, 23 Feb 2011 13:52:29 +0000 Subject: Fix compile errors in bearer tests Excluded maemo code from symbian builds. Reviewed-by: Markus Goetz --- tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp | 8 ++++---- .../tst_qnetworkconfigurationmanager.cpp | 8 ++++---- tests/auto/qnetworksession/test/tst_qnetworksession.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index adcfd93..c31eac7 100644 --- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -52,7 +52,7 @@ */ #include <QNetworkAccessManager> -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) #include <stdio.h> #include <iapconf.h> #endif @@ -73,7 +73,7 @@ private slots: void isRoamingAvailable(); private: -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) Maemo::IAPConf *iapconf; Maemo::IAPConf *iapconf2; Maemo::IAPConf *gprsiap; @@ -85,7 +85,7 @@ private: void tst_QNetworkConfiguration::initTestCase() { -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); iapconf->setValue("wlan_wepkey1", "connt"); @@ -158,7 +158,7 @@ void tst_QNetworkConfiguration::initTestCase() void tst_QNetworkConfiguration::cleanupTestCase() { -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) iapconf->clear(); delete iapconf; iapconf2->clear(); diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 57812d3..3359533 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -45,7 +45,7 @@ #include <QtNetwork/qnetworkconfiguration.h> #include <QtNetwork/qnetworkconfigmanager.h> -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) #include <stdio.h> #include <iapconf.h> #endif @@ -68,7 +68,7 @@ private slots: void configurationFromIdentifier(); private: -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) Maemo::IAPConf *iapconf; Maemo::IAPConf *iapconf2; Maemo::IAPConf *gprsiap; @@ -80,7 +80,7 @@ private: void tst_QNetworkConfigurationManager::initTestCase() { -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); iapconf->setValue("wlan_wepkey1", "connt"); @@ -154,7 +154,7 @@ void tst_QNetworkConfigurationManager::initTestCase() void tst_QNetworkConfigurationManager::cleanupTestCase() { -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) iapconf->clear(); delete iapconf; iapconf2->clear(); diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 3315836..13cedda 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -48,7 +48,7 @@ #include <QtNetwork/qnetworkconfigmanager.h> #include <QtNetwork/qnetworksession.h> -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) #include <stdio.h> #include <iapconf.h> #endif @@ -105,7 +105,7 @@ private: int inProcessSessionManagementCount; -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) Maemo::IAPConf *iapconf; Maemo::IAPConf *iapconf2; Maemo::IAPConf *gprsiap; @@ -140,7 +140,7 @@ void tst_QNetworkSession::initTestCase() testsToRun["userChoiceSession"] = true; testsToRun["sessionOpenCloseStop"] = true; -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) iapconf = new Maemo::IAPConf("007"); iapconf->setValue("ipv4_type", "AUTO"); iapconf->setValue("wlan_wepkey1", "connt"); @@ -226,7 +226,7 @@ void tst_QNetworkSession::cleanupTestCase() "inProcessSessionManagement()"); } -#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD) && !defined (Q_OS_SYMBIAN) iapconf->clear(); delete iapconf; iapconf2->clear(); -- cgit v0.12 From 5953d930bc07fa6734a11d053d26a3f80e9c1e89 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 4 May 2011 16:53:16 +1000 Subject: Remove Q_ASSERT in gestures autotest Rather than aborting on a bad gesture event in debug builds and ignoring the error in release builds, record a count of bad events and fail the test if the count is non-zero at the end of the test function. Change-Id: I6ddd46a5a656185c13eae4bbbb496b986a0c92f6 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/gestures/tst_gestures.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index bff8a04..d580c8b 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -1518,17 +1518,20 @@ void tst_Gestures::autoCancelGestures() { class MockWidget : public GestureWidget { public: - MockWidget(const char *name) : GestureWidget(name) { } + MockWidget(const char *name) : GestureWidget(name), badGestureEvents(0) { } bool event(QEvent *event) { if (event->type() == QEvent::Gesture) { QGestureEvent *ge = static_cast<QGestureEvent*>(event); - Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here... + if (ge->gestures().count() != 1) + ++badGestureEvents; // event should contain exactly one gesture ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); } return GestureWidget::event(event); } + + int badGestureEvents; }; const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer); @@ -1563,22 +1566,26 @@ void tst_Gestures::autoCancelGestures() event.serial = CustomGesture::SerialFinishedThreshold; QApplication::sendEvent(child, &event); QCOMPARE(parent.events.all.count(), 2); + QCOMPARE(parent.badGestureEvents, 0); } void tst_Gestures::autoCancelGestures2() { class MockItem : public GestureItem { public: - MockItem(const char *name) : GestureItem(name) { } + MockItem(const char *name) : GestureItem(name), badGestureEvents(0) { } bool event(QEvent *event) { if (event->type() == QEvent::Gesture) { QGestureEvent *ge = static_cast<QGestureEvent*>(event); - Q_ASSERT(ge->gestures().count() == 1); // can't use QCOMPARE here... + if (ge->gestures().count() != 1) + ++badGestureEvents; // event should contain exactly one gesture ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); } return GestureItem::event(event); } + + int badGestureEvents; }; const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer); @@ -1614,6 +1621,7 @@ void tst_Gestures::autoCancelGestures2() event.serial = CustomGesture::SerialFinishedThreshold; scene.sendEvent(child, &event); QCOMPARE(parent->events.all.count(), 2); + QCOMPARE(parent->badGestureEvents, 0); } void tst_Gestures::graphicsViewParentPropagation() -- cgit v0.12 From a212b402da4b4af9d453fa96dbfa2d32271e857d Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 4 May 2011 16:25:14 +1000 Subject: Remove Q_ASSERT's from exceptionsafety_objects test Report a fatal error in all builds, not just in debug builds. Change-Id: Iad990e2d3b29a55e995254d466e967a4a722bb23 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 2f094f3..d167228 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -371,7 +371,8 @@ struct WidgetCreator : public AbstractTester { void operator()(QObject *parent) { - Q_ASSERT(!parent || parent->isWidgetType()); + if (parent && !parent->isWidgetType()) + qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO); QScopedPointer<T> ptr(parent ? new T(static_cast<QWidget *>(parent)) : new T); } }; @@ -381,7 +382,8 @@ template <> struct WidgetCreator<QSizeGrip> : public AbstractTester { void operator()(QObject *parent) { - Q_ASSERT(!parent || parent->isWidgetType()); + if (parent && !parent->isWidgetType()) + qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO); QScopedPointer<QSizeGrip> ptr(new QSizeGrip(static_cast<QWidget *>(parent))); } }; @@ -391,7 +393,8 @@ template <> struct WidgetCreator<QDesktopWidget> : public AbstractTester { void operator()(QObject *parent) { - Q_ASSERT(!parent || parent->isWidgetType()); + if (parent && !parent->isWidgetType()) + qFatal("%s: parent must be either null or a widget type", Q_FUNC_INFO); QScopedPointer<QDesktopWidget> ptr(new QDesktopWidget()); } }; -- cgit v0.12 From 28ccfa472991c0480e67b5f204a567c4023ba6d4 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 15:30:33 +1000 Subject: Remove Q_ASSERT from qtesselator autotest If the test data is incorrect, print a meaningful warning into the test output. Change-Id: Ibfe64ef41a0ff3eb47c2385d1c31191334a675a8 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtessellator/testtessellator.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qtessellator/testtessellator.cpp b/tests/auto/qtessellator/testtessellator.cpp index 339f05f..d8d6f6f 100644 --- a/tests/auto/qtessellator/testtessellator.cpp +++ b/tests/auto/qtessellator/testtessellator.cpp @@ -42,6 +42,7 @@ #include <private/qtessellator_p.h> #include "math.h" +#include <QtCore/QDebug> class TestTessellator : public QTessellator { @@ -91,7 +92,8 @@ void test_tessellate_polygon_rect(QVector<XTrapezoid> *traps, const QPointF *poi bool winding) { // 5 points per rect - Q_ASSERT(nPoints % 5 == 0); + if (nPoints % 5 != 0) + qWarning() << Q_FUNC_INFO << "multiples of 5 points expected"; TestTessellator t; t.traps = traps; -- cgit v0.12 From f18e0e01468899731bc3777649d69fd6d0041012 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 11:53:57 +1000 Subject: Remove Q_ASSERT from QMutex autotest Rather than aborting in debug mode and doing nothing in release mode when the invariant is violated, count the failures and fail the test gracefully. Change-Id: Ie193460c478ddde540b6b15aafdce32f471b4b2b Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qmutex/tst_qmutex.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp index ea983cb..dc3ffa4 100644 --- a/tests/auto/qmutex/tst_qmutex.cpp +++ b/tests/auto/qmutex/tst_qmutex.cpp @@ -465,7 +465,12 @@ void tst_QMutex::tryLockRace() TryLockRaceThread::mutex.unlock(); } +// Variable that will be protected by the mutex. Volatile so that the +// the optimiser doesn't mess with it based on the increment-then-decrement +// usage pattern. static volatile int qtbug16115_trylock_counter; +// Counter for how many times the protected variable has an incorrect value. +static int qtbug16115_failure_count = 0; void tst_QMutex::qtbug16115_trylock() { @@ -476,8 +481,10 @@ void tst_QMutex::qtbug16115_trylock() void run() { for (int i = 0; i < 1000000; ++i) { if (mut.tryLock(0)) { - Q_ASSERT((++qtbug16115_trylock_counter) == 1); - Q_ASSERT((--qtbug16115_trylock_counter) == 0); + if ((++qtbug16115_trylock_counter) != 1) + ++qtbug16115_failure_count; + if ((--qtbug16115_trylock_counter) != 0) + ++qtbug16115_failure_count; mut.unlock(); } } @@ -493,13 +500,16 @@ void tst_QMutex::qtbug16115_trylock() for (int i = 0; i < 1000000; ++i) { mut.lock(); - Q_ASSERT((++qtbug16115_trylock_counter) == 1); - Q_ASSERT((--qtbug16115_trylock_counter) == 0); + if ((++qtbug16115_trylock_counter) != 1) + ++qtbug16115_failure_count; + if ((--qtbug16115_trylock_counter) != 0) + ++qtbug16115_failure_count; mut.unlock(); } t1.wait(); t2.wait(); t3.wait(); + QCOMPARE(qtbug16115_failure_count, 0); } QTEST_MAIN(tst_QMutex) -- cgit v0.12 From 57f6ed6664f55ccee62b81750a2b3520249503fd Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 10:21:32 +1000 Subject: Remove Q_ASSERT's from large file autotest. These assertions were made obsolete by the previous change to this test. Change-Id: I3156b273a727f753a6c093c8fc7453b694c777ee Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qfile/largefile/tst_largefile.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/auto/qfile/largefile/tst_largefile.cpp b/tests/auto/qfile/largefile/tst_largefile.cpp index 47f2e73..8070ad2 100644 --- a/tests/auto/qfile/largefile/tst_largefile.cpp +++ b/tests/auto/qfile/largefile/tst_largefile.cpp @@ -160,13 +160,10 @@ static inline void appendRaw(QByteArray &array, T data) */ static inline void topUpWith(QByteArray &array, QByteArray filler, int size) { - Q_ASSERT(filler.size() > 0); - for (int i = (size - array.size()) / filler.size(); i > 0; --i) array.append(filler); if (array.size() < size) { - Q_ASSERT(size - array.size() < filler.size()); array.append(filler.left(size - array.size())); } } @@ -212,8 +209,6 @@ static inline QByteArray generateDataBlock(int blockSize, QString text, qint64 u appendRaw(block, userBits); appendRaw(block, randomBits); - Q_ASSERT( block.size() == blockSize ); - ++counter; return block; } -- cgit v0.12 From 3290dd0d3563310f6bdbabf74105367bd8c611d3 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 3 May 2011 15:32:28 +1000 Subject: Remove Q_ASSERT's from QTextEdit autotest Convert Q_ASSERT to QCOMPARE and remove mention of Q_ASSERT in comments to make it easier to check for unwanted Q_ASSERT's in the future. Change-Id: I7ae250428d4d5682806e724a7207523e65cd9851 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtextedit/tst_qtextedit.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 9ca17b9..4a79e38 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -312,7 +312,7 @@ void tst_QTextEdit::getSetCheck() // void QTextEdit::setFontPointSize(qreal) obj1.setFontPointSize(qreal(1.1)); QCOMPARE(qreal(1.1), obj1.fontPointSize()); - // we currently Q_ASSERT_X in QFont::setPointSizeF for that + // we currently assert in QFont::setPointSizeF for that //obj1.setFontPointSize(0.0); //QCOMPARE(1.1, obj1.fontPointSize()); // Should not accept 0.0 => keep old @@ -322,7 +322,7 @@ void tst_QTextEdit::getSetCheck() QCOMPARE(1, obj1.fontWeight()); // Range<1, 99> obj1.setFontWeight(99); QCOMPARE(99, obj1.fontWeight()); // Range<1, 99> - /* Q_ASSERT_X in qfont.cpp + /* assertion in qfont.cpp obj1.setFontWeight(INT_MIN); QCOMPARE(1, obj1.fontWeight()); // Range<1, 99> obj1.setFontWeight(INT_MAX); @@ -2059,7 +2059,7 @@ void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imag QCOMPARE(original.isNull(), false); QCOMPARE(original.size(), image.size()); - Q_ASSERT(image.depth() == 32); + QCOMPARE(image.depth(), 32); QCOMPARE(original.depth(), image.depth()); const int bytesPerLine = image.bytesPerLine(); -- cgit v0.12 From 95aa4e4f9b82c3652ffc93310b190db869d491df Mon Sep 17 00:00:00 2001 From: Martin Jones <martin.jones@nokia.com> Date: Thu, 5 May 2011 13:24:32 +1000 Subject: Uninitialized memory is compared. Memory is allocated and used without first clearing it. At the least this annoys valgrind, but also has potential for real problems. Change-Id: Icf3fd39f44ee0481dd732510e7f8b3ad6cef477d Task-number: QTBUG-15187 Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativeproperty.cpp | 2 ++ src/declarative/qml/qmetaobjectbuilder.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 0dd0edb..a197a95 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1451,6 +1451,7 @@ QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObj QMetaProperty subProp = subObject->property(subIndex); ValueTypeSerializedData sd; + memset(&sd, 0, sizeof(sd)); sd.isValueType = true; sd.core.load(metaObject->property(index)); sd.valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(subProp); @@ -1465,6 +1466,7 @@ QByteArray QDeclarativePropertyPrivate::saveValueType(const QMetaObject *metaObj QByteArray QDeclarativePropertyPrivate::saveProperty(const QMetaObject *metaObject, int index) { SerializedData sd; + memset(&sd, 0, sizeof(sd)); sd.isValueType = false; sd.core.load(metaObject->property(index)); diff --git a/src/declarative/qml/qmetaobjectbuilder.cpp b/src/declarative/qml/qmetaobjectbuilder.cpp index 6a0226f..0be2a41 100644 --- a/src/declarative/qml/qmetaobjectbuilder.cpp +++ b/src/declarative/qml/qmetaobjectbuilder.cpp @@ -1448,6 +1448,7 @@ QMetaObject *QMetaObjectBuilder::toMetaObject() const { int size = buildMetaObject(d, 0, false); char *buf = reinterpret_cast<char *>(qMalloc(size)); + memset(buf, 0, size); buildMetaObject(d, buf, false); return reinterpret_cast<QMetaObject *>(buf); } @@ -1477,6 +1478,7 @@ QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const QByteArray data; data.resize(size); char *buf = data.data(); + memset(buf, 0, size); buildMetaObject(d, buf, true); if (ok) *ok = true; return data; -- cgit v0.12 From 4fbcb6a531bf424a8dbbbd0ca2947d9e15118885 Mon Sep 17 00:00:00 2001 From: Martin Jones <martin.jones@nokia.com> Date: Thu, 5 May 2011 14:18:28 +1000 Subject: Views do not notify count changes properly The views don't have a valid count until both a model and a delegate are provided. But, countChanged() is not called when a delegate is set after the model, so bindings to count were not evaluated. Also test that count is updated for insertion/removal Change-Id: Ic82039a624c02f0bdb2862ac7a6e215df75bb314 Task-number: QTBUG-19037 Reviewed-by: Bea Lam --- src/declarative/graphicsitems/qdeclarativegridview.cpp | 3 +++ src/declarative/graphicsitems/qdeclarativelistview.cpp | 3 +++ src/declarative/graphicsitems/qdeclarativepathview.cpp | 3 +++ tests/auto/declarative/qdeclarativegridview/data/gridview1.qml | 1 + .../declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp | 3 +++ tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml | 1 + .../declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 3 +++ tests/auto/declarative/qdeclarativepathview/data/datamodel.qml | 1 + tests/auto/declarative/qdeclarativepathview/data/pathview0.qml | 1 + .../declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp | 4 ++++ 10 files changed, 23 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 05e64b9..460f2c3 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1499,6 +1499,7 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { + int oldCount = dataModel->count(); dataModel->setDelegate(delegate); if (isComponentComplete()) { for (int i = 0; i < d->visibleItems.count(); ++i) @@ -1516,6 +1517,8 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) } d->moveReason = QDeclarativeGridViewPrivate::Other; } + if (oldCount != dataModel->count()) + emit countChanged(); emit delegateChanged(); } } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 2e9822e..cb40384 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1813,6 +1813,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { + int oldCount = dataModel->count(); dataModel->setDelegate(delegate); if (isComponentComplete()) { for (int i = 0; i < d->visibleItems.count(); ++i) @@ -1831,6 +1832,8 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) } d->updateViewport(); } + if (oldCount != dataModel->count()) + emit countChanged(); } emit delegateChanged(); } diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index aed849b..be2bd60 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -1021,9 +1021,12 @@ void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate) d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { + int oldCount = dataModel->count(); dataModel->setDelegate(delegate); d->modelCount = dataModel->count(); d->regenerate(); + if (oldCount != dataModel->count()) + emit countChanged(); emit delegateChanged(); } } diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml index caa28d6..a2b0a91 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml @@ -2,6 +2,7 @@ import QtQuick 1.1 Rectangle { id: root + property int count: grid.count property bool showHeader: false property bool showFooter: false property int added: -1 diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index c8e7817..dc79370 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -222,6 +222,7 @@ void tst_QDeclarativeGridView::items() QTRY_VERIFY(contentItem != 0); QTRY_COMPARE(gridview->count(), model.count()); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item for (int i = 0; i < model.count(); ++i) { @@ -305,6 +306,7 @@ void tst_QDeclarativeGridView::inserted() QTRY_VERIFY(contentItem != 0); model.insertItem(1, "Will", "9876"); + QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -382,6 +384,7 @@ void tst_QDeclarativeGridView::removed() QTRY_VERIFY(contentItem != 0); model.removeItem(1); + QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml index 3cd6f42..75ddabb 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml @@ -6,6 +6,7 @@ Rectangle { height: 320 color: "#ffffff" + property int count: list.count property bool showHeader: false property bool showFooter: false property real hr: list.visibleArea.heightRatio diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 0c96587..8b90030 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -389,6 +389,7 @@ void tst_QDeclarativeListView::items() QTRY_VERIFY(listview->highlightItem() != 0); QTRY_COMPARE(listview->count(), model.count()); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item // current item should be first item @@ -517,6 +518,7 @@ void tst_QDeclarativeListView::inserted() model.insertItem(0, "Foo", "1111"); // zero index, and current item + QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item name = findItem<QDeclarativeText>(contentItem, "textName", 0); @@ -583,6 +585,7 @@ void tst_QDeclarativeListView::removed(bool animated) QTRY_VERIFY(contentItem != 0); model.removeItem(1); + QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1); QTRY_VERIFY(name != 0); diff --git a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml index 1322025..e2c4e3d 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml @@ -2,6 +2,7 @@ import QtQuick 1.0 PathView { id: pathview + property int viewCount: count objectName: "pathview" width: 240; height: 320 pathItemCount: testObject.pathItemCount diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml index 04c7717..28b6fb9 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml @@ -2,6 +2,7 @@ import QtQuick 1.0 Rectangle { id: root + property int count: view.count property int currentA: -1 property int currentB: -1 property real delegateWidth: 60 diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 46c3519..24b1115 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -253,6 +253,8 @@ void tst_QDeclarativePathView::items() QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view"); QVERIFY(pathview != 0); + QCOMPARE(pathview->count(), model.count()); + QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight for (int i = 0; i < model.count(); ++i) { @@ -400,6 +402,7 @@ void tst_QDeclarativePathView::dataModel() model.insertItem(4, "orange", "10"); QTest::qWait(100); + QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); QTRY_COMPARE(findItems<QDeclarativeItem>(pathview, "wrapper").count(), 14); QVERIFY(pathview->currentIndex() == 0); @@ -409,6 +412,7 @@ void tst_QDeclarativePathView::dataModel() QCOMPARE(text->text(), model.name(4)); model.removeItem(2); + QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); text = findItem<QDeclarativeText>(pathview, "myText", 2); QVERIFY(text); QCOMPARE(text->text(), model.name(2)); -- cgit v0.12 From 5b044c36d0d7671c8ff9776822cf0f1ad7eeec79 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 5 May 2011 15:15:03 +1000 Subject: Fix compile error. The previous change to tst_qscriptv8testsuite.cpp introduced a compile error due to insufficient parameters to QTest::qVerify(). Change-Id: I9ea9462d830b9d796676947a3598e3c066b29180 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp index 0f63675..7328e1b 100644 --- a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp +++ b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp @@ -153,10 +153,14 @@ void tst_QScriptV8TestSuite::runTestFunction(int testIndex) QScriptValue ret = engine.evaluate(contents); if (engine.hasUncaughtException()) { if (!ret.isError()) { - QTest::qVerify(ret.instanceOf(engine.globalObject().property("MjsUnitAssertionError"))); + int lineNumber = ret.property("lineNumber").toInt32(); + QTest::qVerify(ret.instanceOf(engine.globalObject().property("MjsUnitAssertionError")), + ret.toString().toLatin1(), + "", + path.toLatin1(), + lineNumber); QString actual = ret.property("actual").toString(); QString expected = ret.property("expected").toString(); - int lineNumber = ret.property("lineNumber").toInt32(); QString failMessage; if (shouldGenerateExpectedFailures) { if (ret.property("message").isString()) -- cgit v0.12 From e8fc93973a41f193665baa5fdc26cba951bd692f Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen <miikka.heikkinen@digia.com> Date: Thu, 5 May 2011 14:10:51 +0300 Subject: Fix initial main window dimensions for "fullscreen with softkeys" case The application main window defaults to fullscreen size when initially constructed, even if softkeys are specified for it, as the screen furniture is constructed later in show_sys. This resulted in the main window being partially under softkeys. Fixed by invoking handleClientAreaChange() explicitly in show_sys in fullscreen with softkeys case. Task-number: QTBUG-19043 Reviewed-by: Sami Merila --- src/gui/kernel/qwidget_s60.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index d55e1ad..a5d8f9f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -563,6 +563,11 @@ void QWidgetPrivate::show_sys() if (isFullscreen) { const bool cbaVisible = S60->buttonGroupContainer() && S60->buttonGroupContainer()->IsVisible(); S60->setStatusPaneAndButtonGroupVisibility(false, cbaVisible); + if (cbaVisible) { + // Fix window dimensions as without screen furniture they will have + // defaulted to full screen dimensions initially. + id->handleClientAreaChange(); + } } } } -- cgit v0.12 From c8f299b7e675c839b16d750cd2633a57cdd0526f Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Wed, 4 May 2011 16:06:06 +0200 Subject: Add a way to retrieve CTFontRef from QFont Since macFontID restricts to quint32, we have to return that in QFont::handle. Task-number: QTBUG-17890 Reviewed-by: Eskil --- src/gui/text/qfont_mac.cpp | 7 ++++--- src/gui/text/qfontengine_coretext_p.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qfont_mac.cpp b/src/gui/text/qfont_mac.cpp index daf68c0..044fd84 100644 --- a/src/gui/text/qfont_mac.cpp +++ b/src/gui/text/qfont_mac.cpp @@ -43,6 +43,7 @@ #include "qfont_p.h" #include "qfontengine_p.h" #include "qfontengine_mac_p.h" +#include "qfontengine_coretext_p.h" #include "qfontinfo.h" #include "qfontmetrics.h" #include "qpaintdevice.h" @@ -119,10 +120,10 @@ quint32 QFont::macFontID() const // ### need 64-bit version // Returns an ATSUFonFamilyRef Qt::HANDLE QFont::handle() const { -#if 0 +#ifdef QT_MAC_USE_COCOA QFontEngine *fe = d->engineForScript(QUnicodeTables::Common); - if (fe && fe->type() == QFontEngine::Mac) - return (Qt::HANDLE)static_cast<QFontEngineMacMulti*>(fe)->fontFamilyRef(); + if (fe && fe->type() == QFontEngine::Multi) + return (Qt::HANDLE)static_cast<QCoreTextFontEngineMulti*>(fe)->macFontID(); #endif return 0; } diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h index bb80a9b..3775bc6 100644 --- a/src/gui/text/qfontengine_coretext_p.h +++ b/src/gui/text/qfontengine_coretext_p.h @@ -124,6 +124,8 @@ public: QScriptItem *si) const; virtual const char *name() const { return "CoreText"; } + inline CTFontRef macFontID() const { return ctfont; } + protected: virtual void loadEngine(int at); -- cgit v0.12 From 111accbf9aaf95b052448ecb70937c61e9b59d66 Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Thu, 5 May 2011 13:17:26 +0200 Subject: Only enable design metrics for scalable fonts Bitmap fonts don't have linear advance at all. Reviewed-by: Eskil --- src/gui/text/qfontengine_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 237cde4..4dae2a3 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1597,7 +1597,7 @@ void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlag FT_Face face = 0; bool design = (default_hint_style == HintNone || default_hint_style == HintLight || - (flags & HB_ShaperFlag_UseDesignMetrics)); + (flags & HB_ShaperFlag_UseDesignMetrics)) && FT_IS_SCALABLE(freetype->face); for (int i = 0; i < glyphs->numGlyphs; i++) { Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]); if (g) { -- cgit v0.12 From 7ac511d8d906575dff1a02361e31251b244d3b3a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Date: Thu, 5 May 2011 13:43:13 +0200 Subject: Remove misspelled comment in tst_qtextdocument.cpp The comment was copy-pasted, spelling error and all, from the example in the bug report, and really doesn't make any sense at all in this context. Reviewed-by: TrustMe --- tests/auto/qtextdocument/tst_qtextdocument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 26fa43d..7aa6578 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -2742,7 +2742,7 @@ void tst_QTextDocument::copiedFontSize() QTextDocument documentOutput; QFont fontInput; - fontInput.setPixelSize(24); // With pixels font size is not transfered in html + fontInput.setPixelSize(24); QTextCursor cursorInput(&documentInput); QTextCharFormat formatInput = cursorInput.charFormat(); -- cgit v0.12 From cffec6c4fc1aed32ec9b3d9dd1f97105005385dc Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Wed, 4 May 2011 17:27:36 +0100 Subject: Send User-Agent from the network request in http proxy CONNECT command Some proxies can discriminate based on the User-Agent when sent a CONNECT command for establishing a HTTPS connection. With this change, if the User-Agent header is set in the QNetworkRequest then it will be passed to the http socket engine for use in the connect command sent to the proxy. As before, "Mozilla/5.0" will be used by default when no user agent has been set. Task-number: QTBUG-17223 Reviewed-by: Markus Goetz --- src/network/access/qhttpnetworkconnectionchannel.cpp | 6 ++++++ src/network/socket/qabstractsocket.cpp | 4 ++++ src/network/socket/qhttpsocketengine.cpp | 8 +++++++- src/network/ssl/qsslsocket.cpp | 2 ++ tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 10 +++++++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 700b455..bf2fa8f 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -557,6 +557,12 @@ bool QHttpNetworkConnectionChannel::ensureConnection() connectHost = connection->d_func()->networkProxy.hostName(); connectPort = connection->d_func()->networkProxy.port(); } + if (socket->proxy().type() == QNetworkProxy::HttpProxy) { + // Make user-agent field available to HTTP proxy socket engine (QTBUG-17223) + QByteArray value = request.headerField("user-agent"); + if (!value.isEmpty()) + socket->setProperty("_q_user-agent", value); + } #endif if (connection->d_func()->encrypt) { #ifndef QT_NO_OPENSSL diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index f927ae2..0dc08d9 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -549,6 +549,10 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc q->setErrorString(QAbstractSocket::tr("Operation on socket is not supported")); return false; } +#ifndef QT_NO_NETWORKPROXY + //copy user agent to socket engine (if it has been set) + socketEngine->setProperty("_q_user-agent", q->property("_q_user-agent")); +#endif if (!socketEngine->initialize(q->socketType(), protocol)) { #if defined (QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::initSocketLayer(%s, %s) failed (%s)", diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index a338d97..cebff34 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -467,7 +467,13 @@ void QHttpSocketEngine::slotSocketConnected() data += path; data += " HTTP/1.1\r\n"; data += "Proxy-Connection: keep-alive\r\n" - "User-Agent: Mozilla/5.0\r\n" + "User-Agent: "; + QVariant v = property("_q_user-agent"); + if (v.isValid()) + data += v.toByteArray(); + else + data += "Mozilla/5.0"; + data += "\r\n" "Host: " + peerAddress + "\r\n"; QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(d->authenticator); //qDebug() << "slotSocketConnected: priv=" << priv << (priv ? (int)priv->method : -1); diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 4252123..cf95adf 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1698,6 +1698,8 @@ void QSslSocket::connectToHostImplementation(const QString &hostName, quint16 po } #ifndef QT_NO_NETWORKPROXY d->plainSocket->setProxy(proxy()); + //copy user agent down to the plain socket (if it has been set) + d->plainSocket->setProperty("_q_user-agent", property("_q_user-agent")); #endif QIODevice::open(openMode); d->plainSocket->connectToHost(hostName, port, openMode); diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 81278b6..27c5713 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -4537,7 +4537,9 @@ void tst_QNetworkReply::httpProxyCommands() QNetworkProxy proxy(QNetworkProxy::HttpProxy, "127.0.0.1", proxyServer.serverPort()); manager.setProxy(proxy); - QNetworkReplyPtr reply = manager.get(QNetworkRequest(url)); + QNetworkRequest request(url); + request.setRawHeader("User-Agent", "QNetworkReplyAutoTest/1.0"); + QNetworkReplyPtr reply = manager.get(request); manager.setProxy(QNetworkProxy()); // wait for the finished signal @@ -4555,6 +4557,12 @@ void tst_QNetworkReply::httpProxyCommands() QString receivedHeader = proxyServer.receivedData.left(expectedCommand.length()); QCOMPARE(receivedHeader, expectedCommand); + + //QTBUG-17223 - make sure the user agent from the request is sent to proxy server even for CONNECT + int uapos = proxyServer.receivedData.indexOf("User-Agent"); + int uaend = proxyServer.receivedData.indexOf("\r\n", uapos); + QByteArray uaheader = proxyServer.receivedData.mid(uapos, uaend - uapos); + QCOMPARE(uaheader, QByteArray("User-Agent: QNetworkReplyAutoTest/1.0")); } class ProxyChangeHelper : public QObject { -- cgit v0.12 From b5e0130ff16e908a0e77904f34fa9af93b837dcb Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Thu, 5 May 2011 13:53:17 +0100 Subject: Skip test on MacOS due to problems with corewlan plugin Reviewed-by: Cristiano di Flora --- .../tst_qnetworkconfigurationmanager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index 3359533..c270eb8 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -350,10 +350,13 @@ public: // regression test for QTBUG-18795 void tst_QNetworkConfigurationManager::usedInThread() { +#if defined Q_OS_MAC && !defined (QT_NO_COREWLAN) + QSKIP("QTBUG-19070 Mac CoreWlan plugin is broken", SkipAll); +#else QNCMTestThread thread; connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); thread.start(); - QTestEventLoop::instance().enterLoop(5); + QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY could take ~90 seconds to time out in the thread QVERIFY(thread.isFinished()); qDebug() << "prescan:" << thread.preScanConfigs.count(); qDebug() << "postscan:" << thread.configs.count(); @@ -366,6 +369,7 @@ void tst_QNetworkConfigurationManager::usedInThread() QList<QNetworkConfiguration> configs = manager.allConfigurations(); QCOMPARE(thread.configs, configs); QCOMPARE(thread.preScanConfigs, preScanConfigs); +#endif } QTEST_MAIN(tst_QNetworkConfigurationManager) -- cgit v0.12 From d03a28a289cf0665290e6ea0375b31cbb2d6649e Mon Sep 17 00:00:00 2001 From: Markus Goetz <Markus.Goetz@nokia.com> Date: Thu, 5 May 2011 15:44:00 +0200 Subject: QNAM: Re-order checks in migrateBackend() Do the easy checks first, will avoid a crash in the HTTP code if request is serviced from the cache. Task-number: QTBUG-18770 Reviewed-by: Peter Hartmann --- src/network/access/qnetworkreplyimpl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 894df79..069755f 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -913,10 +913,6 @@ bool QNetworkReplyImplPrivate::migrateBackend() if (state == Finished || state == Aborted) return true; - // Backend does not support resuming download. - if (!backend->canResume()) - return false; - // Request has outgoing data, not migrating. if (outgoingData) return false; @@ -925,6 +921,10 @@ bool QNetworkReplyImplPrivate::migrateBackend() if (copyDevice) return true; + // Backend does not support resuming download. + if (!backend->canResume()) + return false; + state = QNetworkReplyImplPrivate::Reconnecting; if (backend) { -- cgit v0.12 From 4e7194ba2fd29dc38adc5580cb85b6eed238ff64 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 5 May 2011 18:42:32 +1000 Subject: Fix compiler warnings in qabstractxmlnodemodel test The first parameter to qWarning() should be a format string to avoid problems caused by the data string containing format specifiers. Change-Id: Ib40c0dcd766203fc41182a50680733fff9035045 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index fbc28d6..054fd69 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include <QFile> #include <QStack> @@ -337,7 +336,7 @@ void Loader::load() /* Fallthrough. */ case QXmlStreamReader::Invalid: { - qWarning(qPrintable(reader.errorString())); + qWarning("%s", qPrintable(reader.errorString())); m_result.clear(); return; } @@ -346,7 +345,7 @@ void Loader::load() if(reader.hasError()) { - qWarning(qPrintable(reader.errorString())); + qWarning("%s", qPrintable(reader.errorString())); m_result.clear(); } } -- cgit v0.12 From 524bd6b7120f70a178b03bc6d337e08abd327076 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 5 May 2011 14:40:40 +1000 Subject: Remove Q_ASSERT's from QAbstractFileEngine autotest Rather than aborting in debug builds and ignoring failures in release builds, report meaningful warnings into the test output and return sentinel values that will cause QVERIFY/QCOMPARE of the returned values to fail the test. Change-Id: I2c5a820637337d0762c71db10a4f270d36b31662 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../tst_qabstractfileengine.cpp | 49 +++++++++++++++++----- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp index 1178169..fc4835a 100644 --- a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp @@ -83,8 +83,12 @@ public: bool open(QIODevice::OpenMode openMode) { - Q_ASSERT(!openForRead_); - Q_ASSERT(!openForWrite_); + if (openForRead_ || openForWrite_) { + qWarning("%s: file is already open for %s", + Q_FUNC_INFO, + (openForRead_ ? "reading" : "writing")); + return false; + } openFile_ = resolveFile(openMode & QIODevice::WriteOnly); if (!openFile_) @@ -132,13 +136,19 @@ public: qint64 pos() const { - Q_ASSERT(openForRead_ || openForWrite_); + if (!openForRead_ && !openForWrite_) { + qWarning("%s: file is not open", Q_FUNC_INFO); + return -1; + } return position_; } bool seek(qint64 pos) { - Q_ASSERT(openForRead_ || openForWrite_); + if (!openForRead_ && !openForWrite_) { + qWarning("%s: file is not open", Q_FUNC_INFO); + return false; + } if (pos >= 0) { position_ = pos; @@ -150,7 +160,11 @@ public: bool flush() { - Q_ASSERT(openForRead_ || openForWrite_); + if (!openForRead_ && !openForWrite_) { + qWarning("%s: file is not open", Q_FUNC_INFO); + return false; + } + return true; } @@ -368,9 +382,16 @@ public: qint64 read(char *data, qint64 maxLen) { - Q_ASSERT(openForRead_); + if (!openForRead_) { + qWarning("%s: file must be open for reading", Q_FUNC_INFO); + return -1; + } + + if (openFile_.isNull()) { + qWarning("%s: file must not be null", Q_FUNC_INFO); + return -1; + } - Q_ASSERT(!openFile_.isNull()); QMutexLocker lock(&openFile_->mutex); qint64 readSize = qMin(openFile_->content.size() - position_, maxLen); if (readSize < 0) @@ -384,12 +405,19 @@ public: qint64 write(const char *data, qint64 length) { - Q_ASSERT(openForWrite_); + if (!openForWrite_) { + qWarning("%s: file must be open for writing", Q_FUNC_INFO); + return -1; + } + + if (openFile_.isNull()) { + qWarning("%s: file must not be null", Q_FUNC_INFO); + return -1; + } if (length < 0) return -1; - Q_ASSERT(!openFile_.isNull()); QMutexLocker lock(&openFile_->mutex); if (openFile_->content.size() == position_) openFile_->content.append(data, length); @@ -434,7 +462,8 @@ protected: QSharedPointer<File> resolveFile(bool create) const { if (openForRead_ || openForWrite_) { - Q_ASSERT(openFile_); + if (!openFile_) + qWarning("%s: file should not be null", Q_FUNC_INFO); return openFile_; } -- cgit v0.12 From 22e99d92a71645d643ebd54c6209bced80f7c5b8 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 5 May 2011 11:20:56 +1000 Subject: Remove Q_ASSERT's from modeltest Report a fatal error in all builds, not just in debug builds. Change-Id: Ia9e265b2082b55fbac18ca046e586de863ac0623 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/modeltest/dynamictreemodel.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/auto/modeltest/dynamictreemodel.cpp b/tests/auto/modeltest/dynamictreemodel.cpp index fa634b6..80708d4 100644 --- a/tests/auto/modeltest/dynamictreemodel.cpp +++ b/tests/auto/modeltest/dynamictreemodel.cpp @@ -44,6 +44,7 @@ #include <QtCore/QHash> #include <QtCore/QList> #include <QtCore/QTimer> +#include <QtCore/QDebug> DynamicTreeModel::DynamicTreeModel(QObject *parent) @@ -66,9 +67,11 @@ QModelIndex DynamicTreeModel::index(int row, int column, const QModelIndex &pare const qint64 grandParent = findParentId(parent.internalId()); if (grandParent >= 0) { QList<QList<qint64> > parentTable = m_childItems.value(grandParent); - Q_ASSERT(parent.column() < parentTable.size()); + if (parent.column() >= parentTable.size()) + qFatal("%s: parent.column() must be less than parentTable.size()", Q_FUNC_INFO); QList<qint64> parentSiblings = parentTable.at(parent.column()); - Q_ASSERT(parent.row() < parentSiblings.size()); + if (parent.row() >= parentSiblings.size()) + qFatal("%s: parent.row() must be less than parentSiblings.size()", Q_FUNC_INFO); } if (childIdColumns.size() == 0) @@ -189,7 +192,8 @@ QModelIndex ModelChangeCommand::findIndex(QList<int> rows) while (i.hasNext()) { parent = m_model->index(i.next(), col, parent); - Q_ASSERT(parent.isValid()); + if (!parent.isValid()) + qFatal("%s: parent must be valid", Q_FUNC_INFO); } return parent; } -- cgit v0.12 From 416d45caa9feefe8337795adc4b93a8148d57a3a Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 5 May 2011 17:36:59 +1000 Subject: Remove Q_ASSERT from qabstractxmlnodemodel test When no content can be loaded to create the model, return a null model (which will make the test fail gracefully) rather than aborting in a debug build and failing silently in a release build. Change-Id: I28f0bb92c617c8dafd1089d0b3dafcfef0c0da53 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index 054fd69..cf85486 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -53,7 +53,6 @@ LoadingModel::LoadingModel(const Node::Vector &content, const QXmlNamePool &np) : QSimpleXmlNodeModel(np) , m_nodes(content) { - Q_ASSERT(!content.isEmpty()); /* foreach(const Node *n, content) qDebug() << "this:" << n @@ -354,6 +353,11 @@ QAbstractXmlNodeModel::Ptr LoadingModel::create(const QXmlNamePool &np) { Loader loader(np); loader.load(); + if (loader.m_result.isEmpty()) { + qWarning("%s: attempt to create model with no content", Q_FUNC_INFO); + return Ptr(0); + } + return Ptr(new LoadingModel(loader.m_result, np)); } #endif //QTEST_XMLPATTERNS -- cgit v0.12 From 841cc610df61a266ebcca2bfef2542a7d4fea68d Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 5 May 2011 14:04:16 +1000 Subject: Remove Q_ASSERT from modeltest Report an informative fatal error if passed a null model, rather than aborting in a debug build and giving a bunch of signal connection errors in a release build. Change-Id: Ia240e741b9d6ec03fd5ed3a14cf4fa44b55af911 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/modeltest/modeltest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/modeltest/modeltest.cpp b/tests/auto/modeltest/modeltest.cpp index 5ef27f9..ec1091a 100644 --- a/tests/auto/modeltest/modeltest.cpp +++ b/tests/auto/modeltest/modeltest.cpp @@ -53,7 +53,8 @@ Q_DECLARE_METATYPE ( QModelIndex ) */ ModelTest::ModelTest ( QAbstractItemModel *_model, QObject *parent ) : QObject ( parent ), model ( _model ), fetchingMore ( false ) { - Q_ASSERT ( model ); + if (!model) + qFatal("%s: model must not be null", Q_FUNC_INFO); connect ( model, SIGNAL ( columnsAboutToBeInserted ( const QModelIndex &, int, int ) ), this, SLOT ( runAllTests() ) ); -- cgit v0.12 From 11254ff409395b67cb28453b3c069860bc28c14d Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Thu, 5 May 2011 11:58:24 +1000 Subject: Remove Q_ASSERT's from modeltest Rather than aborting in debug builds and ignoring the failures in release builds, report specific warnings on each failure, count the failures, and fail the test if the failure counts are non-zero at the end of the test. The same change is also made for a QCOMPARE that appeared inappropriately inside a helper class. QCOMPARE may only appear directly in a test function. Change-Id: I81f0ce80512fa72c67f5aa72c0511a4b650d5d20 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/modeltest/tst_modeltest.cpp | 52 +++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/tests/auto/modeltest/tst_modeltest.cpp b/tests/auto/modeltest/tst_modeltest.cpp index a75fe5b..aedaffe 100644 --- a/tests/auto/modeltest/tst_modeltest.cpp +++ b/tests/auto/modeltest/tst_modeltest.cpp @@ -201,8 +201,10 @@ class ObservingObject : public QObject Q_OBJECT public: ObservingObject(AccessibleProxyModel *proxy, QObject *parent = 0) - : QObject(parent), - m_proxy(proxy) + : QObject(parent) + , m_proxy(proxy) + , storePersistentFailureCount(0) + , checkPersistentFailureCount(0) { connect(m_proxy, SIGNAL(layoutAboutToBeChanged()), SLOT(storePersistent())); connect(m_proxy, SIGNAL(layoutChanged()), SLOT(checkPersistent())); @@ -215,8 +217,14 @@ public slots: for (int row = 0; row < m_proxy->rowCount(parent); ++row) { QModelIndex proxyIndex = m_proxy->index(row, 0, parent); QModelIndex sourceIndex = m_proxy->mapToSource(proxyIndex); - Q_ASSERT(proxyIndex.isValid()); - Q_ASSERT(sourceIndex.isValid()); + if (!proxyIndex.isValid()) { + qWarning("%s: Invalid proxy index", Q_FUNC_INFO); + ++storePersistentFailureCount; + } + if (!sourceIndex.isValid()) { + qWarning("%s: invalid source index", Q_FUNC_INFO); + ++storePersistentFailureCount; + } m_persistentSourceIndexes.append(sourceIndex); m_persistentProxyIndexes.append(proxyIndex); if (m_proxy->hasChildren(proxyIndex)) @@ -226,12 +234,24 @@ public slots: void storePersistent() { - foreach(const QModelIndex &idx, m_persistentProxyIndexes) - Q_ASSERT(idx.isValid()); // This is called from layoutAboutToBeChanged. Persistent indexes should be valid - - Q_ASSERT(m_proxy->persistent().isEmpty()); + // This method is called from layoutAboutToBeChanged. Persistent indexes should be valid + foreach(const QModelIndex &idx, m_persistentProxyIndexes) + if (!idx.isValid()) { + qWarning("%s: persistentProxyIndexes contains invalid index", Q_FUNC_INFO); + ++storePersistentFailureCount; + } + + if (!m_proxy->persistent().isEmpty()) { + qWarning("%s: proxy should have no persistent indexes when storePersistent called", + Q_FUNC_INFO); + ++storePersistentFailureCount; + } storePersistent(QModelIndex()); - Q_ASSERT(!m_proxy->persistent().isEmpty()); + if (m_proxy->persistent().isEmpty()) { + qWarning("%s: proxy should have persistent index after storePersistent called", + Q_FUNC_INFO); + ++storePersistentFailureCount; + } } void checkPersistent() @@ -243,7 +263,10 @@ public slots: for (int row = 0; row < m_persistentProxyIndexes.size(); ++row) { QModelIndex updatedProxy = m_persistentProxyIndexes.at(row); QModelIndex updatedSource = m_persistentSourceIndexes.at(row); - QCOMPARE(m_proxy->mapToSource(updatedProxy), updatedSource); + if (m_proxy->mapToSource(updatedProxy) != updatedSource) { + qWarning("%s: check failed at row %d", Q_FUNC_INFO, row); + ++checkPersistentFailureCount; + } } m_persistentSourceIndexes.clear(); m_persistentProxyIndexes.clear(); @@ -253,6 +276,9 @@ private: AccessibleProxyModel *m_proxy; QList<QPersistentModelIndex> m_persistentSourceIndexes; QList<QPersistentModelIndex> m_persistentProxyIndexes; +public: + int storePersistentFailureCount; + int checkPersistentFailureCount; }; void tst_ModelTest::moveSourceItems() @@ -280,6 +306,9 @@ void tst_ModelTest::moveSourceItems() moveCommand->setDestAncestors(QList<int>() << 1); moveCommand->setDestRow(0); moveCommand->doCommand(); + + QCOMPARE(observer.storePersistentFailureCount, 0); + QCOMPARE(observer.checkPersistentFailureCount, 0); } void tst_ModelTest::testResetThroughProxy() @@ -302,6 +331,9 @@ void tst_ModelTest::testResetThroughProxy() ModelResetCommand *resetCommand = new ModelResetCommand(model, this); resetCommand->setNumCols(0); resetCommand->doCommand(); + + QCOMPARE(observer.storePersistentFailureCount, 0); + QCOMPARE(observer.checkPersistentFailureCount, 0); } -- cgit v0.12 From e6f7509f18ae88069373d59073cbdcda88fd19c8 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 13:12:10 +1000 Subject: Remove Q_ASSERT's from qabstractfileengine test Rather than aborting in debug builds and failing silently in release builds, report a meaningful warning message and skip setting the filename, which should cause a subsequent test failure. Change-Id: I3ae4f4de7b02bf2194019047fa87d8ae06d95634 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp index fc4835a..e77b7bb 100644 --- a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp @@ -360,10 +360,10 @@ public: void setFileName(const QString &file) { - Q_ASSERT(!openForRead_); - Q_ASSERT(!openForWrite_); - - fileName_ = file; + if (openForRead_ || openForWrite_) + qWarning("%s: Can't set file name while file is open", Q_FUNC_INFO); + else + fileName_ = file; } // typedef QAbstractFileEngineIterator Iterator; -- cgit v0.12 From 57fd8c5ac803398238982c4b74bc5ce048671201 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 13:35:14 +1000 Subject: Remove Q_ASSERT from qabstractxmlnodemodel test Constructing a model index from a null pointer will cause the test to crash later. Instead of crashing this way in a release build and aborting in a debug build, report the fatal error in all builds. Change-Id: I43ce4c8fa48caa05aaf09ac3c1453d35a2de65bf Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index cf85486..63fad67 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -77,8 +77,8 @@ const LoadingModel::Node *LoadingModel::toInternal(const QXmlNodeModelIndex &ni) QXmlNodeModelIndex LoadingModel::createIndex(const Node *const internal) const { - Q_ASSERT_X(internal, Q_FUNC_INFO, - "We shouldn't construct from null pointers."); + if (!internal) + qFatal("%s: cannot construct a model index from a null pointer", Q_FUNC_INFO); return QAbstractXmlNodeModel::createIndex(const_cast<Node *>(internal)); } -- cgit v0.12 From 68027b186fe547a5579d07480e097bfb69c79de9 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 13:51:20 +1000 Subject: Remove Q_ASSERT from qabstractxmlnodemodel test Instead of aborting in a debug build and failing silently in a release build when the internal state of the model is incorrect, report a meaningful fatal error in all builds. Change-Id: I64ca4dde070cb7fbe69684a36092d53e5b84d80a Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index 63fad67..c68857b 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -98,8 +98,10 @@ QXmlNodeModelIndex::DocumentOrder LoadingModel::compareOrder(const QXmlNodeModel { const Node *const in1 = toInternal(n1); const Node *const in2 = toInternal(n2); - Q_ASSERT(m_nodes.indexOf(in1) != -1); - Q_ASSERT(m_nodes.indexOf(in2) != -1); + if (m_nodes.indexOf(in1) == -1) + qFatal("%s: node n1 is not in internal node list", Q_FUNC_INFO); + if (m_nodes.indexOf(in2) == -1) + qFatal("%s: node n2 is not in internal node list", Q_FUNC_INFO); if(in1 == in2) return QXmlNodeModelIndex::Is; -- cgit v0.12 From a80ecc34565d6efc474bca2322046f4200ad51db Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 14:00:00 +1000 Subject: Remove Q_ASSERT from qabstractxmlnodemodel test Rather than aborting in a debug build and failing silently in a release build, report a warning and return a null model index if the first (root) node of the model is not a document. The null return value will cause initTestCase() to fail gracefully. Change-Id: I15e9456929bbb3f0bd50d30333c49143b6f0aad7 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index c68857b..01d3164 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -113,7 +113,10 @@ QXmlNodeModelIndex::DocumentOrder LoadingModel::compareOrder(const QXmlNodeModel QXmlNodeModelIndex LoadingModel::root(const QXmlNodeModelIndex &) const { - Q_ASSERT(kind(createIndex(m_nodes.first())) == QXmlNodeModelIndex::Document); + if (kind(createIndex(m_nodes.first())) != QXmlNodeModelIndex::Document) { + qWarning("%s: first node must be a Document node", Q_FUNC_INFO); + return QXmlNodeModelIndex(); + } return createIndex(m_nodes.first()); } -- cgit v0.12 From a0496d1db09dfaa6a2b31a5c23e154de7b4a2eb7 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 14:08:10 +1000 Subject: Remove Q_ASSERT from qabstractxmlnodemodel test Instead of aborting in debug builds and failing silently in release builds, print a meaningful warning message into the test output and return a null QVariant. Change-Id: Idcd70f5cb01528b522d84e391f6f8692a189f420 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index 01d3164..2ce9466 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -129,8 +129,11 @@ QVariant LoadingModel::typedValue(const QXmlNodeModelIndex &ni) const { const Node *const internal = toInternal(ni); - Q_ASSERT(internal->kind == QXmlNodeModelIndex::Attribute - || internal->kind == QXmlNodeModelIndex::Element); + if (internal->kind != QXmlNodeModelIndex::Attribute + && internal->kind != QXmlNodeModelIndex::Element) { + qWarning("%s: node must be an attribute or element", Q_FUNC_INFO); + return QVariant(); + } return internal->value; } -- cgit v0.12 From 75767c69fbba3149a4505287ed441886188a9fd3 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 14:43:03 +1000 Subject: Remove Q_ASSERT from algorithms autotest Report a meaningful warning message rather than aborting in a debug build and failing silently in a release build. Change-Id: Ic77589143ff0d22c95c7b10f2e511f68b3da4d86 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qalgorithms/tst_qalgorithms.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qalgorithms/tst_qalgorithms.cpp b/tests/auto/qalgorithms/tst_qalgorithms.cpp index 8dd7cbc..f0ae08c 100644 --- a/tests/auto/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/qalgorithms/tst_qalgorithms.cpp @@ -241,7 +241,8 @@ QList<ResultSet> testAlgorithm(Algorithm &algorithm, QStringList dataSetTypes, foreach(QString dataSetType, dataSetTypes) { QVector<DataType> container = generateData<DataType>(dataSetType, size); results.append(testRun(container, algorithm, time)); - Q_ASSERT(isSorted(container)); + if (!isSorted(container)) + qWarning("%s: container is not sorted after test", Q_FUNC_INFO); } return results; } -- cgit v0.12 From 6b2e89843a573cd7c143bca17cec8e69209d2fbd Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 15:22:07 +1000 Subject: Remove Q_ASSERT from qitemmodel autotest If populateTestData() is passed an unknown type of model, report a meaningful fatal error rather than failing silently in a release build and aborting with an uninformative error message in a debug build. Change-Id: I7ee8d1262bbced304f9f24c2ec9b40a38704d982 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qitemmodel/modelstotest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp index cec1703..4e63307 100644 --- a/tests/auto/qitemmodel/modelstotest.cpp +++ b/tests/auto/qitemmodel/modelstotest.cpp @@ -372,7 +372,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) return QModelIndex(); } - Q_ASSERT(false); + qFatal("%s: unknown type of model", Q_FUNC_INFO); return QModelIndex(); } -- cgit v0.12 From 7cb0a3baeb361c9909e8ab2caf436e8e44b6a3b6 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 16:22:25 +1000 Subject: Remove Q_ASSERT's in qitemview autotest Rather than aborting in debug builds and failing silently in release builds, report a meaningful warning message and return an appropriate value to indicate the error. Change-Id: I0ceb0a0bfaef34cc6127d768cc75ecfc5a24e3c9 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qitemview/tst_qitemview.cpp | 65 +++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp index c987c8f..fa8367e 100644 --- a/tests/auto/qitemview/tst_qitemview.cpp +++ b/tests/auto/qitemview/tst_qitemview.cpp @@ -148,12 +148,18 @@ public: CheckerModel() : QStandardItemModel() {}; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole ) const { - Q_ASSERT(index.isValid()); + if (!index.isValid()) { + qWarning("%s: index is not valid", Q_FUNC_INFO); + return QVariant(); + } return QStandardItemModel::data(index, role); }; Qt::ItemFlags flags(const QModelIndex & index) const { - Q_ASSERT(index.isValid()); + if (!index.isValid()) { + qWarning("%s: index is not valid", Q_FUNC_INFO); + return Qt::ItemFlags(); + } if (index.row() == 2 || index.row() == rowCount() - 3 || index.column() == 2 || index.column() == columnCount() - 3) { Qt::ItemFlags f = QStandardItemModel::flags(index); @@ -164,14 +170,26 @@ public: }; QModelIndex parent ( const QModelIndex & child ) const { - Q_ASSERT(child.isValid()); + if (!child.isValid()) { + qWarning("%s: child index is not valid", Q_FUNC_INFO); + return QModelIndex(); + } return QStandardItemModel::parent(child); }; QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const { - Q_ASSERT(section >= 0); - if (orientation == Qt::Horizontal) { Q_ASSERT(section <= columnCount());}; - if (orientation == Qt::Vertical) { Q_ASSERT(section <= rowCount());}; + if (orientation == Qt::Horizontal + && (section < 0 || section > columnCount())) { + qWarning("%s: invalid section %d, must be in range 0..%d", + Q_FUNC_INFO, section, columnCount()); + return QVariant(); + } + if (orientation == Qt::Vertical + && (section < 0 || section > rowCount())) { + qWarning("%s: invalid section %d, must be in range 0..%d", + Q_FUNC_INFO, section, rowCount()); + return QVariant(); + } return QStandardItemModel::headerData(section, orientation, role); } @@ -180,23 +198,46 @@ public: }; bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ) { - Q_ASSERT(index.isValid()); + if (!index.isValid()) { + qWarning("%s: index is not valid", Q_FUNC_INFO); + return false; + } return QStandardItemModel::setData(index, value, role); } void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) { - Q_ASSERT(column >= 0 && column <= columnCount()); - QStandardItemModel::sort(column, order); + if (column < 0 || column > columnCount()) + qWarning("%s: invalid column %d, must be in range 0..%d", + Q_FUNC_INFO, column, columnCount()); + else + QStandardItemModel::sort(column, order); }; QModelIndexList match ( const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const { - Q_ASSERT(hits > 0); - Q_ASSERT(value.isValid()); + if (hits <= 0) { + qWarning("%s: hits must be greater than zero", Q_FUNC_INFO); + return QModelIndexList(); + } + if (!value.isValid()) { + qWarning("%s: value is not valid", Q_FUNC_INFO); + return QModelIndexList(); + } return QAbstractItemModel::match(start, role, value, hits, flags); }; bool setHeaderData ( int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole ) { - Q_ASSERT(section >= 0); + if (orientation == Qt::Horizontal + && (section < 0 || section > columnCount())) { + qWarning("%s: invalid section %d, must be in range 0..%d", + Q_FUNC_INFO, section, columnCount()); + return false; + } + if (orientation == Qt::Vertical + && (section < 0 || section > rowCount())) { + qWarning("%s: invalid section %d, must be in range 0..%d", + Q_FUNC_INFO, section, rowCount()); + return false; + } return QAbstractItemModel::setHeaderData(section, orientation, value, role); }; }; -- cgit v0.12 From 8512dc16553ecf511c40a2ba7a815f777d7d5c59 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 16:34:15 +1000 Subject: Remove Q_ASSERT from QMetaType autotest Replace Q_ASSERT in helper class with code to count failures and report meaningful warnings. The test function then fails the test if any failures were recorded. Change-Id: I0d6650e6036c8e45729c16d1dbb7543b4fb42553 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qmetatype/tst_qmetatype.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp index fcb949f..ccf0ac5 100644 --- a/tests/auto/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/qmetatype/tst_qmetatype.cpp @@ -96,10 +96,18 @@ struct Bar Bar() { // check re-entrancy - Q_ASSERT(QMetaType::isRegistered(qRegisterMetaType<Foo>("Foo"))); + if (!QMetaType::isRegistered(qRegisterMetaType<Foo>("Foo"))) { + qWarning("%s: re-entrancy test failed", Q_FUNC_INFO); + ++failureCount; + } } + +public: + static int failureCount; }; +int Bar::failureCount = 0; + class MetaTypeTorturer: public QThread { Q_OBJECT @@ -161,6 +169,7 @@ void tst_QMetaType::threadSafety() QCOMPARE(t1.failureCount, 0); QCOMPARE(t2.failureCount, 0); QCOMPARE(t3.failureCount, 0); + QCOMPARE(Bar::failureCount, 0); } namespace TestSpace -- cgit v0.12 From 8d2127d44e6c8af6b041688376de0e5747a1810a Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 16:55:31 +1000 Subject: Remove Q_ASSERT's from QMutex autotest Don't perform actions needed for the test inside Q_ASSERT, because these actions won't happen in a non-debug build. Instead count the number of failures and verify that the count is zero at the end of the test. Change-Id: Ibe0d194111e5247118d59a7760f0946d2c44faf9 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qmutex/tst_qmutex.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/auto/qmutex/tst_qmutex.cpp b/tests/auto/qmutex/tst_qmutex.cpp index dc3ffa4..e1ad2d2 100644 --- a/tests/auto/qmutex/tst_qmutex.cpp +++ b/tests/auto/qmutex/tst_qmutex.cpp @@ -393,6 +393,7 @@ public: static QBasicAtomicInt lockCount; static QBasicAtomicInt sentinel; static QMutex mutex; + static int errorCount; void start() { t.start(); @@ -402,13 +403,13 @@ public: { while (t.elapsed() < one_minute) { mutex.lock(); - Q_ASSERT(!sentinel.ref()); - Q_ASSERT(sentinel.deref()); + if (sentinel.ref()) ++errorCount; + if (!sentinel.deref()) ++errorCount; lockCount.ref(); mutex.unlock(); if (mutex.tryLock()) { - Q_ASSERT(!sentinel.ref()); - Q_ASSERT(sentinel.deref()); + if (sentinel.ref()) ++errorCount; + if (!sentinel.deref()) ++errorCount; lockCount.ref(); mutex.unlock(); } @@ -418,6 +419,7 @@ public: QMutex StressTestThread::mutex; QBasicAtomicInt StressTestThread::lockCount = Q_BASIC_ATOMIC_INITIALIZER(0); QBasicAtomicInt StressTestThread::sentinel = Q_BASIC_ATOMIC_INITIALIZER(-1); +int StressTestThread::errorCount = 0; void tst_QMutex::stressTest() { @@ -427,6 +429,7 @@ void tst_QMutex::stressTest() QVERIFY(threads[0].wait(one_minute + 10000)); for (int i = 1; i < threadCount; ++i) QVERIFY(threads[i].wait(10000)); + QCOMPARE(StressTestThread::errorCount, 0); qDebug("locked %d times", int(StressTestThread::lockCount)); } -- cgit v0.12 From 55446d104db77fc7994ab12352b1c08bb7b63346 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Date: Fri, 6 May 2011 10:25:20 +0200 Subject: Fix QPainter::drawGlyphs() with non-affine transformation When the matrix has an non-affine transformation, the text will have to be rendered using the default path-renderer. This means going through the drawTextItem() path (since drawStaticText() has no support for those transformations) and it also means not pre-transforming the coordinates, since the default implementation of drawTextItem() supports transformations. Task-number: QTBUG-18214 Reviewed-by: Jiang Jiang --- src/gui/painting/qpainter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 9e28102..ee960d1 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5819,6 +5819,13 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs) d->extended != 0 ? qt_paintengine_supports_transformations(d->extended->type()) : qt_paintengine_supports_transformations(d->engine->type()); + + // If the matrix is not affine, the paint engine will fall back to + // drawing the glyphs as paths, which in turn means we should not + // preprocess the glyph positions + if (!d->state->matrix.isAffine()) + paintEngineSupportsTransformations = true; + for (int i=0; i<count; ++i) { QPointF processedPosition = position + glyphPositions.at(i); if (!paintEngineSupportsTransformations) @@ -5862,7 +5869,7 @@ void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, in QFixed width = rightMost - leftMost; - if (extended != 0) { + if (extended != 0 && state->matrix.isAffine()) { QStaticTextItem staticTextItem; staticTextItem.color = state->pen.color(); staticTextItem.font = state->font; -- cgit v0.12 From e6bb6ba76942d98e4b50a7fd32bf44e211f2fa5e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Date: Wed, 20 Apr 2011 16:27:55 +0200 Subject: make relative paths in qt.conf work inside qmake Task-number: QTBUG-11602 Reviewed-by: joerg --- src/corelib/global/qlibraryinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 1fecc26..e69e0a6 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -453,7 +453,7 @@ QLibraryInfo::location(LibraryLocation loc) if (loc == PrefixPath) { // we make the prefix path absolute to the executable's directory #ifdef BOOTSTRAPPING - return QFileInfo(qmake_libraryInfoFile()).absolutePath(); + return QDir(QFileInfo(qmake_libraryInfoFile()).absolutePath()).absoluteFilePath(ret); #else if (QCoreApplication::instance()) { #ifdef Q_OS_MAC -- cgit v0.12 From 9cd62e4f7b23894a672297f6eebda64cdbd53cb0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Date: Wed, 20 Apr 2011 16:28:58 +0200 Subject: make QLibraryInfo return clean paths as a side effect, don't use QDir for path resolution - it doesn't buy us anything. Task-number: QTBUG-1371 Reviewed-by: joerg --- src/corelib/global/qlibraryinfo.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index e69e0a6..6060dde 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -450,10 +450,11 @@ QLibraryInfo::location(LibraryLocation loc) } if (QDir::isRelativePath(ret)) { + QString baseDir; if (loc == PrefixPath) { // we make the prefix path absolute to the executable's directory #ifdef BOOTSTRAPPING - return QDir(QFileInfo(qmake_libraryInfoFile()).absolutePath()).absoluteFilePath(ret); + baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); #else if (QCoreApplication::instance()) { #ifdef Q_OS_MAC @@ -466,15 +467,16 @@ QLibraryInfo::location(LibraryLocation loc) } } #endif - return QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(ret); + baseDir = QCoreApplication::applicationDirPath(); } else { - return QDir::current().absoluteFilePath(ret); + baseDir = QDir::currentPath(); } #endif } else { // we make any other path absolute to the prefix directory - return QDir(location(PrefixPath)).absoluteFilePath(ret); + baseDir = location(PrefixPath); } + ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret); } return ret; } -- cgit v0.12 From 2ca4ce848c63c9fa0a48c0f9f4e7fdbc90463bf1 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Date: Wed, 20 Apr 2011 19:47:49 +0200 Subject: don't ignore create_prl for static plugins Task-number: QTBUG-18436 Reviewed-by: joerg --- qmake/generators/makefile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 3c5948f..b9089fc 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1109,7 +1109,7 @@ MakefileGenerator::writePrlFile() && project->isActiveConfig("create_prl") && (project->first("TEMPLATE") == "lib" || project->first("TEMPLATE") == "vclib") - && !project->isActiveConfig("plugin")) { //write prl file + && (!project->isActiveConfig("plugin") || project->isActiveConfig("static"))) { //write prl file QString local_prl = prlFileName(); QString prl = fileFixify(local_prl); mkdir(fileInfo(local_prl).path()); -- cgit v0.12 From a780cf591ed2d311489576152be7c4b453ad5963 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Date: Fri, 6 May 2011 11:00:47 +0200 Subject: fix random miscompilation with msvc Reviewed-by: joerg --- src/tools/uic3/uic3.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/uic3/uic3.pro b/src/tools/uic3/uic3.pro index 5ad3c4d..54f7dc8 100644 --- a/src/tools/uic3/uic3.pro +++ b/src/tools/uic3/uic3.pro @@ -1,5 +1,6 @@ TEMPLATE = app CONFIG += console qt_no_compat_warning +win32-msvc*:CONFIG += no_batch # otherwise the wrong main.cpp may be picked up CONFIG -= app_bundle build_all:!build_pass { CONFIG -= build_all -- cgit v0.12 From 891b6ac7236d21b69bdb54b00051422cee004059 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Fri, 6 May 2011 13:31:43 +0200 Subject: Add internal documentation for QUnifiedToolbarSurface. This document is aimed for developers. This is why it is directly written in the header file. This is not part of the public API. Reviewed-by: Richard Moe Gustavsen --- src/gui/painting/qunifiedtoolbarsurface_mac_p.h | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h index 0a7ebf1..6b1243e 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h +++ b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h @@ -65,6 +65,39 @@ QT_BEGIN_NAMESPACE class QNativeImage; +// +// This is the implementation of the unified toolbar on Mac OS X +// with the graphics system raster. +// +// General idea: +// ------------- +// We redirect the painting of widgets inside the unified toolbar +// to a special window surface, the QUnifiedToolbarSurface. +// We need a separate window surface because the unified toolbar +// is out of the content view. +// The input system is the same as for the unified toolbar with the +// native (CoreGraphics) engine. +// +// Execution flow: +// --------------- +// The unified toolbar is triggered by QMainWindow::setUnifiedTitleAndToolBarOnMac(). +// It calls QMainWindowLayout::insertIntoMacToolbar() which will +// set all the appropriate variables (offsets, redirection, ...). +// When Qt tells a widget to repaint, QWidgetPrivate::drawWidget() +// checks if the widget is inside the unified toolbar and exits without +// painting is that is the case. +// We trigger the rendering of the unified toolbar in QWidget::repaint() +// and QWidget::update(). +// We keep track of flush requests via "flushRequested" variable. That +// allow flush() to be a no-op if no repaint occured for a widget. +// We rely on the needsDisplay: and drawRect: mecanism for drawing our +// content into the graphics context. +// +// Notes: +// ------ +// The painting of items inside the unified toolbar is expensive. +// Too many repaints will drastically slow down the whole application. +// class QUnifiedToolbarSurfacePrivate { -- cgit v0.12 From a423ff5474b89028eeca95b254f5184311c8223b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= <samuel.rodal@nokia.com> Date: Fri, 6 May 2011 15:23:43 +0200 Subject: Remove warning from QColor::setNamedColor(). This warning is pointless as the user can anyway check if the color is valid after making the call by calling isValid(). Using isValidColor() could be used but it has a big performance overhead as validation then needs to be done twice. Task-number: QTBUG-19098 Reviewed-by: Erik Verbruggen --- src/gui/painting/qcolor.cpp | 3 +-- tests/auto/qcolor/tst_qcolor.cpp | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index ff6c24e..cd87d21 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -532,8 +532,7 @@ QString QColor::name() const void QColor::setNamedColor(const QString &name) { - if (!setColorFromString(name)) - qWarning("QColor::setNamedColor: Unknown color name '%s'", name.toLatin1().constData()); + setColorFromString(name); } /*! diff --git a/tests/auto/qcolor/tst_qcolor.cpp b/tests/auto/qcolor/tst_qcolor.cpp index d42c26c..b02537e 100644 --- a/tests/auto/qcolor/tst_qcolor.cpp +++ b/tests/auto/qcolor/tst_qcolor.cpp @@ -1506,7 +1506,6 @@ void tst_QColor::setallowX11ColorNames() for (int i = 0; i < x11RgbTblSize; ++i) { QString colorName = QLatin1String(x11RgbTbl[i].name); QColor color; - QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1()); color.setNamedColor(colorName); QVERIFY(!color.isValid()); } @@ -1528,7 +1527,6 @@ void tst_QColor::setallowX11ColorNames() for (int i = 0; i < x11RgbTblSize; ++i) { QString colorName = QLatin1String(x11RgbTbl[i].name); QColor color; - QTest::ignoreMessage(QtWarningMsg, QString("QColor::setNamedColor: Unknown color name '%1'").arg(colorName).toLatin1()); color.setNamedColor(colorName); QVERIFY(!color.isValid()); } -- cgit v0.12 From 821b8b540af491ce60d35bd84d3c91399ecc0d16 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Date: Fri, 6 May 2011 15:45:37 +0200 Subject: Fix QRawFont::setPixelSize() on Mac When refactoring the setPixelSize() code of QRawFont, it was broken on Mac. To avoid making the same mistake again, I've added a simple autotest to check that the pixel size is actually set. Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine_coretext.mm | 2 +- tests/auto/qrawfont/tst_qrawfont.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index d4df218..cbf51e6 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -871,7 +871,7 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const newFontDef.pixelSize = pixelSize; newFontDef.pointSize = pixelSize * 72.0 / qt_defaultDpi(); - return new QCoreTextFontEngine(cgFont, fontDef); + return new QCoreTextFontEngine(cgFont, newFontDef); } QT_END_NAMESPACE diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp index 4b42c74..ad16a9a 100644 --- a/tests/auto/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/qrawfont/tst_qrawfont.cpp @@ -91,6 +91,9 @@ private slots: void unsupportedWritingSystem_data(); void unsupportedWritingSystem(); + + void rawFontSetPixelSize_data(); + void rawFontSetPixelSize(); #endif // QT_NO_RAWFONT }; @@ -807,6 +810,39 @@ void tst_QRawFont::unsupportedWritingSystem() fontDatabase.removeApplicationFont(id); } +void tst_QRawFont::rawFontSetPixelSize_data() +{ + QTest::addColumn<QFont::HintingPreference>("hintingPreference"); + + QTest::newRow("Default hinting preference") << QFont::PreferDefaultHinting; + QTest::newRow("No hinting preference") << QFont::PreferNoHinting; + QTest::newRow("Vertical hinting preference") << QFont::PreferVerticalHinting; + QTest::newRow("Full hinting preference") << QFont::PreferFullHinting; +} + +void tst_QRawFont::rawFontSetPixelSize() +{ + QFETCH(QFont::HintingPreference, hintingPreference); + + QTextLayout layout("Foobar"); + + QFont font = layout.font(); + font.setHintingPreference(hintingPreference); + font.setPixelSize(12); + layout.setFont(font); + + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QGlyphs glyphs = layout.glyphs().at(0); + QRawFont rawFont = glyphs.font(); + QCOMPARE(rawFont.pixelSize(), 12.0); + + rawFont.setPixelSize(24); + QCOMPARE(rawFont.pixelSize(), 24.0); +} + #endif // QT_NO_RAWFONT QTEST_MAIN(tst_QRawFont) -- cgit v0.12 From e2654a15e78165c91c068f68265cc11b2f07c588 Mon Sep 17 00:00:00 2001 From: Victor Ostashevsky <ostash@ostash.kiev.ua> Date: Sun, 8 May 2011 12:01:06 +0300 Subject: Ukrainian translation updated --- translations/designer_uk.ts | 10 +++++----- translations/qt_uk.ts | 4 ---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/translations/designer_uk.ts b/translations/designer_uk.ts index dccfb5f..7d1065c 100644 --- a/translations/designer_uk.ts +++ b/translations/designer_uk.ts @@ -4860,21 +4860,21 @@ Please select another name.</source> <name>qdesigner_internal::PreviewDeviceSkin</name> <message> <source>&Portrait</source> - <translation>Книжка</translation> + <translation>&Книжка</translation> </message> <message> <source>Landscape (&CCW)</source> <extracomment>Rotate form preview counter-clockwise</extracomment> - <translation>Альбом (проти ГС)</translation> + <translation>Альбом (проти &ГС)</translation> </message> <message> <source>&Landscape (CW)</source> <extracomment>Rotate form preview clockwise</extracomment> - <translation>Альбом (за ГС)</translation> + <translation>А&льбом (за ГС)</translation> </message> <message> <source>&Close</source> - <translation>Закрити</translation> + <translation>З&акрити</translation> </message> </context> <context> @@ -5833,7 +5833,7 @@ This indicates an inconsistency in the ui-file.</source> <name>qdesigner_internal::ZoomablePreviewDeviceSkin</name> <message> <source>&Zoom</source> - <translation>Масштаб</translation> + <translation>Мас&штаб</translation> </message> </context> </TS> diff --git a/translations/qt_uk.ts b/translations/qt_uk.ts index 52e70a2..c3cfec0 100644 --- a/translations/qt_uk.ts +++ b/translations/qt_uk.ts @@ -1721,10 +1721,6 @@ to <translation>Властивість-псевдонім виходить за межі псевдоніму</translation> </message> <message> - <source>Invalid alias reference. An alias reference must be specified as <id> or <id>.<property></source> - <translation type="obsolete">Неправильне посилання на псевдонім. Посилання на псевдонім має бути вказане, як <id> або <id>.<property></translation> - </message> - <message> <source>Invalid alias reference. Unable to find id "%1"</source> <translation>Неправильне посилання на псевдонім. Неможливо знайти id "%1"</translation> </message> -- cgit v0.12 From b7d421da6d5e945b74ffbc3a7aa635a6ce63ebda Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 15:12:03 +1000 Subject: Remove Q_ASSERT from qitemmodel autotest Don't perform actions needed for the test inside Q_ASSERT, because these actions won't happen in a non-debug build. Change-Id: I0758e9f29f38c1a83a1501357286877f05beb6c8 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qitemmodel/modelstotest.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp index 4e63307..7ebf2c7 100644 --- a/tests/auto/qitemmodel/modelstotest.cpp +++ b/tests/auto/qitemmodel/modelstotest.cpp @@ -313,10 +313,17 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) } if (QDirModel *dirModel = qobject_cast<QDirModel *>(model)) { - // Don't risk somthing bad happening, assert if this fails - Q_ASSERT(QDir(QDir::currentPath()).mkdir("test")); - for (int i = 0; i < 26; ++i) - Q_ASSERT(QDir(QDir::currentPath()).mkdir(QString("test/foo_%1").arg(i))); + if (!QDir::current().mkdir("test")) + qFatal("%s: cannot create directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test"))); + for (int i = 0; i < 26; ++i) { + QString subdir = QString("test/foo_%1").arg(i); + if (!QDir::current().mkdir(subdir)) + qFatal("%s: cannot create directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir))); + } return dirModel->index(QDir::currentPath()+"/test"); } @@ -386,9 +393,17 @@ void ModelsToTest::cleanupTestArea(QAbstractItemModel *model) { if (QDir(QDir::currentPath()+"/test").exists()) { - for (int i = 0; i < 26; ++i) - QDir::current().rmdir(QString("test/foo_%1").arg(i)); - Q_ASSERT(QDir::current().rmdir("test")); + for (int i = 0; i < 26; ++i) { + QString subdir(QString("test/foo_%1").arg(i)); + if (!QDir::current().rmdir(subdir)) + qFatal("%s: cannot remove directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/"+subdir))); + } + if (!QDir::current().rmdir("test")) + qFatal("%s: cannot remove directory %s", + Q_FUNC_INFO, + qPrintable(QDir::toNativeSeparators(QDir::currentPath()+"/test"))); } } else if (qobject_cast<QSqlQueryModel *>(model)) { QSqlQuery q("DROP TABLE test"); -- cgit v0.12 From 136f39bbb63706819eb18d000f305edbe1cc6a81 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 11:50:23 +1000 Subject: Remove Q_ASSERT's from QNetworkReply autotest Rather than aborting in debug builds and ignoring the failure in release builds, report a fatal error in all builds. Change-Id: I1fb8e692c65cf23cf5d2453173db742260ddca48 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 2c79951..b5bbd84 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -582,9 +582,14 @@ public: } QIODevice *prepare(const QNetworkCacheMetaData &) - { Q_ASSERT(0 && "Should not have tried to add to the cache"); return 0; } + { + qFatal("%s: Should not have tried to add to the cache", Q_FUNC_INFO); + return 0; + } void insert(QIODevice *) - { Q_ASSERT(0 && "Should not have tried to add to the cache"); } + { + qFatal("%s: Should not have tried to add to the cache", Q_FUNC_INFO); + } void clear() { cache.clear(); } }; -- cgit v0.12 From 844906474dd6905d36003143a03a2fbccf0ad0dd Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 13:01:40 +1000 Subject: Remove Q_ASSERT's from QObject autotest Rather than aborting in debug builds and failing silently in release builds, report a meaningful fatal error in all builds. Change-Id: I3b874f187d482e9785a839cab1a3855b631404c3 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qobject/signalbug.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/qobject/signalbug.cpp b/tests/auto/qobject/signalbug.cpp index f9c9650..55ef5b3 100644 --- a/tests/auto/qobject/signalbug.cpp +++ b/tests/auto/qobject/signalbug.cpp @@ -69,7 +69,8 @@ void Receiver::received () ::Step++; const int stepCopy = ::Step; TRACE (stepCopy, "Receiver::received()"); - Q_ASSERT (::Step == 2 || ::Step == 4); + if (::Step != 2 && ::Step != 4) + qFatal("%s: Incorrect Step: %d (should be 2 or 4)", Q_FUNC_INFO, ::Step); if (::Step == 2) s->fire (); @@ -91,7 +92,8 @@ void Disconnector::received () ::Step++; const int stepCopy = ::Step; TRACE (stepCopy, "Disconnector::received()"); - Q_ASSERT (::Step == 5 || ::Step == 6); + if (::Step != 5 && ::Step != 6) + qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step); fprintf (stderr, "Disconnector<%s>::received() sender=%s\n", (const char *) objectName ().toAscii (), sender ()->metaObject()->className()); @@ -124,7 +126,8 @@ void Sender::fire () ::Step++; const int stepCopy = ::Step; TRACE (stepCopy, "Sender::fire()"); - Q_ASSERT (::Step == 1 || ::Step == 3); + if (::Step != 1 && ::Step != 3) + qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step); emit fired (); TRACE (stepCopy, "ends Sender::fire()"); -- cgit v0.12 From 0c157af3e5aa7c56c53b9eabe1510cc639610969 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 13:16:39 +1000 Subject: Remove Q_ASSERT's from QObject autotest Rather than aborting in debug builds and failing silently in release builds, report a fatal error in all builds if the helper class methods are called more than once. Change-Id: Id1fda8dc7caf008bbc8f6ae6384abee1aa8f50eb Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qobject/tst_qobject.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 29b07af..0e5a087 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -1330,14 +1330,16 @@ public: void customEvent(QEvent *) { - Q_ASSERT(customEventThread == 0); + if (customEventThread) + qFatal("%s: customEventThread should be null", Q_FUNC_INFO); customEventThread = QThread::currentThread(); emit theSignal(); } void timerEvent(QTimerEvent *) { - Q_ASSERT(timerEventThread == 0); + if (timerEventThread) + qFatal("%s: timerEventThread should be null", Q_FUNC_INFO); timerEventThread = QThread::currentThread(); emit theSignal(); } @@ -1345,7 +1347,8 @@ public: public slots: void theSlot() { - Q_ASSERT(slotThread == 0); + if (slotThread) + qFatal("%s: slotThread should be null", Q_FUNC_INFO); slotThread = QThread::currentThread(); emit theSignal(); } -- cgit v0.12 From 00f724c943b83f10f9ca9475570708536947538e Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 13:46:32 +1000 Subject: Remove Q_ASSERT's from qreadwritelock autotest The tryWriteLock testfunction didn't do anything useful in non-debug builds, due to the thread having the important code inside Q_ASSERT's, which are no-ops in non-debug builds. This commit removes the Q_ASSERT's, counts the number of failures in the thread and fails the test if there are any failures recorded. Change-Id: I4750f66eeba22ab51ba348ebc06704052421f1ae Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qreadwritelock/tst_qreadwritelock.cpp | 29 +++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/tests/auto/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/qreadwritelock/tst_qreadwritelock.cpp index e0cc2fa..0d575a1 100644 --- a/tests/auto/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/qreadwritelock/tst_qreadwritelock.cpp @@ -362,34 +362,45 @@ void tst_QReadWriteLock::tryWriteLock() class Thread : public QThread { public: + Thread() : failureCount(0) { } void run() { testsTurn.release(); threadsTurn.acquire(); - Q_ASSERT(!readWriteLock.tryLockForWrite()); + if (readWriteLock.tryLockForWrite()) + failureCount++; testsTurn.release(); threadsTurn.acquire(); - Q_ASSERT(readWriteLock.tryLockForWrite()); - Q_ASSERT(lockCount.testAndSetRelaxed(0, 1)); - Q_ASSERT(lockCount.testAndSetRelaxed(1, 0)); + if (!readWriteLock.tryLockForWrite()) + failureCount++; + if (!lockCount.testAndSetRelaxed(0, 1)) + failureCount++; + if (!lockCount.testAndSetRelaxed(1, 0)) + failureCount++; readWriteLock.unlock(); testsTurn.release(); threadsTurn.acquire(); - Q_ASSERT(!readWriteLock.tryLockForWrite(1000)); + if (readWriteLock.tryLockForWrite(1000)) + failureCount++; testsTurn.release(); threadsTurn.acquire(); - Q_ASSERT(readWriteLock.tryLockForWrite(1000)); - Q_ASSERT(lockCount.testAndSetRelaxed(0, 1)); - Q_ASSERT(lockCount.testAndSetRelaxed(1, 0)); + if (!readWriteLock.tryLockForWrite(1000)) + failureCount++; + if (!lockCount.testAndSetRelaxed(0, 1)) + failureCount++; + if (!lockCount.testAndSetRelaxed(1, 0)) + failureCount++; readWriteLock.unlock(); testsTurn.release(); threadsTurn.acquire(); } + + int failureCount; }; Thread thread; @@ -419,6 +430,8 @@ void tst_QReadWriteLock::tryWriteLock() testsTurn.acquire(); threadsTurn.release(); thread.wait(); + + QCOMPARE(thread.failureCount, 0); } } -- cgit v0.12 From 3b7f3757efb038fe523a00d474d1b92920f9abe8 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 14:52:46 +1000 Subject: Remove Q_ASSERT from qscriptengine autotest Rather than aborting in debug builds and failing silently in release builds, output a meaningful warning message and return a null QScriptValue which will cause the "isQObject" check in the testfunction to fail. Change-Id: I69fd9c15a69924d0abfde6710ea6ae4bf7e013fa Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptengine/tst_qscriptengine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index bc4091d..1a9db8f 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -5701,7 +5701,10 @@ void tst_QScriptEngine::collectGarbageAfterNativeArguments() static QScriptValue constructQObjectFromThisObject(QScriptContext *ctx, QScriptEngine *eng) { - Q_ASSERT(ctx->isCalledAsConstructor()); + if (!ctx->isCalledAsConstructor()) { + qWarning("%s: ctx->isCalledAsConstructor() returned false", Q_FUNC_INFO); + return QScriptValue(); + } return eng->newQObject(ctx->thisObject(), new QObject, QScriptEngine::ScriptOwnership); } -- cgit v0.12 From 20512cdab97b530ee8ec767254e553d80164b3c6 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 15:02:54 +1000 Subject: Remove Q_ASSERT's from V8 autotest Report a fatal error when the realFail() function is missing or misbehaving rather than silently ignoring the failure in non-debug builds. Change-Id: I8b27aeb1c9dab5752a5dbedafc4d420bb4121d2b Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp index 7328e1b..75c9acb 100644 --- a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp +++ b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp @@ -95,9 +95,11 @@ protected: static QScriptValue qscript_fail(QScriptContext *ctx, QScriptEngine *eng) { QScriptValue realFail = ctx->callee().data(); - Q_ASSERT(realFail.isFunction()); + if (!realFail.isFunction()) + qFatal("%s: realFail must be a function", Q_FUNC_INFO); QScriptValue ret = realFail.call(ctx->thisObject(), ctx->argumentsObject()); - Q_ASSERT(eng->hasUncaughtException()); + if (!eng->hasUncaughtException()) + qFatal("%s: realFail function did not throw an exception", Q_FUNC_INFO); ret.setProperty("expected", ctx->argument(0)); ret.setProperty("actual", ctx->argument(1)); ret.setProperty("message", ctx->argument(2)); -- cgit v0.12 From 385107ebc71a74dae031b713ea5a9c54635eeff8 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 15:36:04 +1000 Subject: Remove Q_ASSERT's from qscriptvaluegenerated test Report a fatal error if there are problems reading from the input data stream rather than failing silently in non-debug builds. Change-Id: I7a913bf47dccb37bab09e1cd79e5022b04e42c27 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- .../testgen/testgenerator.cpp | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp index 4d20f89..df2d38a 100644 --- a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp +++ b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp @@ -545,6 +545,17 @@ static void squashTags(QString dataTag, const QVector<bool>& results, QList<QStr } } +static QString streamStatusString(QDataStream::Status s) +{ + switch (s) { + case QDataStream::ReadPastEnd: + return QString("ReadPastEnd"); + case QDataStream::ReadCorruptData: + return QString("ReadCorruptData"); + default: + return QString("Unknown (%1)").arg(static_cast<int>(s)); + } +} QHash<QString, QString> TestGenerator::generateTest() { @@ -596,7 +607,10 @@ QHash<QString, QString> TestGenerator::generateTest() m_tempFile.seek(0); QDataStream in(&m_tempFile); in >> dataTags; - Q_ASSERT(in.status() == in.Ok); + if (in.status() != in.Ok) + qFatal("%s: stream has bad status %s after reading dataTags", + Q_FUNC_INFO, + qPrintable(streamStatusString(in.status()))); while(!in.atEnd()) { @@ -720,10 +734,13 @@ QHash<QString, QString> TestGenerator::generateTest() castUInt32List.append(QPair<QString, quint32>(dataTag, castUInt32Res)); castUInt16List.append(QPair<QString, quint16>(dataTag, castUInt16Res)); - Q_ASSERT(in.status() == in.Ok); + if (in.status() != in.Ok) + qFatal("%s: stream has bad status %s after reading data items", + Q_FUNC_INFO, + qPrintable(streamStatusString(in.status()))); } - - Q_ASSERT(in.atEnd()); + if (!in.atEnd()) + qFatal("%s: stream has more data after reading all data items", Q_FUNC_INFO); // Generate. QHash<QString, QString> result; -- cgit v0.12 From a4f105070799d4b4362b80b77c5960b364f77000 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 15:38:42 +1000 Subject: Remove Q_ASSERT from qscriptvaluegenerated test Report a fatal error if an empty test is generated rather than failing silently in non-debug builds. Change-Id: I79aa7a9eb09e387cef1960816a4bcce7b1af282d Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptvaluegenerated/testgen/testgenerator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h index be4f79f..d3096c0 100644 --- a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h +++ b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.h @@ -59,7 +59,8 @@ public: void run() { prepareData(); - Q_ASSERT(m_tempFile.size()); + if (!m_tempFile.size()) + qFatal("%s: prepareData failed to generate any data", Q_FUNC_INFO); save(generateTest()); } -- cgit v0.12 From 224050aae75fd5b1d6c57909d894a3eba7ac43fc Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 15:47:20 +1000 Subject: Remove unused function from qtessellator autotest Change-Id: I24c1db8392370d19970421a014f7bb6c4bc7c6e8 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtessellator/oldtessellator.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/auto/qtessellator/oldtessellator.cpp b/tests/auto/qtessellator/oldtessellator.cpp index 10b8710..e6a0451 100644 --- a/tests/auto/qtessellator/oldtessellator.cpp +++ b/tests/auto/qtessellator/oldtessellator.cpp @@ -80,19 +80,6 @@ struct QEdge { horizontal = p1.y == p2.y; } - inline qreal xAt(const qreal &y) const - { - Q_ASSERT(p1.y != p2.y); - XFixed yf = XDoubleToFixed(y); - - if (yf == p1.y) - return XFixedToDouble(p1.x); - else if (yf == p2.y) - return XFixedToDouble(p2.x); - - return (!vertical) ? (((y - b)*im)) : pf1.x(); - } - QPointF pf1, pf2; XPointFixed p1, p2; qreal m; -- cgit v0.12 From c0c7e04c9248ce38278aceefeb527f29149cfb4e Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 15:53:13 +1000 Subject: Remove Q_ASSERT from qtesselator autotest Report a fatal error rather than failing silently in non-debug builds. Change-Id: I625c5aa6f86a5764cd8f078baa074d6475a67736 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtessellator/oldtessellator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qtessellator/oldtessellator.cpp b/tests/auto/qtessellator/oldtessellator.cpp index e6a0451..bc24d7e 100644 --- a/tests/auto/qtessellator/oldtessellator.cpp +++ b/tests/auto/qtessellator/oldtessellator.cpp @@ -371,7 +371,8 @@ void old_tesselate_polygon(QVector<XTrapezoid> *traps, const QPointF *pg, int pg isects[i].edge = edge; } - Q_ASSERT(isects.size()%2 == 1); + if (isects.size()%2 != 1) + qFatal("%s: number of intersection points must be odd", Q_FUNC_INFO); // sort intersection points qSort(&isects[0], &isects[isects.size()-1], compareIntersections); -- cgit v0.12 From e12b912de89088a307c3519a01198a5314b8dd1a Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 17:14:39 +1000 Subject: Remove Q_ASSERT's from QTreeView autotest Report fatal errors instead of failing silently in non-debug builds. Change-Id: Ieaff30b71dba2a385a5fffc93d2a8c0f5864aa18 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtreeview/tst_qtreeview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 551b63f..1f0c2ce 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -277,7 +277,8 @@ public: } int rowCount(const QModelIndex& parent = QModelIndex()) const { - Q_ASSERT(fetched); + if (!fetched) + qFatal("%s: rowCount should not be called before fetching", Q_FUNC_INFO); if ((parent.column() > 0) || (level(parent) > levels)) return 0; return rows; @@ -2567,7 +2568,8 @@ public: } } if (parent == 0) { - Q_ASSERT(children.isEmpty()); + if (!children.isEmpty()) + qFatal("%s: children should be empty when parent is null", Q_FUNC_INFO); populate(); } else { isDead = true; -- cgit v0.12 From 912b6804bcacbf1b4f356d947986df8156a545a4 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer <bero@arklinux.ch> Date: Mon, 9 May 2011 11:34:17 +0200 Subject: Don't run XLib check if -no-gui is used Currently, an attempt to compile Qt even with -no-gui on a Linux box that doesn't have libX11 installed fails becaue of the XLib functionality check in configure. This check can be turned off in -no-gui mode, since QtCore, QtXml, QtNetwork and friends don't use libX11. Merge-request: 1214 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 8355997..95debec 100755 --- a/configure +++ b/configure @@ -5515,7 +5515,7 @@ if [ "$PLATFORM_X11" = "yes" -o "$PLATFORM_QWS" = "yes" ]; then fi # X11/QWS # X11 -if [ "$PLATFORM_X11" = "yes" ]; then +if [ "$PLATFORM_X11" = "yes" -a "$CFG_GUI" != "no" ]; then x11tests="$relpath/config.tests/x11" X11TESTS_FLAGS= -- cgit v0.12 From f0ae4f8ebdc6b7c50c163cfa29e686f3f87c8ba5 Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer <bero@arklinux.ch> Date: Mon, 9 May 2011 11:34:23 +0200 Subject: Fix -no-gui -no-gui still tried to build the graphicssystem and inputmethod plugins, both of which require QtGui Merge-request: 1215 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> --- src/plugins/plugins.pro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index e778ab7..42499dd 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -7,9 +7,9 @@ unix:!symbian { SUBDIRS *= codecs } !contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats iconengines -!embedded:SUBDIRS *= graphicssystems +!embedded:!contains(QT_CONFIG, no-gui):SUBDIRS *= graphicssystems embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers -!win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods +!win32:!embedded:!mac:!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS *= inputmethods !symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon -- cgit v0.12 From 0c9cb9a34d6b472cb53bf1af4616af55b593b616 Mon Sep 17 00:00:00 2001 From: Martin Petersson <martin.petersson@nokia.com> Date: Mon, 9 May 2011 13:56:47 +0200 Subject: emit QNetWorkAccessManager::finished on QNetworkReply::abort() If we can not get online when the request is made then we are in the WaitingForSession state. This will happen for example if the device is in flight mode. This fix follows the same logic as in _q_networkSessionFailed, but we should look into why we have the WaitingForSession check in finished(). Task-number: QT-4747 Reviewed-by: Markus Goetz --- src/network/access/qnetworkreplyimpl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 069755f..09fab51 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -775,6 +775,8 @@ void QNetworkReplyImpl::abort() if (d->state != QNetworkReplyImplPrivate::Finished) { // emit signals d->error(OperationCanceledError, tr("Operation canceled")); + if (d->state == QNetworkReplyImplPrivate::WaitingForSession) + d->state = QNetworkReplyImplPrivate::Working; d->finished(); } d->state = QNetworkReplyImplPrivate::Aborted; -- cgit v0.12 From 1c5da7207a21cc44a4a08d291c290ffcd9b958fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= <samuel.rodal@nokia.com> Date: Mon, 9 May 2011 16:54:41 +0200 Subject: Prevent crash in OpenGL engine when scaling images / pixmaps. Make sure the resulting image / pixmap is valid if the source was valid. Task-number: QTBUG-19157 Reviewed-by: Kim Reviewed-by: Benjamin Poulain --- src/gui/image/qimage.cpp | 2 ++ src/gui/image/qpixmap.cpp | 2 ++ tests/auto/qimage/tst_qimage.cpp | 8 ++++++++ tests/auto/qpixmap/tst_qpixmap.cpp | 8 ++++++++ 4 files changed, 20 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 441bdb1..c867984 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4377,6 +4377,8 @@ QImage QImage::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::Transf QSize newSize = size(); newSize.scale(s, aspectMode); + newSize.rwidth() = qMax(newSize.width(), 1); + newSize.rheight() = qMax(newSize.height(), 1); if (newSize == size()) return *this; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 1a83318..ed1b0f0 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1479,6 +1479,8 @@ QPixmap QPixmap::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::Tran QSize newSize = size(); newSize.scale(s, aspectMode); + newSize.rwidth() = qMax(newSize.width(), 1); + newSize.rheight() = qMax(newSize.height(), 1); if (newSize == size()) return *this; diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 558dfaa..6bb08b0 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -144,6 +144,7 @@ private slots: void rgbSwapped(); void deepCopyWhenPaintingActive(); + void scaled_QTBUG19157(); }; tst_QImage::tst_QImage() @@ -1902,5 +1903,12 @@ void tst_QImage::deepCopyWhenPaintingActive() QVERIFY(copy != image); } +void tst_QImage::scaled_QTBUG19157() +{ + QImage foo(5000, 1, QImage::Format_RGB32); + foo = foo.scaled(1024, 1024, Qt::KeepAspectRatio); + QVERIFY(!foo.isNull()); +} + QTEST_MAIN(tst_QImage) #include "tst_qimage.moc" diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 0b2f527..12d31e3 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -196,6 +196,7 @@ private slots: #endif void drawPixmapWhilePainterOpen(); + void scaled_QTBUG19157(); }; static bool lenientCompare(const QPixmap &actual, const QPixmap &expected) @@ -1942,5 +1943,12 @@ void tst_QPixmap::drawPixmapWhilePainterOpen() } } +void tst_QPixmap::scaled_QTBUG19157() +{ + QPixmap foo(5000, 1); + foo = foo.scaled(1024, 1024, Qt::KeepAspectRatio); + QVERIFY(!foo.isNull()); +} + QTEST_MAIN(tst_QPixmap) #include "tst_qpixmap.moc" -- cgit v0.12 From 74a4aad171b39018d596b99684286b9426a091a5 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 17:34:45 +1000 Subject: Remove Q_ASSERT from QVariant autotest I missed one Q_ASSERT in the previous commit. Also changing to use Q_FUNC_INFO instead of hard-coded function names in the warning messages. Change-Id: I0ff5b2b2cda02597836beb5d2811fa8dd2a344ab Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qvariant/tst_qvariant.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index fef7ec2..8d4b056 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -3234,19 +3234,22 @@ struct MyData MyData() : ptr(this) {} ~MyData() { - if (ptr != this) qWarning("MyData::~MyData(): object has moved"); + if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO); + } + MyData(const MyData& o) : ptr(this) + { + if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO); } - MyData(const MyData& o) : ptr(this) { Q_ASSERT(o.ptr == &o); } MyData &operator=(const MyData &o) { - if (ptr != this) qWarning("MyData::operator=(): object has moved"); - if (o.ptr != &o) qWarning("MyData::operator=(): other object has moved"); + if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO); + if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO); return *this; } bool operator==(const MyData &o) const { - if (ptr != this) qWarning("MyData::operator==(): object has moved"); - if (o.ptr != &o) qWarning("MyData::operator==(): other object has moved"); + if (ptr != this) qWarning("%s: object has moved", Q_FUNC_INFO); + if (o.ptr != &o) qWarning("%s: other object has moved", Q_FUNC_INFO); return true; } }; -- cgit v0.12 From fe170938cf963e0a0a20b19f97ee6e18b6808a90 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 15:13:15 +1000 Subject: Remove Q_ASSERT from qscriptvaluegenerated test Report a fatal error if an unknown type of comparison is requested rather than failing silently in non-debug builds. Also fixes the misspelled parameter name. Change-Id: I84bd018aa99e99a98d97c43343032b38ca9cbccb Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp index df2d38a..c9eacd4 100644 --- a/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp +++ b/tests/auto/qscriptvaluegenerated/testgen/testgenerator.cpp @@ -467,7 +467,7 @@ QString generateCastDef<qsreal>(const QList<QPair<QString, qsreal> >& list) QString::number(list.count())); } -static QString generateCompareDef(const QString& comparisionType, const QList<QString> tags) +static QString generateCompareDef(const QString& comparisonType, const QList<QString> tags) { static const QString templ = "\n"\ "void tst_QScriptValueGenerated::%1_initData()\n"\ @@ -501,10 +501,11 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS "}\n"\ "\n"\ "DEFINE_TEST_FUNCTION(%1)\n"; - Q_ASSERT(comparisionType == "strictlyEquals" - || comparisionType == "equals" - || comparisionType == "lessThan" - || comparisionType == "instanceOf"); + if (comparisonType != "strictlyEquals" + && comparisonType != "equals" + && comparisonType != "lessThan" + && comparisonType != "instanceOf") + qFatal("%s: Unknown comparisonType: %s", Q_FUNC_INFO, qPrintable(comparisonType)); QString result = templ; QStringList set; @@ -516,7 +517,7 @@ static QString generateCompareDef(const QString& comparisionType, const QList<QS set.append(escape(tmp)); set.append("\""); } - return result.arg(comparisionType, set.join(""), QString::number(tags.count())); + return result.arg(comparisonType, set.join(""), QString::number(tags.count())); } static QString generateInitDef(const QVector<QString>& allDataTags) -- cgit v0.12 From f859ab10715a3cb69aa3f03574a046c886d34b44 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Fri, 6 May 2011 14:16:48 +1000 Subject: Remove Q_ASSERT from qabstractxmlnodemodel test If new "axis" enum values are added in the future, the test should report a meaningful warning in the test output rather than aborting with a meaningless message in debug builds and failing silently in release builds. Change-Id: Ifdc7a9492c3ee196d7f0e6958eec34693efd244f Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index 2ce9466..052c781 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -173,10 +173,10 @@ QXmlNodeModelIndex LoadingModel::nextFromSimpleAxis(QAbstractXmlNodeModel::Simpl return internal->precedingSibling ? createIndex(internal->precedingSibling) : QXmlNodeModelIndex(); case NextSibling: return internal->followingSibling ? createIndex(internal->followingSibling) : QXmlNodeModelIndex(); + default: + qWarning("%s: unknown axis enum value %d", Q_FUNC_INFO, static_cast<int>(axis)); + return QXmlNodeModelIndex(); } - - Q_ASSERT(false); - return QXmlNodeModelIndex(); } QVector<QXmlNodeModelIndex> LoadingModel::attributes(const QXmlNodeModelIndex &ni) const -- cgit v0.12 From 6e3fcd6ff50e6435fd90629ed695196d25312ffc Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 10 May 2011 11:33:37 +1000 Subject: Remove Q_ASSERT's from QXmlStream autotest Report fatal errors rather than ignoring them in non-debug builds. Change-Id: Ieafc58f3603fa953f4a963394039e613dcd442fb Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlstream/qc14n.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/auto/qxmlstream/qc14n.h b/tests/auto/qxmlstream/qc14n.h index 99432f3..c7d3a7d 100644 --- a/tests/auto/qxmlstream/qc14n.h +++ b/tests/auto/qxmlstream/qc14n.h @@ -71,12 +71,14 @@ bool QC14N::isEqual(QIODevice *const firstDocument, QString *const message) { qDebug() << Q_FUNC_INFO; - Q_ASSERT_X(firstDocument, Q_FUNC_INFO, - "A valid QIODevice pointer must be supplied"); - Q_ASSERT_X(secondDocument, Q_FUNC_INFO, - "A valid QIODevice pointer must be supplied"); - Q_ASSERT_X(firstDocument->isReadable(), Q_FUNC_INFO, "The device must be readable."); - Q_ASSERT_X(secondDocument->isReadable(), Q_FUNC_INFO, "The device must be readable."); + if (!firstDocument) + qFatal("%s: A valid firstDocument QIODevice pointer must be supplied", Q_FUNC_INFO); + if (!secondDocument) + qFatal("%s: A valid secondDocument QIODevice pointer must be supplied", Q_FUNC_INFO); + if (!firstDocument->isReadable()) + qFatal("%s: The firstDocument device must be readable.", Q_FUNC_INFO); + if (!secondDocument->isReadable()) + qFatal("%s: The secondDocument device must be readable.", Q_FUNC_INFO); QXmlStreamReader r1(firstDocument); QXmlStreamReader r2(secondDocument); -- cgit v0.12 From b841d30f25a87f8aafc4624fe09a3503ddc6ccda Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 18:21:18 +1000 Subject: Remove Q_ASSERT from qxmlquery autotest Make stream validity check part of the regular test logic rather than aborting in debug builds and ignoring the error in release builds. Change-Id: I07dcba079eecd88bf16672c6019a8d6f5a829fee Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlquery/PushBaseliner.h | 7 ++++++- tests/auto/qxmlquery/tst_qxmlquery.cpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/auto/qxmlquery/PushBaseliner.h b/tests/auto/qxmlquery/PushBaseliner.h index 0648c90..8478a6a 100644 --- a/tests/auto/qxmlquery/PushBaseliner.h +++ b/tests/auto/qxmlquery/PushBaseliner.h @@ -65,9 +65,9 @@ public: const QXmlNamePool &namePool) : m_out(out) , m_namePool(namePool) { - Q_ASSERT(m_out.codec()); } + bool isValid() const; virtual void startElement(const QXmlName&); virtual void endElement(); virtual void attribute(const QXmlName&, const QStringRef&); @@ -86,6 +86,11 @@ private: const QXmlNamePool m_namePool; }; +bool PushBaseliner::isValid() const +{ + return m_out.codec(); +} + void PushBaseliner::startElement(const QXmlName &name) { m_out << "startElement(" << name.toClarkName(m_namePool) << ')'<< endl; diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index e3c97d2..e22f528 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -967,6 +967,7 @@ void tst_QXmlQuery::evaluateToReceiver() QString produced; QTextStream stream(&produced, QIODevice::WriteOnly); PushBaseliner push(stream, query.namePool()); + QVERIFY(push.isValid()); query.evaluateTo(&push); const QString baselineName(inputFile(QLatin1String(SRCDIR "pushBaselines/") + inputQuery.left(inputQuery.length() - 2) + QString::fromLatin1("ref"))); @@ -1685,6 +1686,7 @@ void tst_QXmlQuery::constCorrectness() const QString dummyString; QTextStream dummyStream(&dummyString); PushBaseliner dummy(dummyStream, query.namePool()); + QVERIFY(dummy.isValid()); query.evaluateTo(&dummy); } } -- cgit v0.12 From 1acca025082bad566e5fe7078aa41f73316cd40b Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 17:45:52 +1000 Subject: Remove Q_ASSERT's from qxmlquery autotest Make url validity check part of the regular test logic rather than aborting in debug builds and ignoring the error in release builds. Change-Id: Ic00610c04ee596f519b9d461748b401719cf41c0 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlquery/NetworkOverrider.h | 13 +++++++++---- tests/auto/qxmlquery/tst_qxmlquery.cpp | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/auto/qxmlquery/NetworkOverrider.h b/tests/auto/qxmlquery/NetworkOverrider.h index 10a85c1..2f227ea 100644 --- a/tests/auto/qxmlquery/NetworkOverrider.h +++ b/tests/auto/qxmlquery/NetworkOverrider.h @@ -70,6 +70,7 @@ public: virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData); + bool isValid() const; private: const QUrl m_rewriteFrom; @@ -77,11 +78,10 @@ private: }; NetworkOverrider::NetworkOverrider(const QUrl &rewriteFrom, - const QUrl &rewriteTo) : m_rewriteFrom(rewriteFrom) - , m_rewriteTo(rewriteTo) + const QUrl &rewriteTo) + : m_rewriteFrom(rewriteFrom) + , m_rewriteTo(rewriteTo) { - Q_ASSERT(m_rewriteFrom.isValid()); - Q_ASSERT(m_rewriteTo.isValid()); } QNetworkReply *NetworkOverrider::createRequest(Operation op, @@ -95,4 +95,9 @@ QNetworkReply *NetworkOverrider::createRequest(Operation op, return QNetworkAccessManager::createRequest(op, newReq, outgoingData); } + +bool NetworkOverrider::isValid() const +{ + return m_rewriteFrom.isValid() && m_rewriteTo.isValid(); +} #endif diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index e22f528..c002f83 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -3080,6 +3080,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/queries/simpleDocument.xml")))); + QVERIFY(networkOverrider.isValid()); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); @@ -3096,6 +3097,7 @@ void tst_QXmlQuery::setNetworkAccessManager() const { NetworkOverrider networkOverrider(QUrl(QLatin1String("tag:example.com:DOESNOTEXIST")), QUrl(inputFileAsURI(QLatin1String(XMLPATTERNSDIR "/queries/concat.xq")))); + QVERIFY(networkOverrider.isValid()); QXmlQuery query; query.setNetworkAccessManager(&networkOverrider); -- cgit v0.12 From 984a72a8bbf853059f0eb7e1054538b48d5f3bc8 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 10 May 2011 11:48:36 +1000 Subject: Remove Q_ASSERT from QItemModel autotest If populateTestData() would return an invalid model index, report a meaningful fatal error rather than failing silently in a release build and aborting with an uninformative error message in a debug build. Change-Id: I96820429a25ce5c4eb375d50e7e1f672851e26e6 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qitemmodel/modelstotest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qitemmodel/modelstotest.cpp b/tests/auto/qitemmodel/modelstotest.cpp index 7ebf2c7..df06c95 100644 --- a/tests/auto/qitemmodel/modelstotest.cpp +++ b/tests/auto/qitemmodel/modelstotest.cpp @@ -308,7 +308,8 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) */ } QModelIndex returnIndex = model->index(0,0); - Q_ASSERT(returnIndex.isValid()); + if (!returnIndex.isValid()) + qFatal("%s: model index to be returned is invalid", Q_FUNC_INFO); return returnIndex; } -- cgit v0.12 From 4793c3bd1dfddcc98eae12e5caf29ff6aabd31b2 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 10 May 2011 11:43:08 +1000 Subject: Remove Q_ASSERT's from QXmlStream autotest Report fatal errors rather than ignoring them in non-debug builds. Change-Id: I62dd177e2f391e64c12314bf224f8952ed6f3144 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlstream/tst_qxmlstream.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp index 5324264..946a19a 100644 --- a/tests/auto/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp @@ -264,7 +264,8 @@ public: expected(aExpected), output(aOutput) { - Q_ASSERT(!aId.isEmpty()); + if (aId.isEmpty()) + qFatal("%s: aId must not be an empty string", Q_FUNC_INFO); } QString id; @@ -288,7 +289,8 @@ public: TestSuiteHandler(const QUrl &baseURI) : runCount(0), skipCount(0) { - Q_ASSERT(baseURI.isValid()); + if (!baseURI.isValid()) + qFatal("%s: baseURI must be valid", Q_FUNC_INFO); m_baseURI.push(baseURI); } @@ -480,9 +482,12 @@ public: static bool isWellformed(QIODevice *const inputFile, const ParseMode mode) { - Q_ASSERT(inputFile); - Q_ASSERT_X(inputFile->isOpen(), Q_FUNC_INFO, "The caller is responsible for opening the device."); - Q_ASSERT(mode == ParseIncrementally || mode == ParseSinglePass); + if (!inputFile) + qFatal("%s: inputFile must be a valid QIODevice pointer", Q_FUNC_INFO); + if (!inputFile->isOpen()) + qFatal("%s: inputFile must be opened by the caller", Q_FUNC_INFO); + if (mode != ParseIncrementally && mode != ParseSinglePass) + qFatal("%s: mode must be either ParseIncrementally or ParseSinglePass", Q_FUNC_INFO); if(mode == ParseIncrementally) { -- cgit v0.12 From cb84f3d1a1499485d4c5314b6e94745c6def6888 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 17:40:30 +1000 Subject: Remove Q_ASSERT from qxmlquery autotest Report fatal error in all builds not just debug builds. Change-Id: I6c64435d0382a160ac3602e5243fad9d9585f057 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlquery/MessageValidator.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/auto/qxmlquery/MessageValidator.cpp b/tests/auto/qxmlquery/MessageValidator.cpp index 58b2b31..99a115e 100644 --- a/tests/auto/qxmlquery/MessageValidator.cpp +++ b/tests/auto/qxmlquery/MessageValidator.cpp @@ -51,9 +51,8 @@ MessageValidator::MessageValidator() : m_success(false) MessageValidator::~MessageValidator() { - Q_ASSERT_X(m_hasChecked, - Q_FUNC_INFO, - "You must call success()."); + if (!m_hasChecked) + qFatal("%s: You must call success().", Q_FUNC_INFO); } void MessageValidator::handleMessage(QtMsgType type, -- cgit v0.12 From 1c85fc559ee456a165527d23cb1b7dc237f5504b Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 10 May 2011 13:19:25 +1000 Subject: Remove Q_ASSERT from QXmlStream autotest Report a meaningful fatal error if an unknown token type is encountered rather than ignoring the error in non-debug builds and reporting an uninformative message in debug builds. Change-Id: Id219f3c7cbd4ba3e9875cb81f833720d5d153132 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qxmlstream/qc14n.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qxmlstream/qc14n.h b/tests/auto/qxmlstream/qc14n.h index c7d3a7d..661ddee 100644 --- a/tests/auto/qxmlstream/qc14n.h +++ b/tests/auto/qxmlstream/qc14n.h @@ -191,9 +191,9 @@ bool QC14N::isDifferent(const QXmlStreamReader &r1, r2.processingInstructionData() == r2.processingInstructionData(); } + default: + qFatal("%s: Unknown tokenType: %d", Q_FUNC_INFO, static_cast<int>(r1.tokenType())); + return false; } - - Q_ASSERT_X(false, Q_FUNC_INFO, "This line should never be reached"); - return false; } -- cgit v0.12 From 6f5751c45868a6dde51647462a331d49f848f2f0 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Tue, 10 May 2011 13:30:56 +1000 Subject: Remove Q_ASSERT's from qabstractxmlnodemodel test Report fatal errors rather than ignoring the errors in non-debug builds. Change-Id: I5d2f20113cbca11e272cf8fc2591e38b94d6853b Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qabstractxmlnodemodel/LoadingModel.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp index 052c781..bb8538c 100644 --- a/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp +++ b/tests/auto/qabstractxmlnodemodel/LoadingModel.cpp @@ -84,13 +84,14 @@ QXmlNodeModelIndex LoadingModel::createIndex(const Node *const internal) const QUrl LoadingModel::documentUri(const QXmlNodeModelIndex &) const { - Q_ASSERT(false); + qFatal("%s: This method should not be called during the test", Q_FUNC_INFO); return QUrl(); } QXmlNodeModelIndex::NodeKind LoadingModel::kind(const QXmlNodeModelIndex &ni) const { - Q_ASSERT(!ni.isNull()); + if (ni.isNull()) + qFatal("%s: node model index should not be null", Q_FUNC_INFO); return toInternal(ni)->kind; } @@ -332,13 +333,11 @@ void Loader::load() break; } case QXmlStreamReader::DTD: - /* Fallthrough. */ + qFatal("%s: QXmlStreamReader::DTD token is not supported", Q_FUNC_INFO); + break; case QXmlStreamReader::EntityReference: - { - Q_ASSERT_X(false, Q_FUNC_INFO, - "We don't support this."); - /* Fallthrough. */ - } + qFatal("%s: QXmlStreamReader::EntityReference token is not supported", Q_FUNC_INFO); + break; case QXmlStreamReader::NoToken: /* Fallthrough. */ case QXmlStreamReader::Invalid: -- cgit v0.12 From bbfefe1b764cd41b7e677f26621fb6e76a67f9d7 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Mon, 9 May 2011 12:18:50 +1000 Subject: Remove Q_ASSERT's from QNetworkReply autotest Rather than aborting in debug builds and failing mysteriously in release builds, report fatal errors in all builds. Change-Id: I020b06e19b7ffc8ae4413e1756259f4ca608f253 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index b5bbd84..610ca1f 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -739,7 +739,9 @@ public: QTcpSocket* waitForNextConnectionSocket() { waitForNewConnection(-1); if (doSsl) { - Q_ASSERT(sslSocket); + if (!sslSocket) + qFatal("%s: sslSocket should not be null after calling waitForNewConnection()", + Q_FUNC_INFO); return sslSocket; } else { //qDebug() << "returning nextPendingConnection"; @@ -911,7 +913,8 @@ protected: while (dataIndex < wantedSize) { const int remainingBytes = wantedSize - measuredSentBytes; const int bytesToWrite = qMin(remainingBytes, static_cast<int>(BlockSize)); - Q_ASSERT(bytesToWrite); + if (bytesToWrite <= 0) + qFatal("%s: attempt to write %d bytes", Q_FUNC_INFO, bytesToWrite); measuredSentBytes += writeNextData(client, bytesToWrite); while (client->bytesToWrite() > 0) { @@ -970,7 +973,8 @@ public: // Wait for data to be readyRead bool ok = connect(&senderObj, SIGNAL(dataReady()), this, SLOT(slotDataReady())); - Q_ASSERT(ok); + if (!ok) + qFatal("%s: Cannot connect dataReady signal", Q_FUNC_INFO); } void wrapUp() @@ -993,9 +997,9 @@ protected: void timerEvent(QTimerEvent *) { //qDebug() << "RateControlledReader: timerEvent bytesAvailable=" << device->bytesAvailable(); - if (readBufferSize > 0) { - // This asserts passes all the time, except in the final flush. - //Q_ASSERT(device->bytesAvailable() <= readBufferSize); + if (readBufferSize > 0 && device->bytesAvailable() > readBufferSize) { + // This passes all the time, except in the final flush. + //qFatal("%s: Too many bytes available", Q_FUNC_INFO); } qint64 bytesRead = 0; @@ -1122,7 +1126,7 @@ QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op, break; default: - Q_ASSERT_X(false, "tst_QNetworkReply", "Invalid/unknown operation requested"); + qFatal("%s: Invalid/unknown operation requested", Q_FUNC_INFO); } reply->setParent(this); -- cgit v0.12 From 0ec06f76484d64676bcd8b981b54593cdb8b539e Mon Sep 17 00:00:00 2001 From: Sami Merila <sami.merila@nokia.com> Date: Tue, 10 May 2011 11:48:29 +0300 Subject: Fix Symbian/WinsCW build break A new exported method qt_draw_decoration_for_glyphs was recently added to the QtGui, but DEF file was only adjusted for ARM. Reviewed-by: Tomi Vihria --- src/s60installs/bwins/QtGuiu.def | 1 + 1 file changed, 1 insertion(+) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 45a8d7b..5dcd9f8 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12982,4 +12982,5 @@ EXPORTS ?releaseCachedResources@QGraphicsSystem@@UAEXXZ @ 12981 NONAME ; void QGraphicsSystem::releaseCachedResources(void) ?qt_s60_setPartialScreenInputMode@@YAX_N@Z @ 12982 NONAME ; void qt_s60_setPartialScreenInputMode(bool) ?paintingActive@QVolatileImage@@QBE_NXZ @ 12983 NONAME ; bool QVolatileImage::paintingActive(void) const + ?qt_draw_decoration_for_glyphs@@YAXPAVQPainter@@PBIPBUQFixedPoint@@HPAVQFontEngine@@ABVQFont@@ABVQTextCharFormat@@@Z @ 12984 NONAME ; void qt_draw_decoration_for_glyphs(class QPainter *, unsigned int const *, struct QFixedPoint const *, int, class QFontEngine *, class QFont const &, class QTextCharFormat const &) -- cgit v0.12 From 84ef364302728b68d2d29ea9c4ccbec32c7bb115 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Date: Tue, 10 May 2011 09:43:00 +0200 Subject: Rename QGlyphs -> QGlyphRun API clean-up for QGlyphRun: 1. QGlyphs -> QGlyphRun 2. QGlyphRun's font()/setFont() -> rawFont()/setRawFont() 3. QPainter::drawGlyphs() -> drawGlyphRun() 4. QTextLayout and QTextFragment's glyphs() -> glyphRuns() Reviewed-by: Jiang Jiang --- src/gui/painting/qpaintbuffer.cpp | 6 +- src/gui/painting/qpainter.cpp | 18 +- src/gui/painting/qpainter.h | 4 +- src/gui/text/qglyphrun.cpp | 324 ++++++++++++++++++ src/gui/text/qglyphrun.h | 107 ++++++ src/gui/text/qglyphrun_p.h | 103 ++++++ src/gui/text/qglyphs.cpp | 323 ------------------ src/gui/text/qglyphs.h | 107 ------ src/gui/text/qglyphs_p.h | 103 ------ src/gui/text/qrawfont.cpp | 18 +- src/gui/text/qtextlayout.cpp | 22 +- src/gui/text/qtextlayout.h | 6 +- src/gui/text/qtextobject.cpp | 10 +- src/gui/text/qtextobject.h | 4 +- src/gui/text/text.pri | 10 +- tests/auto/gui.pro | 2 +- tests/auto/qglyphrun/qglyphrun.pro | 11 + tests/auto/qglyphrun/test.ttf | Bin 0 -> 3712 bytes tests/auto/qglyphrun/tst_qglyphrun.cpp | 582 +++++++++++++++++++++++++++++++++ tests/auto/qglyphs/qglyphs.pro | 11 - tests/auto/qglyphs/test.ttf | Bin 3712 -> 0 bytes tests/auto/qglyphs/tst_qglyphs.cpp | 582 --------------------------------- tests/auto/qrawfont/tst_qrawfont.cpp | 16 +- 23 files changed, 1185 insertions(+), 1184 deletions(-) create mode 100644 src/gui/text/qglyphrun.cpp create mode 100644 src/gui/text/qglyphrun.h create mode 100644 src/gui/text/qglyphrun_p.h delete mode 100644 src/gui/text/qglyphs.cpp delete mode 100644 src/gui/text/qglyphs.h delete mode 100644 src/gui/text/qglyphs_p.h create mode 100644 tests/auto/qglyphrun/qglyphrun.pro create mode 100644 tests/auto/qglyphrun/test.ttf create mode 100644 tests/auto/qglyphrun/tst_qglyphrun.cpp delete mode 100644 tests/auto/qglyphs/qglyphs.pro delete mode 100644 tests/auto/qglyphs/test.ttf delete mode 100644 tests/auto/qglyphs/tst_qglyphs.cpp diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 51171c5..6f6cd6f 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -1768,12 +1768,12 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) rawFontD->fontEngine = fontD->engineForScript(QUnicodeTables::Common); rawFontD->fontEngine->ref.ref(); - QGlyphs glyphs; - glyphs.setFont(rawFont); + QGlyphRun glyphs; + glyphs.setRawFont(rawFont); glyphs.setGlyphIndexes(glyphIndexes); glyphs.setPositions(positions); - painter->drawGlyphs(QPointF(), glyphs); + painter->drawGlyphRun(QPointF(), glyphs); break; } #endif diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index ee960d1..7130fbf 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -62,7 +62,7 @@ #include "qthread.h" #include "qvarlengtharray.h" #include "qstatictext.h" -#include "qglyphs.h" +#include "qglyphrun.h" #include <private/qfontengine_p.h> #include <private/qpaintengine_p.h> @@ -73,7 +73,7 @@ #include <private/qpaintengine_raster_p.h> #include <private/qmath_p.h> #include <private/qstatictext_p.h> -#include <private/qglyphs_p.h> +#include <private/qglyphrun_p.h> #include <private/qstylehelper_p.h> #include <private/qrawfont_p.h> @@ -5798,19 +5798,19 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR \since 4.8 - \sa QGlyphs::setFont(), QGlyphs::setPositions(), QGlyphs::setGlyphIndexes() + \sa QGlyphRun::setRawFont(), QGlyphRun::setPositions(), QGlyphRun::setGlyphIndexes() */ #if !defined(QT_NO_RAWFONT) -void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs) +void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun) { Q_D(QPainter); - QRawFont font = glyphs.font(); + QRawFont font = glyphRun.rawFont(); if (!font.isValid()) return; - QVector<quint32> glyphIndexes = glyphs.glyphIndexes(); - QVector<QPointF> glyphPositions = glyphs.positions(); + QVector<quint32> glyphIndexes = glyphRun.glyphIndexes(); + QVector<QPointF> glyphPositions = glyphRun.positions(); int count = qMin(glyphIndexes.size(), glyphPositions.size()); QVarLengthArray<QFixedPoint, 128> fixedPointPositions(count); @@ -5833,8 +5833,8 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs) fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition); } - d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphs.overline(), - glyphs.underline(), glyphs.strikeOut()); + d->drawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count, font, glyphRun.overline(), + glyphRun.underline(), glyphRun.strikeOut()); } void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, int glyphCount, diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 1a432e6..601c386 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -79,7 +79,7 @@ class QTextItem; class QMatrix; class QTransform; class QStaticText; -class QGlyphs; +class QGlyphRun; class QPainterPrivateDeleter; @@ -400,7 +400,7 @@ public: Qt::LayoutDirection layoutDirection() const; #if !defined(QT_NO_RAWFONT) - void drawGlyphs(const QPointF &position, const QGlyphs &glyphs); + void drawGlyphRun(const QPointF &position, const QGlyphRun &glyphRun); #endif void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText); diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp new file mode 100644 index 0000000..ea52788 --- /dev/null +++ b/src/gui/text/qglyphrun.cpp @@ -0,0 +1,324 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qglobal.h" + +#if !defined(QT_NO_RAWFONT) + +#include "qglyphrun.h" +#include "qglyphrun_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QGlyphRun + \brief The QGlyphRun class provides direct access to the internal glyphs in a font. + \since 4.8 + + \ingroup text + \mainclass + + When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points + into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode + representation of the text and the QFont object will in this case serve as a convenient + abstraction that hides the details of what actually takes place when displaying the text + on-screen. For instance, by the time the text actually reaches the screen, it may be represented + by a set of fonts in addition to the one specified by the user, e.g. in case the originally + selected font did not support all the writing systems contained in the text. + + Under certain circumstances, it can be useful as an application developer to have more low-level + control over which glyphs in a specific font are drawn to the screen. This could for instance + be the case in applications that use an external font engine and text shaper together with Qt. + QGlyphRun provides an interface to the raw data needed to get text on the screen. It + contains a list of glyph indexes, a position for each glyph and a font. + + It is the user's responsibility to ensure that the selected font actually contains the + provided glyph indexes. + + QTextLayout::glyphRuns() or QTextFragment::glyphRuns() can be used to convert unicode encoded + text into a list of QGlyphRun objects, and QPainter::drawGlyphRun() can be used to draw the + glyphs. + + \note Please note that QRawFont is considered local to the thread in which it is constructed. + This in turn means that a new QRawFont will have to be created and set on the QGlyphRun if it is + moved to a different thread. If the QGlyphRun contains a reference to a QRawFont from a different + thread than the current, it will not be possible to draw the glyphs using a QPainter, as the + QRawFont is considered invalid and inaccessible in this case. +*/ + + +/*! + Constructs an empty QGlyphRun object. +*/ +QGlyphRun::QGlyphRun() : d(new QGlyphRunPrivate) +{ +} + +/*! + Constructs a QGlyphRun object which is a copy of \a other. +*/ +QGlyphRun::QGlyphRun(const QGlyphRun &other) +{ + d = other.d; +} + +/*! + Destroys the QGlyphRun. +*/ +QGlyphRun::~QGlyphRun() +{ + // Required for QExplicitlySharedDataPointer +} + +/*! + \internal +*/ +void QGlyphRun::detach() +{ + if (d->ref != 1) + d.detach(); +} + +/*! + Assigns \a other to this QGlyphRun object. +*/ +QGlyphRun &QGlyphRun::operator=(const QGlyphRun &other) +{ + d = other.d; + return *this; +} + +/*! + Compares \a other to this QGlyphRun object. Returns true if the list of glyph indexes, + the list of positions and the font are all equal, otherwise returns false. +*/ +bool QGlyphRun::operator==(const QGlyphRun &other) const +{ + return ((d == other.d) + || (d->glyphIndexes == other.d->glyphIndexes + && d->glyphPositions == other.d->glyphPositions + && d->overline == other.d->overline + && d->underline == other.d->underline + && d->strikeOut == other.d->strikeOut + && d->rawFont == other.d->rawFont)); +} + +/*! + Compares \a other to this QGlyphRun object. Returns true if any of the list of glyph + indexes, the list of positions or the font are different, otherwise returns false. +*/ +bool QGlyphRun::operator!=(const QGlyphRun &other) const +{ + return !(*this == other); +} + +/*! + \internal + + Adds together the lists of glyph indexes and positions in \a other and this QGlyphRun + object and returns the result. The font in the returned QGlyphRun will be the same as in + this QGlyphRun object. +*/ +QGlyphRun QGlyphRun::operator+(const QGlyphRun &other) const +{ + QGlyphRun ret(*this); + ret += other; + return ret; +} + +/*! + \internal + + Appends the glyph indexes and positions in \a other to this QGlyphRun object and returns + a reference to the current object. +*/ +QGlyphRun &QGlyphRun::operator+=(const QGlyphRun &other) +{ + detach(); + + d->glyphIndexes += other.d->glyphIndexes; + d->glyphPositions += other.d->glyphPositions; + + return *this; +} + +/*! + Returns the font selected for this QGlyphRun object. + + \sa setRawFont() +*/ +QRawFont QGlyphRun::rawFont() const +{ + return d->rawFont; +} + +/*! + Sets the font in which to look up the glyph indexes to \a font. + + \sa rawFont(), setGlyphIndexes() +*/ +void QGlyphRun::setRawFont(const QRawFont &rawFont) +{ + detach(); + d->rawFont = rawFont; +} + +/*! + Returns the glyph indexes for this QGlyphRun object. + + \sa setGlyphIndexes(), setPositions() +*/ +QVector<quint32> QGlyphRun::glyphIndexes() const +{ + return d->glyphIndexes; +} + +/*! + Set the glyph indexes for this QGlyphRun object to \a glyphIndexes. The glyph indexes must + be valid for the selected font. +*/ +void QGlyphRun::setGlyphIndexes(const QVector<quint32> &glyphIndexes) +{ + detach(); + d->glyphIndexes = glyphIndexes; +} + +/*! + Returns the position of the edge of the baseline for each glyph in this set of glyph indexes. +*/ +QVector<QPointF> QGlyphRun::positions() const +{ + return d->glyphPositions; +} + +/*! + Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to + \a positions. +*/ +void QGlyphRun::setPositions(const QVector<QPointF> &positions) +{ + detach(); + d->glyphPositions = positions; +} + +/*! + Clears all data in the QGlyphRun object. +*/ +void QGlyphRun::clear() +{ + detach(); + d->glyphPositions = QVector<QPointF>(); + d->glyphIndexes = QVector<quint32>(); + d->rawFont = QRawFont(); + d->strikeOut = false; + d->overline = false; + d->underline = false; +} + +/*! + Returns true if this QGlyphRun should be painted with an overline decoration. + + \sa setOverline() +*/ +bool QGlyphRun::overline() const +{ + return d->overline; +} + +/*! + Indicates that this QGlyphRun should be painted with an overline decoration if \a overline is true. + Otherwise the QGlyphRun should be painted with no overline decoration. + + \sa overline() +*/ +void QGlyphRun::setOverline(bool overline) +{ + detach(); + d->overline = overline; +} + +/*! + Returns true if this QGlyphRun should be painted with an underline decoration. + + \sa setUnderline() +*/ +bool QGlyphRun::underline() const +{ + return d->underline; +} + +/*! + Indicates that this QGlyphRun should be painted with an underline decoration if \a underline is + true. Otherwise the QGlyphRun should be painted with no underline decoration. + + \sa underline() +*/ +void QGlyphRun::setUnderline(bool underline) +{ + detach(); + d->underline = underline; +} + +/*! + Returns true if this QGlyphRun should be painted with a strike out decoration. + + \sa setStrikeOut() +*/ +bool QGlyphRun::strikeOut() const +{ + return d->strikeOut; +} + +/*! + Indicates that this QGlyphRun should be painted with an strike out decoration if \a strikeOut is + true. Otherwise the QGlyphRun should be painted with no strike out decoration. + + \sa strikeOut() +*/ +void QGlyphRun::setStrikeOut(bool strikeOut) +{ + detach(); + d->strikeOut = strikeOut; +} + +QT_END_NAMESPACE + +#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h new file mode 100644 index 0000000..dcc166e --- /dev/null +++ b/src/gui/text/qglyphrun.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLYPHRUN_H +#define QGLYPHRUN_H + +#include <QtCore/qsharedpointer.h> +#include <QtCore/qvector.h> +#include <QtCore/qpoint.h> +#include <QtGui/qrawfont.h> + +#if !defined(QT_NO_RAWFONT) + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QGlyphRunPrivate; +class Q_GUI_EXPORT QGlyphRun +{ +public: + QGlyphRun(); + QGlyphRun(const QGlyphRun &other); + ~QGlyphRun(); + + QRawFont rawFont() const; + void setRawFont(const QRawFont &rawFont); + + QVector<quint32> glyphIndexes() const; + void setGlyphIndexes(const QVector<quint32> &glyphIndexes); + + QVector<QPointF> positions() const; + void setPositions(const QVector<QPointF> &positions); + + void clear(); + + QGlyphRun &operator=(const QGlyphRun &other); + bool operator==(const QGlyphRun &other) const; + bool operator!=(const QGlyphRun &other) const; + + void setOverline(bool overline); + bool overline() const; + + void setUnderline(bool underline); + bool underline() const; + + void setStrikeOut(bool strikeOut); + bool strikeOut() const; + +private: + friend class QGlyphRunPrivate; + friend class QTextLine; + + QGlyphRun operator+(const QGlyphRun &other) const; + QGlyphRun &operator+=(const QGlyphRun &other); + + void detach(); + QExplicitlySharedDataPointer<QGlyphRunPrivate> d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QT_NO_RAWFONT + +#endif // QGLYPHS_H diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h new file mode 100644 index 0000000..4aa01d6 --- /dev/null +++ b/src/gui/text/qglyphrun_p.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLYPHRUN_P_H +#define QGLYPHRUN_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include "qglyphrun.h" +#include "qrawfont.h" + +#include <qfont.h> + +#if !defined(QT_NO_RAWFONT) + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QGlyphRunPrivate: public QSharedData +{ +public: + QGlyphRunPrivate() + : overline(false) + , underline(false) + , strikeOut(false) + { + } + + QGlyphRunPrivate(const QGlyphRunPrivate &other) + : QSharedData(other) + , glyphIndexes(other.glyphIndexes) + , glyphPositions(other.glyphPositions) + , rawFont(other.rawFont) + , overline(other.overline) + , underline(other.underline) + , strikeOut(other.strikeOut) + { + } + + QVector<quint32> glyphIndexes; + QVector<QPointF> glyphPositions; + QRawFont rawFont; + + uint overline : 1; + uint underline : 1; + uint strikeOut : 1; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QGLYPHS_P_H + +#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphs.cpp deleted file mode 100644 index cfea6ec..0000000 --- a/src/gui/text/qglyphs.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qglobal.h" - -#if !defined(QT_NO_RAWFONT) - -#include "qglyphs.h" -#include "qglyphs_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QGlyphs - \brief The QGlyphs class provides direct access to the internal glyphs in a font. - \since 4.8 - - \ingroup text - \mainclass - - When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points - into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode - representation of the text and the QFont object will in this case serve as a convenient - abstraction that hides the details of what actually takes place when displaying the text - on-screen. For instance, by the time the text actually reaches the screen, it may be represented - by a set of fonts in addition to the one specified by the user, e.g. in case the originally - selected font did not support all the writing systems contained in the text. - - Under certain circumstances, it can be useful as an application developer to have more low-level - control over which glyphs in a specific font are drawn to the screen. This could for instance - be the case in applications that use an external font engine and text shaper together with Qt. - QGlyphs provides an interface to the raw data needed to get text on the screen. It - contains a list of glyph indexes, a position for each glyph and a font. - - It is the user's responsibility to ensure that the selected font actually contains the - provided glyph indexes. - - QTextLayout::glyphs() or QTextFragment::glyphs() can be used to convert unicode encoded text - into a list of QGlyphs objects, and QPainter::drawGlyphs() can be used to draw the glyphs. - - \note Please note that QRawFont is considered local to the thread in which it is constructed. - This in turn means that a new QRawFont will have to be created and set on the QGlyphs if it is - moved to a different thread. If the QGlyphs contains a reference to a QRawFont from a different - thread than the current, it will not be possible to draw the glyphs using a QPainter, as the - QRawFont is considered invalid and inaccessible in this case. -*/ - - -/*! - Constructs an empty QGlyphs object. -*/ -QGlyphs::QGlyphs() : d(new QGlyphsPrivate) -{ -} - -/*! - Constructs a QGlyphs object which is a copy of \a other. -*/ -QGlyphs::QGlyphs(const QGlyphs &other) -{ - d = other.d; -} - -/*! - Destroys the QGlyphs. -*/ -QGlyphs::~QGlyphs() -{ - // Required for QExplicitlySharedDataPointer -} - -/*! - \internal -*/ -void QGlyphs::detach() -{ - if (d->ref != 1) - d.detach(); -} - -/*! - Assigns \a other to this QGlyphs object. -*/ -QGlyphs &QGlyphs::operator=(const QGlyphs &other) -{ - d = other.d; - return *this; -} - -/*! - Compares \a other to this QGlyphs object. Returns true if the list of glyph indexes, - the list of positions and the font are all equal, otherwise returns false. -*/ -bool QGlyphs::operator==(const QGlyphs &other) const -{ - return ((d == other.d) - || (d->glyphIndexes == other.d->glyphIndexes - && d->glyphPositions == other.d->glyphPositions - && d->overline == other.d->overline - && d->underline == other.d->underline - && d->strikeOut == other.d->strikeOut - && d->font == other.d->font)); -} - -/*! - Compares \a other to this QGlyphs object. Returns true if any of the list of glyph - indexes, the list of positions or the font are different, otherwise returns false. -*/ -bool QGlyphs::operator!=(const QGlyphs &other) const -{ - return !(*this == other); -} - -/*! - \internal - - Adds together the lists of glyph indexes and positions in \a other and this QGlyphs - object and returns the result. The font in the returned QGlyphs will be the same as in - this QGlyphs object. -*/ -QGlyphs QGlyphs::operator+(const QGlyphs &other) const -{ - QGlyphs ret(*this); - ret += other; - return ret; -} - -/*! - \internal - - Appends the glyph indexes and positions in \a other to this QGlyphs object and returns - a reference to the current object. -*/ -QGlyphs &QGlyphs::operator+=(const QGlyphs &other) -{ - detach(); - - d->glyphIndexes += other.d->glyphIndexes; - d->glyphPositions += other.d->glyphPositions; - - return *this; -} - -/*! - Returns the font selected for this QGlyphs object. - - \sa setFont() -*/ -QRawFont QGlyphs::font() const -{ - return d->font; -} - -/*! - Sets the font in which to look up the glyph indexes to \a font. - - \sa font(), setGlyphIndexes() -*/ -void QGlyphs::setFont(const QRawFont &font) -{ - detach(); - d->font = font; -} - -/*! - Returns the glyph indexes for this QGlyphs object. - - \sa setGlyphIndexes(), setPositions() -*/ -QVector<quint32> QGlyphs::glyphIndexes() const -{ - return d->glyphIndexes; -} - -/*! - Set the glyph indexes for this QGlyphs object to \a glyphIndexes. The glyph indexes must - be valid for the selected font. -*/ -void QGlyphs::setGlyphIndexes(const QVector<quint32> &glyphIndexes) -{ - detach(); - d->glyphIndexes = glyphIndexes; -} - -/*! - Returns the position of the edge of the baseline for each glyph in this set of glyph indexes. -*/ -QVector<QPointF> QGlyphs::positions() const -{ - return d->glyphPositions; -} - -/*! - Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to - \a positions. -*/ -void QGlyphs::setPositions(const QVector<QPointF> &positions) -{ - detach(); - d->glyphPositions = positions; -} - -/*! - Clears all data in the QGlyphs object. -*/ -void QGlyphs::clear() -{ - detach(); - d->glyphPositions = QVector<QPointF>(); - d->glyphIndexes = QVector<quint32>(); - d->font = QRawFont(); - d->strikeOut = false; - d->overline = false; - d->underline = false; -} - -/*! - Returns true if this QGlyphs should be painted with an overline decoration. - - \sa setOverline() -*/ -bool QGlyphs::overline() const -{ - return d->overline; -} - -/*! - Indicates that this QGlyphs should be painted with an overline decoration if \a overline is true. - Otherwise the QGlyphs should be painted with no overline decoration. - - \sa overline() -*/ -void QGlyphs::setOverline(bool overline) -{ - detach(); - d->overline = overline; -} - -/*! - Returns true if this QGlyphs should be painted with an underline decoration. - - \sa setUnderline() -*/ -bool QGlyphs::underline() const -{ - return d->underline; -} - -/*! - Indicates that this QGlyphs should be painted with an underline decoration if \a underline is - true. Otherwise the QGlyphs should be painted with no underline decoration. - - \sa underline() -*/ -void QGlyphs::setUnderline(bool underline) -{ - detach(); - d->underline = underline; -} - -/*! - Returns true if this QGlyphs should be painted with a strike out decoration. - - \sa setStrikeOut() -*/ -bool QGlyphs::strikeOut() const -{ - return d->strikeOut; -} - -/*! - Indicates that this QGlyphs should be painted with an strike out decoration if \a strikeOut is - true. Otherwise the QGlyphs should be painted with no strike out decoration. - - \sa strikeOut() -*/ -void QGlyphs::setStrikeOut(bool strikeOut) -{ - detach(); - d->strikeOut = strikeOut; -} - -QT_END_NAMESPACE - -#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qglyphs.h b/src/gui/text/qglyphs.h deleted file mode 100644 index 4d7dcaf..0000000 --- a/src/gui/text/qglyphs.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLYPHS_H -#define QGLYPHS_H - -#include <QtCore/qsharedpointer.h> -#include <QtCore/qvector.h> -#include <QtCore/qpoint.h> -#include <QtGui/qrawfont.h> - -#if !defined(QT_NO_RAWFONT) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QGlyphsPrivate; -class Q_GUI_EXPORT QGlyphs -{ -public: - QGlyphs(); - QGlyphs(const QGlyphs &other); - ~QGlyphs(); - - QRawFont font() const; - void setFont(const QRawFont &font); - - QVector<quint32> glyphIndexes() const; - void setGlyphIndexes(const QVector<quint32> &glyphIndexes); - - QVector<QPointF> positions() const; - void setPositions(const QVector<QPointF> &positions); - - void clear(); - - QGlyphs &operator=(const QGlyphs &other); - bool operator==(const QGlyphs &other) const; - bool operator!=(const QGlyphs &other) const; - - void setOverline(bool overline); - bool overline() const; - - void setUnderline(bool underline); - bool underline() const; - - void setStrikeOut(bool strikeOut); - bool strikeOut() const; - -private: - friend class QGlyphsPrivate; - friend class QTextLine; - - QGlyphs operator+(const QGlyphs &other) const; - QGlyphs &operator+=(const QGlyphs &other); - - void detach(); - QExplicitlySharedDataPointer<QGlyphsPrivate> d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QT_NO_RAWFONT - -#endif // QGLYPHS_H diff --git a/src/gui/text/qglyphs_p.h b/src/gui/text/qglyphs_p.h deleted file mode 100644 index 944f777..0000000 --- a/src/gui/text/qglyphs_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QGLYPHS_P_H -#define QGLYPHS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of internal files. This header file may change from version to version -// without notice, or even be removed. -// -// We mean it. -// - -#include "qglyphs.h" -#include "qrawfont.h" - -#include <qfont.h> - -#if !defined(QT_NO_RAWFONT) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGlyphsPrivate: public QSharedData -{ -public: - QGlyphsPrivate() - : overline(false) - , underline(false) - , strikeOut(false) - { - } - - QGlyphsPrivate(const QGlyphsPrivate &other) - : QSharedData(other) - , glyphIndexes(other.glyphIndexes) - , glyphPositions(other.glyphPositions) - , font(other.font) - , overline(other.overline) - , underline(other.underline) - , strikeOut(other.strikeOut) - { - } - - QVector<quint32> glyphIndexes; - QVector<QPointF> glyphPositions; - QRawFont font; - - uint overline : 1; - uint underline : 1; - uint strikeOut : 1; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QGLYPHS_P_H - -#endif // QT_NO_RAWFONT diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 46c892c..4f2a01e 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE A QRawFont object represents a single, physical instance of a given font in a given pixel size. I.e. in the typical case it represents a set of TrueType or OpenType font tables and uses a user specified pixel size to convert metrics into logical pixel units. In can be used in - combination with the QGlyphs class to draw specific glyph indexes at specific positions, and + combination with the QGlyphRun class to draw specific glyph indexes at specific positions, and also have accessors to some relevant data in the physical font. QRawFont only provides support for the main font technologies: GDI and DirectWrite on Windows @@ -87,9 +87,9 @@ QT_BEGIN_NAMESPACE QRawFont can be constructed in a number of ways: \list - \o \l It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The - returned QGlyphs objects will contain QRawFont objects which represent the actual fonts - used to render each portion of the text. + \o \l It can be constructed by calling QTextLayout::glyphRuns() or QTextFragment::glyphRuns(). + The returned QGlyphRun objects will contain QRawFont objects which represent the actual + fonts used to render each portion of the text. \o \l It can be constructed by passing a QFont object to QRawFont::fromFont(). The function will return a QRawFont object representing the font that will be selected as response to the QFont query and the selected writing system. @@ -234,7 +234,7 @@ void QRawFont::loadFromData(const QByteArray &fontData, the pixel in the rasterization of the glyph. Otherwise, the image will be in the format of QImage::Format_A8 and each pixel will contain the opacity of the pixel in the rasterization. - \sa pathForGlyph(), QPainter::drawGlyphs() + \sa pathForGlyph(), QPainter::drawGlyphRun() */ QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType, const QTransform &transform) const @@ -426,9 +426,9 @@ int QRawFont::weight() const underlying font. Note that in cases where there are other tables in the font that affect the shaping of the text, the returned glyph indexes will not correctly represent the rendering of the text. To get the correctly shaped text, you can use QTextLayout to lay out and shape the - text, and then call QTextLayout::glyphs() to get the set of glyph index list and QRawFont pairs. + text, and then call QTextLayout::glyphRuns() to get the set of glyph index list and QRawFont pairs. - \sa advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs() + \sa advancesForGlyphIndexes(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns() */ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const { @@ -587,12 +587,12 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ layout.beginLayout(); QTextLine line = layout.createLine(); layout.endLayout(); - QList<QGlyphs> list = layout.glyphs(); + QList<QGlyphRun> list = layout.glyphRuns(); if (list.size()) { // Pick the one matches the family name we originally requested, // if none of them match, just pick the first one for (int i = 0; i < list.size(); i++) { - QGlyphs glyphs = list.at(i); + QGlyphRun glyphs = list.at(i); QRawFont rawfont = glyphs.font(); if (rawfont.familyName() == font.family()) return rawfont; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 01748b9..1280b46 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -52,8 +52,8 @@ #include "qtextformat_p.h" #include "qstyleoption.h" #include "qpainterpath.h" -#include "qglyphs.h" -#include "qglyphs_p.h" +#include "qglyphrun.h" +#include "qglyphrun_p.h" #include "qrawfont.h" #include "qrawfont_p.h" #include <limits.h> @@ -994,12 +994,12 @@ static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip) \since 4.8 - \sa draw(), QPainter::drawGlyphs() + \sa draw(), QPainter::drawGlyphRun() */ #if !defined(QT_NO_RAWFONT) -QList<QGlyphs> QTextLayout::glyphs() const +QList<QGlyphRun> QTextLayout::glyphRuns() const { - QList<QGlyphs> glyphs; + QList<QGlyphRun> glyphs; for (int i=0; i<d->lines.size(); ++i) glyphs += QTextLine(i, d).glyphs(-1, -1); @@ -2093,15 +2093,15 @@ namespace { \since 4.8 - \sa QTextLayout::glyphs() + \sa QTextLayout::glyphRuns() */ #if !defined(QT_NO_RAWFONT) -QList<QGlyphs> QTextLine::glyphs(int from, int length) const +QList<QGlyphRun> QTextLine::glyphs(int from, int length) const { const QScriptLine &line = eng->lines[i]; if (line.length == 0) - return QList<QGlyphs>(); + return QList<QGlyphRun>(); QHash<QFontEngine *, GlyphInfo> glyphLayoutHash; @@ -2166,7 +2166,7 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const } } - QHash<QPair<QFontEngine *, int>, QGlyphs> glyphsHash; + QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphsHash; QList<QFontEngine *> keys = glyphLayoutHash.uniqueKeys(); for (int i=0; i<keys.size(); ++i) { @@ -2223,14 +2223,14 @@ QList<QGlyphs> QTextLine::glyphs(int from, int length) const positions.append(positionsArray.at(i).toPointF() + pos); } - QGlyphs glyphIndexes; + QGlyphRun glyphIndexes; glyphIndexes.setGlyphIndexes(glyphs); glyphIndexes.setPositions(positions); glyphIndexes.setOverline(flags.testFlag(QTextItem::Overline)); glyphIndexes.setUnderline(flags.testFlag(QTextItem::Underline)); glyphIndexes.setStrikeOut(flags.testFlag(QTextItem::StrikeOut)); - glyphIndexes.setFont(font); + glyphIndexes.setRawFont(font); QPair<QFontEngine *, int> key(fontEngine, int(flags)); if (!glyphsHash.contains(key)) diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 6aa81f9..8fe488a 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -49,7 +49,7 @@ #include <QtCore/qobject.h> #include <QtGui/qevent.h> #include <QtGui/qtextformat.h> -#include <QtGui/qglyphs.h> +#include <QtGui/qglyphrun.h> #include <QtGui/qtextcursor.h> QT_BEGIN_HEADER @@ -174,7 +174,7 @@ public: qreal maximumWidth() const; #if !defined(QT_NO_RAWFONT) - QList<QGlyphs> glyphs() const; + QList<QGlyphRun> glyphRuns() const; #endif QTextEngine *engine() const { return d; } @@ -249,7 +249,7 @@ private: void layout_helper(int numGlyphs); #if !defined(QT_NO_RAWFONT) - QList<QGlyphs> glyphs(int from, int length) const; + QList<QGlyphRun> glyphs(int from, int length) const; #endif friend class QTextLayout; diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 5c1c8b9..8dabcc7 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -1664,25 +1664,25 @@ QTextBlock::iterator &QTextBlock::iterator::operator--() Returns the glyphs of this text fragment. The positions of the glyphs are relative to the position of the QTextBlock's layout. - \sa QGlyphs, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphs() + \sa QGlyphRun, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphRun() */ #if !defined(QT_NO_RAWFONT) -QList<QGlyphs> QTextFragment::glyphs() const +QList<QGlyphRun> QTextFragment::glyphRuns() const { if (!p || !n) - return QList<QGlyphs>(); + return QList<QGlyphRun>(); int pos = position(); int len = length(); if (len == 0) - return QList<QGlyphs>(); + return QList<QGlyphRun>(); int blockNode = p->blockMap().findNode(pos); const QTextBlockData *blockData = p->blockMap().fragment(blockNode); QTextLayout *layout = blockData->layout; - QList<QGlyphs> ret; + QList<QGlyphRun> ret; for (int i=0; i<layout->lineCount(); ++i) { QTextLine textLine = layout->lineAt(i); ret += textLine.glyphs(pos, len); diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index ad8e657..1588349 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -44,7 +44,7 @@ #include <QtCore/qobject.h> #include <QtGui/qtextformat.h> -#include <QtGui/qglyphs.h> +#include <QtGui/qglyphrun.h> QT_BEGIN_HEADER @@ -317,7 +317,7 @@ public: QString text() const; #if !defined(QT_NO_RAWFONT) - QList<QGlyphs> glyphs() const; + QList<QGlyphRun> glyphRuns() const; #endif private: diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index e5d57d0..b6cdc52 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -40,10 +40,10 @@ HEADERS += \ text/qtextodfwriter_p.h \ text/qstatictext_p.h \ text/qstatictext.h \ - text/qglyphs.h \ - text/qglyphs_p.h \ text/qrawfont.h \ - text/qrawfont_p.h + text/qrawfont_p.h \ + text/qglyphrun.h \ + text/qglyphrun_p.h SOURCES += \ text/qfont.cpp \ @@ -74,8 +74,8 @@ SOURCES += \ text/qzip.cpp \ text/qtextodfwriter.cpp \ text/qstatictext.cpp \ - text/qglyphs.cpp \ - text/qrawfont.cpp + text/qrawfont.cpp \ + text/qglyphrun.cpp win32 { SOURCES += \ diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index 22c5e51..42c8fb4 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -58,7 +58,7 @@ SUBDIRS=\ qfontdialog \ qfontmetrics \ qformlayout \ - qglyphs \ + qglyphrun \ qgraphicsanchorlayout \ qgraphicsanchorlayout1 \ qgraphicseffect \ diff --git a/tests/auto/qglyphrun/qglyphrun.pro b/tests/auto/qglyphrun/qglyphrun.pro new file mode 100644 index 0000000..480ad5b --- /dev/null +++ b/tests/auto/qglyphrun/qglyphrun.pro @@ -0,0 +1,11 @@ +load(qttest_p4) +QT = core gui + +SOURCES += \ + tst_qglyphrun.cpp + +wince*|symbian*: { + DEFINES += SRCDIR=\\\"\\\" +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} diff --git a/tests/auto/qglyphrun/test.ttf b/tests/auto/qglyphrun/test.ttf new file mode 100644 index 0000000..9043a57 Binary files /dev/null and b/tests/auto/qglyphrun/test.ttf differ diff --git a/tests/auto/qglyphrun/tst_qglyphrun.cpp b/tests/auto/qglyphrun/tst_qglyphrun.cpp new file mode 100644 index 0000000..aefc228 --- /dev/null +++ b/tests/auto/qglyphrun/tst_qglyphrun.cpp @@ -0,0 +1,582 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <qglyphrun.h> +#include <qpainter.h> +#include <qtextlayout.h> +#include <qfontdatabase.h> + +// #define DEBUG_SAVE_IMAGE + +class tst_QGlyphRun: public QObject +{ + Q_OBJECT + +#if !defined(QT_NO_RAWFONT) +private slots: + void initTestCase(); + void cleanupTestCase(); + + void constructionAndDestruction(); + void copyConstructor(); + void assignment(); + void equalsOperator_data(); + void equalsOperator(); + void textLayoutGlyphIndexes(); + void drawExistingGlyphs(); + void drawNonExistentGlyphs(); + void drawMultiScriptText1(); + void drawMultiScriptText2(); + void drawStruckOutText(); + void drawOverlinedText(); + void drawUnderlinedText(); + void drawRightToLeft(); + void detach(); + +private: + int m_testFontId; + QFont m_testFont; +#endif // QT_NO_RAWFONT + +}; + +#if !defined(QT_NO_RAWFONT) + +Q_DECLARE_METATYPE(QGlyphRun); + +void tst_QGlyphRun::initTestCase() +{ + m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf"); + QVERIFY(m_testFontId >= 0); + + m_testFont = QFont("QtsSpecialTestFont"); + + QCOMPARE(QFontInfo(m_testFont).family(), QString::fromLatin1("QtsSpecialTestFont")); +} + +void tst_QGlyphRun::cleanupTestCase() +{ + QFontDatabase::removeApplicationFont(m_testFontId); +} + +void tst_QGlyphRun::constructionAndDestruction() +{ + QGlyphRun glyphIndexes; +} + +static QGlyphRun make_dummy_indexes() +{ + QGlyphRun glyphs; + + QVector<quint32> glyphIndexes; + QVector<QPointF> positions; + QFont font; + font.setPointSize(18); + + glyphIndexes.append(1); + glyphIndexes.append(2); + glyphIndexes.append(3); + + positions.append(QPointF(1, 2)); + positions.append(QPointF(3, 4)); + positions.append(QPointF(5, 6)); + + glyphs.setRawFont(QRawFont::fromFont(font)); + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(positions); + + return glyphs; +} + +void tst_QGlyphRun::copyConstructor() +{ + QGlyphRun glyphs; + + { + QVector<quint32> glyphIndexes; + QVector<QPointF> positions; + QFont font; + font.setPointSize(18); + + glyphIndexes.append(1); + glyphIndexes.append(2); + glyphIndexes.append(3); + + positions.append(QPointF(1, 2)); + positions.append(QPointF(3, 4)); + positions.append(QPointF(5, 6)); + + glyphs.setRawFont(QRawFont::fromFont(font)); + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(positions); + } + + QGlyphRun otherGlyphs(glyphs); + QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont()); + QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes()); + QCOMPARE(glyphs.positions(), otherGlyphs.positions()); +} + +void tst_QGlyphRun::assignment() +{ + QGlyphRun glyphs(make_dummy_indexes()); + + QGlyphRun otherGlyphs = glyphs; + QCOMPARE(otherGlyphs.rawFont(), glyphs.rawFont()); + QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes()); + QCOMPARE(glyphs.positions(), otherGlyphs.positions()); +} + +void tst_QGlyphRun::equalsOperator_data() +{ + QTest::addColumn<QGlyphRun>("one"); + QTest::addColumn<QGlyphRun>("two"); + QTest::addColumn<bool>("equals"); + + QGlyphRun one(make_dummy_indexes()); + QGlyphRun two(make_dummy_indexes()); + + QTest::newRow("Identical") << one << two << true; + + { + QGlyphRun busted(two); + + QVector<QPointF> positions = busted.positions(); + positions[2] += QPointF(1, 1); + busted.setPositions(positions); + + + QTest::newRow("Different positions") << one << busted << false; + } + + { + QGlyphRun busted(two); + + QFont font; + font.setPixelSize(busted.rawFont().pixelSize() * 2); + busted.setRawFont(QRawFont::fromFont(font)); + + QTest::newRow("Different fonts") << one << busted << false; + } + + { + QGlyphRun busted(two); + + QVector<quint32> glyphIndexes = busted.glyphIndexes(); + glyphIndexes[2] += 1; + busted.setGlyphIndexes(glyphIndexes); + + QTest::newRow("Different glyph indexes") << one << busted << false; + } + +} + +void tst_QGlyphRun::equalsOperator() +{ + QFETCH(QGlyphRun, one); + QFETCH(QGlyphRun, two); + QFETCH(bool, equals); + + QCOMPARE(one == two, equals); + QCOMPARE(one != two, !equals); +} + + +void tst_QGlyphRun::textLayoutGlyphIndexes() +{ + QString s; + s.append(QLatin1Char('A')); + s.append(QChar(0xe000)); + + QTextLayout layout(s); + layout.setFont(m_testFont); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList<QGlyphRun> listOfGlyphs = layout.glyphRuns(); + QCOMPARE(listOfGlyphs.size(), 1); + + QGlyphRun glyphs = listOfGlyphs.at(0); + + QCOMPARE(glyphs.glyphIndexes().size(), 2); + QCOMPARE(glyphs.glyphIndexes().at(0), quint32(2)); + QCOMPARE(glyphs.glyphIndexes().at(1), quint32(1)); +} + +void tst_QGlyphRun::drawExistingGlyphs() +{ + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QString s; + s.append(QLatin1Char('A')); + s.append(QChar(0xe000)); + + QTextLayout layout(s); + layout.setFont(m_testFont); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphRun glyphs = layout.glyphRuns().size() > 0 + ? layout.glyphRuns().at(0) + : QGlyphRun(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawExistingGlyphs_textLayoutDraw.png"); + drawGlyphs.save("drawExistingGlyphs_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + +void tst_QGlyphRun::drawNonExistentGlyphs() +{ + QVector<quint32> glyphIndexes; + glyphIndexes.append(3); + + QVector<QPointF> glyphPositions; + glyphPositions.append(QPointF(0, 0)); + + QGlyphRun glyphs; + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(glyphPositions); + glyphs.setRawFont(QRawFont::fromFont(m_testFont)); + + QPixmap image(1000, 1000); + image.fill(Qt::white); + + QPixmap imageBefore = image; + { + QPainter p(&image); + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + image.save("drawNonExistentGlyphs.png"); +#endif + + QCOMPARE(image, imageBefore); // Should be unchanged +} + +void tst_QGlyphRun::drawMultiScriptText1() +{ + QString text; + text += QChar(0x03D0); // Greek, beta + + QTextLayout textLayout(text); + textLayout.beginLayout(); + textLayout.createLine(); + textLayout.endLayout(); + + QPixmap textLayoutDraw(1000, 1000); + textLayoutDraw.fill(Qt::white); + + QPixmap drawGlyphs(1000, 1000); + drawGlyphs.fill(Qt::white); + + QList<QGlyphRun> glyphsList = textLayout.glyphRuns(); + QCOMPARE(glyphsList.size(), 1); + + { + QPainter p(&textLayoutDraw); + textLayout.draw(&p, QPointF(50, 50)); + } + + { + QPainter p(&drawGlyphs); + foreach (QGlyphRun glyphs, glyphsList) + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawMultiScriptText1_textLayoutDraw.png"); + drawGlyphs.save("drawMultiScriptText1_drawGlyphIndexes.png"); +#endif + + QCOMPARE(drawGlyphs, textLayoutDraw); +} + + +void tst_QGlyphRun::drawMultiScriptText2() +{ + QString text; + text += QChar(0x0621); // Arabic, Hamza + text += QChar(0x03D0); // Greek, beta + + QTextLayout textLayout(text); + textLayout.beginLayout(); + textLayout.createLine(); + textLayout.endLayout(); + + QPixmap textLayoutDraw(1000, 1000); + textLayoutDraw.fill(Qt::white); + + QPixmap drawGlyphs(1000, 1000); + drawGlyphs.fill(Qt::white); + + QList<QGlyphRun> glyphsList = textLayout.glyphRuns(); + QCOMPARE(glyphsList.size(), 2); + + { + QPainter p(&textLayoutDraw); + textLayout.draw(&p, QPointF(50, 50)); + } + + { + QPainter p(&drawGlyphs); + foreach (QGlyphRun glyphs, glyphsList) + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawMultiScriptText2_textLayoutDraw.png"); + drawGlyphs.save("drawMultiScriptText2_drawGlyphIndexes.png"); +#endif + + QCOMPARE(drawGlyphs, textLayoutDraw); +} + +void tst_QGlyphRun::detach() +{ + QGlyphRun glyphs; + + glyphs.setGlyphIndexes(QVector<quint32>() << 1 << 2 << 3); + + QGlyphRun otherGlyphs; + otherGlyphs = glyphs; + + QCOMPARE(otherGlyphs.glyphIndexes(), glyphs.glyphIndexes()); + + otherGlyphs.setGlyphIndexes(QVector<quint32>() << 4 << 5 << 6); + + QCOMPARE(otherGlyphs.glyphIndexes(), QVector<quint32>() << 4 << 5 << 6); + QCOMPARE(glyphs.glyphIndexes(), QVector<quint32>() << 1 << 2 << 3); +} + +void tst_QGlyphRun::drawStruckOutText() +{ + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QString s = QString::fromLatin1("Foobar"); + + QFont font; + font.setStrikeOut(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphRun glyphs = layout.glyphRuns().size() > 0 + ? layout.glyphRuns().at(0) + : QGlyphRun(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawStruckOutText_textLayoutDraw.png"); + drawGlyphs.save("drawStruckOutText_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + +void tst_QGlyphRun::drawOverlinedText() +{ + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QString s = QString::fromLatin1("Foobar"); + + QFont font; + font.setOverline(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphRun glyphs = layout.glyphRuns().size() > 0 + ? layout.glyphRuns().at(0) + : QGlyphRun(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawOverlineText_textLayoutDraw.png"); + drawGlyphs.save("drawOverlineText_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + +void tst_QGlyphRun::drawUnderlinedText() +{ + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QString s = QString::fromLatin1("Foobar"); + + QFont font; + font.setUnderline(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphRun glyphs = layout.glyphRuns().size() > 0 + ? layout.glyphRuns().at(0) + : QGlyphRun(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawUnderlineText_textLayoutDraw.png"); + drawGlyphs.save("drawUnderlineText_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + +void tst_QGlyphRun::drawRightToLeft() +{ + QString s; + s.append(QChar(1575)); + s.append(QChar(1578)); + + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QFont font; + font.setUnderline(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphRun glyphs = layout.glyphRuns().size() > 0 + ? layout.glyphRuns().at(0) + : QGlyphRun(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphRun(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawRightToLeft_textLayoutDraw.png"); + drawGlyphs.save("drawRightToLeft_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); + +} + +#endif // QT_NO_RAWFONT + +QTEST_MAIN(tst_QGlyphRun) +#include "tst_qglyphrun.moc" + diff --git a/tests/auto/qglyphs/qglyphs.pro b/tests/auto/qglyphs/qglyphs.pro deleted file mode 100644 index 5084cf9..0000000 --- a/tests/auto/qglyphs/qglyphs.pro +++ /dev/null @@ -1,11 +0,0 @@ -load(qttest_p4) -QT = core gui - -SOURCES += \ - tst_qglyphs.cpp - -wince*|symbian*: { - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" -} \ No newline at end of file diff --git a/tests/auto/qglyphs/test.ttf b/tests/auto/qglyphs/test.ttf deleted file mode 100644 index 9043a57..0000000 Binary files a/tests/auto/qglyphs/test.ttf and /dev/null differ diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp deleted file mode 100644 index ffa0d00..0000000 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> - -#include <qglyphs.h> -#include <qpainter.h> -#include <qtextlayout.h> -#include <qfontdatabase.h> - -// #define DEBUG_SAVE_IMAGE - -class tst_QGlyphs: public QObject -{ - Q_OBJECT - -#if !defined(QT_NO_RAWFONT) -private slots: - void initTestCase(); - void cleanupTestCase(); - - void constructionAndDestruction(); - void copyConstructor(); - void assignment(); - void equalsOperator_data(); - void equalsOperator(); - void textLayoutGlyphIndexes(); - void drawExistingGlyphs(); - void drawNonExistentGlyphs(); - void drawMultiScriptText1(); - void drawMultiScriptText2(); - void drawStruckOutText(); - void drawOverlinedText(); - void drawUnderlinedText(); - void drawRightToLeft(); - void detach(); - -private: - int m_testFontId; - QFont m_testFont; -#endif // QT_NO_RAWFONT - -}; - -#if !defined(QT_NO_RAWFONT) - -Q_DECLARE_METATYPE(QGlyphs); - -void tst_QGlyphs::initTestCase() -{ - m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf"); - QVERIFY(m_testFontId >= 0); - - m_testFont = QFont("QtsSpecialTestFont"); - - QCOMPARE(QFontInfo(m_testFont).family(), QString::fromLatin1("QtsSpecialTestFont")); -} - -void tst_QGlyphs::cleanupTestCase() -{ - QFontDatabase::removeApplicationFont(m_testFontId); -} - -void tst_QGlyphs::constructionAndDestruction() -{ - QGlyphs glyphIndexes; -} - -static QGlyphs make_dummy_indexes() -{ - QGlyphs glyphs; - - QVector<quint32> glyphIndexes; - QVector<QPointF> positions; - QFont font; - font.setPointSize(18); - - glyphIndexes.append(1); - glyphIndexes.append(2); - glyphIndexes.append(3); - - positions.append(QPointF(1, 2)); - positions.append(QPointF(3, 4)); - positions.append(QPointF(5, 6)); - - glyphs.setFont(QRawFont::fromFont(font)); - glyphs.setGlyphIndexes(glyphIndexes); - glyphs.setPositions(positions); - - return glyphs; -} - -void tst_QGlyphs::copyConstructor() -{ - QGlyphs glyphs; - - { - QVector<quint32> glyphIndexes; - QVector<QPointF> positions; - QFont font; - font.setPointSize(18); - - glyphIndexes.append(1); - glyphIndexes.append(2); - glyphIndexes.append(3); - - positions.append(QPointF(1, 2)); - positions.append(QPointF(3, 4)); - positions.append(QPointF(5, 6)); - - glyphs.setFont(QRawFont::fromFont(font)); - glyphs.setGlyphIndexes(glyphIndexes); - glyphs.setPositions(positions); - } - - QGlyphs otherGlyphs(glyphs); - QCOMPARE(otherGlyphs.font(), glyphs.font()); - QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes()); - QCOMPARE(glyphs.positions(), otherGlyphs.positions()); -} - -void tst_QGlyphs::assignment() -{ - QGlyphs glyphs(make_dummy_indexes()); - - QGlyphs otherGlyphs = glyphs; - QCOMPARE(otherGlyphs.font(), glyphs.font()); - QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes()); - QCOMPARE(glyphs.positions(), otherGlyphs.positions()); -} - -void tst_QGlyphs::equalsOperator_data() -{ - QTest::addColumn<QGlyphs>("one"); - QTest::addColumn<QGlyphs>("two"); - QTest::addColumn<bool>("equals"); - - QGlyphs one(make_dummy_indexes()); - QGlyphs two(make_dummy_indexes()); - - QTest::newRow("Identical") << one << two << true; - - { - QGlyphs busted(two); - - QVector<QPointF> positions = busted.positions(); - positions[2] += QPointF(1, 1); - busted.setPositions(positions); - - - QTest::newRow("Different positions") << one << busted << false; - } - - { - QGlyphs busted(two); - - QFont font; - font.setPixelSize(busted.font().pixelSize() * 2); - busted.setFont(QRawFont::fromFont(font)); - - QTest::newRow("Different fonts") << one << busted << false; - } - - { - QGlyphs busted(two); - - QVector<quint32> glyphIndexes = busted.glyphIndexes(); - glyphIndexes[2] += 1; - busted.setGlyphIndexes(glyphIndexes); - - QTest::newRow("Different glyph indexes") << one << busted << false; - } - -} - -void tst_QGlyphs::equalsOperator() -{ - QFETCH(QGlyphs, one); - QFETCH(QGlyphs, two); - QFETCH(bool, equals); - - QCOMPARE(one == two, equals); - QCOMPARE(one != two, !equals); -} - - -void tst_QGlyphs::textLayoutGlyphIndexes() -{ - QString s; - s.append(QLatin1Char('A')); - s.append(QChar(0xe000)); - - QTextLayout layout(s); - layout.setFont(m_testFont); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - QList<QGlyphs> listOfGlyphs = layout.glyphs(); - QCOMPARE(listOfGlyphs.size(), 1); - - QGlyphs glyphs = listOfGlyphs.at(0); - - QCOMPARE(glyphs.glyphIndexes().size(), 2); - QCOMPARE(glyphs.glyphIndexes().at(0), quint32(2)); - QCOMPARE(glyphs.glyphIndexes().at(1), quint32(1)); -} - -void tst_QGlyphs::drawExistingGlyphs() -{ - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QString s; - s.append(QLatin1Char('A')); - s.append(QChar(0xe000)); - - QTextLayout layout(s); - layout.setFont(m_testFont); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphs glyphs = layout.glyphs().size() > 0 - ? layout.glyphs().at(0) - : QGlyphs(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawExistingGlyphs_textLayoutDraw.png"); - drawGlyphs.save("drawExistingGlyphs_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); -} - -void tst_QGlyphs::drawNonExistentGlyphs() -{ - QVector<quint32> glyphIndexes; - glyphIndexes.append(3); - - QVector<QPointF> glyphPositions; - glyphPositions.append(QPointF(0, 0)); - - QGlyphs glyphs; - glyphs.setGlyphIndexes(glyphIndexes); - glyphs.setPositions(glyphPositions); - glyphs.setFont(QRawFont::fromFont(m_testFont)); - - QPixmap image(1000, 1000); - image.fill(Qt::white); - - QPixmap imageBefore = image; - { - QPainter p(&image); - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - image.save("drawNonExistentGlyphs.png"); -#endif - - QCOMPARE(image, imageBefore); // Should be unchanged -} - -void tst_QGlyphs::drawMultiScriptText1() -{ - QString text; - text += QChar(0x03D0); // Greek, beta - - QTextLayout textLayout(text); - textLayout.beginLayout(); - textLayout.createLine(); - textLayout.endLayout(); - - QPixmap textLayoutDraw(1000, 1000); - textLayoutDraw.fill(Qt::white); - - QPixmap drawGlyphs(1000, 1000); - drawGlyphs.fill(Qt::white); - - QList<QGlyphs> glyphsList = textLayout.glyphs(); - QCOMPARE(glyphsList.size(), 1); - - { - QPainter p(&textLayoutDraw); - textLayout.draw(&p, QPointF(50, 50)); - } - - { - QPainter p(&drawGlyphs); - foreach (QGlyphs glyphs, glyphsList) - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawMultiScriptText1_textLayoutDraw.png"); - drawGlyphs.save("drawMultiScriptText1_drawGlyphIndexes.png"); -#endif - - QCOMPARE(drawGlyphs, textLayoutDraw); -} - - -void tst_QGlyphs::drawMultiScriptText2() -{ - QString text; - text += QChar(0x0621); // Arabic, Hamza - text += QChar(0x03D0); // Greek, beta - - QTextLayout textLayout(text); - textLayout.beginLayout(); - textLayout.createLine(); - textLayout.endLayout(); - - QPixmap textLayoutDraw(1000, 1000); - textLayoutDraw.fill(Qt::white); - - QPixmap drawGlyphs(1000, 1000); - drawGlyphs.fill(Qt::white); - - QList<QGlyphs> glyphsList = textLayout.glyphs(); - QCOMPARE(glyphsList.size(), 2); - - { - QPainter p(&textLayoutDraw); - textLayout.draw(&p, QPointF(50, 50)); - } - - { - QPainter p(&drawGlyphs); - foreach (QGlyphs glyphs, glyphsList) - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawMultiScriptText2_textLayoutDraw.png"); - drawGlyphs.save("drawMultiScriptText2_drawGlyphIndexes.png"); -#endif - - QCOMPARE(drawGlyphs, textLayoutDraw); -} - -void tst_QGlyphs::detach() -{ - QGlyphs glyphs; - - glyphs.setGlyphIndexes(QVector<quint32>() << 1 << 2 << 3); - - QGlyphs otherGlyphs; - otherGlyphs = glyphs; - - QCOMPARE(otherGlyphs.glyphIndexes(), glyphs.glyphIndexes()); - - otherGlyphs.setGlyphIndexes(QVector<quint32>() << 4 << 5 << 6); - - QCOMPARE(otherGlyphs.glyphIndexes(), QVector<quint32>() << 4 << 5 << 6); - QCOMPARE(glyphs.glyphIndexes(), QVector<quint32>() << 1 << 2 << 3); -} - -void tst_QGlyphs::drawStruckOutText() -{ - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setStrikeOut(true); - - QTextLayout layout(s); - layout.setFont(font); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphs glyphs = layout.glyphs().size() > 0 - ? layout.glyphs().at(0) - : QGlyphs(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawStruckOutText_textLayoutDraw.png"); - drawGlyphs.save("drawStruckOutText_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); -} - -void tst_QGlyphs::drawOverlinedText() -{ - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setOverline(true); - - QTextLayout layout(s); - layout.setFont(font); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphs glyphs = layout.glyphs().size() > 0 - ? layout.glyphs().at(0) - : QGlyphs(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawOverlineText_textLayoutDraw.png"); - drawGlyphs.save("drawOverlineText_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); -} - -void tst_QGlyphs::drawUnderlinedText() -{ - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QString s = QString::fromLatin1("Foobar"); - - QFont font; - font.setUnderline(true); - - QTextLayout layout(s); - layout.setFont(font); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphs glyphs = layout.glyphs().size() > 0 - ? layout.glyphs().at(0) - : QGlyphs(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawUnderlineText_textLayoutDraw.png"); - drawGlyphs.save("drawUnderlineText_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); -} - -void tst_QGlyphs::drawRightToLeft() -{ - QString s; - s.append(QChar(1575)); - s.append(QChar(1578)); - - QPixmap textLayoutDraw(1000, 1000); - QPixmap drawGlyphs(1000, 1000); - - textLayoutDraw.fill(Qt::white); - drawGlyphs.fill(Qt::white); - - QFont font; - font.setUnderline(true); - - QTextLayout layout(s); - layout.setFont(font); - layout.beginLayout(); - layout.createLine(); - layout.endLayout(); - - { - QPainter p(&textLayoutDraw); - layout.draw(&p, QPointF(50, 50)); - } - - QGlyphs glyphs = layout.glyphs().size() > 0 - ? layout.glyphs().at(0) - : QGlyphs(); - - { - QPainter p(&drawGlyphs); - p.drawGlyphs(QPointF(50, 50), glyphs); - } - -#if defined(DEBUG_SAVE_IMAGE) - textLayoutDraw.save("drawRightToLeft_textLayoutDraw.png"); - drawGlyphs.save("drawRightToLeft_drawGlyphIndexes.png"); -#endif - - QCOMPARE(textLayoutDraw, drawGlyphs); - -} - -#endif // QT_NO_RAWFONT - -QTEST_MAIN(tst_QGlyphs) -#include "tst_qglyphs.moc" - diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp index ad16a9a..cf46471 100644 --- a/tests/auto/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/qrawfont/tst_qrawfont.cpp @@ -296,12 +296,12 @@ void tst_QRawFont::textLayout() layout.createLine(); layout.endLayout(); - QList<QGlyphs> glyphss = layout.glyphs(); - QCOMPARE(glyphss.size(), 1); + QList<QGlyphRun> glyphRuns = layout.glyphRuns(); + QCOMPARE(glyphRuns.size(), 1); - QGlyphs glyphs = glyphss.at(0); + QGlyphRun glyphs = glyphRuns.at(0); - QRawFont rawFont = glyphs.font(); + QRawFont rawFont = glyphs.rawFont(); QVERIFY(rawFont.isValid()); QCOMPARE(rawFont.familyName(), familyName); QCOMPARE(rawFont.pixelSize(), 18.0); @@ -795,11 +795,11 @@ void tst_QRawFont::unsupportedWritingSystem() layout.createLine(); layout.endLayout(); - QList<QGlyphs> glyphss = layout.glyphs(); - QCOMPARE(glyphss.size(), 1); + QList<QGlyphRun> glyphRuns = layout.glyphRuns(); + QCOMPARE(glyphRuns.size(), 1); - QGlyphs glyphs = glyphss.at(0); - QRawFont layoutFont = glyphs.font(); + QGlyphRun glyphs = glyphRuns.at(0); + QRawFont layoutFont = glyphs.rawFont(); QVERIFY(layoutFont.familyName() != QString::fromLatin1("QtBidiTestFont")); QCOMPARE(layoutFont.pixelSize(), 12.0); -- cgit v0.12 From ae245c770449f3cc8629d9d9836ef9c03486b852 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas <jani.hautakangas@nokia.com> Date: Tue, 10 May 2011 11:08:59 +0300 Subject: Introduce platform extension to QGraphicsSystem Qt on Symbian needs some special capabilities to be able to work on 32MB GPU. This patch introduces some Symbian specific functions to QGraphicsSystem Task-number: QTBUG-17882 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qwidget_p.h | 1 + src/gui/kernel/qwidget_s60.cpp | 4 +- src/gui/painting/painting.pri | 7 +- src/gui/painting/qgraphicssystem.cpp | 16 ++- src/gui/painting/qgraphicssystem_p.h | 3 +- src/gui/painting/qgraphicssystemex_p.h | 66 +++++++++++ src/gui/painting/qgraphicssystemex_symbian.cpp | 87 ++++++++++++++ src/gui/painting/qgraphicssystemex_symbian_p.h | 73 ++++++++++++ src/opengl/qgraphicssystem_gl.cpp | 10 +- src/opengl/qgraphicssystem_gl_p.h | 13 +- .../graphicssystems/openvg/qgraphicssystem_vg.cpp | 8 +- .../graphicssystems/openvg/qgraphicssystem_vg_p.h | 12 +- src/s60installs/bwins/QtCoreu.def | 46 +++++++ src/s60installs/bwins/QtDeclarativeu.def | 9 ++ src/s60installs/bwins/QtGuiu.def | 132 ++++++++++++++++++++- src/s60installs/bwins/QtMultimediau.def | 5 + src/s60installs/bwins/QtNetworku.def | 14 +++ src/s60installs/bwins/QtOpenGLu.def | 4 +- src/s60installs/bwins/QtScriptu.def | 2 + src/s60installs/bwins/QtSqlu.def | 3 + src/s60installs/bwins/QtTestu.def | 90 ++++++++++++++ src/s60installs/bwins/QtXmlPatternsu.def | 3 + src/s60installs/bwins/QtXmlu.def | 7 ++ src/s60installs/bwins/phononu.def | 4 + src/s60installs/eabi/QtCoreu.def | 13 ++ src/s60installs/eabi/QtGuiu.def | 13 +- src/s60installs/eabi/QtOpenGLu.def | 5 +- src/s60installs/eabi/QtTestu.def | 93 +++++++++++++++ 28 files changed, 726 insertions(+), 17 deletions(-) create mode 100644 src/gui/painting/qgraphicssystemex_p.h create mode 100644 src/gui/painting/qgraphicssystemex_symbian.cpp create mode 100644 src/gui/painting/qgraphicssystemex_symbian_p.h diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index c9dba29..7bf65f6 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -227,6 +227,7 @@ struct QTLWExtra { #elif defined(Q_OS_SYMBIAN) uint inExpose : 1; // Prevents drawing recursion uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency + uint forcedToRaster : 1; #endif }; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index a5d8f9f..1dd1477 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -825,7 +825,8 @@ void QWidgetPrivate::s60UpdateIsOpaque() RWindow *const window = static_cast<RWindow *>(q->effectiveWinId()->DrawableWindow()); #ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE - if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces) { + if (QApplicationPrivate::instance()->useTranslucentEGLSurfaces + && !extra->topextra->forcedToRaster) { window->SetSurfaceTransparency(!isOpaque); extra->topextra->nativeWindowTransparencyEnabled = !isOpaque; return; @@ -1009,6 +1010,7 @@ void QWidgetPrivate::createTLSysExtra() { extra->topextra->inExpose = 0; extra->topextra->nativeWindowTransparencyEnabled = 0; + extra->topextra->forcedToRaster = 0; } void QWidgetPrivate::deleteTLSysExtra() diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index bd37d9f..b3b647a 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -9,6 +9,7 @@ HEADERS += \ painting/qdrawutil.h \ painting/qemulationpaintengine_p.h \ painting/qgraphicssystem_p.h \ + painting/qgraphicssystemex_p.h \ painting/qmatrix.h \ painting/qmemrotate_p.h \ painting/qoutlinemapper_p.h \ @@ -235,8 +236,10 @@ embedded { symbian { HEADERS += painting/qwindowsurface_s60_p.h \ - painting/qdrawhelper_arm_simd_p.h - SOURCES += painting/qwindowsurface_s60.cpp + painting/qdrawhelper_arm_simd_p.h \ + painting/qgraphicssystemex_symbian_p.h + SOURCES += painting/qwindowsurface_s60.cpp \ + painting/qgraphicssystemex_symbian.cpp armccIfdefBlock = \ "$${LITERAL_HASH}if defined(ARMV6)" \ "MACRO QT_HAVE_ARM_SIMD" \ diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index 5112019..4b79600 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -52,6 +52,9 @@ #endif #ifdef Q_OS_SYMBIAN # include <private/qpixmap_s60_p.h> +# include <private/qgraphicssystemex_symbian_p.h> +#else +# include <private/qgraphicssystemex_p.h> #endif QT_BEGIN_NAMESPACE @@ -84,9 +87,18 @@ QPixmapData *QGraphicsSystem::createPixmapData(QPixmapData *origin) return createPixmapData(origin->pixelType()); } -void QGraphicsSystem::releaseCachedResources() +#ifdef Q_OS_SYMBIAN +Q_GLOBAL_STATIC(QSymbianGraphicsSystemEx, symbianPlatformExtension) +#endif + +QGraphicsSystemEx* QGraphicsSystem::platformExtension() { - // Do nothing here +#ifdef Q_OS_SYMBIAN + // this is used on raster graphics systems. HW accelerated + // graphics systems will overwrite this function. + return symbianPlatformExtension(); +#endif + return 0; } QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 80e8959..d5acaa4 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE class QPixmapFilter; +class QGraphicsSystemEx; class Q_GUI_EXPORT QGraphicsSystem { @@ -73,7 +74,7 @@ public: // to have a graphics system. static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type); - virtual void releaseCachedResources(); + virtual QGraphicsSystemEx* platformExtension(); }; QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemex_p.h b/src/gui/painting/qgraphicssystemex_p.h new file mode 100644 index 0000000..6feb116 --- /dev/null +++ b/src/gui/painting/qgraphicssystemex_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSSYSTEMEX_P_H +#define QGRAPHICSSYSTEMEX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <qglobal.h> + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QGraphicsSystemEx +{ +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/gui/painting/qgraphicssystemex_symbian.cpp b/src/gui/painting/qgraphicssystemex_symbian.cpp new file mode 100644 index 0000000..54d21ac --- /dev/null +++ b/src/gui/painting/qgraphicssystemex_symbian.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicssystemex_symbian_p.h" +#include "private/qwidget_p.h" +#include "private/qbackingstore_p.h" +#include "private/qapplication_p.h" +#include "qwidget_p.h" + +#include <QDebug> + +QT_BEGIN_NAMESPACE + +void QSymbianGraphicsSystemEx::releaseCachedGpuResources() +{ + // Do nothing here + // This is implemented in graphics system specific plugin +} + +void QSymbianGraphicsSystemEx::releaseAllGpuResources() +{ + releaseCachedGpuResources(); + + foreach (QWidget *widget, QApplication::topLevelWidgets()) { + if (QTLWExtra *topExtra = qt_widget_private(widget)->maybeTopData()) + topExtra->backingStore.destroy(); + } +} + +bool QSymbianGraphicsSystemEx::hasBCM2727() +{ + return !QApplicationPrivate::instance()->useTranslucentEGLSurfaces; +} + +void QSymbianGraphicsSystemEx::forceToRaster(QWidget *window) +{ + if (window && window->isWindow()) { + qt_widget_private(window)->createTLExtra(); + if (QTLWExtra *topExtra = qt_widget_private(window)->maybeTopData()) { + topExtra->forcedToRaster = 1; + if (topExtra->backingStore.data()) { + topExtra->backingStore.create(window); + topExtra->backingStore.registerWidget(window); + } + } + } +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystemex_symbian_p.h b/src/gui/painting/qgraphicssystemex_symbian_p.h new file mode 100644 index 0000000..0b1e39e --- /dev/null +++ b/src/gui/painting/qgraphicssystemex_symbian_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSYMBIANGRAPHICSSYSTEMEX_P_H +#define QSYMBIANGRAPHICSSYSTEMEX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qgraphicssystemex_p.h" + +QT_BEGIN_NAMESPACE + +class QWidget; + +class Q_GUI_EXPORT QSymbianGraphicsSystemEx : public QGraphicsSystemEx +{ +public: + virtual void releaseCachedGpuResources(); + virtual void releaseAllGpuResources(); + virtual bool hasBCM2727(); + virtual void forceToRaster(QWidget *window); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp index 0aa3c2e..5a01d8c 100644 --- a/src/opengl/qgraphicssystem_gl.cpp +++ b/src/opengl/qgraphicssystem_gl.cpp @@ -104,11 +104,17 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const return new QGLWindowSurface(widget); } -#ifdef QGL_USE_TEXTURE_POOL -void QGLGraphicsSystem::releaseCachedResources() +#ifdef Q_OS_SYMBIAN +void QGLGraphicsSystem::releaseCachedGpuResources() { QGLTexturePool::instance()->hibernate(); } + +QGraphicsSystemEx* QGLGraphicsSystem::platformExtension() +{ + return this; +} #endif + QT_END_NAMESPACE diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h index 5829dcc..5372443 100644 --- a/src/opengl/qgraphicssystem_gl_p.h +++ b/src/opengl/qgraphicssystem_gl_p.h @@ -55,11 +55,19 @@ #include "private/qgraphicssystem_p.h" +#ifdef Q_OS_SYMBIAN +#include "private/qgraphicssystemex_symbian_p.h" +#endif + #include <QMap> QT_BEGIN_NAMESPACE class Q_OPENGL_EXPORT QGLGraphicsSystem : public QGraphicsSystem +#ifdef Q_OS_SYMBIAN + , public QSymbianGraphicsSystemEx +#endif + { public: QGLGraphicsSystem(bool useX11GL); @@ -67,8 +75,9 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QWindowSurface *createWindowSurface(QWidget *widget) const; -#ifdef QGL_USE_TEXTURE_POOL - void releaseCachedResources(); +#ifdef Q_OS_SYMBIAN + void releaseCachedGpuResources(); + QGraphicsSystemEx* platformExtension(); #endif private: bool m_useX11GL; diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp index 4b4f677..bf29dd4 100644 --- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp +++ b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp @@ -80,9 +80,15 @@ QWindowSurface *QVGGraphicsSystem::createWindowSurface(QWidget *widget) const return new QVGWindowSurface(widget); } -void QVGGraphicsSystem::releaseCachedResources() +#ifdef Q_OS_SYMBIAN +void QVGGraphicsSystem::releaseCachedGpuResources() { QVGImagePool::instance()->hibernate(); } +QGraphicsSystemEx *QVGGraphicsSystem::platformExtension() +{ + return this; +} +#endif QT_END_NAMESPACE diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h index 9c9b3e2..feff451 100644 --- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h +++ b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h @@ -55,9 +55,16 @@ #include <QtGui/private/qgraphicssystem_p.h> +#ifdef Q_OS_SYMBIAN +#include <QtGui/private/qgraphicssystemex_symbian_p.h> +#endif + QT_BEGIN_NAMESPACE class QVGGraphicsSystem : public QGraphicsSystem +#ifdef Q_OS_SYMBIAN + , public QSymbianGraphicsSystemEx +#endif { public: QVGGraphicsSystem(); @@ -65,7 +72,10 @@ public: QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QWindowSurface *createWindowSurface(QWidget *widget) const; - void releaseCachedResources(); +#ifdef Q_OS_SYMBIAN + void releaseCachedGpuResources(); + QGraphicsSystemEx* platformExtension(); +#endif }; QT_END_NAMESPACE diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index b82f6e5..d1e734d 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4489,4 +4489,50 @@ EXPORTS ?symbianCommandLine@QCoreApplicationPrivate@@SAPAVCApaCommandLine@@XZ @ 4488 NONAME ; class CApaCommandLine * QCoreApplicationPrivate::symbianCommandLine(void) ?revision@QMetaProperty@@QBEHXZ @ 4489 NONAME ; int QMetaProperty::revision(void) const ?revision@QMetaMethod@@QBEHXZ @ 4490 NONAME ; int QMetaMethod::revision(void) const + ??_EQDateTime@@QAE@I@Z @ 4491 NONAME ; QDateTime::~QDateTime(unsigned int) + ??4QDate@@QAEAAV0@ABV0@@Z @ 4492 NONAME ; class QDate & QDate::operator=(class QDate const &) + ??4QSizeF@@QAEAAV0@ABV0@@Z @ 4493 NONAME ; class QSizeF & QSizeF::operator=(class QSizeF const &) + ??0QSize@@QAE@ABV0@@Z @ 4494 NONAME ; QSize::QSize(class QSize const &) + ??0QEvent@@QAE@ABV0@@Z @ 4495 NONAME ; QEvent::QEvent(class QEvent const &) + ??0QTextCodecFactoryInterface@@QAE@XZ @ 4496 NONAME ; QTextCodecFactoryInterface::QTextCodecFactoryInterface(void) + ??0QPointF@@QAE@ABV0@@Z @ 4497 NONAME ; QPointF::QPointF(class QPointF const &) + ??_EQUrl@@QAE@I@Z @ 4498 NONAME ; QUrl::~QUrl(unsigned int) + ??0QGenericArgument@@QAE@ABV0@@Z @ 4499 NONAME ; QGenericArgument::QGenericArgument(class QGenericArgument const &) + ??_EQVariant@@QAE@I@Z @ 4500 NONAME ; QVariant::~QVariant(unsigned int) + ??4QLineF@@QAEAAV0@ABV0@@Z @ 4501 NONAME ; class QLineF & QLineF::operator=(class QLineF const &) + ??0QXmlStreamAttributes@@QAE@ABV0@@Z @ 4502 NONAME ; QXmlStreamAttributes::QXmlStreamAttributes(class QXmlStreamAttributes const &) + ??0QMetaEnum@@QAE@ABV0@@Z @ 4503 NONAME ; QMetaEnum::QMetaEnum(class QMetaEnum const &) + ??4QUuid@@QAEAAU0@ABU0@@Z @ 4504 NONAME ; struct QUuid & QUuid::operator=(struct QUuid const &) + ??0CQtActiveScheduler@@QAE@XZ @ 4505 NONAME ; CQtActiveScheduler::CQtActiveScheduler(void) + ??0QSizeF@@QAE@ABV0@@Z @ 4506 NONAME ; QSizeF::QSizeF(class QSizeF const &) + ??4QMetaEnum@@QAEAAV0@ABV0@@Z @ 4507 NONAME ; class QMetaEnum & QMetaEnum::operator=(class QMetaEnum const &) + ??4QRect@@QAEAAV0@ABV0@@Z @ 4508 NONAME ; class QRect & QRect::operator=(class QRect const &) + ??_EQMutexPool@@QAE@I@Z @ 4509 NONAME ; QMutexPool::~QMutexPool(unsigned int) + ??0QMetaClassInfo@@QAE@ABV0@@Z @ 4510 NONAME ; QMetaClassInfo::QMetaClassInfo(class QMetaClassInfo const &) + ??0QDate@@QAE@ABV0@@Z @ 4511 NONAME ; QDate::QDate(class QDate const &) + ??_EQTextDecoder@@QAE@I@Z @ 4512 NONAME ; QTextDecoder::~QTextDecoder(unsigned int) + ??_EQMutex@@QAE@I@Z @ 4513 NONAME ; QMutex::~QMutex(unsigned int) + ??0QTimerEvent@@QAE@ABV0@@Z @ 4514 NONAME ; QTimerEvent::QTimerEvent(class QTimerEvent const &) + ??0QXmlStreamAttributes@@QAE@XZ @ 4515 NONAME ; QXmlStreamAttributes::QXmlStreamAttributes(void) + ??_EConverterState@QTextCodec@@QAE@I@Z @ 4516 NONAME ; QTextCodec::ConverterState::~ConverterState(unsigned int) + ??4QTime@@QAEAAV0@ABV0@@Z @ 4517 NONAME ; class QTime & QTime::operator=(class QTime const &) + ??0QMetaMethod@@QAE@ABV0@@Z @ 4518 NONAME ; QMetaMethod::QMetaMethod(class QMetaMethod const &) + ??_EQTextEncoder@@QAE@I@Z @ 4519 NONAME ; QTextEncoder::~QTextEncoder(unsigned int) + ??_EQFileInfo@@QAE@I@Z @ 4520 NONAME ; QFileInfo::~QFileInfo(unsigned int) + ??4QRectF@@QAEAAV0@ABV0@@Z @ 4521 NONAME ; class QRectF & QRectF::operator=(class QRectF const &) + ??4QXmlStreamStringRef@@QAEAAV0@ABV0@@Z @ 4522 NONAME ; class QXmlStreamStringRef & QXmlStreamStringRef::operator=(class QXmlStreamStringRef const &) + ??4QBasicAtomicInt@@QAEAAV0@ABV0@@Z @ 4523 NONAME ; class QBasicAtomicInt & QBasicAtomicInt::operator=(class QBasicAtomicInt const &) + ??_EQEasingCurve@@QAE@I@Z @ 4524 NONAME ; QEasingCurve::~QEasingCurve(unsigned int) + ??_EQReadWriteLock@@QAE@I@Z @ 4525 NONAME ; QReadWriteLock::~QReadWriteLock(unsigned int) + ??0QFactoryInterface@@QAE@XZ @ 4526 NONAME ; QFactoryInterface::QFactoryInterface(void) + ??4QLine@@QAEAAV0@ABV0@@Z @ 4527 NONAME ; class QLine & QLine::operator=(class QLine const &) + ??0QMetaProperty@@QAE@ABV0@@Z @ 4528 NONAME ; QMetaProperty::QMetaProperty(class QMetaProperty const &) + ??_EQBitArray@@QAE@I@Z @ 4529 NONAME ; QBitArray::~QBitArray(unsigned int) + ??0QTime@@QAE@ABV0@@Z @ 4530 NONAME ; QTime::QTime(class QTime const &) + ??4QPoint@@QAEAAV0@ABV0@@Z @ 4531 NONAME ; class QPoint & QPoint::operator=(class QPoint const &) + ??4QSize@@QAEAAV0@ABV0@@Z @ 4532 NONAME ; class QSize & QSize::operator=(class QSize const &) + ??0QPoint@@QAE@ABV0@@Z @ 4533 NONAME ; QPoint::QPoint(class QPoint const &) + ??4QPointF@@QAEAAV0@ABV0@@Z @ 4534 NONAME ; class QPointF & QPointF::operator=(class QPointF const &) + ??_EQRegExp@@QAE@I@Z @ 4535 NONAME ; QRegExp::~QRegExp(unsigned int) + ??4QLocalePrivate@@QAEAAU0@ABU0@@Z @ 4536 NONAME ; struct QLocalePrivate & QLocalePrivate::operator=(struct QLocalePrivate const &) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index 5490f0d..b3309ad 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -1893,4 +1893,13 @@ EXPORTS ?setLayoutMirror@QDeclarativeItemPrivate@@QAEX_N@Z @ 1892 NONAME ; void QDeclarativeItemPrivate::setLayoutMirror(bool) ?setImplicitLayoutMirror@QDeclarativeItemPrivate@@QAEX_N0@Z @ 1893 NONAME ; void QDeclarativeItemPrivate::setImplicitLayoutMirror(bool, bool) ?isMirrored@QDeclarativeItemPrivate@@QBE_NXZ @ 1894 NONAME ; bool QDeclarativeItemPrivate::isMirrored(void) const + ??_EQDeclarativeListReference@@QAE@I@Z @ 1895 NONAME ; QDeclarativeListReference::~QDeclarativeListReference(unsigned int) + ??_EVariant@QDeclarativeParser@@QAE@I@Z @ 1896 NONAME ; QDeclarativeParser::Variant::~Variant(unsigned int) + ??_EQDeclarativeProperty@@QAE@I@Z @ 1897 NONAME ; QDeclarativeProperty::~QDeclarativeProperty(unsigned int) + ??_EQDeclarativeError@@QAE@I@Z @ 1898 NONAME ; QDeclarativeError::~QDeclarativeError(unsigned int) + ??_EQDeclarativeCustomParserProperty@@QAE@I@Z @ 1899 NONAME ; QDeclarativeCustomParserProperty::~QDeclarativeCustomParserProperty(unsigned int) + ??0QDeclarativeExtensionInterface@@QAE@XZ @ 1900 NONAME ; QDeclarativeExtensionInterface::QDeclarativeExtensionInterface(void) + ??_EQDeclarativeScriptString@@QAE@I@Z @ 1901 NONAME ; QDeclarativeScriptString::~QDeclarativeScriptString(unsigned int) + ??_EQDeclarativeCustomParserNode@@QAE@I@Z @ 1902 NONAME ; QDeclarativeCustomParserNode::~QDeclarativeCustomParserNode(unsigned int) + ??_EQDeclarativePixmap@@QAE@I@Z @ 1903 NONAME ; QDeclarativePixmap::~QDeclarativePixmap(unsigned int) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 5dcd9f8..b68f59f 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12979,8 +12979,136 @@ EXPORTS ?byteCount@QVolatileImage@@QBEHXZ @ 12978 NONAME ; int QVolatileImage::byteCount(void) const ??0QVolatileImage@@QAE@ABV0@@Z @ 12979 NONAME ; QVolatileImage::QVolatileImage(class QVolatileImage const &) ?depth@QVolatileImage@@QBEHXZ @ 12980 NONAME ; int QVolatileImage::depth(void) const - ?releaseCachedResources@QGraphicsSystem@@UAEXXZ @ 12981 NONAME ; void QGraphicsSystem::releaseCachedResources(void) + ?releaseCachedResources@QGraphicsSystem@@UAEXXZ @ 12981 NONAME ABSENT ; void QGraphicsSystem::releaseCachedResources(void) ?qt_s60_setPartialScreenInputMode@@YAX_N@Z @ 12982 NONAME ; void qt_s60_setPartialScreenInputMode(bool) ?paintingActive@QVolatileImage@@QBE_NXZ @ 12983 NONAME ; bool QVolatileImage::paintingActive(void) const - ?qt_draw_decoration_for_glyphs@@YAXPAVQPainter@@PBIPBUQFixedPoint@@HPAVQFontEngine@@ABVQFont@@ABVQTextCharFormat@@@Z @ 12984 NONAME ; void qt_draw_decoration_for_glyphs(class QPainter *, unsigned int const *, struct QFixedPoint const *, int, class QFontEngine *, class QFont const &, class QTextCharFormat const &) + ??_EQFontPrivate@@QAE@I@Z @ 12984 NONAME ; QFontPrivate::~QFontPrivate(unsigned int) + ??0QMimeSource@@QAE@XZ @ 12985 NONAME ; QMimeSource::QMimeSource(void) + ??0QStyleFactoryInterface@@QAE@XZ @ 12986 NONAME ; QStyleFactoryInterface::QStyleFactoryInterface(void) + ??0QFileOpenEvent@@QAE@ABV0@@Z @ 12987 NONAME ; QFileOpenEvent::QFileOpenEvent(class QFileOpenEvent const &) + ??4QStyleOptionViewItemV2@@QAEAAV0@ABV0@@Z @ 12988 NONAME ; class QStyleOptionViewItemV2 & QStyleOptionViewItemV2::operator=(class QStyleOptionViewItemV2 const &) + ??0QShowEvent@@QAE@ABV0@@Z @ 12989 NONAME ; QShowEvent::QShowEvent(class QShowEvent const &) + ??0QMouseEvent@@QAE@ABV0@@Z @ 12990 NONAME ; QMouseEvent::QMouseEvent(class QMouseEvent const &) + ??0QActionEvent@@QAE@ABV0@@Z @ 12991 NONAME ; QActionEvent::QActionEvent(class QActionEvent const &) + ??0QTouchEvent@@QAE@ABV0@@Z @ 12992 NONAME ; QTouchEvent::QTouchEvent(class QTouchEvent const &) + ??_EQImageData@@QAE@I@Z @ 12993 NONAME ; QImageData::~QImageData(unsigned int) + ??4QBezier@@QAEAAV0@ABV0@@Z @ 12994 NONAME ; class QBezier & QBezier::operator=(class QBezier const &) + ??0QIconEngineV2@@QAE@XZ @ 12995 NONAME ; QIconEngineV2::QIconEngineV2(void) + ??4iterator@QTextBlock@@QAEAAV01@ABV01@@Z @ 12996 NONAME ; class QTextBlock::iterator & QTextBlock::iterator::operator=(class QTextBlock::iterator const &) + ??0QIconEngineV2@@QAE@ABV0@@Z @ 12997 NONAME ; QIconEngineV2::QIconEngineV2(class QIconEngineV2 const &) + ??0QIconEngineFactoryInterfaceV2@@QAE@XZ @ 12998 NONAME ; QIconEngineFactoryInterfaceV2::QIconEngineFactoryInterfaceV2(void) + ??4QTextLine@@QAEAAV0@ABV0@@Z @ 12999 NONAME ; class QTextLine & QTextLine::operator=(class QTextLine const &) + ??0QToolBarChangeEvent@@QAE@ABV0@@Z @ 13000 NONAME ; QToolBarChangeEvent::QToolBarChangeEvent(class QToolBarChangeEvent const &) + ??0QResizeEvent@@QAE@ABV0@@Z @ 13001 NONAME ; QResizeEvent::QResizeEvent(class QResizeEvent const &) + ??0QIconEngineFactoryInterface@@QAE@XZ @ 13002 NONAME ; QIconEngineFactoryInterface::QIconEngineFactoryInterface(void) + ??0QPictureFormatInterface@@QAE@XZ @ 13003 NONAME ; QPictureFormatInterface::QPictureFormatInterface(void) + ??_EQPolygon@@QAE@I@Z @ 13004 NONAME ; QPolygon::~QPolygon(unsigned int) + ??_EQImageReader@@QAE@I@Z @ 13005 NONAME ; QImageReader::~QImageReader(unsigned int) + ??4QStyleOptionGraphicsItem@@QAEAAV0@ABV0@@Z @ 13006 NONAME ; class QStyleOptionGraphicsItem & QStyleOptionGraphicsItem::operator=(class QStyleOptionGraphicsItem const &) + ??4QStyleOptionProgressBarV2@@QAEAAV0@ABV0@@Z @ 13007 NONAME ; class QStyleOptionProgressBarV2 & QStyleOptionProgressBarV2::operator=(class QStyleOptionProgressBarV2 const &) + ??0QDragEnterEvent@@QAE@ABV0@@Z @ 13008 NONAME ; QDragEnterEvent::QDragEnterEvent(class QDragEnterEvent const &) + ??_EKey@QPixmapCache@@QAE@I@Z @ 13009 NONAME ; QPixmapCache::Key::~Key(unsigned int) + ??_EQCursor@@QAE@I@Z @ 13010 NONAME ; QCursor::~QCursor(unsigned int) + ??0QShortcutEvent@@QAE@ABV0@@Z @ 13011 NONAME ; QShortcutEvent::QShortcutEvent(class QShortcutEvent const &) + ??_EQTextCursor@@QAE@I@Z @ 13012 NONAME ; QTextCursor::~QTextCursor(unsigned int) + ??0QGradient@@QAE@ABV0@@Z @ 13013 NONAME ; QGradient::QGradient(class QGradient const &) + ??4QInputMethodEvent@@QAEAAV0@ABV0@@Z @ 13014 NONAME ; class QInputMethodEvent & QInputMethodEvent::operator=(class QInputMethodEvent const &) + ??0QVector2D@@QAE@ABV0@@Z @ 13015 NONAME ; QVector2D::QVector2D(class QVector2D const &) + ??4QStyleOptionFocusRect@@QAEAAV0@ABV0@@Z @ 13016 NONAME ; class QStyleOptionFocusRect & QStyleOptionFocusRect::operator=(class QStyleOptionFocusRect const &) + ??_EQPen@@QAE@I@Z @ 13017 NONAME ; QPen::~QPen(unsigned int) + ??_EQKeySequence@@QAE@I@Z @ 13018 NONAME ; QKeySequence::~QKeySequence(unsigned int) + ??4QGradient@@QAEAAV0@ABV0@@Z @ 13019 NONAME ; class QGradient & QGradient::operator=(class QGradient const &) + ??0QTextTableFormat@@QAE@ABV0@@Z @ 13020 NONAME ; QTextTableFormat::QTextTableFormat(class QTextTableFormat const &) + ??_EQImagePixmapCleanupHooks@@QAE@I@Z @ 13021 NONAME ; QImagePixmapCleanupHooks::~QImagePixmapCleanupHooks(unsigned int) + ??0QStatusTipEvent@@QAE@ABV0@@Z @ 13022 NONAME ; QStatusTipEvent::QStatusTipEvent(class QStatusTipEvent const &) + ??0Value@QCss@@QAE@ABU01@@Z @ 13023 NONAME ; QCss::Value::Value(struct QCss::Value const &) + ??4QSizePolicy@@QAEAAV0@ABV0@@Z @ 13024 NONAME ; class QSizePolicy & QSizePolicy::operator=(class QSizePolicy const &) + ??_ETouchPoint@QTouchEvent@@QAE@I@Z @ 13025 NONAME ; QTouchEvent::TouchPoint::~TouchPoint(unsigned int) + ??4QItemSelection@@QAEAAV0@ABV0@@Z @ 13026 NONAME ; class QItemSelection & QItemSelection::operator=(class QItemSelection const &) + ??4QStyleOptionQ3ListView@@QAEAAV0@ABV0@@Z @ 13027 NONAME ; class QStyleOptionQ3ListView & QStyleOptionQ3ListView::operator=(class QStyleOptionQ3ListView const &) + ??0QSizePolicy@@QAE@ABV0@@Z @ 13028 NONAME ; QSizePolicy::QSizePolicy(class QSizePolicy const &) + ??4QStyleOptionFrameV2@@QAEAAV0@ABV0@@Z @ 13029 NONAME ; class QStyleOptionFrameV2 & QStyleOptionFrameV2::operator=(class QStyleOptionFrameV2 const &) + ??4QVector3D@@QAEAAV0@ABV0@@Z @ 13030 NONAME ; class QVector3D & QVector3D::operator=(class QVector3D const &) + ??4QStyleOptionQ3DockWindow@@QAEAAV0@ABV0@@Z @ 13031 NONAME ; class QStyleOptionQ3DockWindow & QStyleOptionQ3DockWindow::operator=(class QStyleOptionQ3DockWindow const &) + ??_EQFont@@QAE@I@Z @ 13032 NONAME ; QFont::~QFont(unsigned int) + ??4QStyleOptionDockWidget@@QAEAAV0@ABV0@@Z @ 13033 NONAME ; class QStyleOptionDockWidget & QStyleOptionDockWidget::operator=(class QStyleOptionDockWidget const &) + ??0QPainterState@@QAE@ABV0@@Z @ 13034 NONAME ; QPainterState::QPainterState(class QPainterState const &) + ??4QStyleOptionFrame@@QAEAAV0@ABV0@@Z @ 13035 NONAME ; class QStyleOptionFrame & QStyleOptionFrame::operator=(class QStyleOptionFrame const &) + ?qt_draw_decoration_for_glyphs@@YAXPAVQPainter@@PBIPBUQFixedPoint@@HPAVQFontEngine@@ABVQFont@@ABVQTextCharFormat@@@Z @ 13036 NONAME ; void qt_draw_decoration_for_glyphs(class QPainter *, unsigned int const *, struct QFixedPoint const *, int, class QFontEngine *, class QFont const &, class QTextCharFormat const &) + ??4QTextLength@@QAEAAV0@ABV0@@Z @ 13037 NONAME ; class QTextLength & QTextLength::operator=(class QTextLength const &) + ??0QHelpEvent@@QAE@ABV0@@Z @ 13038 NONAME ; QHelpEvent::QHelpEvent(class QHelpEvent const &) + ??0QContextMenuEvent@@QAE@ABV0@@Z @ 13039 NONAME ; QContextMenuEvent::QContextMenuEvent(class QContextMenuEvent const &) + ??0QWhatsThisClickedEvent@@QAE@ABV0@@Z @ 13040 NONAME ; QWhatsThisClickedEvent::QWhatsThisClickedEvent(class QWhatsThisClickedEvent const &) + ??4QStyleOptionTab@@QAEAAV0@ABV0@@Z @ 13041 NONAME ; class QStyleOptionTab & QStyleOptionTab::operator=(class QStyleOptionTab const &) + ??0QTabletEvent@@QAE@ABV0@@Z @ 13042 NONAME ; QTabletEvent::QTabletEvent(class QTabletEvent const &) + ??4QItemSelectionRange@@QAEAAV0@ABV0@@Z @ 13043 NONAME ; class QItemSelectionRange & QItemSelectionRange::operator=(class QItemSelectionRange const &) + ??_EQStyleOptionViewItemV4@@QAE@I@Z @ 13044 NONAME ; QStyleOptionViewItemV4::~QStyleOptionViewItemV4(unsigned int) + ??0QSymbianGraphicsSystemEx@@QAE@XZ @ 13045 NONAME ; QSymbianGraphicsSystemEx::QSymbianGraphicsSystemEx(void) + ??4QEglProperties@@QAEAAV0@ABV0@@Z @ 13046 NONAME ; class QEglProperties & QEglProperties::operator=(class QEglProperties const &) + ??0QHoverEvent@@QAE@ABV0@@Z @ 13047 NONAME ; QHoverEvent::QHoverEvent(class QHoverEvent const &) + ??0QPaintEngineState@@QAE@XZ @ 13048 NONAME ; QPaintEngineState::QPaintEngineState(void) + ??0QKeyEvent@@QAE@ABV0@@Z @ 13049 NONAME ; QKeyEvent::QKeyEvent(class QKeyEvent const &) + ??0QIconEngine@@QAE@ABV0@@Z @ 13050 NONAME ; QIconEngine::QIconEngine(class QIconEngine const &) + ??4QStyleOptionToolBoxV2@@QAEAAV0@ABV0@@Z @ 13051 NONAME ; class QStyleOptionToolBoxV2 & QStyleOptionToolBoxV2::operator=(class QStyleOptionToolBoxV2 const &) + ??0QImageIOHandlerFactoryInterface@@QAE@XZ @ 13052 NONAME ; QImageIOHandlerFactoryInterface::QImageIOHandlerFactoryInterface(void) + ??_EQRegion@@QAE@I@Z @ 13053 NONAME ; QRegion::~QRegion(unsigned int) + ??4QStyleOptionComplex@@QAEAAV0@ABV0@@Z @ 13054 NONAME ; class QStyleOptionComplex & QStyleOptionComplex::operator=(class QStyleOptionComplex const &) + ??_EFileInfo@QZipReader@@QAE@I@Z @ 13055 NONAME ; QZipReader::FileInfo::~FileInfo(unsigned int) + ??0QBitmap@@QAE@ABV0@@Z @ 13056 NONAME ; QBitmap::QBitmap(class QBitmap const &) + ?forceToRaster@QSymbianGraphicsSystemEx@@UAEXPAVQWidget@@@Z @ 13057 NONAME ; void QSymbianGraphicsSystemEx::forceToRaster(class QWidget *) + ?leadingSpaceWidth@QTextEngine@@QAE?AUQFixed@@ABUQScriptLine@@@Z @ 13058 NONAME ; struct QFixed QTextEngine::leadingSpaceWidth(struct QScriptLine const &) + ?releaseCachedGpuResources@QSymbianGraphicsSystemEx@@UAEXXZ @ 13059 NONAME ; void QSymbianGraphicsSystemEx::releaseCachedGpuResources(void) + ??_EQTextFormat@@QAE@I@Z @ 13060 NONAME ; QTextFormat::~QTextFormat(unsigned int) + ??4QStyleOptionTabWidgetFrame@@QAEAAV0@ABV0@@Z @ 13061 NONAME ; class QStyleOptionTabWidgetFrame & QStyleOptionTabWidgetFrame::operator=(class QStyleOptionTabWidgetFrame const &) + ??4QMouseEvent@@QAEAAV0@ABV0@@Z @ 13062 NONAME ; class QMouseEvent & QMouseEvent::operator=(class QMouseEvent const &) + ??_EQPainter@@QAE@I@Z @ 13063 NONAME ; QPainter::~QPainter(unsigned int) + ??4QStyleOptionTabBarBaseV2@@QAEAAV0@ABV0@@Z @ 13064 NONAME ; class QStyleOptionTabBarBaseV2 & QStyleOptionTabBarBaseV2::operator=(class QStyleOptionTabBarBaseV2 const &) + ??4QInputEvent@@QAEAAV0@ABV0@@Z @ 13065 NONAME ; class QInputEvent & QInputEvent::operator=(class QInputEvent const &) + ??_EQPainterPath@@QAE@I@Z @ 13066 NONAME ; QPainterPath::~QPainterPath(unsigned int) + ??4QQuaternion@@QAEAAV0@ABV0@@Z @ 13067 NONAME ; class QQuaternion & QQuaternion::operator=(class QQuaternion const &) + ??4Symbol@QCss@@QAEAAU01@ABU01@@Z @ 13068 NONAME ; struct QCss::Symbol & QCss::Symbol::operator=(struct QCss::Symbol const &) + ??0QIconDragEvent@@QAE@ABV0@@Z @ 13069 NONAME ; QIconDragEvent::QIconDragEvent(class QIconDragEvent const &) + ??0QTextImageFormat@@QAE@ABV0@@Z @ 13070 NONAME ; QTextImageFormat::QTextImageFormat(class QTextImageFormat const &) + ??0QMoveEvent@@QAE@ABV0@@Z @ 13071 NONAME ; QMoveEvent::QMoveEvent(class QMoveEvent const &) + ??0QInputContextFactoryInterface@@QAE@XZ @ 13072 NONAME ; QInputContextFactoryInterface::QInputContextFactoryInterface(void) + ??0QTextFrameFormat@@QAE@ABV0@@Z @ 13073 NONAME ; QTextFrameFormat::QTextFrameFormat(class QTextFrameFormat const &) + ??0Symbol@QCss@@QAE@ABU01@@Z @ 13074 NONAME ; QCss::Symbol::Symbol(struct QCss::Symbol const &) + ??4QStyleOptionFrameV3@@QAEAAV0@ABV0@@Z @ 13075 NONAME ; class QStyleOptionFrameV3 & QStyleOptionFrameV3::operator=(class QStyleOptionFrameV3 const &) + ??0QGraphicsSystem@@QAE@XZ @ 13076 NONAME ; QGraphicsSystem::QGraphicsSystem(void) + ??4QStyleOptionViewItem@@QAEAAV0@ABV0@@Z @ 13077 NONAME ; class QStyleOptionViewItem & QStyleOptionViewItem::operator=(class QStyleOptionViewItem const &) + ??4QStyleOptionProgressBar@@QAEAAV0@ABV0@@Z @ 13078 NONAME ; class QStyleOptionProgressBar & QStyleOptionProgressBar::operator=(class QStyleOptionProgressBar const &) + ??4QStyleOptionRubberBand@@QAEAAV0@ABV0@@Z @ 13079 NONAME ; class QStyleOptionRubberBand & QStyleOptionRubberBand::operator=(class QStyleOptionRubberBand const &) + ??0QDragResponseEvent@@QAE@ABV0@@Z @ 13080 NONAME ; QDragResponseEvent::QDragResponseEvent(class QDragResponseEvent const &) + ??0QIconEngine@@QAE@XZ @ 13081 NONAME ; QIconEngine::QIconEngine(void) + ??_EQBrush@@QAE@I@Z @ 13082 NONAME ; QBrush::~QBrush(unsigned int) + ??_EQTableWidgetSelectionRange@@QAE@I@Z @ 13083 NONAME ; QTableWidgetSelectionRange::~QTableWidgetSelectionRange(unsigned int) + ??4QStyleOptionTabBarBase@@QAEAAV0@ABV0@@Z @ 13084 NONAME ; class QStyleOptionTabBarBase & QStyleOptionTabBarBase::operator=(class QStyleOptionTabBarBase const &) + ??0QTextObjectInterface@@QAE@XZ @ 13085 NONAME ; QTextObjectInterface::QTextObjectInterface(void) + ??0QHideEvent@@QAE@ABV0@@Z @ 13086 NONAME ; QHideEvent::QHideEvent(class QHideEvent const &) + ??0QCloseEvent@@QAE@ABV0@@Z @ 13087 NONAME ; QCloseEvent::QCloseEvent(class QCloseEvent const &) + ??0QTextFrameLayoutData@@QAE@XZ @ 13088 NONAME ; QTextFrameLayoutData::QTextFrameLayoutData(void) + ??4QStyleOptionTabWidgetFrameV2@@QAEAAV0@ABV0@@Z @ 13089 NONAME ; class QStyleOptionTabWidgetFrameV2 & QStyleOptionTabWidgetFrameV2::operator=(class QStyleOptionTabWidgetFrameV2 const &) + ??4QStyleOptionTabV2@@QAEAAV0@ABV0@@Z @ 13090 NONAME ; class QStyleOptionTabV2 & QStyleOptionTabV2::operator=(class QStyleOptionTabV2 const &) + ?platformExtension@QGraphicsSystem@@UAEPAVQGraphicsSystemEx@@XZ @ 13091 NONAME ; class QGraphicsSystemEx * QGraphicsSystem::platformExtension(void) + ??4QTextListFormat@@QAEAAV0@ABV0@@Z @ 13092 NONAME ; class QTextListFormat & QTextListFormat::operator=(class QTextListFormat const &) + ??_EQPalette@@QAE@I@Z @ 13093 NONAME ; QPalette::~QPalette(unsigned int) + ?releaseAllGpuResources@QSymbianGraphicsSystemEx@@UAEXXZ @ 13094 NONAME ; void QSymbianGraphicsSystemEx::releaseAllGpuResources(void) + ??0QFocusEvent@@QAE@ABV0@@Z @ 13095 NONAME ; QFocusEvent::QFocusEvent(class QFocusEvent const &) + ??4QStyleOptionQ3ListViewItem@@QAEAAV0@ABV0@@Z @ 13096 NONAME ; class QStyleOptionQ3ListViewItem & QStyleOptionQ3ListViewItem::operator=(class QStyleOptionQ3ListViewItem const &) + ??_EQIcon@@QAE@I@Z @ 13097 NONAME ; QIcon::~QIcon(unsigned int) + ??0QTextListFormat@@QAE@ABV0@@Z @ 13098 NONAME ; QTextListFormat::QTextListFormat(class QTextListFormat const &) + ??0QGuiPlatformPluginInterface@@QAE@XZ @ 13099 NONAME ; QGuiPlatformPluginInterface::QGuiPlatformPluginInterface(void) + ??_EQTextLayout@@QAE@I@Z @ 13100 NONAME ; QTextLayout::~QTextLayout(unsigned int) + ??0QWheelEvent@@QAE@ABV0@@Z @ 13101 NONAME ; QWheelEvent::QWheelEvent(class QWheelEvent const &) + ??0QWindowStateChangeEvent@@QAE@ABV0@@Z @ 13102 NONAME ; QWindowStateChangeEvent::QWindowStateChangeEvent(class QWindowStateChangeEvent const &) + ??_EQTextEngine@@QAE@I@Z @ 13103 NONAME ; QTextEngine::~QTextEngine(unsigned int) + ??4QStyleOptionTitleBar@@QAEAAV0@ABV0@@Z @ 13104 NONAME ; class QStyleOptionTitleBar & QStyleOptionTitleBar::operator=(class QStyleOptionTitleBar const &) + ??4Value@QCss@@QAEAAU01@ABU01@@Z @ 13105 NONAME ; struct QCss::Value & QCss::Value::operator=(struct QCss::Value const &) + ?hasBCM2727@QSymbianGraphicsSystemEx@@UAE_NXZ @ 13106 NONAME ; bool QSymbianGraphicsSystemEx::hasBCM2727(void) + ??0QDragLeaveEvent@@QAE@ABV0@@Z @ 13107 NONAME ; QDragLeaveEvent::QDragLeaveEvent(class QDragLeaveEvent const &) + ??4QBitmap@@QAEAAV0@ABV0@@Z @ 13108 NONAME ; class QBitmap & QBitmap::operator=(class QBitmap const &) + ??0QItemSelection@@QAE@ABV0@@Z @ 13109 NONAME ; QItemSelection::QItemSelection(class QItemSelection const &) + ??4QTextFrameFormat@@QAEAAV0@ABV0@@Z @ 13110 NONAME ; class QTextFrameFormat & QTextFrameFormat::operator=(class QTextFrameFormat const &) + ?setInstantInvalidatePropagation@QGraphicsLayout@@SAX_N@Z @ 13111 NONAME ; void QGraphicsLayout::setInstantInvalidatePropagation(bool) + ?instantInvalidatePropagation@QGraphicsLayout@@SA_NXZ @ 13112 NONAME ; bool QGraphicsLayout::instantInvalidatePropagation(void) diff --git a/src/s60installs/bwins/QtMultimediau.def b/src/s60installs/bwins/QtMultimediau.def index b8cf6b9..19e6bc7 100644 --- a/src/s60installs/bwins/QtMultimediau.def +++ b/src/s60installs/bwins/QtMultimediau.def @@ -274,4 +274,9 @@ EXPORTS ?sampleRate@QAudioFormat@@QBEHXZ @ 273 NONAME ; int QAudioFormat::sampleRate(void) const ?supportedSampleRates@QAudioDeviceInfo@@QBE?AV?$QList@H@@XZ @ 274 NONAME ; class QList<int> QAudioDeviceInfo::supportedSampleRates(void) const ?setChannelCount@QAudioFormat@@QAEXH@Z @ 275 NONAME ; void QAudioFormat::setChannelCount(int) + ??0QAbstractAudioInput@@QAE@XZ @ 276 NONAME ; QAbstractAudioInput::QAbstractAudioInput(void) + ??0QAudioEngineFactoryInterface@@QAE@XZ @ 277 NONAME ; QAudioEngineFactoryInterface::QAudioEngineFactoryInterface(void) + ??0QAbstractAudioDeviceInfo@@QAE@XZ @ 278 NONAME ; QAbstractAudioDeviceInfo::QAbstractAudioDeviceInfo(void) + ??0QAbstractAudioOutput@@QAE@XZ @ 279 NONAME ; QAbstractAudioOutput::QAbstractAudioOutput(void) + ??_EQAudioDeviceInfo@@QAE@I@Z @ 280 NONAME ; QAudioDeviceInfo::~QAudioDeviceInfo(unsigned int) diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def index 21718d3..c044693 100644 --- a/src/s60installs/bwins/QtNetworku.def +++ b/src/s60installs/bwins/QtNetworku.def @@ -1145,4 +1145,18 @@ EXPORTS ?setNetworkAccessible@QNetworkAccessManager@@QAEXW4NetworkAccessibility@1@@Z @ 1144 NONAME ; void QNetworkAccessManager::setNetworkAccessible(enum QNetworkAccessManager::NetworkAccessibility) ??_EQBearerEngineFactoryInterface@@UAE@I@Z @ 1145 NONAME ; QBearerEngineFactoryInterface::~QBearerEngineFactoryInterface(unsigned int) ?enablePolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1146 NONAME ; void QNetworkConfigurationManagerPrivate::enablePolling(void) + ??_EQSslError@@QAE@I@Z @ 1147 NONAME ; QSslError::~QSslError(unsigned int) + ??0QBearerEngineFactoryInterface@@QAE@XZ @ 1148 NONAME ; QBearerEngineFactoryInterface::QBearerEngineFactoryInterface(void) + ??_EQSslCipher@@QAE@I@Z @ 1149 NONAME ; QSslCipher::~QSslCipher(unsigned int) + ??_EQSslConfiguration@@QAE@I@Z @ 1150 NONAME ; QSslConfiguration::~QSslConfiguration(unsigned int) + ??_EQSslCertificate@@QAE@I@Z @ 1151 NONAME ; QSslCertificate::~QSslCertificate(unsigned int) + ??_EQNetworkInterface@@QAE@I@Z @ 1152 NONAME ; QNetworkInterface::~QNetworkInterface(unsigned int) + ??_EQNetworkProxy@@QAE@I@Z @ 1153 NONAME ; QNetworkProxy::~QNetworkProxy(unsigned int) + ??_EQHostAddress@@QAE@I@Z @ 1154 NONAME ; QHostAddress::~QHostAddress(unsigned int) + ??_EQNetworkConfiguration@@QAE@I@Z @ 1155 NONAME ; QNetworkConfiguration::~QNetworkConfiguration(unsigned int) + ??_EQHostInfo@@QAE@I@Z @ 1156 NONAME ; QHostInfo::~QHostInfo(unsigned int) + ??_EQNetworkRequest@@QAE@I@Z @ 1157 NONAME ; QNetworkRequest::~QNetworkRequest(unsigned int) + ??4QIPv6Address@@QAEAAV0@ABV0@@Z @ 1158 NONAME ; class QIPv6Address & QIPv6Address::operator=(class QIPv6Address const &) + ??_EQNetworkAddressEntry@@QAE@I@Z @ 1159 NONAME ; QNetworkAddressEntry::~QNetworkAddressEntry(unsigned int) + ??_EQNetworkCookie@@QAE@I@Z @ 1160 NONAME ; QNetworkCookie::~QNetworkCookie(unsigned int) diff --git a/src/s60installs/bwins/QtOpenGLu.def b/src/s60installs/bwins/QtOpenGLu.def index d7c8394..75c0d5e 100644 --- a/src/s60installs/bwins/QtOpenGLu.def +++ b/src/s60installs/bwins/QtOpenGLu.def @@ -715,11 +715,13 @@ EXPORTS ?detachTextureFromPool@QGLPixmapData@@QAEXXZ @ 714 NONAME ; void QGLPixmapData::detachTextureFromPool(void) ?reclaimTexture@QGLPixmapData@@QAEXXZ @ 715 NONAME ; void QGLPixmapData::reclaimTexture(void) ?destroyTexture@QGLPixmapData@@QAEXXZ @ 716 NONAME ; void QGLPixmapData::destroyTexture(void) - ?releaseCachedResources@QGLGraphicsSystem@@UAEXXZ @ 717 NONAME ; void QGLGraphicsSystem::releaseCachedResources(void) + ?releaseCachedResources@QGLGraphicsSystem@@UAEXXZ @ 717 NONAME ABSENT ; void QGLGraphicsSystem::releaseCachedResources(void) ?serialNumber@QGLTextureGlyphCache@@QBEHXZ @ 718 NONAME ; int QGLTextureGlyphCache::serialNumber(void) const ?forceToImage@QGLPixmapData@@QAEXXZ @ 719 NONAME ; void QGLPixmapData::forceToImage(void) ?idealFormat@QGLPixmapData@@QAE?AW4Format@QImage@@AAV3@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 720 NONAME ; enum QImage::Format QGLPixmapData::idealFormat(class QImage &, class QFlags<enum Qt::ImageConversionFlag>) ?releaseNativeImageHandle@QGLPixmapData@@QAEXXZ @ 721 NONAME ; void QGLPixmapData::releaseNativeImageHandle(void) ?createFromNativeImageHandleProvider@QGLPixmapData@@QAEXXZ @ 722 NONAME ; void QGLPixmapData::createFromNativeImageHandleProvider(void) ?initFromNativeImageHandle@QGLPixmapData@@QAE_NPAXABVQString@@@Z @ 723 NONAME ; bool QGLPixmapData::initFromNativeImageHandle(void *, class QString const &) + ?platformExtension@QGLGraphicsSystem@@UAEPAVQGraphicsSystemEx@@XZ @ 724 NONAME ; class QGraphicsSystemEx * QGLGraphicsSystem::platformExtension(void) + ?releaseCachedGpuResources@QGLGraphicsSystem@@UAEXXZ @ 725 NONAME ; void QGLGraphicsSystem::releaseCachedGpuResources(void) diff --git a/src/s60installs/bwins/QtScriptu.def b/src/s60installs/bwins/QtScriptu.def index 02a0819..3185819 100644 --- a/src/s60installs/bwins/QtScriptu.def +++ b/src/s60installs/bwins/QtScriptu.def @@ -405,4 +405,6 @@ EXPORTS ?compare@QScriptDeclarativeClass@@UAE_NPAUObject@1@0@Z @ 404 NONAME ; bool QScriptDeclarativeClass::compare(struct QScriptDeclarativeClass::Object *, struct QScriptDeclarativeClass::Object *) ?toString@PersistentIdentifier@QScriptDeclarativeClass@@QBE?AVQString@@XZ @ 405 NONAME ; class QString QScriptDeclarativeClass::PersistentIdentifier::toString(void) const ?startsWithUpper@QScriptDeclarativeClass@@QAE_NABQAX@Z @ 406 NONAME ; bool QScriptDeclarativeClass::startsWithUpper(void * const const &) + ??0QScriptExtensionInterface@@QAE@XZ @ 407 NONAME ; QScriptExtensionInterface::QScriptExtensionInterface(void) + ??_EQScriptValue@@QAE@I@Z @ 408 NONAME ; QScriptValue::~QScriptValue(unsigned int) diff --git a/src/s60installs/bwins/QtSqlu.def b/src/s60installs/bwins/QtSqlu.def index 75fa3d0..8b857c1 100644 --- a/src/s60installs/bwins/QtSqlu.def +++ b/src/s60installs/bwins/QtSqlu.def @@ -458,4 +458,7 @@ EXPORTS ?staticMetaObject@QSqlDriver@@2UQMetaObject@@B @ 457 NONAME ; struct QMetaObject const QSqlDriver::staticMetaObject ?staticMetaObject@QSqlQueryModel@@2UQMetaObject@@B @ 458 NONAME ; struct QMetaObject const QSqlQueryModel::staticMetaObject ?staticMetaObject@QSQLiteDriver@@2UQMetaObject@@B @ 459 NONAME ; struct QMetaObject const QSQLiteDriver::staticMetaObject + ??4QSqlRelation@@QAEAAV0@ABV0@@Z @ 460 NONAME ; class QSqlRelation & QSqlRelation::operator=(class QSqlRelation const &) + ??0QSqlDriverFactoryInterface@@QAE@XZ @ 461 NONAME ; QSqlDriverFactoryInterface::QSqlDriverFactoryInterface(void) + ??0QSqlRelation@@QAE@ABV0@@Z @ 462 NONAME ; QSqlRelation::QSqlRelation(class QSqlRelation const &) diff --git a/src/s60installs/bwins/QtTestu.def b/src/s60installs/bwins/QtTestu.def index a7bb9cd..40ff5e2 100644 --- a/src/s60installs/bwins/QtTestu.def +++ b/src/s60installs/bwins/QtTestu.def @@ -77,4 +77,94 @@ EXPORTS ?staticMetaObject@QTestEventLoop@@2UQMetaObject@@B @ 76 NONAME ; struct QMetaObject const QTestEventLoop::staticMetaObject ?setBenchmarkResult@QTest@@YAXMW4QBenchmarkMetric@1@@Z @ 77 NONAME ; void QTest::setBenchmarkResult(float, enum QTest::QBenchmarkMetric) ?endBenchmarkMeasurement@QTest@@YA_KXZ @ 78 NONAME ; unsigned long long QTest::endBenchmarkMeasurement(void) + ?addBenchmarkResult@QTestLog@@SAXABVQBenchmarkResult@@@Z @ 79 NONAME ; void QTestLog::addBenchmarkResult(class QBenchmarkResult const &) + ?currentTestLocation@QTestResult@@SA?AW4TestLocation@1@XZ @ 80 NONAME ; enum QTestResult::TestLocation QTestResult::currentTestLocation(void) + ?setCurrentTestLocation@QTestResult@@SAXW4TestLocation@1@@Z @ 81 NONAME ; void QTestResult::setCurrentTestLocation(enum QTestResult::TestLocation) + ?testFailed@QTestResult@@SA_NXZ @ 82 NONAME ; bool QTestResult::testFailed(void) + ?setVerboseLevel@QTestLog@@SAXH@Z @ 83 NONAME ; void QTestLog::setVerboseLevel(int) + ?setCurrentTestObject@QTestResult@@SAXPBD@Z @ 84 NONAME ; void QTestResult::setCurrentTestObject(char const *) + ?isEmpty@QTestTable@@QBE_NXZ @ 85 NONAME ; bool QTestTable::isEmpty(void) const + ?reset@QTestResult@@SAXXZ @ 86 NONAME ; void QTestResult::reset(void) + ?info@QTestLog@@SAXPBD0H@Z @ 87 NONAME ; void QTestLog::info(char const *, char const *, int) + ?adjustMedianIterationCount@QBenchmarkGlobalData@@QAEHXZ @ 88 NONAME ; int QBenchmarkGlobalData::adjustMedianIterationCount(void) + ?addColumn@QTestTable@@QAEXHPBD@Z @ 89 NONAME ; void QTestTable::addColumn(int, char const *) + ?setMode@QBenchmarkGlobalData@@QAEXW4Mode@1@@Z @ 90 NONAME ; void QBenchmarkGlobalData::setMode(enum QBenchmarkGlobalData::Mode) + ?addFailure@QTestResult@@SAXPBD0H@Z @ 91 NONAME ; void QTestResult::addFailure(char const *, char const *, int) + ?indexOf@QTestTable@@QBEHPBD@Z @ 92 NONAME ; int QTestTable::indexOf(char const *) const + ?warn@QTestLog@@SAXPBD@Z @ 93 NONAME ; void QTestLog::warn(char const *) + ?currentTestData@QTestResult@@SAPAVQTestData@@XZ @ 94 NONAME ; class QTestData * QTestResult::currentTestData(void) + ?endDataRun@QBenchmarkTestMethodData@@QAEXXZ @ 95 NONAME ; void QBenchmarkTestMethodData::endDataRun(void) + ?globalTestTable@QTestTable@@SAPAV1@XZ @ 96 NONAME ; class QTestTable * QTestTable::globalTestTable(void) + ?elementCount@QTestTable@@QBEHXZ @ 97 NONAME ; int QTestTable::elementCount(void) const + ??0QTestLog@@AAE@XZ @ 98 NONAME ; QTestLog::QTestLog(void) + ?allDataPassed@QTestResult@@SA_NXZ @ 99 NONAME ; bool QTestResult::allDataPassed(void) + ??0QBenchmarkTestMethodData@@QAE@XZ @ 100 NONAME ; QBenchmarkTestMethodData::QBenchmarkTestMethodData(void) + ?qtest_qParseArgs@QTest@@YAXHQAPAD_N@Z @ 101 NONAME ; void QTest::qtest_qParseArgs(int, char * * const, bool) + ?unhandledIgnoreMessages@QTestLog@@SAHXZ @ 102 NONAME ; int QTestLog::unhandledIgnoreMessages(void) + ?setCurrentTestFunction@QTestResult@@SAXPBD@Z @ 103 NONAME ; void QTestResult::setCurrentTestFunction(char const *) + ?enterTestFunction@QTestLog@@SAXPBD@Z @ 104 NONAME ; void QTestLog::enterTestFunction(char const *) + ?testFunctions@QTest@@3VQStringList@@A @ 105 NONAME ; class QStringList QTest::testFunctions + ?addSkip@QTestResult@@SAXPBDW4SkipMode@QTest@@0H@Z @ 106 NONAME ; void QTestResult::addSkip(char const *, enum QTest::SkipMode, char const *, int) + ?currentGlobalDataTag@QTestResult@@SAPBDXZ @ 107 NONAME ; char const * QTestResult::currentGlobalDataTag(void) + ?stopLogging@QTestLog@@SAXXZ @ 108 NONAME ; void QTestLog::stopLogging(void) + ??_EQTestData@@QAE@I@Z @ 109 NONAME ; QTestData::~QTestData(unsigned int) + ??1QTestLog@@AAE@XZ @ 110 NONAME ; QTestLog::~QTestLog(void) + ?skipCount@QTestResult@@SAHXZ @ 111 NONAME ; int QTestResult::skipCount(void) + ?setCurrentGlobalTestData@QTestResult@@SAXPAVQTestData@@@Z @ 112 NONAME ; void QTestResult::setCurrentGlobalTestData(class QTestData *) + ?elementTypeId@QTestTable@@QBEHH@Z @ 113 NONAME ; int QTestTable::elementTypeId(int) const + ?dataTag@QTestTable@@QBEPBDH@Z @ 114 NONAME ; char const * QTestTable::dataTag(int) const + ?dataCount@QTestTable@@QBEHXZ @ 115 NONAME ; int QTestTable::dataCount(void) const + ?printUnhandledIgnoreMessages@QTestLog@@SAXXZ @ 116 NONAME ; void QTestLog::printUnhandledIgnoreMessages(void) + ??1QBenchmarkTestMethodData@@QAE@XZ @ 117 NONAME ; QBenchmarkTestMethodData::~QBenchmarkTestMethodData(void) + ??1QTestTable@@QAE@XZ @ 118 NONAME ; QTestTable::~QTestTable(void) + ?current@QBenchmarkGlobalData@@2PAV1@A @ 119 NONAME ; class QBenchmarkGlobalData * QBenchmarkGlobalData::current + ?setFlushMode@QTestLog@@SAXW4FlushMode@1@@Z @ 120 NONAME ; void QTestLog::setFlushMode(enum QTestLog::FlushMode) + ?ignoreMessage@QTestResult@@SAXW4QtMsgType@@PBD@Z @ 121 NONAME ; void QTestResult::ignoreMessage(enum QtMsgType, char const *) + ?failCount@QTestResult@@SAHXZ @ 122 NONAME ; int QTestResult::failCount(void) + ?mode@QBenchmarkGlobalData@@QBE?AW4Mode@1@XZ @ 123 NONAME ; enum QBenchmarkGlobalData::Mode QBenchmarkGlobalData::mode(void) const + ?addSkip@QTestLog@@SAXPBDW4SkipMode@QTest@@0H@Z @ 124 NONAME ; void QTestLog::addSkip(char const *, enum QTest::SkipMode, char const *, int) + ?outputFileName@QTestLog@@SAPBDXZ @ 125 NONAME ; char const * QTestLog::outputFileName(void) + ?expectFail@QTestResult@@SA_NPBD0W4TestFailMode@QTest@@0H@Z @ 126 NONAME ; bool QTestResult::expectFail(char const *, char const *, enum QTest::TestFailMode, char const *, int) + ?passCount@QTestResult@@SAHXZ @ 127 NONAME ; int QTestResult::passCount(void) + ?logMode@QTestLog@@SA?AW4LogMode@1@XZ @ 128 NONAME ; enum QTestLog::LogMode QTestLog::logMode(void) + ?skipCurrentTest@QTestResult@@SA_NXZ @ 129 NONAME ; bool QTestResult::skipCurrentTest(void) + ?addXPass@QTestLog@@SAXPBD0H@Z @ 130 NONAME ; void QTestLog::addXPass(char const *, char const *, int) + ?testTags@QTest@@3VQStringList@@A @ 131 NONAME ; class QStringList QTest::testTags + ?isBenchmark@QBenchmarkTestMethodData@@QBE_NXZ @ 132 NONAME ; bool QBenchmarkTestMethodData::isBenchmark(void) const + ?adjustIterationCount@QBenchmarkTestMethodData@@QAEHH@Z @ 133 NONAME ; int QBenchmarkTestMethodData::adjustIterationCount(int) + ??1QBenchmarkGlobalData@@QAE@XZ @ 134 NONAME ; QBenchmarkGlobalData::~QBenchmarkGlobalData(void) + ?printAvailableFunctions@QTest@@3_NA @ 135 NONAME ; bool QTest::printAvailableFunctions + ?testData@QTestTable@@QBEPAVQTestData@@H@Z @ 136 NONAME ; class QTestData * QTestTable::testData(int) const + ?setCurrentTestData@QTestResult@@SAXPAVQTestData@@@Z @ 137 NONAME ; void QTestResult::setCurrentTestData(class QTestData *) + ?compare@QTestResult@@SA_N_NPBD1H@Z @ 138 NONAME ; bool QTestResult::compare(bool, char const *, char const *, int) + ?currentTestFailed@QTestResult@@SA_NXZ @ 139 NONAME ; bool QTestResult::currentTestFailed(void) + ?compare@QTestResult@@SA_N_NPBDPAD2111H@Z @ 140 NONAME ; bool QTestResult::compare(bool, char const *, char *, char *, char const *, char const *, char const *, int) + ?addXFail@QTestLog@@SAXPBD0H@Z @ 141 NONAME ; void QTestLog::addXFail(char const *, char const *, int) + ??_EQTestTable@@QAE@I@Z @ 142 NONAME ; QTestTable::~QTestTable(unsigned int) + ??0QBenchmarkGlobalData@@QAE@XZ @ 143 NONAME ; QBenchmarkGlobalData::QBenchmarkGlobalData(void) + ?beginDataRun@QBenchmarkTestMethodData@@QAEXXZ @ 144 NONAME ; void QBenchmarkTestMethodData::beginDataRun(void) + ?resultsAccepted@QBenchmarkTestMethodData@@QBE_NXZ @ 145 NONAME ; bool QBenchmarkTestMethodData::resultsAccepted(void) const + ?addIgnoreMessage@QTestLog@@SAXW4QtMsgType@@PBD@Z @ 146 NONAME ; void QTestLog::addIgnoreMessage(enum QtMsgType, char const *) + ?startLogging@QTestLog@@SAXXZ @ 147 NONAME ; void QTestLog::startLogging(void) + ?currentDataTag@QTestResult@@SAPBDXZ @ 148 NONAME ; char const * QTestResult::currentDataTag(void) + ?redirectOutput@QTestLog@@SAXPBD@Z @ 149 NONAME ; void QTestLog::redirectOutput(char const *) + ?currentTestObjectName@QTestResult@@SAPBDXZ @ 150 NONAME ; char const * QTestResult::currentTestObjectName(void) + ?newData@QTestTable@@QAEPAVQTestData@@PBD@Z @ 151 NONAME ; class QTestData * QTestTable::newData(char const *) + ?addPass@QTestLog@@SAXPBD@Z @ 152 NONAME ; void QTestLog::addPass(char const *) + ?verboseLevel@QTestLog@@SAHXZ @ 153 NONAME ; int QTestLog::verboseLevel(void) + ?createMeasurer@QBenchmarkGlobalData@@QAEPAVQBenchmarkMeasurerBase@@XZ @ 154 NONAME ; class QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer(void) + ?currentGlobalTestData@QTestResult@@SAPAVQTestData@@XZ @ 155 NONAME ; class QTestData * QTestResult::currentGlobalTestData(void) + ?setSkipCurrentTest@QTestResult@@SAX_N@Z @ 156 NONAME ; void QTestResult::setSkipCurrentTest(bool) + ?setResult@QBenchmarkTestMethodData@@QAEXMW4QBenchmarkMetric@QTest@@_N@Z @ 157 NONAME ; void QBenchmarkTestMethodData::setResult(float, enum QTest::QBenchmarkMetric, bool) + ?verify@QTestResult@@SA_N_NPBD11H@Z @ 158 NONAME ; bool QTestResult::verify(bool, char const *, char const *, char const *, int) + ?leaveTestFunction@QTestLog@@SAXXZ @ 159 NONAME ; void QTestLog::leaveTestFunction(void) + ?finishedCurrentTestFunction@QTestResult@@SAXXZ @ 160 NONAME ; void QTestResult::finishedCurrentTestFunction(void) + ?currentTestTable@QTestTable@@SAPAV1@XZ @ 161 NONAME ; class QTestTable * QTestTable::currentTestTable(void) + ?currentTestFunction@QTestResult@@SAPBDXZ @ 162 NONAME ; char const * QTestResult::currentTestFunction(void) + ?setLogMode@QTestLog@@SAXW4LogMode@1@@Z @ 163 NONAME ; void QTestLog::setLogMode(enum QTestLog::LogMode) + ?clearGlobalTestTable@QTestTable@@SAXXZ @ 164 NONAME ; void QTestTable::clearGlobalTestTable(void) + ?addFail@QTestLog@@SAXPBD0H@Z @ 165 NONAME ; void QTestLog::addFail(char const *, char const *, int) + ??0QTestTable@@QAE@XZ @ 166 NONAME ; QTestTable::QTestTable(void) + ?setMaxWarnings@QTestLog@@SAXH@Z @ 167 NONAME ; void QTestLog::setMaxWarnings(int) + ?current@QBenchmarkTestMethodData@@2PAV1@A @ 168 NONAME ; class QBenchmarkTestMethodData * QBenchmarkTestMethodData::current diff --git a/src/s60installs/bwins/QtXmlPatternsu.def b/src/s60installs/bwins/QtXmlPatternsu.def index 57a75d4..5a458b3 100644 --- a/src/s60installs/bwins/QtXmlPatternsu.def +++ b/src/s60installs/bwins/QtXmlPatternsu.def @@ -277,4 +277,7 @@ EXPORTS ?writeEscapedAttribute@QXmlSerializer@@AAEXABVQString@@@Z @ 276 NONAME ; void QXmlSerializer::writeEscapedAttribute(class QString const &) ?staticMetaObject@QAbstractMessageHandler@@2UQMetaObject@@B @ 277 NONAME ; struct QMetaObject const QAbstractMessageHandler::staticMetaObject ?staticMetaObject@QAbstractUriResolver@@2UQMetaObject@@B @ 278 NONAME ; struct QMetaObject const QAbstractUriResolver::staticMetaObject + ??_EQXmlQuery@@QAE@I@Z @ 279 NONAME ; QXmlQuery::~QXmlQuery(unsigned int) + ??4QXmlNodeModelIndex@@QAEAAV0@ABV0@@Z @ 280 NONAME ; class QXmlNodeModelIndex & QXmlNodeModelIndex::operator=(class QXmlNodeModelIndex const &) + ??_EQXmlItem@@QAE@I@Z @ 281 NONAME ; QXmlItem::~QXmlItem(unsigned int) diff --git a/src/s60installs/bwins/QtXmlu.def b/src/s60installs/bwins/QtXmlu.def index 744a744..f54e317 100644 --- a/src/s60installs/bwins/QtXmlu.def +++ b/src/s60installs/bwins/QtXmlu.def @@ -400,4 +400,11 @@ EXPORTS ?warning@QXmlDefaultHandler@@UAE_NABVQXmlParseException@@@Z @ 399 NONAME ; bool QXmlDefaultHandler::warning(class QXmlParseException const &) ?EndOfDocument@QXmlInputSource@@2GB @ 400 NONAME ; unsigned short const QXmlInputSource::EndOfDocument ?EndOfData@QXmlInputSource@@2GB @ 401 NONAME ; unsigned short const QXmlInputSource::EndOfData + ??0QXmlContentHandler@@QAE@XZ @ 402 NONAME ; QXmlContentHandler::QXmlContentHandler(void) + ??0QXmlDTDHandler@@QAE@XZ @ 403 NONAME ; QXmlDTDHandler::QXmlDTDHandler(void) + ??0QXmlReader@@QAE@XZ @ 404 NONAME ; QXmlReader::QXmlReader(void) + ??0QXmlLexicalHandler@@QAE@XZ @ 405 NONAME ; QXmlLexicalHandler::QXmlLexicalHandler(void) + ??0QXmlDeclHandler@@QAE@XZ @ 406 NONAME ; QXmlDeclHandler::QXmlDeclHandler(void) + ??0QXmlEntityResolver@@QAE@XZ @ 407 NONAME ; QXmlEntityResolver::QXmlEntityResolver(void) + ??0QXmlErrorHandler@@QAE@XZ @ 408 NONAME ; QXmlErrorHandler::QXmlErrorHandler(void) diff --git a/src/s60installs/bwins/phononu.def b/src/s60installs/bwins/phononu.def index fe80e12..15f83b1 100644 --- a/src/s60installs/bwins/phononu.def +++ b/src/s60installs/bwins/phononu.def @@ -570,4 +570,8 @@ EXPORTS ?setOutputDevice@PulseSupport@Phonon@@QAE_NVQString@@H@Z @ 569 NONAME ; bool Phonon::PulseSupport::setOutputDevice(class QString, int) ?qt_metacast@AudioDataOutput@Phonon@@UAEPAXPBD@Z @ 570 NONAME ; void * Phonon::AudioDataOutput::qt_metacast(char const *) ?clearStreamCache@PulseSupport@Phonon@@QAEXVQString@@@Z @ 571 NONAME ; void Phonon::PulseSupport::clearStreamCache(class QString) + ??_EEffectParameter@Phonon@@QAE@I@Z @ 572 NONAME ; Phonon::EffectParameter::~EffectParameter(unsigned int) + ??_EPath@Phonon@@QAE@I@Z @ 573 NONAME ; Phonon::Path::~Path(unsigned int) + ??_EMediaSource@Phonon@@QAE@I@Z @ 574 NONAME ; Phonon::MediaSource::~MediaSource(unsigned int) + ??_EObjectDescriptionData@Phonon@@QAE@I@Z @ 575 NONAME ; Phonon::ObjectDescriptionData::~ObjectDescriptionData(unsigned int) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index fce55dd..f92cb5a 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3717,4 +3717,17 @@ EXPORTS _ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3716 NONAME _ZNK11QMetaMethod8revisionEv @ 3717 NONAME _ZNK13QMetaProperty8revisionEv @ 3718 NONAME + _ZN5RHeap10Extension_EjRPvS0_ @ 3719 NONAME + _ZN5RHeap13DebugFunctionEiPvS0_ @ 3720 NONAME + _ZN5RHeap4FreeEPv @ 3721 NONAME + _ZN5RHeap5AllocEi @ 3722 NONAME + _ZN5RHeap5ResetEv @ 3723 NONAME + _ZN5RHeap7ReAllocEPvii @ 3724 NONAME + _ZN5RHeap8CompressEv @ 3725 NONAME + _ZN8UserHeap15OffsetChunkHeapE6RChunkiiiiiim @ 3726 NONAME + _ZN8UserHeap16CreateThreadHeapER24SStdEpocThreadCreateInfoRP5RHeapii @ 3727 NONAME + _ZN8UserHeap9ChunkHeapE6RChunkiiiiim @ 3728 NONAME + _ZNK5RHeap8AllocLenEPKv @ 3729 NONAME + _ZNK5RHeap9AllocSizeERi @ 3730 NONAME + _ZNK5RHeap9AvailableERi @ 3731 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 318b394..d0c789f 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12180,8 +12180,19 @@ EXPORTS _ZNK14QVolatileImage7toImageEv @ 12179 NONAME _ZNK14QVolatileImage9byteCountEv @ 12180 NONAME _ZNK14QVolatileImage9constBitsEv @ 12181 NONAME - _ZN15QGraphicsSystem22releaseCachedResourcesEv @ 12182 NONAME + _ZN15QGraphicsSystem22releaseCachedResourcesEv @ 12182 NONAME ABSENT _Z32qt_s60_setPartialScreenInputModeb @ 12183 NONAME _Z29qt_draw_decoration_for_glyphsP8QPainterPKjPK11QFixedPointiP11QFontEngineRK5QFontRK15QTextCharFormat @ 12184 NONAME _ZNK14QVolatileImage14paintingActiveEv @ 12185 NONAME + _ZN11QTextEngine17leadingSpaceWidthERK11QScriptLine @ 12186 NONAME + _ZN15QGraphicsLayout28instantInvalidatePropagationEv @ 12187 NONAME + _ZN15QGraphicsLayout31setInstantInvalidatePropagationEb @ 12188 NONAME + _ZN15QGraphicsSystem17platformExtensionEv @ 12189 NONAME + _ZN24QSymbianGraphicsSystemEx10hasBCM2727Ev @ 12190 NONAME + _ZN24QSymbianGraphicsSystemEx13forceToRasterEP7QWidget @ 12191 NONAME + _ZN24QSymbianGraphicsSystemEx22releaseAllGpuResourcesEv @ 12192 NONAME + _ZN24QSymbianGraphicsSystemEx25releaseCachedGpuResourcesEv @ 12193 NONAME + _ZTI17QGraphicsSystemEx @ 12194 NONAME + _ZTI24QSymbianGraphicsSystemEx @ 12195 NONAME + _ZTV24QSymbianGraphicsSystemEx @ 12196 NONAME diff --git a/src/s60installs/eabi/QtOpenGLu.def b/src/s60installs/eabi/QtOpenGLu.def index 488c6cd..5a8c0ee 100644 --- a/src/s60installs/eabi/QtOpenGLu.def +++ b/src/s60installs/eabi/QtOpenGLu.def @@ -719,9 +719,12 @@ EXPORTS _ZN13QGLPixmapData14reclaimTextureEv @ 718 NONAME _ZN13QGLPixmapData21detachTextureFromPoolEv @ 719 NONAME _ZN13QGLPixmapData9hibernateEv @ 720 NONAME - _ZN17QGLGraphicsSystem22releaseCachedResourcesEv @ 721 NONAME + _ZN17QGLGraphicsSystem22releaseCachedResourcesEv @ 721 NONAME ABSENT _ZN13QGLPixmapData11idealFormatER6QImage6QFlagsIN2Qt19ImageConversionFlagEE @ 722 NONAME _ZN13QGLPixmapData24releaseNativeImageHandleEv @ 723 NONAME _ZN13QGLPixmapData25initFromNativeImageHandleEPvRK7QString @ 724 NONAME _ZN13QGLPixmapData35createFromNativeImageHandleProviderEv @ 725 NONAME + _ZN17QGLGraphicsSystem17platformExtensionEv @ 726 NONAME + _ZN17QGLGraphicsSystem25releaseCachedGpuResourcesEv @ 727 NONAME + _ZThn4_N17QGLGraphicsSystem25releaseCachedGpuResourcesEv @ 728 NONAME diff --git a/src/s60installs/eabi/QtTestu.def b/src/s60installs/eabi/QtTestu.def index 5cb95ba..3b8c297 100644 --- a/src/s60installs/eabi/QtTestu.def +++ b/src/s60installs/eabi/QtTestu.def @@ -70,4 +70,97 @@ EXPORTS _ZTI14QTestEventLoop @ 69 NONAME _ZTV14QTestEventLoop @ 70 NONAME _ZN5QTest18setBenchmarkResultEfNS_16QBenchmarkMetricE @ 71 NONAME + _ZN10QTestTable15globalTestTableEv @ 72 NONAME + _ZN10QTestTable16currentTestTableEv @ 73 NONAME + _ZN10QTestTable20clearGlobalTestTableEv @ 74 NONAME + _ZN10QTestTable7newDataEPKc @ 75 NONAME + _ZN10QTestTable9addColumnEiPKc @ 76 NONAME + _ZN10QTestTableC1Ev @ 77 NONAME + _ZN10QTestTableC2Ev @ 78 NONAME + _ZN10QTestTableD1Ev @ 79 NONAME + _ZN10QTestTableD2Ev @ 80 NONAME + _ZN11QTestResult10addFailureEPKcS1_i @ 81 NONAME + _ZN11QTestResult10expectFailEPKcS1_N5QTest12TestFailModeES1_i @ 82 NONAME + _ZN11QTestResult10testFailedEv @ 83 NONAME + _ZN11QTestResult13allDataPassedEv @ 84 NONAME + _ZN11QTestResult13ignoreMessageE9QtMsgTypePKc @ 85 NONAME + _ZN11QTestResult14currentDataTagEv @ 86 NONAME + _ZN11QTestResult15currentTestDataEv @ 87 NONAME + _ZN11QTestResult15skipCurrentTestEv @ 88 NONAME + _ZN11QTestResult17currentTestFailedEv @ 89 NONAME + _ZN11QTestResult18setCurrentTestDataEP9QTestData @ 90 NONAME + _ZN11QTestResult18setSkipCurrentTestEb @ 91 NONAME + _ZN11QTestResult19currentTestFunctionEv @ 92 NONAME + _ZN11QTestResult19currentTestLocationEv @ 93 NONAME + _ZN11QTestResult20currentGlobalDataTagEv @ 94 NONAME + _ZN11QTestResult20setCurrentTestObjectEPKc @ 95 NONAME + _ZN11QTestResult21currentGlobalTestDataEv @ 96 NONAME + _ZN11QTestResult21currentTestObjectNameEv @ 97 NONAME + _ZN11QTestResult22setCurrentTestFunctionEPKc @ 98 NONAME + _ZN11QTestResult22setCurrentTestLocationENS_12TestLocationE @ 99 NONAME + _ZN11QTestResult24setCurrentGlobalTestDataEP9QTestData @ 100 NONAME + _ZN11QTestResult27finishedCurrentTestFunctionEv @ 101 NONAME + _ZN11QTestResult5resetEv @ 102 NONAME + _ZN11QTestResult6verifyEbPKcS1_S1_i @ 103 NONAME + _ZN11QTestResult7addSkipEPKcN5QTest8SkipModeES1_i @ 104 NONAME + _ZN11QTestResult7compareEbPKcPcS2_S1_S1_S1_i @ 105 NONAME + _ZN11QTestResult7compareEbPKcS1_i @ 106 NONAME + _ZN11QTestResult9failCountEv @ 107 NONAME + _ZN11QTestResult9passCountEv @ 108 NONAME + _ZN11QTestResult9skipCountEv @ 109 NONAME + _ZN20QBenchmarkGlobalData14createMeasurerEv @ 110 NONAME + _ZN20QBenchmarkGlobalData26adjustMedianIterationCountEv @ 111 NONAME + _ZN20QBenchmarkGlobalData7currentE @ 112 NONAME DATA 4 + _ZN20QBenchmarkGlobalData7setModeENS_4ModeE @ 113 NONAME + _ZN20QBenchmarkGlobalDataC1Ev @ 114 NONAME + _ZN20QBenchmarkGlobalDataC2Ev @ 115 NONAME + _ZN20QBenchmarkGlobalDataD1Ev @ 116 NONAME + _ZN20QBenchmarkGlobalDataD2Ev @ 117 NONAME + _ZN24QBenchmarkTestMethodData10endDataRunEv @ 118 NONAME + _ZN24QBenchmarkTestMethodData12beginDataRunEv @ 119 NONAME + _ZN24QBenchmarkTestMethodData20adjustIterationCountEi @ 120 NONAME + _ZN24QBenchmarkTestMethodData7currentE @ 121 NONAME DATA 4 + _ZN24QBenchmarkTestMethodData9setResultEfN5QTest16QBenchmarkMetricEb @ 122 NONAME + _ZN24QBenchmarkTestMethodDataC1Ev @ 123 NONAME + _ZN24QBenchmarkTestMethodDataC2Ev @ 124 NONAME + _ZN24QBenchmarkTestMethodDataD1Ev @ 125 NONAME + _ZN24QBenchmarkTestMethodDataD2Ev @ 126 NONAME + _ZN5QTest13testFunctionsE @ 127 NONAME DATA 4 + _ZN5QTest16qtest_qParseArgsEiPPcb @ 128 NONAME + _ZN5QTest23printAvailableFunctionsE @ 129 NONAME DATA 1 + _ZN5QTest8testTagsE @ 130 NONAME DATA 4 + _ZN8QTestLog10setLogModeENS_7LogModeE @ 131 NONAME + _ZN8QTestLog11stopLoggingEv @ 132 NONAME + _ZN8QTestLog12setFlushModeENS_9FlushModeE @ 133 NONAME + _ZN8QTestLog12startLoggingEv @ 134 NONAME + _ZN8QTestLog12verboseLevelEv @ 135 NONAME + _ZN8QTestLog14outputFileNameEv @ 136 NONAME + _ZN8QTestLog14redirectOutputEPKc @ 137 NONAME + _ZN8QTestLog14setMaxWarningsEi @ 138 NONAME + _ZN8QTestLog15setVerboseLevelEi @ 139 NONAME + _ZN8QTestLog16addIgnoreMessageE9QtMsgTypePKc @ 140 NONAME + _ZN8QTestLog17enterTestFunctionEPKc @ 141 NONAME + _ZN8QTestLog17leaveTestFunctionEv @ 142 NONAME + _ZN8QTestLog18addBenchmarkResultERK16QBenchmarkResult @ 143 NONAME + _ZN8QTestLog23unhandledIgnoreMessagesEv @ 144 NONAME + _ZN8QTestLog28printUnhandledIgnoreMessagesEv @ 145 NONAME + _ZN8QTestLog4infoEPKcS1_i @ 146 NONAME + _ZN8QTestLog4warnEPKc @ 147 NONAME + _ZN8QTestLog7addFailEPKcS1_i @ 148 NONAME + _ZN8QTestLog7addPassEPKc @ 149 NONAME + _ZN8QTestLog7addSkipEPKcN5QTest8SkipModeES1_i @ 150 NONAME + _ZN8QTestLog7logModeEv @ 151 NONAME + _ZN8QTestLog8addXFailEPKcS1_i @ 152 NONAME + _ZN8QTestLog8addXPassEPKcS1_i @ 153 NONAME + _ZN8QTestLogC1Ev @ 154 NONAME + _ZN8QTestLogC2Ev @ 155 NONAME + _ZN8QTestLogD1Ev @ 156 NONAME + _ZN8QTestLogD2Ev @ 157 NONAME + _ZNK10QTestTable12elementCountEv @ 158 NONAME + _ZNK10QTestTable13elementTypeIdEi @ 159 NONAME + _ZNK10QTestTable7dataTagEi @ 160 NONAME + _ZNK10QTestTable7indexOfEPKc @ 161 NONAME + _ZNK10QTestTable7isEmptyEv @ 162 NONAME + _ZNK10QTestTable8testDataEi @ 163 NONAME + _ZNK10QTestTable9dataCountEv @ 164 NONAME -- cgit v0.12 From 4b95d9939db75d7bd55db4bbbf2d67af459f7eb5 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Date: Tue, 10 May 2011 13:06:57 +0200 Subject: Compile on Mac Missing API update in Q_WS_MAC block Reviewed-by: Jiang Jiang --- src/gui/text/qrawfont.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 4f2a01e..29394e9 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -593,11 +593,11 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ // if none of them match, just pick the first one for (int i = 0; i < list.size(); i++) { QGlyphRun glyphs = list.at(i); - QRawFont rawfont = glyphs.font(); + QRawFont rawfont = glyphs.rawFont(); if (rawfont.familyName() == font.family()) return rawfont; } - return list.at(0).font(); + return list.at(0).rawFont(); } return QRawFont(); #else -- cgit v0.12 From 965af9eb2932efae5d736df54c3859460017b6a5 Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Tue, 10 May 2011 13:30:33 +0200 Subject: Add some QRawFont related low level functions to avoid extra copying Added functions: - QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const - QRawFont::advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const Reviewed-by: Eskil --- src/gui/text/qrawfont.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++---- src/gui/text/qrawfont.h | 2 ++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 29394e9..44ddfd2 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -428,7 +428,7 @@ int QRawFont::weight() const of the text. To get the correctly shaped text, you can use QTextLayout to lay out and shape the text, and then call QTextLayout::glyphRuns() to get the set of glyph index list and QRawFont pairs. - \sa advancesForGlyphIndexes(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns() + \sa advancesForGlyphIndexes(), glyphIndexesForChars(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns() */ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const { @@ -437,11 +437,9 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const int nglyphs = text.size(); QVarLengthGlyphLayoutArray glyphs(nglyphs); - if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs, - QTextEngine::GlyphIndicesOnly)) { + if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) { glyphs.resize(nglyphs); - if (!d->fontEngine->stringToCMap(text.data(), text.size(), &glyphs, &nglyphs, - QTextEngine::GlyphIndicesOnly)) { + if (!glyphIndexesForChars(text.data(), text.size(), glyphs.glyphs, &nglyphs)) { Q_ASSERT_X(false, Q_FUNC_INFO, "stringToCMap shouldn't fail twice"); return QVector<quint32>(); } @@ -455,6 +453,26 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const } /*! + Converts a string of unicode points to glyph indexes using the CMAP table in the + underlying font. The function works like glyphIndexesForString() except it take + an array (\a chars), the results will be returned though \a glyphIndexes array + and number of glyphs will be set in \a numGlyphs. The size of \a glyphIndexes array + must be at least \a numChars, if that's still not enough, this function will return + false, then you can resize \a glyphIndexes from the size returned in \a numGlyphs. + + \sa glyphIndexesForString(), advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs() +*/ +bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const +{ + if (!isValid()) + return false; + + QGlyphLayout glyphs; + glyphs.glyphs = glyphIndexes; + return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QTextEngine::GlyphIndicesOnly); +} + +/*! Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances give the distance from the position of a given glyph to where the next glyph should be drawn to make it appear as if the two glyphs are unspaced. @@ -480,6 +498,36 @@ QVector<QPointF> QRawFont::advancesForGlyphIndexes(const QVector<quint32> &glyph } /*! + Returns the QRawFont's advances for each of the \a glyphIndexes in pixel units. The advances + give the distance from the position of a given glyph to where the next glyph should be drawn + to make it appear as if the two glyphs are unspaced. The glyph indexes are given with the + array \a glyphIndexes while the results are returned through \a advances, both of them must + have \a numGlyphs elements. + + \sa QTextLine::horizontalAdvance(), QFontMetricsF::width() +*/ +bool QRawFont::advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const +{ + if (!isValid()) + return false; + + QGlyphLayout glyphs; + glyphs.glyphs = const_cast<HB_Glyph *>(glyphIndexes); + glyphs.numGlyphs = numGlyphs; + QVarLengthArray<QFixed> advances_x(numGlyphs); + QVarLengthArray<QFixed> advances_y(numGlyphs); + glyphs.advances_x = advances_x.data(); + glyphs.advances_y = advances_y.data(); + + d->fontEngine->recalcAdvances(&glyphs, 0); + + for (int i=0; i<numGlyphs; ++i) + advances[i] = QPointF(glyphs.advances_x[i].toReal(), glyphs.advances_y[i].toReal()); + + return true; +} + +/*! Returns the hinting preference used to construct this QRawFont. \sa QFont::hintingPreference() diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index 900c07a..3875fec 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -90,6 +90,8 @@ public: QVector<quint32> glyphIndexesForString(const QString &text) const; QVector<QPointF> advancesForGlyphIndexes(const QVector<quint32> &glyphIndexes) const; + bool glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const; + bool advancesForGlyphIndexes(const quint32 *glyphIndexes, QPointF *advances, int numGlyphs) const; QImage alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialiasingType = SubPixelAntialiasing, -- cgit v0.12 From 0ad6cec5d77fffa5d64b841bd7496088df6fcaab Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Tue, 10 May 2011 14:01:43 +0200 Subject: Build fix for tst_qrawfont Reviewed-by: Eskil --- tests/auto/qrawfont/tst_qrawfont.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qrawfont/tst_qrawfont.cpp b/tests/auto/qrawfont/tst_qrawfont.cpp index cf46471..8c58407 100644 --- a/tests/auto/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/qrawfont/tst_qrawfont.cpp @@ -835,8 +835,8 @@ void tst_QRawFont::rawFontSetPixelSize() layout.createLine(); layout.endLayout(); - QGlyphs glyphs = layout.glyphs().at(0); - QRawFont rawFont = glyphs.font(); + QGlyphRun glyphs = layout.glyphRuns().at(0); + QRawFont rawFont = glyphs.rawFont(); QCOMPARE(rawFont.pixelSize(), 12.0); rawFont.setPixelSize(24); -- cgit v0.12 From 36f43e454e772776f77401806b49115894963dfa Mon Sep 17 00:00:00 2001 From: Jani Hautakangas <jani.hautakangas@nokia.com> Date: Tue, 10 May 2011 21:21:54 +0300 Subject: Fix QtCoreu.def file error Hybrid heap exports should not be listed in QtCoreu.def Reviewed-by: TRUSTME --- src/s60installs/eabi/QtCoreu.def | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index f92cb5a..fce55dd 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3717,17 +3717,4 @@ EXPORTS _ZN23QCoreApplicationPrivate18symbianCommandLineEv @ 3716 NONAME _ZNK11QMetaMethod8revisionEv @ 3717 NONAME _ZNK13QMetaProperty8revisionEv @ 3718 NONAME - _ZN5RHeap10Extension_EjRPvS0_ @ 3719 NONAME - _ZN5RHeap13DebugFunctionEiPvS0_ @ 3720 NONAME - _ZN5RHeap4FreeEPv @ 3721 NONAME - _ZN5RHeap5AllocEi @ 3722 NONAME - _ZN5RHeap5ResetEv @ 3723 NONAME - _ZN5RHeap7ReAllocEPvii @ 3724 NONAME - _ZN5RHeap8CompressEv @ 3725 NONAME - _ZN8UserHeap15OffsetChunkHeapE6RChunkiiiiiim @ 3726 NONAME - _ZN8UserHeap16CreateThreadHeapER24SStdEpocThreadCreateInfoRP5RHeapii @ 3727 NONAME - _ZN8UserHeap9ChunkHeapE6RChunkiiiiim @ 3728 NONAME - _ZNK5RHeap8AllocLenEPKv @ 3729 NONAME - _ZNK5RHeap9AllocSizeERi @ 3730 NONAME - _ZNK5RHeap9AvailableERi @ 3731 NONAME -- cgit v0.12 From 637456edef085d1825f15429cd921f2f0d4bd6a2 Mon Sep 17 00:00:00 2001 From: Jason McDonald <jason.mcdonald@nokia.com> Date: Wed, 11 May 2011 12:00:40 +1000 Subject: Remove Q_ASSERT's from qsharedmemory autotest Report a fatal error rather than ignoring the error in non-debug builds. Change-Id: Ib6ef993e6e0c65bd9adea994ea7b454cc147f3d4 Task-number: QTBUG-17582 Reviewed-by: Rohan McGovern --- tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp | 3 ++- tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp index 6db84dd..647d857 100644 --- a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp +++ b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_unix.cpp @@ -207,7 +207,8 @@ bool QSystemLockPrivate::modifySemaphore(QSystemLockPrivate::Operation op, if ((lockCount == 0 && op == Lock) || (lockCount > 0 && op == Unlock)) { if (op == Unlock) { --lockCount; - Q_ASSERT(lockCount >= 0); + if (lockCount < 0) + qFatal("%s: lockCount must not be negative", Q_FUNC_INFO); if (lockCount > 0) return true; } diff --git a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp index f6803f7..f7e4ab2 100644 --- a/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp +++ b/tests/auto/qtipc/qsharedmemory/src/qsystemlock_win.cpp @@ -157,7 +157,8 @@ bool QSystemLockPrivate::modifySemaphore(QSystemLockPrivate::Operation op, if ((lockCount == 0 && op == Lock) || (lockCount > 0 && op == Unlock)) { if (op == Unlock) { --lockCount; - Q_ASSERT(lockCount >= 0); + if (lockCount < 0) + qFatal("%s: lockCount must not be negative", Q_FUNC_INFO); if (lockCount > 0) return true; } -- cgit v0.12 From a368c351928a95d21663bbd0404f887cc3cf7974 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Wed, 11 May 2011 11:24:57 +0200 Subject: Fix misspelled word in comment. Reviewed-by: trustme --- src/gui/painting/qunifiedtoolbarsurface_mac_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h index 6b1243e..ce07f5c 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h +++ b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h @@ -89,7 +89,7 @@ class QNativeImage; // We trigger the rendering of the unified toolbar in QWidget::repaint() // and QWidget::update(). // We keep track of flush requests via "flushRequested" variable. That -// allow flush() to be a no-op if no repaint occured for a widget. +// allow flush() to be a no-op if no repaint occurred for a widget. // We rely on the needsDisplay: and drawRect: mecanism for drawing our // content into the graphics context. // -- cgit v0.12 From 360c5f2c39a39c2a8296f21e6f5f577367610853 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Wed, 11 May 2011 13:30:35 +0200 Subject: Move the painting redirection to the unified toolbar surface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the new parent of a widget is inside the unified toolbar, we need to update the redirection. Task-number: QTBUG-18150 Reviewed-by: Samuel Rødal --- src/gui/kernel/qwidget.cpp | 10 ---------- src/gui/kernel/qwidget_mac.mm | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 80d7b85..4c1a6dd 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1389,16 +1389,6 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) QApplication::postEvent(q, new QEvent(QEvent::PolishRequest)); extraPaintEngine = 0; - -#ifdef QT_MAC_USE_COCOA - // If we add a child to the unified toolbar, we have to redirect the painting. - if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) { - if (parentWidget->d_func()->unifiedSurface) { - QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor; - parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset); - } - } -#endif // QT_MAC_USE_COCOA } diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 27a1bb6..468de22 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3032,6 +3032,16 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) q->setAttribute(Qt::WA_WState_Hidden); q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden); +#ifdef QT_MAC_USE_COCOA + // If we add a child to the unified toolbar, we have to redirect the painting. + if (parent && parent->d_func() && parent->d_func()->isInUnifiedToolbar) { + if (parent->d_func()->unifiedSurface) { + QWidget *toolbar = parent->d_func()->toolbar_ancestor; + parent->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset); + } + } +#endif // QT_MAC_USE_COCOA + if (wasCreated) { transferChildren(); #ifndef QT_MAC_USE_COCOA -- cgit v0.12 From 5eba82b752e85a5d6cb3a893214ed2646d75f362 Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Wed, 11 May 2011 12:13:01 +0200 Subject: Move QTextCursor::MoveStyle to Qt namespace We cannot use QTextCursor::MoveStyle enums in QTextLine because QTextCursor is not a QObject, while referring to that enum in Q_PROPERTY requires it to be. That's why we need to move the enums in Qt namespace. Reviewed-by: David Boddie --- src/corelib/global/qnamespace.h | 6 ++++++ src/gui/text/qtextcursor.cpp | 18 +++++++++--------- src/gui/text/qtextcursor.h | 4 ---- src/gui/text/qtextdocument.cpp | 6 +++--- src/gui/text/qtextdocument.h | 6 +++--- src/gui/text/qtextdocument_p.cpp | 2 +- src/gui/text/qtextdocument_p.h | 2 +- src/gui/text/qtextengine_p.h | 2 +- src/gui/text/qtextlayout.cpp | 14 +++++++------- src/gui/text/qtextlayout.h | 4 ++-- src/gui/widgets/qlinecontrol.cpp | 2 +- src/gui/widgets/qlinecontrol_p.h | 8 ++++---- src/gui/widgets/qlineedit.cpp | 8 ++++---- src/gui/widgets/qlineedit.h | 5 +++-- tests/auto/qcomplextext/tst_qcomplextext.cpp | 2 +- tests/auto/qlineedit/tst_qlineedit.cpp | 4 ++-- tests/auto/qtextedit/tst_qtextedit.cpp | 4 ++-- 17 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 75ce68a..f086513 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -94,6 +94,7 @@ Qt { Q_ENUMS(GestureState) Q_ENUMS(GestureType) #endif + Q_ENUMS(CursorMoveStyle) #endif // (defined(Q_MOC_RUN) || defined(QT_JAMBI_RUN)) #if defined(Q_MOC_RUN) @@ -1784,6 +1785,11 @@ public: NavigationModeCursorAuto, NavigationModeCursorForceVisible }; + + enum CursorMoveStyle { + LogicalMoveStyle, + VisualMoveStyle + }; } #ifdef Q_MOC_RUN ; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 4f6857a..17bcc6c 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -362,7 +362,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor currentCharFormat = -1; bool adjustX = true; QTextBlock blockIt = block(); - bool visualMovement = priv->defaultCursorMoveStyle == QTextCursor::Visual; + bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle; if (!blockIt.isValid()) return false; @@ -2568,18 +2568,18 @@ QTextDocument *QTextCursor::document() const } /*! - \enum QTextCursor::MoveStyle + \enum Qt::CursorMoveStyle - This enum describes the movement style available to QTextCursor. The options + This enum describes the movement style available to text cursors. The options are: - \value Logical Within a left-to-right text block, increase cursor position - when pressing left arrow key, decrease cursor position when pressing the - right arrow key. If the text block is right-to-left, the opposite behavior + \value LogicalMoveStyle Within a left-to-right text block, decrease cursor + position when pressing left arrow key, increase cursor position when pressing + the right arrow key. If the text block is right-to-left, the opposite behavior applies. - \value Visual Pressing the left arrow key will always cause the cursor to move - left, regardless of the text's writing direction. The same behavior applies to - right arrow key. + \value VisualMoveStyle Pressing the left arrow key will always cause the cursor + to move left, regardless of the text's writing direction. Pressing the right + arrow key will always cause the cursor to move right. */ QT_END_NAMESPACE diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 9e4c0b8..4eaeb41 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -86,10 +86,6 @@ public: MoveAnchor, KeepAnchor }; - enum MoveStyle { - Logical, - Visual - }; void setPosition(int pos, MoveMode mode = MoveAnchor); int position() const; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 9169955..0d33912 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -589,9 +589,9 @@ void QTextDocument::setDefaultTextOption(const QTextOption &option) \since 4.8 The default cursor movement style is used by all QTextCursor objects - created from the document. The default is QTextCursor::Logical. + created from the document. The default is Qt::LogicalMoveStyle. */ -QTextCursor::MoveStyle QTextDocument::defaultCursorMoveStyle() const +Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const { Q_D(const QTextDocument); return d->defaultCursorMoveStyle; @@ -602,7 +602,7 @@ QTextCursor::MoveStyle QTextDocument::defaultCursorMoveStyle() const Set the default cursor movement style. */ -void QTextDocument::setDefaultCursorMoveStyle(QTextCursor::MoveStyle style) +void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style) { Q_D(QTextDocument); d->defaultCursorMoveStyle = style; diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index e515b36..b826dc1 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -46,7 +46,6 @@ #include <QtCore/qsize.h> #include <QtCore/qrect.h> #include <QtGui/qfont.h> -#include <QtGui/qtextcursor.h> QT_BEGIN_HEADER @@ -70,6 +69,7 @@ class QUrl; class QVariant; class QRectF; class QTextOption; +class QTextCursor; template<typename T> class QVector; @@ -269,8 +269,8 @@ public: QTextOption defaultTextOption() const; void setDefaultTextOption(const QTextOption &option); - QTextCursor::MoveStyle defaultCursorMoveStyle() const; - void setDefaultCursorMoveStyle(QTextCursor::MoveStyle style); + Qt::CursorMoveStyle defaultCursorMoveStyle() const; + void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style); Q_SIGNALS: void contentsChange(int from, int charsRemoves, int charsAdded); diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 779b1ff..640f7aa 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -209,7 +209,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() defaultTextOption.setTabStop(80); // same as in qtextengine.cpp defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); - defaultCursorMoveStyle = QTextCursor::Logical; + defaultCursorMoveStyle = Qt::LogicalMoveStyle; indentWidth = 40; documentMargin = 4; diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 6563920..e72d676 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -342,7 +342,7 @@ private: public: QTextOption defaultTextOption; - QTextCursor::MoveStyle defaultCursorMoveStyle; + Qt::CursorMoveStyle defaultCursorMoveStyle; #ifndef QT_NO_CSSPARSER QCss::StyleSheet parsedDefaultStyleSheet; #endif diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index c476485..e06ca1c 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -598,7 +598,7 @@ public: inline bool visualCursorMovement() const { return (visualMovement || - (block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == QTextCursor::Visual : false)); + (block.docHandle() ? block.docHandle()->defaultCursorMoveStyle == Qt::VisualMoveStyle : false)); } struct SpecialData { diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 1280b46..07aeb72 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -579,27 +579,27 @@ bool QTextLayout::cacheEnabled() const } /*! - Set the visual cursor movement style. If the QTextLayout is backed by + Set the cursor movement style. If the QTextLayout is backed by a document, you can ignore this and use the option in QTextDocument, this option is for widgets like QLineEdit or custom widgets without - a QTextDocument. Default value is QTextCursor::Logical. + a QTextDocument. Default value is Qt::LogicalMoveStyle. \sa setCursorMoveStyle() */ -void QTextLayout::setCursorMoveStyle(QTextCursor::MoveStyle style) +void QTextLayout::setCursorMoveStyle(Qt::CursorMoveStyle style) { - d->visualMovement = style == QTextCursor::Visual ? true : false; + d->visualMovement = style == Qt::VisualMoveStyle ? true : false; } /*! The cursor movement style of this QTextLayout. The default is - QTextCursor::Logical. + Qt::LogicalMoveStyle. \sa setCursorMoveStyle() */ -QTextCursor::MoveStyle QTextLayout::cursorMoveStyle() const +Qt::CursorMoveStyle QTextLayout::cursorMoveStyle() const { - return d->visualMovement ? QTextCursor::Visual : QTextCursor::Logical; + return d->visualMovement ? Qt::VisualMoveStyle : Qt::LogicalMoveStyle; } /*! diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index 8fe488a..89fbfb2 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -137,8 +137,8 @@ public: void setCacheEnabled(bool enable); bool cacheEnabled() const; - void setCursorMoveStyle(QTextCursor::MoveStyle style); - QTextCursor::MoveStyle cursorMoveStyle() const; + void setCursorMoveStyle(Qt::CursorMoveStyle style); + Qt::CursorMoveStyle cursorMoveStyle() const; void beginLayout(); void endLayout(); diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 4fb0f0c..2a15555 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -1593,7 +1593,7 @@ void QLineControl::processKeyEvent(QKeyEvent* event) } bool unknown = false; - bool visual = cursorMoveStyle() == QTextCursor::Visual; + bool visual = cursorMoveStyle() == Qt::VisualMoveStyle; if (false) { } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 0655276..9764ba9 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -160,8 +160,8 @@ public: int cursorWidth() const { return m_cursorWidth; } void setCursorWidth(int value) { m_cursorWidth = value; } - QTextCursor::MoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); } - void setCursorMoveStyle(QTextCursor::MoveStyle style) { m_textLayout.setCursorMoveStyle(style); } + Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); } + void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); } void moveCursor(int pos, bool mark = false); void cursorForward(bool mark, int steps) @@ -169,11 +169,11 @@ public: int c = m_cursor; if (steps > 0) { while (steps--) - c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.rightCursorPosition(c) + c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.rightCursorPosition(c) : m_textLayout.nextCursorPosition(c); } else if (steps < 0) { while (steps++) - c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.leftCursorPosition(c) + c = cursorMoveStyle() == Qt::VisualMoveStyle ? m_textLayout.leftCursorPosition(c) : m_textLayout.previousCursorPosition(c); } moveCursor(c, mark); diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 43c3f52..3c9874e 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1116,24 +1116,24 @@ void QLineEdit::setDragEnabled(bool b) \brief the movement style of cursor in this line edit \since 4.8 - When this property is set to QTextCursor::Visual, the line edit will use visual + When this property is set to Qt::VisualMoveStyle, the line edit will use visual movement style. Pressing the left arrow key will always cause the cursor to move left, regardless of the text's writing direction. The same behavior applies to right arrow key. - When the property is QTextCursor::Logical (the default), within a LTR text block, + When the property is Qt::LogicalMoveStyle (the default), within a LTR text block, increase cursor position when pressing left arrow key, decrease cursor position when pressing the right arrow key. If the text block is right to left, the opposite behavior applies. */ -QTextCursor::MoveStyle QLineEdit::cursorMoveStyle() const +Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const { Q_D(const QLineEdit); return d->control->cursorMoveStyle(); } -void QLineEdit::setCursorMoveStyle(QTextCursor::MoveStyle style) +void QLineEdit::setCursorMoveStyle(Qt::CursorMoveStyle style) { Q_D(QLineEdit); d->control->setCursorMoveStyle(style); diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index 73a736c..e88273f 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -85,6 +85,7 @@ class Q_GUI_EXPORT QLineEdit : public QWidget Q_PROPERTY(bool redoAvailable READ isRedoAvailable) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText) + Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle) public: explicit QLineEdit(QWidget* parent=0); @@ -159,8 +160,8 @@ public: void setDragEnabled(bool b); bool dragEnabled() const; - void setCursorMoveStyle(QTextCursor::MoveStyle style); - QTextCursor::MoveStyle cursorMoveStyle() const; + void setCursorMoveStyle(Qt::CursorMoveStyle style); + Qt::CursorMoveStyle cursorMoveStyle() const; QString inputMask() const; void setInputMask(const QString &inputMask); diff --git a/tests/auto/qcomplextext/tst_qcomplextext.cpp b/tests/auto/qcomplextext/tst_qcomplextext.cpp index 58b31b4..ae63bac 100644 --- a/tests/auto/qcomplextext/tst_qcomplextext.cpp +++ b/tests/auto/qcomplextext/tst_qcomplextext.cpp @@ -214,7 +214,7 @@ void tst_QComplexText::bidiCursorMovement() QTextOption option = layout.textOption(); option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft); layout.setTextOption(option); - layout.setCursorMoveStyle(QTextCursor::Visual); + layout.setCursorMoveStyle(Qt::VisualMoveStyle); bool moved; int oldPos, newPos = 0; qreal x, newX; diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index f45481c..d5d9029 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -3815,7 +3815,7 @@ void tst_QLineEdit::bidiVisualMovement() QLineEdit le; le.setText(logical); - le.setCursorMoveStyle(QTextCursor::Visual); + le.setCursorMoveStyle(Qt::VisualMoveStyle); le.setCursorPosition(0); bool moved; @@ -3863,7 +3863,7 @@ void tst_QLineEdit::bidiLogicalMovement() QLineEdit le; le.setText(logical); - le.setCursorMoveStyle(QTextCursor::Logical); + le.setCursorMoveStyle(Qt::LogicalMoveStyle); le.setCursorPosition(0); bool moved; diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 5a64593..992d2f2 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -2292,7 +2292,7 @@ void tst_QTextEdit::bidiVisualMovement() option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft); ed->document()->setDefaultTextOption(option); - ed->document()->setDefaultCursorMoveStyle(QTextCursor::Visual); + ed->document()->setDefaultCursorMoveStyle(Qt::VisualMoveStyle); ed->moveCursor(QTextCursor::Start); ed->show(); @@ -2346,7 +2346,7 @@ void tst_QTextEdit::bidiLogicalMovement() option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft); ed->document()->setDefaultTextOption(option); - ed->document()->setDefaultCursorMoveStyle(QTextCursor::Logical); + ed->document()->setDefaultCursorMoveStyle(Qt::LogicalMoveStyle); ed->moveCursor(QTextCursor::Start); ed->show(); -- cgit v0.12 From 1f854897da1231594d916ca3b094fcc59e43e8eb Mon Sep 17 00:00:00 2001 From: Jani Hautakangas <jani.hautakangas@nokia.com> Date: Wed, 11 May 2011 00:38:01 +0300 Subject: Enable multisampling on Symbian if hw supports it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BCM2727 don't have hw support for multisampling but on other chips it should be enabled on Symbian. Task-number: QTBUG-19183 Reviewed-by: Samuel Rødal --- src/opengl/qgl_symbian.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index 1b41db4..ab37977 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -49,6 +49,9 @@ #include <private/qpaintengine_opengl_p.h> #include <private/qwidget_p.h> // to access QWExtra #include <private/qnativeimagehandleprovider_p.h> +#include <private/qapplication_p.h> +#include <private/qgraphicssystem_p.h> +#include <private/qgraphicssystemex_symbian_p.h> #include "qgl_egl_p.h" #include "qpixmapdata_gl_p.h" #include "qgltexturepool_p.h" @@ -180,6 +183,15 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as d->ownsEglContext = true; d->eglContext->setApi(QEgl::OpenGL); + QGraphicsSystemEx *ex = QApplicationPrivate::graphicsSystem()->platformExtension(); + QSymbianGraphicsSystemEx *symex = static_cast<QSymbianGraphicsSystemEx*>(ex); + if (symex && !symex->hasBCM2727()) { + // Most likely we have hw support for multisampling + // so let's enable it. + d->glFormat.setSampleBuffers(1); + d->glFormat.setSamples(4); + } + // If the device is a widget with WA_TranslucentBackground set, make sure the glFormat // has the alpha channel option set: if (devType == QInternal::Widget) { @@ -229,20 +241,20 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as d->eglSurface = QEgl::createSurface(device(), d->eglContext->config()); - eglGetError(); // Clear error state first. + eglGetError(); // Clear error state first. #ifdef QGL_NO_PRESERVED_SWAP - eglSurfaceAttrib(QEgl::display(), d->eglSurface, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); + eglSurfaceAttrib(QEgl::display(), d->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); - if (eglGetError() != EGL_SUCCESS) - qWarning("QGLContext: could not enable destroyed swap behaviour"); + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLContext: could not enable destroyed swap behaviour"); #else - eglSurfaceAttrib(QEgl::display(), d->eglSurface, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + eglSurfaceAttrib(QEgl::display(), d->eglSurface, + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - if (eglGetError() != EGL_SUCCESS) - qWarning("QGLContext: could not enable preserved swap behaviour"); + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLContext: could not enable preserved swap behaviour"); #endif setWindowCreated(true); -- cgit v0.12 From 004ad12669ef696eeba70fd57d1eb0c67c806d1d Mon Sep 17 00:00:00 2001 From: Craig Scott <craig.scott@csiro.au> Date: Wed, 11 May 2011 16:51:28 +1000 Subject: Fix incorrect hardware address on systems without getifaddrs() On unix systems for which QT_NO_GETIFADDRS is defined, the way that the hardware address field is extracted from the result of a call to qt_safe_ioctl() is incorrect. The address of the ifreq.ifr_addr struct is taken rather than the appropriate member within that struct, sa_data, resulting in a memory offset and subsequently the hardware address has garbage in the first two of six fields. This commit modifies the code to pass the sa_data member instead of the address of the struct as a whole. Task-number: QTBUG-19165 Merge-request: 2614 Reviewed-by: Martin Petersson --- src/network/kernel/qnetworkinterface_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index 6098bde..7f251a7 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -219,7 +219,7 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfa #ifdef SIOCGIFHWADDR // Get the HW address if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) { - uchar *addr = (uchar *)&req.ifr_addr; + uchar *addr = (uchar *)req.ifr_addr.sa_data; iface->hardwareAddress = iface->makeHwAddress(6, addr); } #endif -- cgit v0.12 From 8a5e82732be3aac37d14ef85c6974add46c6b65f Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Wed, 11 May 2011 15:21:14 +0200 Subject: Fix tst_QVariant::invalidColor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since a423ff5474b89028eeca95b254f5184311c8223b, the warning message is no longer produced. Reviewed-by: Samuel Rødal --- tests/auto/qvariant/tst_qvariant.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 6ebe84e..3e65d7e 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -2650,7 +2650,6 @@ void tst_QVariant::invalidAsByteArray() void tst_QVariant::invalidQColor() const { QVariant va("An invalid QColor::name() value."); - QTest::ignoreMessage(QtWarningMsg, "QColor::setNamedColor: Unknown color name 'An invalid QColor::name() value.'"); QVERIFY(va.canConvert(QVariant::Color)); QVERIFY(!va.convert(QVariant::Color)); -- cgit v0.12 From 4d2edca95edbb93fb7c79c4ddb19e12cc4416ff2 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland <kim.kalland@nokia.com> Date: Wed, 11 May 2011 10:53:00 +0200 Subject: Check if OES_texture_npot is present on OpenGL ES 2. Unless the OES_texture_npot extension is present, non-power- of-two textures have some restrictions on OpenGL ES 2. Reviewed-by: Samuel --- src/opengl/qglfunctions.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp index be8219a..9137e0f 100644 --- a/src/opengl/qglfunctions.cpp +++ b/src/opengl/qglfunctions.cpp @@ -211,19 +211,24 @@ QGLFunctions::QGLFunctions(const QGLContext *context) static int qt_gl_resolve_features() { #if defined(QT_OPENGL_ES_2) - return QGLFunctions::Multitexture | - QGLFunctions::Shaders | - QGLFunctions::Buffers | - QGLFunctions::Framebuffers | - QGLFunctions::BlendColor | - QGLFunctions::BlendEquation | - QGLFunctions::BlendEquationSeparate | - QGLFunctions::BlendFuncSeparate | - QGLFunctions::BlendSubtract | - QGLFunctions::CompressedTextures | - QGLFunctions::Multisample | - QGLFunctions::StencilSeparate | - QGLFunctions::NPOTTextures; + int features = QGLFunctions::Multitexture | + QGLFunctions::Shaders | + QGLFunctions::Buffers | + QGLFunctions::Framebuffers | + QGLFunctions::BlendColor | + QGLFunctions::BlendEquation | + QGLFunctions::BlendEquationSeparate | + QGLFunctions::BlendFuncSeparate | + QGLFunctions::BlendSubtract | + QGLFunctions::CompressedTextures | + QGLFunctions::Multisample | + QGLFunctions::StencilSeparate; + QGLExtensionMatcher extensions; + if (extensions.match("GL_OES_texture_npot")) + features |= QGLFunctions::NPOTTextures; + if (extensions.match("GL_IMG_texture_npot")) + features |= QGLFunctions::NPOTTextures; + return features; #elif defined(QT_OPENGL_ES) int features = QGLFunctions::Multitexture | QGLFunctions::Buffers | @@ -240,6 +245,8 @@ static int qt_gl_resolve_features() features |= QGLFunctions::BlendSubtract; if (extensions.match("GL_OES_texture_npot")) features |= QGLFunctions::NPOTTextures; + if (extensions.match("GL_IMG_texture_npot")) + features |= QGLFunctions::NPOTTextures; return features; #else int features = 0; -- cgit v0.12 From c5846314dfd80e7f7f32ba737f1884dcccbbd80d Mon Sep 17 00:00:00 2001 From: Jiang Jiang <jiang.jiang@nokia.com> Date: Wed, 11 May 2011 16:56:24 +0200 Subject: Fix QGLWidget::renderPixmap for raster engine on Mac The QPixmap buffer is backed by QRasterPixmapData instead of QMacPixmapData for the raster engine, thus we have to update qt_mac_pixmap_get_base() and qt_mac_pixmap_get_bytes_per_line(), so that QGLWidget can locate the offscreen buffer from a QPixmap. Reviewed-by: Fabien Freling --- src/gui/image/qpixmap_mac.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp index 72e2aa6..e107d88 100644 --- a/src/gui/image/qpixmap_mac.cpp +++ b/src/gui/image/qpixmap_mac.cpp @@ -54,6 +54,7 @@ #include <private/qpaintengine_mac_p.h> #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> +#include <private/qapplication_p.h> #include <limits.h> #include <string.h> @@ -73,12 +74,18 @@ static int qt_pixmap_serial = 0; Q_GUI_EXPORT quint32 *qt_mac_pixmap_get_base(const QPixmap *pix) { - return static_cast<QMacPixmapData*>(pix->data.data())->pixels; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return reinterpret_cast<quint32 *>(static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bits()); + else + return static_cast<QMacPixmapData*>(pix->data.data())->pixels; } Q_GUI_EXPORT int qt_mac_pixmap_get_bytes_per_line(const QPixmap *pix) { - return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow; + if (QApplicationPrivate::graphics_system_name == QLatin1String("raster")) + return static_cast<QRasterPixmapData*>(pix->data.data())->buffer()->bytesPerLine(); + else + return static_cast<QMacPixmapData*>(pix->data.data())->bytesPerRow; } void qt_mac_cgimage_data_free(void *info, const void *memoryToFree, size_t) -- cgit v0.12 From 6fbfb1ab3f26ad672eb24f9b4a0ce1a8eea08298 Mon Sep 17 00:00:00 2001 From: Andrew den Exter <andrew.den-exter@nokia.com> Date: Mon, 9 May 2011 14:04:08 +1000 Subject: Don't crash on an invalid replacementStart from an input method. Ensure the cursor position does not exceed the bounds of the current text. Change-Id: If38f7729372562324d11eadd1a976c0c6da91863 Task-number: QTBUG-19054 Reviewed-by: Martin Jones --- src/gui/widgets/qlinecontrol.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 202ea7a..8d4a90e 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -435,6 +435,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) c += event->commitString().length() - qMin(-event->replacementStart(), event->replacementLength()); m_cursor += event->replacementStart(); + if (m_cursor < 0) + m_cursor = 0; // insert commit string if (event->replacementLength()) { @@ -447,7 +449,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) cursorPositionChanged = true; } - m_cursor = qMin(c, m_text.length()); + m_cursor = qBound(0, c, m_text.length()); for (int i = 0; i < event->attributes().size(); ++i) { const QInputMethodEvent::Attribute &a = event->attributes().at(i); -- cgit v0.12 From 88492fcea5d5c8dd6a8e1c2458a6a2b8747e84c7 Mon Sep 17 00:00:00 2001 From: Andrew den Exter <andrew.den-exter@nokia.com> Date: Mon, 9 May 2011 13:57:34 +1000 Subject: Ensure the TextEdit cursor delegate is repositioned on mouse events. Update the micro focus when a mouse press changes the cursor position of a read only TextEdit. Change-Id: I11855037f7938b2cd23ac6ad165722b5289b4f46 Task-number: QTBUG-19109 Reviewed-by: Martin Jones --- src/gui/text/qtextcontrol.cpp | 4 +++- .../tst_qdeclarativetextedit.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 3fd3ab5..cf8e313 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1578,8 +1578,10 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con emit q->cursorPositionChanged(); _q_updateCurrentCharFormatAndSelection(); } else { - if (cursor.position() != oldCursorPos) + if (cursor.position() != oldCursorPos) { emit q->cursorPositionChanged(); + emit q->microFocusChanged(); + } selectionChanged(); } repaintOldAndNewSelection(oldSelection); diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 2fad88d..7bbef21 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -1639,6 +1639,26 @@ void tst_qdeclarativetextedit::cursorDelegate() QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); } + // Clear preedit text; + QInputMethodEvent event; + QApplication::sendEvent(view, &event); + + // Test delegate gets moved on mouse press. + textEditObject->setSelectByMouse(true); + textEditObject->setCursorPosition(0); + qDebug() << textEditObject->boundingRect() << textEditObject->positionToRectangle(5).center() << view->mapFromScene(textEditObject->positionToRectangle(5).center()); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center())); + QVERIFY(textEditObject->cursorPosition() != 0); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + + textEditObject->setReadOnly(true); + textEditObject->setCursorPosition(0); + QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center())); + QVERIFY(textEditObject->cursorPosition() != 0); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + textEditObject->setCursorPosition(0); QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); -- cgit v0.12 From 877bb2132bdd94a62526a5fea6a7e5f6f813395e Mon Sep 17 00:00:00 2001 From: Sami Merila <sami.merila@nokia.com> Date: Thu, 12 May 2011 12:05:32 +0300 Subject: QWidgetPrivate::setParent_sys might be using null pointer Fix possible null pointer usage. Issue found by Coverity tool. Reviewed-by: Miikka Heikkinen --- src/gui/kernel/qwidget_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 1dd1477..8ca29cd 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -782,7 +782,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) adjustFlags(data.window_flags, q); // keep compatibility with previous versions, we need to preserve the created state // (but we recreate the winId for the widget being reparented, again for compatibility) - if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created))) + if (wasCreated || (!q->isWindow() && parent && parent->testAttribute(Qt::WA_WState_Created))) createWinId(); if (q->isWindow() || (!parent || parent->isVisible()) || explicitlyHidden) q->setAttribute(Qt::WA_WState_Hidden); -- cgit v0.12 From 2bb185d5e65be09b4e1f73eadd0ab87f9d6aecbb Mon Sep 17 00:00:00 2001 From: Olivier Goffart <olivier.goffart@nokia.com> Date: Thu, 12 May 2011 11:12:55 +0200 Subject: Compile --- src/gui/painting/qgraphicssystemex_symbian.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/painting/qgraphicssystemex_symbian.cpp b/src/gui/painting/qgraphicssystemex_symbian.cpp index 54d21ac..2d3f137 100644 --- a/src/gui/painting/qgraphicssystemex_symbian.cpp +++ b/src/gui/painting/qgraphicssystemex_symbian.cpp @@ -43,7 +43,6 @@ #include "private/qwidget_p.h" #include "private/qbackingstore_p.h" #include "private/qapplication_p.h" -#include "qwidget_p.h" #include <QDebug> -- cgit v0.12 From 708fcbe457304ac8035c20302e6dc6628a0f6aa4 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas <jani.hautakangas@nokia.com> Date: Thu, 12 May 2011 13:54:46 +0300 Subject: Fix for rounded corners bug in QMenu Currently QMenus have opaque black corners in cases where theme supports rounded corners. This patch fixes it by setting WA_TranslucentBackground flag to QMenu widget. Task-number: QTBUG-16857 Reviewed-by: Sami Merila --- src/gui/widgets/qmenu.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 2f4bb4b..d573ebf 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -82,6 +82,10 @@ # include <private/qt_cocoa_helpers_mac_p.h> #endif +#ifdef Q_WS_S60 +# include "private/qt_s60_p.h" +#endif + QT_BEGIN_NAMESPACE @@ -172,6 +176,14 @@ void QMenuPrivate::init() q->addAction(selectAction); q->addAction(cancelAction); #endif + +#ifdef Q_WS_S60 + if (S60->avkonComponentsSupportTransparency) { + bool noSystemBackground = q->testAttribute(Qt::WA_NoSystemBackground); + q->setAttribute(Qt::WA_TranslucentBackground); // also sets WA_NoSystemBackground + q->setAttribute(Qt::WA_NoSystemBackground, noSystemBackground); // restore system background attribute + } +#endif } int QMenuPrivate::scrollerHeight() const -- cgit v0.12 From b7b9a22ce263fcb430ff4228fb88ca5229a6e226 Mon Sep 17 00:00:00 2001 From: Fabien Freling <fabien.freling@nokia.com> Date: Thu, 12 May 2011 14:10:56 +0200 Subject: Clear confusion between QMainWindow and QMainWindowLayout. The variables activateUnifiedToolbarAfterFullScreen and useHIToolBar were implemented in both classes. This was an obvious bug, where variable would be initialized in one class and use in the other one. Task-number: QTBUG-18874 Reviewed-by: Yoann Lopes (cherry picked from commit 15a5eaf0eeb44833a052b6201171fca4b9e8f74e) --- src/gui/widgets/qmainwindow.cpp | 2 -- src/gui/widgets/qmainwindowlayout.cpp | 1 + src/gui/widgets/qmainwindowlayout_p.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index d8f8e91..0db5bba 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -78,7 +78,6 @@ public: : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) #ifdef Q_WS_MAC , useHIToolBar(false) - , activateUnifiedToolbarAfterFullScreen(false) #endif #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) , hasOldCursor(false) , cursorAdjusted(false) @@ -90,7 +89,6 @@ public: Qt::ToolButtonStyle toolButtonStyle; #ifdef Q_WS_MAC bool useHIToolBar; - bool activateUnifiedToolbarAfterFullScreen; #endif void init(); QList<int> hoverSeparator; diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 6bc07e1..51267c1 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1695,6 +1695,7 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay , gapIndicator(new QRubberBand(QRubberBand::Rectangle, mainwindow)) #endif //QT_NO_RUBBERBAND #ifdef Q_WS_MAC + , activateUnifiedToolbarAfterFullScreen(false) , blockVisiblityCheck(false) #endif { diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h index 489e913..289a49c 100644 --- a/src/gui/widgets/qmainwindowlayout_p.h +++ b/src/gui/widgets/qmainwindowlayout_p.h @@ -334,7 +334,6 @@ public: void removeFromMacToolbar(QToolBar *toolbar); void cleanUpMacToolbarItems(); void fixSizeInUnifiedToolbar(QToolBar *tb) const; - bool useHIToolBar; bool activateUnifiedToolbarAfterFullScreen; void syncUnifiedToolbarVisibility(); bool blockVisiblityCheck; -- cgit v0.12 From 96a3bf7a8bbc1e5361e16cbeeceb4be674b88c30 Mon Sep 17 00:00:00 2001 From: Rohan McGovern <rohan.mcgovern@nokia.com> Date: Thu, 12 May 2011 17:45:55 +1000 Subject: Ensure that recursive QMAKE_EXTRA_TARGETS use the correct makefile Recursive QMAKE_EXTRA_TARGETS were omitting the `-f' option to make. This would break in the case where the correct makefile was not named `Makefile'. The included autotest demonstrates the problem. Note that this was fixed for normal targets back in 2005 by faac7bd178654fd67a6f3f9cf4f6f2605071448d (p4 202370), but was not fixed for extra targets. Reviewed-by: ossi --- qmake/generators/makefile.cpp | 5 +---- .../subdir_via_pro_file_extra_target/simple/main.cpp | 3 +++ .../subdir_via_pro_file_extra_target/simple/simple.pro | 5 +++++ .../testdata/subdir_via_pro_file_extra_target/subdir.pro | 7 +++++++ .../subdir_via_pro_file_extra_target.pro | 7 +++++++ tests/auto/qmake/tst_qmake.cpp | 14 ++++++++++++++ 6 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp create mode 100644 tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro create mode 100644 tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro create mode 100644 tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 595768f..e4764e0 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2638,10 +2638,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QList<MakefileGenerator::SubT QString out_directory_cdin, out_directory_cdout; MAKE_CD_IN_AND_OUT(out_directory); - //don't need the makefile arg if it isn't changed - QString makefilein; - if(subtarget->makefile != "$(MAKEFILE)") - makefilein = " -f " + subtarget->makefile; + QString makefilein = " -f " + subtarget->makefile; //write the rule/depends if(flags & SubTargetOrdered) { diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp new file mode 100644 index 0000000..3c850d4 --- /dev/null +++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp @@ -0,0 +1,3 @@ +int main(int,char**) +{ +} diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro new file mode 100644 index 0000000..2db08a2 --- /dev/null +++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/simple.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +SOURCES = main.cpp + +extratarget.commands = @echo extra target worked OK +QMAKE_EXTRA_TARGETS += extratarget diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro new file mode 100644 index 0000000..be0d80a --- /dev/null +++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs +SUBDIRS = simple + +extratarget.CONFIG = recursive +extratarget.recurse = $$SUBDIRS +extratarget.recurse_target = extratarget +QMAKE_EXTRA_TARGETS += extratarget diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro new file mode 100644 index 0000000..7c07859 --- /dev/null +++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/subdir_via_pro_file_extra_target.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs +SUBDIRS = subdir.pro + +extratarget.CONFIG = recursive +extratarget.recurse = $$SUBDIRS +extratarget.recurse_target = extratarget +QMAKE_EXTRA_TARGETS += extratarget diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 81a51e1..afd28e1 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -69,6 +69,7 @@ private slots: void simple_lib(); void simple_dll(); void subdirs(); + void subdir_via_pro_file_extra_target(); void functions(); void operators(); void variables(); @@ -234,6 +235,19 @@ void tst_qmake::subdirs() QVERIFY( test_compiler.removeMakefile( workDir ) ); } +void tst_qmake::subdir_via_pro_file_extra_target() +{ + QString workDir = base_path + "/testdata/subdir_via_pro_file_extra_target"; + + QDir D; + D.remove( workDir + "/Makefile"); + D.remove( workDir + "/Makefile.subdir"); + D.remove( workDir + "/simple/Makefile"); + D.remove( workDir + "/simple/Makefile.subdir"); + QVERIFY( test_compiler.qmake( workDir, "subdir_via_pro_file_extra_target" )); + QVERIFY( test_compiler.make( workDir, "extratarget" )); +} + void tst_qmake::functions() { QString workDir = base_path + "/testdata/functions"; -- cgit v0.12 From 2caea6081fc46217636f0ab70d09891efd2d2864 Mon Sep 17 00:00:00 2001 From: Rohan McGovern <rohan.mcgovern@nokia.com> Date: Fri, 13 May 2011 14:10:29 +1000 Subject: Fixed license header. --- .../simple/main.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp index 3c850d4..a023aa6 100644 --- a/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp +++ b/tests/auto/qmake/testdata/subdir_via_pro_file_extra_target/simple/main.cpp @@ -1,3 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + int main(int,char**) { } -- cgit v0.12 From f69e465e15930ef02dceba7175eed6f3f1df070e Mon Sep 17 00:00:00 2001 From: Andrew den Exter <andrew.den-exter@nokia.com> Date: Fri, 13 May 2011 13:49:20 +1000 Subject: Make TextEdit word selection more natural. QTextControl will only extend the selection to a word if the cursor is directly over it which prevents the selection being extended if the mouse is dragged up or down a to a shorter line of text making it difficult to select multiple lines of text. Just disable that limitation when the TextEdit word selection is enabled. Change-Id: I3b9d1575c0141db8441197d740de94a90eacc077 Task-number: QTBUG-19230 Reviewed-by: Martin Jones --- src/gui/text/qtextcontrol.cpp | 2 +- .../data/mouseselection_multiline.qml | 8 +++++ .../tst_qdeclarativetextedit.cpp | 36 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index cf8e313..88e0573 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -676,7 +676,7 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea const qreal wordEndX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x(); - if (mouseXPosition < wordStartX || mouseXPosition > wordEndX) + if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX)) return; // keep the already selected word even when moving to the left diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml new file mode 100644 index 0000000..af23f6d --- /dev/null +++ b/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml @@ -0,0 +1,8 @@ +import QtQuick 1.1 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRS\nTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextInput.SelectWords +} diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 7bbef21..f8af433 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -119,6 +119,7 @@ private slots: void moveCursorSelectionSequence(); void mouseSelection_data(); void mouseSelection(); + void multilineMouseSelection(); void deferEnableSelectByMouse_data(); void deferEnableSelectByMouse(); void deferDisableSelectByMouse_data(); @@ -1364,6 +1365,41 @@ void tst_qdeclarativetextedit::mouseSelection() delete canvas; } +void tst_qdeclarativetextedit::multilineMouseSelection() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/mouseselection_multiline.qml"); + + canvas->show(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + + QVERIFY(canvas->rootObject() != 0); + QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject()); + QVERIFY(textEditObject != 0); + + // press-and-drag from x1,y1 to x2,y1 + int x1 = 10; + int x2 = textEditObject->width() - 10; + int y1 = textEditObject->height() / 4; + int y2 = textEditObject->height() * 3 / 4; + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y1))); + QMouseEvent mv1(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y1)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv1); + QString str1 = textEditObject->selectedText(); + QVERIFY(str1.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform) + + // drag-and-release from x2,y1 to x2,y2 + QMouseEvent mv2(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y2)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv2); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y2))); + QString str2 = textEditObject->selectedText(); + QVERIFY(str1 != str2); + QVERIFY(str2.length() > 3); + + delete canvas; +} + void tst_qdeclarativetextedit::deferEnableSelectByMouse_data() { QTest::addColumn<QString>("qmlfile"); -- cgit v0.12 From 576d577438f1193bbc934e904b809d5b23b8d54e Mon Sep 17 00:00:00 2001 From: Martin Jones <martin.jones@nokia.com> Date: Fri, 13 May 2011 15:28:30 +1000 Subject: ListViews loses items if all visible items are removed. Occurs when at end of list and all visible items are removed in multiple steps, without entering the event loop. We were not updating visibleIndex if there were no visible items when handling itemsRemoved(). Also avoid skipping items in refill if there are no valid visible items for reference. Change-Id: I2ff58fb191f6b053f33d5446220d597eb15b66d4 Task-number: QTBUG-19198 Reviewed-by: Bea Lam --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 11 +++++++---- .../qdeclarativelistview/tst_qdeclarativelistview.cpp | 10 ++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index cb40384..79d67e7 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -733,6 +733,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) if (doBuffer && (bufferMode & BufferBefore)) fillFrom = bufferFrom; + bool haveValidItems = false; int modelIndex = visibleIndex; qreal itemEnd = visiblePos-1; if (!visibleItems.isEmpty()) { @@ -741,11 +742,13 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) int i = visibleItems.count() - 1; while (i > 0 && visibleItems.at(i)->index == -1) --i; - if (visibleItems.at(i)->index != -1) + if (visibleItems.at(i)->index != -1) { + haveValidItems = true; modelIndex = visibleItems.at(i)->index + 1; + } } - if (visibleItems.count() && (fillFrom > itemEnd+averageSize+spacing + if (haveValidItems && (fillFrom > itemEnd+averageSize+spacing || fillTo < visiblePos - averageSize - spacing)) { // We've jumped more than a page. Estimate which items are now // visible and fill from there. @@ -3406,9 +3409,9 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count) } } - if (removedVisible && !haveVisibleIndex) { + if (!haveVisibleIndex) { d->timeline.clear(); - if (d->itemCount == 0) { + if (removedVisible && d->itemCount == 0) { d->visibleIndex = 0; d->visiblePos = d->header ? d->header->size() : 0; d->setPosition(0); diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 8b90030..23ac523 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -714,6 +714,16 @@ void tst_QDeclarativeListView::removed(bool animated) QTRY_VERIFY(name = findItem<QDeclarativeText>(contentItem, "textName", model.count()-1)); QCOMPARE(name->text(), QString("New")); + // Add some more items so that we don't run out + for (int i = 50; i < 100; i++) + model.addItem("Item" + QString::number(i), ""); + + // QTBUG-19198 move to end and remove all visible items one at a time. + listview->positionViewAtEnd(); + for (int i = 0; i < 18; ++i) + model.removeItems(model.count() - 1, 1); + QTRY_VERIFY(findItems<QDeclarativeItem>(contentItem, "wrapper").count() > 16); + delete canvas; } -- cgit v0.12 From 80db0a1e59658f9e445219fc48d9236a79edca72 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Date: Fri, 13 May 2011 17:01:28 +1000 Subject: QDeclarativeMouseArea: block context menu events If the MouseArea accepts the same button used to trigger a context menu event, it should not let the event to be delivered to item behind. This is important for items that do implement contextMenuEvent(), like QDeclarativeWebView. When there's a mouse area on top of this item and that accepts the right click (in Linux), the event was still being delivered and the WebView menu was incorrectly appearing. QtWebKit bug https://bugs.webkit.org/show_bug.cgi?id=56526 documents this problem. Change-Id: I386fac6c96f47b8616e2eeb7e5f97043ba418980 Merge-request: 1185 Reviewed-by: Martin Jones <martin.jones@nokia.com> --- .../graphicsitems/qdeclarativemousearea.cpp | 26 +++++++++ .../graphicsitems/qdeclarativemousearea_p.h | 3 ++ .../data/preventContextMenu.qml | 22 ++++++++ .../tst_qdeclarativemousearea.cpp | 63 ++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index d4e7f7b..6633256 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -660,6 +660,32 @@ void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) setHovered(false); } +#ifndef QT_NO_CONTEXTMENU +void QDeclarativeMouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +{ + bool acceptsContextMenuButton; +#if defined(Q_OS_SYMBIAN) + // In Symbian a Long Tap on the screen will trigger. See QSymbianControl::HandleLongTapEventL(). + acceptsContextMenuButton = acceptedButtons() & Qt::LeftButton; +#elif defined(Q_WS_WINCE) + // ### WinCE can trigger context menu event with a gesture in the left button or a + // click with the right button. Since we have no way here to differentiate them when + // event happens, accepting either of the them will block the event. + acceptsContextMenuButton = acceptedButtons() & (Qt::LeftButton | Qt::RightButton); +#else + acceptsContextMenuButton = acceptedButtons() & Qt::RightButton; +#endif + + if (isEnabled() && event->reason() == QGraphicsSceneContextMenuEvent::Mouse + && acceptsContextMenuButton) { + // Do not let the context menu event propagate to items behind. + return; + } + + QDeclarativeItem::contextMenuEvent(event); +} +#endif // QT_NO_CONTEXTMENU + bool QDeclarativeMouseArea::sceneEvent(QEvent *event) { bool rv = QDeclarativeItem::sceneEvent(event); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p.h index 351d4de..0fe8c6a 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p.h @@ -190,6 +190,9 @@ protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverMoveEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); +#ifndef QT_NO_CONTEXTMENU + void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); +#endif // QT_NO_CONTEXTMENU bool sceneEvent(QEvent *); bool sendMouseEvent(QGraphicsSceneMouseEvent *event); bool sceneEventFilter(QGraphicsItem *i, QEvent *e); diff --git a/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml b/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml new file mode 100644 index 0000000..dcbb5d7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml @@ -0,0 +1,22 @@ +import QtQuick 1.1 +import Test 1.0 + +Item { + width: 200 + height: 200 + + property alias mouseAreaEnabled: mouseArea.enabled + property alias eventsReceived: receiver.eventCount + + ContextMenuEventReceiver { + id: receiver + anchors.fill: parent + } + + MouseArea { + id: mouseArea + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton + enabled: true + } +} diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index e1c34fc..fea7865 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -47,6 +47,7 @@ #include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativecontext.h> #include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativeproperty.h> #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -70,6 +71,9 @@ private slots: void preventStealing(); void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); +#ifndef QT_NO_CONTEXTMENU + void preventContextMenu(); +#endif // QT_NO_CONTEXTMENU private: QDeclarativeView *createView(); @@ -637,6 +641,65 @@ void tst_QDeclarativeMouseArea::testQtQuick11Attributes_data() << ":1 \"MouseArea.preventStealing\" is not available in QtQuick 1.0.\n"; } +#ifndef QT_NO_CONTEXTMENU +class ContextMenuEventReceiver : public QDeclarativeItem +{ + Q_OBJECT + Q_PROPERTY(int eventCount READ eventCount NOTIFY eventCountChanged); +public: + ContextMenuEventReceiver(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent), m_eventCount(0) { } + int eventCount() const { return m_eventCount; } +signals: + void eventCountChanged(int); +protected: + void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { + if (event->reason() == QGraphicsSceneContextMenuEvent::Mouse) { + m_eventCount++; + emit eventCountChanged(m_eventCount); + } + } +private: + int m_eventCount; +}; + +void tst_QDeclarativeMouseArea::preventContextMenu() +{ + // A MouseArea accepting Left, Middle and Right buttons should prevent context menu + // events with "Mouse" reason to hit the Item below. + + qmlRegisterType<ContextMenuEventReceiver>("Test", 1, 0, "ContextMenuEventReceiver"); + + QDeclarativeView *view = createView(); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/preventContextMenu.qml")); + view->show(); + QVERIFY(view->rootObject() != 0); + + QDeclarativeProperty mouseAreaEnabled(view->rootObject(), "mouseAreaEnabled"); + QVERIFY(mouseAreaEnabled.read().toBool()); + + QDeclarativeProperty eventsReceived(view->rootObject(), "eventsReceived"); + QCOMPARE(eventsReceived.read().toInt(), 0); + + QPoint targetPoint = view->mapFromScene(QPoint(80, 80)); + + QContextMenuEvent fakeEvent1(QContextMenuEvent::Mouse, targetPoint); + QApplication::sendEvent(view->viewport(), &fakeEvent1); + QCOMPARE(eventsReceived.read().toInt(), 0); + + mouseAreaEnabled.write(false); + QVERIFY(!mouseAreaEnabled.read().toBool()); + QContextMenuEvent fakeEvent2(QContextMenuEvent::Mouse, targetPoint); + QApplication::sendEvent(view->viewport(), &fakeEvent2); + QCOMPARE(eventsReceived.read().toInt(), 1); + + mouseAreaEnabled.write(true); + QVERIFY(mouseAreaEnabled.read().toBool()); + QContextMenuEvent fakeEvent3(QContextMenuEvent::Mouse, targetPoint); + QApplication::sendEvent(view->viewport(), &fakeEvent3); + QCOMPARE(eventsReceived.read().toInt(), 1); +} +#endif // QT_NO_CONTEXTMENU + QTEST_MAIN(tst_QDeclarativeMouseArea) #include "tst_qdeclarativemousearea.moc" -- cgit v0.12 From dabc653c47c3fcdbbe9e59b8e55306bc0a4d8006 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen <miikka.heikkinen@digia.com> Date: Fri, 13 May 2011 15:29:53 +0300 Subject: Fix softkey icon positioning in S60 5.3 In S60 5.3, Avkon apparently expects softkey icons to be 32x32 and positions them accordingly into the softkey, instead of needing the application to supply the whole softkey image. Fixed by skipping the softkey image centering when S60 version is 5.3 or larger. Task-number: QTBUG-19104 Reviewed-by: Sami Merila --- src/gui/kernel/qsoftkeymanager_s60.cpp | 35 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index 79ed91a..0d64d8a 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -176,22 +176,27 @@ void QSoftKeyManagerPrivateS60::setNativeSoftkey(CEikButtonGroupContainer &cba, QPoint QSoftKeyManagerPrivateS60::softkeyIconPosition(int position, QSize sourceSize, QSize targetSize) { QPoint iconPosition(0,0); - switch( AknLayoutUtils::CbaLocation() ) - { - case AknLayoutUtils::EAknCbaLocationBottom: - // RSK must be moved to right, LSK in on correct position by default - if (position == RSK_POSITION) - iconPosition.setX(targetSize.width() - sourceSize.width()); - break; - case AknLayoutUtils::EAknCbaLocationRight: - case AknLayoutUtils::EAknCbaLocationLeft: - // Already in correct position - default: - break; - } - // Align horizontally to center - iconPosition.setY((targetSize.height() - sourceSize.height()) >> 1); + // Prior to S60 5.3 icons need to be properly positioned to buttons, but starting with 5.3 + // positioning is done on Avkon side. + if (QSysInfo::s60Version() < QSysInfo::SV_S60_5_3) { + switch (AknLayoutUtils::CbaLocation()) + { + case AknLayoutUtils::EAknCbaLocationBottom: + // RSK must be moved to right, LSK in on correct position by default + if (position == RSK_POSITION) + iconPosition.setX(targetSize.width() - sourceSize.width()); + break; + case AknLayoutUtils::EAknCbaLocationRight: + case AknLayoutUtils::EAknCbaLocationLeft: + // Already in correct position + default: + break; + } + + // Align horizontally to center + iconPosition.setY((targetSize.height() - sourceSize.height()) >> 1); + } return iconPosition; } -- cgit v0.12 From 1f292c52cb09444bad4a888df20971c61a4e72a2 Mon Sep 17 00:00:00 2001 From: Sami Merila <sami.merila@nokia.com> Date: Fri, 13 May 2011 15:36:43 +0300 Subject: Support word selection list with predictive text from splitview When splitview is active and user taps a predicted word, mouse button should be forwarded to m_pointerHandler, which opens a suggested word list. When splitview is not active, but there are HW QWERTY keys in the device, tapping a word, should only move the cursor. Without HW QWERTY and no splitview, native editing state handles the functionality. Task-number: QTBUG-19062 Reviewed-by: Miikka Heikkinen --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 47 +++++++++++++------------ src/gui/kernel/qapplication_s60.cpp | 2 ++ src/gui/kernel/qt_s60_p.h | 2 ++ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 06dc25c..b74cd5e 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -235,21 +235,6 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) return false; switch (event->type()) { - case QEvent::MouseButtonPress: - // Alphanumeric keypad doesn't like it when we click and text is still getting displayed - // It ignores the mouse event, so we need to commit and send a selection event (which will get triggered - // after the commit) - if (!m_preeditString.isEmpty()) { - commitCurrentString(true); - - int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); - - QList<QInputMethodEvent::Attribute> selectAttributes; - selectAttributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos, 0, QVariant()); - QInputMethodEvent selectEvent(QLatin1String(""), selectAttributes); - sendEvent(selectEvent); - } - break; case QEvent::KeyPress: commitTemporaryPreeditString(); // fall through intended @@ -328,7 +313,10 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) if (sControl) { sControl->setIgnoreFocusChanged(false); } - return true; + //If m_pointerHandler has already been set, it means that fep inline editing is in progress. + //When this is happening, do not filter out pointer events. + if (!m_pointerHandler) + return true; } return false; @@ -380,18 +368,31 @@ void QCoeFepInputContext::commitTemporaryPreeditString() commitCurrentString(false); } -void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event) +void QCoeFepInputContext::mouseHandler(int x, QMouseEvent *event) { Q_ASSERT(focusWidget()); if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) { - commitCurrentString(true); - int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); + QWidget *proxy = focusWidget()->focusProxy(); + Qt::InputMethodHints currentHints = proxy ? proxy->inputMethodHints() : focusWidget()->inputMethodHints(); + + //If splitview is open and T9 word is tapped, pass the pointer event to pointer handler. + //This will open the "suggested words" list. Pass pointer position always as zero, to make + //full word replacement in case user makes a selection. + if (S60->partial_keyboard && S60->partialKeyboardOpen + && m_pointerHandler + && !(currentHints & Qt::ImhNoPredictiveText) + && (x > 0 && x < m_preeditString.length())) { + m_pointerHandler->HandlePointerEventInInlineTextL(TPointerEvent::EButton1Up, 0, 0); + } else { + commitCurrentString(true); + int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); - QList<QInputMethodEvent::Attribute> attributes; - attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos + x, 0, QVariant()); - QInputMethodEvent event(QLatin1String(""), attributes); - sendEvent(event); + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos + x, 0, QVariant()); + QInputMethodEvent event(QLatin1String(""), attributes); + sendEvent(event); + } } } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 6620efd..0b7e85d 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1481,8 +1481,10 @@ void QSymbianControl::HandleResourceChange(int resourceType) } if (ic && isSplitViewWidget(widget)) { if (resourceType == KSplitViewCloseEvent) { + S60->partialKeyboardOpen = false; ic->resetSplitViewWidget(); } else { + S60->partialKeyboardOpen = true; ic->ensureFocusWidgetVisible(widget); } } diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 8aba53a..3a910e4 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -153,6 +153,7 @@ public: int menuBeingConstructed : 1; int orientationSet : 1; int partial_keyboard : 1; + int partialKeyboardOpen : 1; QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type QPointer<QWidget> splitViewLastWidget; @@ -340,6 +341,7 @@ inline QS60Data::QS60Data() menuBeingConstructed(0), orientationSet(0), partial_keyboard(0), + partialKeyboardOpen(0), s60ApplicationFactory(0) #ifdef Q_OS_SYMBIAN ,s60InstalledTrapHandler(0) -- cgit v0.12 From e2320ec17446dc6e851fcf4ea2d998177b0d8049 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Fri, 13 May 2011 16:32:58 +0100 Subject: Fix instability in QNetworkConfigurationManager autotest QThread::isFinished() can return false after the finished() signal is emitted, so test the event loop's timeout() function instead. Don't compare prescan configurations, as these may be cached by the OS. It was causing the test to fail on linux if run before any other network test. Reviewed-by: mread --- .../tst_qnetworkconfigurationmanager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp index c270eb8..8939ffe 100644 --- a/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp +++ b/tests/auto/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp @@ -357,7 +357,7 @@ void tst_QNetworkConfigurationManager::usedInThread() connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); thread.start(); QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY could take ~90 seconds to time out in the thread - QVERIFY(thread.isFinished()); + QVERIFY(!QTestEventLoop::instance().timeout()); qDebug() << "prescan:" << thread.preScanConfigs.count(); qDebug() << "postscan:" << thread.configs.count(); @@ -368,7 +368,9 @@ void tst_QNetworkConfigurationManager::usedInThread() QTRY_VERIFY(spy.count() == 1); //wait for scan to complete QList<QNetworkConfiguration> configs = manager.allConfigurations(); QCOMPARE(thread.configs, configs); - QCOMPARE(thread.preScanConfigs, preScanConfigs); + //Don't compare pre scan configs, because these may be cached and therefore give different results + //which makes the test unstable. The post scan results should have all configurations every time + //QCOMPARE(thread.preScanConfigs, preScanConfigs); #endif } -- cgit v0.12 From e9e95f75e7c1e8325c2acce0087ff8677d773779 Mon Sep 17 00:00:00 2001 From: Shane Kearns <shane.kearns@accenture.com> Date: Fri, 13 May 2011 16:19:18 +0100 Subject: Fix thread safety regression of QNetworkConfigurationManager Changes in 4.8 led to a timer being created in the wrong thread. I have restored the invokeMethod used to call startPolling() to solve this problem. Reviewed-By: mread --- src/network/bearer/qnetworkconfigmanager_p.cpp | 2 +- src/network/bearer/qnetworkconfigmanager_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index a948d91..42fc49d 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -488,7 +488,7 @@ void QNetworkConfigurationManagerPrivate::enablePolling() ++forcedPolling; if (forcedPolling == 1) - startPolling(); + QMetaObject::invokeMethod(this, "startPolling"); } void QNetworkConfigurationManagerPrivate::disablePolling() diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index abc4b9b..45d6a75 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -107,7 +107,7 @@ private Q_SLOTS: void pollEngines(); private: - void startPolling(); + Q_INVOKABLE void startPolling(); QTimer *pollTimer; private: -- cgit v0.12 From cb5b6799333794496269aa7e6515f96c2ac96d37 Mon Sep 17 00:00:00 2001 From: Thiago Macieira <thiago.macieira@nokia.com> Date: Mon, 16 May 2011 13:20:25 +0200 Subject: Fix regression that caused waitForXXX(-1) to fail. Regression was introduced by 8d4cd52b6981a4e6deea7fdb77f56e40c4f3e6ba when it failed to check when msecs == -1. This manifested visibly in KDE failing to connect to any SSL site -- kioslaves are synchronous and use waitForXXX(-1) (in this particular case, waitForEncrypted, which calls waitForReadyRead). Also, take the opportunity to convert these tests in QTcpSocket to use port 80 (a defined service in the test server) instead of port 22. Reviewed-by: Martin Petersson --- src/network/socket/qabstractsocket.cpp | 2 +- tests/auto/qsslsocket/tst_qsslsocket.cpp | 15 +++++++++++++ tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 36 ++++++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index fc0bb85..e5af5c6 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -1908,7 +1908,7 @@ bool QAbstractSocket::waitForReadyRead(int msecs) if (state() != ConnectedState) return false; - } while (qt_timeout_value(msecs, stopWatch.elapsed()) > 0); + } while (msecs == -1 || qt_timeout_value(msecs, stopWatch.elapsed()) > 0); return false; } diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index b508d47..786899e 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -156,6 +156,7 @@ private slots: void setSslConfiguration_data(); void setSslConfiguration(); void waitForEncrypted(); + void waitForEncryptedMinusOne(); void waitForConnectedEncryptedReadyRead(); void startClientEncryption(); void startServerEncryption(); @@ -1098,6 +1099,20 @@ void tst_QSslSocket::waitForEncrypted() QVERIFY(socket->waitForEncrypted(10000)); } +void tst_QSslSocket::waitForEncryptedMinusOne() +{ + if (!QSslSocket::supportsSsl()) + return; + + QSslSocketPtr socket = newSocket(); + this->socket = socket; + + connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + + QVERIFY(socket->waitForEncrypted(-1)); +} + void tst_QSslSocket::waitForConnectedEncryptedReadyRead() { if (!QSslSocket::supportsSsl()) diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index f83c4cf..d19475f 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -166,7 +166,9 @@ private slots: void readLineString(); void readChunks(); void waitForBytesWritten(); + void waitForBytesWrittenMinusOne(); void waitForReadyRead(); + void waitForReadyReadMinusOne(); void flush(); void synchronousApi(); void dontCloseOnTimeout(); @@ -1417,10 +1419,10 @@ void tst_QTcpSocket::readChunks() void tst_QTcpSocket::waitForBytesWritten() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 22); + socket->connectToHost(QtNetworkSettings::serverName(), 80); QVERIFY(socket->waitForConnected(10000)); - socket->write(QByteArray(10000, '@')); + socket->write("GET / HTTP/1.0\r\n\r\n"); qint64 toWrite = socket->bytesToWrite(); QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(toWrite > socket->bytesToWrite()); @@ -1429,11 +1431,37 @@ void tst_QTcpSocket::waitForBytesWritten() } //---------------------------------------------------------------------------------- +void tst_QTcpSocket::waitForBytesWrittenMinusOne() +{ + QTcpSocket *socket = newSocket(); + socket->connectToHost(QtNetworkSettings::serverName(), 80); + QVERIFY(socket->waitForConnected(10000)); + + socket->write("GET / HTTP/1.0\r\n\r\n"); + qint64 toWrite = socket->bytesToWrite(); + QVERIFY(socket->waitForBytesWritten(-1)); + QVERIFY(toWrite > socket->bytesToWrite()); + + delete socket; +} + +//---------------------------------------------------------------------------------- void tst_QTcpSocket::waitForReadyRead() { QTcpSocket *socket = newSocket(); - socket->connectToHost(QtNetworkSettings::serverName(), 22); - socket->waitForReadyRead(0); + socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->write("GET / HTTP/1.0\r\n\r\n"); + QVERIFY(socket->waitForReadyRead(5000)); + delete socket; +} + +//---------------------------------------------------------------------------------- +void tst_QTcpSocket::waitForReadyReadMinusOne() +{ + QTcpSocket *socket = newSocket(); + socket->connectToHost(QtNetworkSettings::serverName(), 80); + socket->write("GET / HTTP/1.0\r\n\r\n"); + QVERIFY(socket->waitForReadyRead(-1)); delete socket; } -- cgit v0.12 From 4f7af4c544c3b793ba8cccb28e5c856f3d754e4a Mon Sep 17 00:00:00 2001 From: Robert Griebl <robert.griebl@nokia.com> Date: Thu, 12 May 2011 15:54:11 +0200 Subject: Revert all QScroller and QFlickGesture related code. This reverts commits 0274e68767cce6440515a68d6af868725d5577a4 2770b1277744bb676e96e4ae8c89acd645ec895d 02e1f4e83dc8e3c4ab957095167b3d34c51ba3c1 fdf3be5b6b5db75833e0a7e9a90445ddd794fe4d d1f9a534da288884f443a975f428b0cfe0a7b29b 205d607c3387d074fb87f8deb77a8f515ae2e189 32d200da9cc7a4dfb3f302f22ef5718a286845c9 3e0df49f978933b1e4e6b48c695bf813ec9a2828 82bbc1c1611bde33680d22a1a3c6449e51d7b0b9 b78ffe51f9a4c4ac705e435d45fffe39864c032d fe438d7d828021d7f86301af36fe8dff2768532a df30d58de183d13c649ef7e0fbb8e2b3658e0862 fa845566b3733bc06454b71e33b1ff405ba32280 4f9a318d639c4e7e09e56751d31608fb39d472af 4810b587a65d81f8f90646efd09cadeb1276a756 7bad867382ad6c84155ffcfbb361709a8e8184ab 64ec011c6132496eb9555c1d09e7fd4ddf472837 81492e56aba5b5761500543665012a85d6835513 b668857b3749b39c3a61e0a25e750740b74df552 78a7a02b3b85435bc28eb23e9210522467171e42 Reviewed-By: Ralf Engels --- doc/src/examples/wheel.qdoc | 109 -- examples/examples.pro | 1 - examples/scroller/graphicsview/graphicsview.pro | 8 - examples/scroller/graphicsview/main.cpp | 295 ---- examples/scroller/plot/main.cpp | 221 --- examples/scroller/plot/plot.pro | 13 - examples/scroller/plot/plotwidget.cpp | 204 --- examples/scroller/plot/plotwidget.h | 88 - examples/scroller/plot/settingswidget.cpp | 689 -------- examples/scroller/plot/settingswidget.h | 108 -- examples/scroller/scroller.pro | 11 - examples/scroller/wheel/main.cpp | 122 -- examples/scroller/wheel/wheel.pro | 11 - examples/scroller/wheel/wheelwidget.cpp | 275 --- examples/scroller/wheel/wheelwidget.h | 103 -- src/corelib/kernel/qcoreevent.cpp | 2 - src/corelib/kernel/qcoreevent.h | 3 - src/gui/itemviews/qabstractitemview.cpp | 44 - src/gui/itemviews/qabstractitemview.h | 3 - src/gui/itemviews/qabstractitemview_p.h | 7 - src/gui/kernel/qapplication_x11.cpp | 3 - src/gui/kernel/qevent.cpp | 219 --- src/gui/kernel/qevent.h | 46 - src/gui/kernel/qevent_p.h | 28 - src/gui/kernel/qt_x11_p.h | 2 - src/gui/util/qflickgesture.cpp | 715 -------- src/gui/util/qflickgesture_p.h | 113 -- src/gui/util/qscroller.cpp | 2056 ----------------------- src/gui/util/qscroller.h | 155 -- src/gui/util/qscroller_mac.mm | 71 - src/gui/util/qscroller_p.h | 209 --- src/gui/util/qscrollerproperties.cpp | 393 ----- src/gui/util/qscrollerproperties.h | 140 -- src/gui/util/qscrollerproperties_p.h | 94 -- src/gui/util/util.pri | 12 - src/gui/widgets/qabstractscrollarea.cpp | 107 +- src/gui/widgets/qabstractscrollarea_p.h | 2 - tests/auto/gui.pro | 1 - tests/auto/qscroller/qscroller.pro | 3 - tests/auto/qscroller/tst_qscroller.cpp | 537 ------ tools/qml/texteditautoresizer_maemo5.h | 12 +- 41 files changed, 7 insertions(+), 7228 deletions(-) delete mode 100644 doc/src/examples/wheel.qdoc delete mode 100644 examples/scroller/graphicsview/graphicsview.pro delete mode 100644 examples/scroller/graphicsview/main.cpp delete mode 100644 examples/scroller/plot/main.cpp delete mode 100644 examples/scroller/plot/plot.pro delete mode 100644 examples/scroller/plot/plotwidget.cpp delete mode 100644 examples/scroller/plot/plotwidget.h delete mode 100644 examples/scroller/plot/settingswidget.cpp delete mode 100644 examples/scroller/plot/settingswidget.h delete mode 100644 examples/scroller/scroller.pro delete mode 100644 examples/scroller/wheel/main.cpp delete mode 100644 examples/scroller/wheel/wheel.pro delete mode 100644 examples/scroller/wheel/wheelwidget.cpp delete mode 100644 examples/scroller/wheel/wheelwidget.h delete mode 100644 src/gui/util/qflickgesture.cpp delete mode 100644 src/gui/util/qflickgesture_p.h delete mode 100644 src/gui/util/qscroller.cpp delete mode 100644 src/gui/util/qscroller.h delete mode 100644 src/gui/util/qscroller_mac.mm delete mode 100644 src/gui/util/qscroller_p.h delete mode 100644 src/gui/util/qscrollerproperties.cpp delete mode 100644 src/gui/util/qscrollerproperties.h delete mode 100644 src/gui/util/qscrollerproperties_p.h delete mode 100644 tests/auto/qscroller/qscroller.pro delete mode 100644 tests/auto/qscroller/tst_qscroller.cpp diff --git a/doc/src/examples/wheel.qdoc b/doc/src/examples/wheel.qdoc deleted file mode 100644 index 995ff87..0000000 --- a/doc/src/examples/wheel.qdoc +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of this -** file. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example scroller/wheel - \title Wheel Scroller Example - - The Wheel Scroller Example shows how to use QScroller, QScrollEvent - and QScrollPrepareEvent to implement smooth scrolling for a - custom Widget. - - \section1 Basics - - The QScroller class is the main part of the smooth scrolling - mechanism in Qt. It keeps track of the current scroll position and - speed and updates the object through events. - QScroller will get touch events via the QFlickGesture. - It will query the target object through a QScrollPrepareEvent for - the scroll area and other information. - QScroller will send QScrollEvents to inform the target object about - the current scroll position. - The target object (usually a QWidget or a QGraphicsObject) will - then need to update it's graphical representation to reflect the - new scroll position. - - \section1 The Wheel Widget class - - To demonstrate how to use the QScroller we implement a QWidget that - looks and works like the wheel of a slot machine. - The wheel can be started via touch events and will continue getting - slower. - Additionally the wheel should appear as if no border exists (which - would seem unnatural) and the scrolling should snap to center one - item. - - In the widget we need to grab the QFlickGesture. The gesture itself - will setAcceptTouchEvents for us, so we don't need to do that here. - - \snippet examples/scroller/wheel/wheelwidget.cpp 0 - - The widget will get gesture events but in addition we also will - get the events from QScroller. - We will need to accept the QScrollPrepareEvent to indicate that - a scrolling should really be started from the given position. - - \snippet examples/scroller/wheel/wheelwidget.cpp 1 - - We should call all three set functions form QScrollPrepareEvent. - - \list - \o \c setViewportSize to indicate our viewport size. Actually the - given code could be improved by giving our size minus the borders. - \o \c setMaxContentPos to indicate the maximum values for the scroll - position. The minimum values are implicitely set to 0. - In our example we give a very high number here and hope that the user - is not patient enough to scroll until the very end. - \o \c setContentPos to indicate the current scroll position. - We give a position in the middle of the huge scroll area. - Actually we give this position every time a new scroll is started so - the user will only reach the end if he continuously scrolls in one - direction which is not very likely. - \endlist - - The handling of the QScrollEvent is a lengthly code not fully shown here. - \snippet examples/scroller/wheel/wheelwidget.cpp 2 - - In principle it does three steps. - \list - \o It calculates and updates the current scroll position as given by - QScroller. - \o It repaints the widget so that the new position is shown. - \o It centers the item as soon as the scrolling stopps. - \endlist - - The following code does the centering. - \snippet examples/scroller/wheel/wheelwidget.cpp 3 - - We check if the scrolling is finished which is indicated in the - QScrollEvent by the \c isLast flag. - We then check if the item is not already centered and if not start a new - scroll by calling QScroller::scrollTo. - - As you can see the QScroller can be used for other things besides simple - scroll areas. -*/ diff --git a/examples/examples.pro b/examples/examples.pro index 968740d..f233aba 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -20,7 +20,6 @@ SUBDIRS = \ mainwindows \ painting \ richtext \ - scroller \ sql \ tools \ tutorials \ diff --git a/examples/scroller/graphicsview/graphicsview.pro b/examples/scroller/graphicsview/graphicsview.pro deleted file mode 100644 index dcebe62..0000000 --- a/examples/scroller/graphicsview/graphicsview.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/scroller/graphicsview -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS graphicsview.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/scroller/graphicsview -INSTALLS += target sources diff --git a/examples/scroller/graphicsview/main.cpp b/examples/scroller/graphicsview/main.cpp deleted file mode 100644 index 738a824..0000000 --- a/examples/scroller/graphicsview/main.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore> -#include <QtGui> - -#define NUM_ITEMS 100 -#define NUM_LISTS 10 - -/*! - \class RectObject - Note that it needs to be a QGraphicsObject or else the gestures will not work correctly. -*/ -class RectObject : public QGraphicsObject -{ - Q_OBJECT - -public: - - RectObject(const QString &text, qreal x, qreal y, qreal width, qreal height, QBrush brush, QGraphicsItem *parent = 0) - : QGraphicsObject(parent) - , m_text(text) - , m_rect(x, y, width, height) - , m_pen(brush.color().lighter(), 3.0) - , m_brush(brush) - { - setFlag(QGraphicsItem::ItemClipsToShape, true); - } - - QRectF boundingRect() const - { - // here we only want the size of the children and not the size of the children of the children... - qreal halfpw = m_pen.widthF() / 2; - QRectF rect = m_rect; - if (halfpw > 0.0) - rect.adjust(-halfpw, -halfpw, halfpw, halfpw); - - return rect; - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(m_pen); - painter->setBrush(m_brush); - painter->drawRect(m_rect); - - painter->setPen(Qt::black); - QFont f; - f.setPixelSize(m_rect.height()); - painter->setFont(f); - painter->drawText(m_rect, Qt::AlignCenter, m_text); - } - - QString m_text; - QRectF m_rect; - QPen m_pen; - QBrush m_brush; -}; - -class ViewObject : public QGraphicsObject -{ - Q_OBJECT -public: - ViewObject(QGraphicsObject *parent) - : QGraphicsObject(parent) - { } - - QRectF boundingRect() const - { - QRectF rect; - foreach (QGraphicsItem *item, childItems()) - rect |= item->boundingRect().translated(item->pos()); - return rect; - } - - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) - { } -}; - -class ListObject : public QGraphicsObject -{ - Q_OBJECT - -public: - ListObject(const QSizeF &size, bool useTouch) - { - m_size = size; - setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); - // grab gesture via Touch or Mouse events - QScroller::grabGesture(this, useTouch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture); - - // this needs to be QGraphicsOBJECT - otherwise gesture recognition - // will not work for the parent of the viewport (in this case the - // list) - m_viewport = new ViewObject(this); - - } - - QGraphicsObject *viewport() const - { - return m_viewport; - } - - bool event(QEvent *e) - { - switch (e->type()) { -// ![2] - case QEvent::ScrollPrepare: { - QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e); - se->setViewportSize(m_size); - QRectF br = m_viewport->boundingRect(); - se->setContentPosRange(QRectF(0, 0, - qMax(qreal(0), br.width() - m_size.width()), - qMax(qreal(0), br.height() - m_size.height()))); - se->setContentPos(-m_viewport->pos()); - se->accept(); - return true; - } -// ![1] -// ![2] - case QEvent::Scroll: { - QScrollEvent *se = static_cast<QScrollEvent *>(e); - m_viewport->setPos(-se->contentPos() - se->overshootDistance()); - return true; - } -// ![2] - default: - break; - } - return QGraphicsObject::event(e); - } - - bool sceneEvent(QEvent *e) - { - switch (e->type()) { - case QEvent::TouchBegin: { - // We need to return true for the TouchBegin here in the - // top-most graphics object - otherwise gestures in our parent - // objects will NOT work at all (the accept() flag is already - // set due to our setAcceptTouchEvents(true) call in the c'tor - return true; - - } - case QEvent::GraphicsSceneMousePress: { - // We need to return true for the MousePress here in the - // top-most graphics object - otherwise gestures in our parent - // objects will NOT work at all (the accept() flag is already - // set to true by Qt) - return true; - - } - default: - break; - } - return QGraphicsObject::sceneEvent(e); - } - - QRectF boundingRect() const - { - return QRectF(0, 0, m_size.width() + 3, m_size.height()); - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(QPen(QColor(100, 100, 100), 3.0)); - painter->drawRect(QRect(1.5, 1.5, m_size.width() - 3, m_size.height() - 3)); - } - - QSizeF m_size; - ViewObject *m_viewport; -}; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(bool useTouch) - { - m_scene = new QGraphicsScene(); - - // -- make the main list - ListObject *mainList = new ListObject(QSizeF(780, 400), useTouch); - mainList->setObjectName(QLatin1String("MainList")); - m_scene->addItem(mainList); -// ![3] - for (int i=0; i<NUM_LISTS; i++) { - ListObject *childList = new ListObject(QSizeF(mainList->m_size.width()/3, mainList->m_size.height()), useTouch); - childList->setObjectName(QString("ChildList %1").arg(i)); - fillList(childList); - childList->setParentItem(mainList->viewport()); - childList->setPos(i*mainList->m_size.width()/3, 0); - } - mainList->viewport()->setPos(0, 0); - - - /* - list1->setTransformOriginPoint(200, 200); - list1->setRotation(135); - list1->setPos(20 + 200 * .41, 20 + 200 * .41); - */ -// ![3] - - m_view = new QGraphicsView(m_scene); - setCentralWidget(m_view); - setWindowTitle(tr("Gesture example")); - m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height()); - } - - /** - * Fills the list object \a list with RectObjects. - */ - void fillList(ListObject *list) - { - qreal h = list->m_size.height() / 10; - for (int i=0; i<NUM_ITEMS; i++) { - QColor color = QColor(255*i/NUM_ITEMS, 255*(NUM_ITEMS-i)/NUM_ITEMS, 127*(i%2)+64*(i/2%2)); - QString text = QLatin1String("Item #") + QString::number(i); - QGraphicsItem *rect = new RectObject(text, 0, 0, list->m_size.width() - 6, h - 3, QBrush(color), list->viewport()); - rect->setPos(3, h*i+3); - } - list->viewport()->setPos(0, 0); - } - - -protected: - void resizeEvent(QResizeEvent *e) - { - // resize the scene according to our own size to prevent scrolling - m_scene->setSceneRect(0, 0, m_view->viewport()->width(), m_view->viewport()->height()); - QMainWindow::resizeEvent(e); - } - - QGraphicsScene *m_scene; - QGraphicsView *m_view; -}; - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - bool touch = (a.arguments().contains(QLatin1String("--touch"))); - MainWindow mw(touch); -#ifdef Q_WS_S60 - mw.showMaximized(); -#else - mw.show(); -#endif -#ifdef Q_WS_MAC - mw.raise(); -#endif - return a.exec(); -} - -#include "main.moc" diff --git a/examples/scroller/plot/main.cpp b/examples/scroller/plot/main.cpp deleted file mode 100644 index 178a094..0000000 --- a/examples/scroller/plot/main.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QApplication> -#include <QListWidget> -#include <QListWidgetItem> -#include <QSplitter> -#include <QStackedWidget> -#include <QSignalMapper> -#include <QMainWindow> -#include <QMenuBar> -#include <QActionGroup> -#include <QWebView> -#include <QTimer> -#include <QScroller> - -#include <QtDebug> - -#include <QGesture> - -#include "settingswidget.h" -#include "plotwidget.h" - - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - MainWindow(bool smallscreen, bool touch) - : QMainWindow(), m_touch(touch) - { - m_list = new QListWidget(); - m_list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - m_list_scroller = installKineticScroller(m_list); - - for (int i = 0; i < 1000; ++i) - new QListWidgetItem(QString("This is a test text %1 %2").arg(i).arg(QString("--------").left(i % 8)), m_list); - - connect(m_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(listItemActivated(QListWidgetItem*))); - connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(listItemClicked(QListWidgetItem*))); - connect(m_list, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(listItemPressed(QListWidgetItem*))); - connect(m_list, SIGNAL(itemSelectionChanged()), this, SLOT(listItemSelectionChanged())); - connect(m_list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(listItemCurrentChanged(QListWidgetItem*))); - - m_web = new QWebView(); - m_web_scroller = installKineticScroller(m_web); - - QTimer::singleShot(1000, this, SLOT(loadUrl())); - - m_settings = new SettingsWidget(smallscreen); - installKineticScroller(m_settings); - m_plot = new PlotWidget(smallscreen); - - QStackedWidget *stack = new QStackedWidget(); - stack->addWidget(m_list); - stack->addWidget(m_web); - - QActionGroup *pages = new QActionGroup(this); - pages->setExclusive(true); - QSignalMapper *mapper = new QSignalMapper(this); - connect(mapper, SIGNAL(mapped(int)), stack, SLOT(setCurrentIndex(int))); - - createAction("List", pages, mapper, 0, true); - createAction("Web", pages, mapper, 1); - - if (smallscreen) { - stack->addWidget(m_settings); - stack->addWidget(m_plot); - - createAction("Settings", pages, mapper, 2); - createAction("Plot", pages, mapper, 3); - - setCentralWidget(stack); - } else { - QSplitter *split = new QSplitter(); - m_settings->setMinimumWidth(m_settings->sizeHint().width()); - split->addWidget(stack); - split->addWidget(m_settings); - split->addWidget(m_plot); - setCentralWidget(split); - } - menuBar()->addMenu(QLatin1String("Pages"))->addActions(pages->actions()); - connect(stack, SIGNAL(currentChanged(int)), this, SLOT(pageChanged(int))); - pageChanged(0); - } - -private slots: - void pageChanged(int page) - { - if (page < 0 || page > 1) - return; - switch (page) { - case 0: - m_settings->setScroller(m_list); - m_plot->setScroller(m_list); - break; - case 1: - m_settings->setScroller(m_web); - m_plot->setScroller(m_web); - break; - default: - break; - } - } - - void loadUrl() - { - m_web->load(QUrl("http://www.google.com")); - } - - void listItemActivated(QListWidgetItem *lwi) { qWarning() << "Item ACTIVATED: " << lwi->text(); } - void listItemClicked(QListWidgetItem *lwi) { qWarning() << "Item CLICKED: " << lwi->text(); } - void listItemPressed(QListWidgetItem *lwi) { qWarning() << "Item PRESSED: " << lwi->text(); } - void listItemCurrentChanged(QListWidgetItem *lwi) { qWarning() << "Item CURRENT: " << (lwi ? lwi->text() : QString("(none)")); } - void listItemSelectionChanged() - { - int n = m_list->selectedItems().count(); - qWarning("Item%s SELECTED: %d", n == 1 ? "" : "s", n); - foreach (QListWidgetItem *lwi, m_list->selectedItems()) - qWarning() << " " << lwi->text(); - } - -private: - QAction *createAction(const char *text, QActionGroup *group, QSignalMapper *mapper, int mapping, bool checked = false) - { - QAction *a = new QAction(QLatin1String(text), group); - a->setCheckable(true); - a->setChecked(checked); -#if defined(Q_WS_MAC) - a->setMenuRole(QAction::NoRole); -#endif - mapper->setMapping(a, mapping); - connect(a, SIGNAL(toggled(bool)), mapper, SLOT(map())); - return a; - } - - QScroller *installKineticScroller(QWidget *w) - { - if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(w)) { - QScroller::grabGesture(area->viewport(), m_touch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture); - return QScroller::scroller(area->viewport()); - } else if (QWebView *web = qobject_cast<QWebView *>(w)) { - QScroller::grabGesture(web, m_touch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture); - } - return QScroller::scroller(w); - } - -private: - QListWidget *m_list; - QWebView *m_web; - QScroller *m_list_scroller, *m_web_scroller; - SettingsWidget *m_settings; - PlotWidget *m_plot; - bool m_touch; -}; - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - -#if defined(Q_WS_MAEMO_5) || defined(Q_WS_S60) || defined(Q_WS_WINCE) - bool smallscreen = true; -#else - bool smallscreen = false; -#endif - bool touch = false; - - if (a.arguments().contains(QLatin1String("--small"))) - smallscreen = true; - if (a.arguments().contains(QLatin1String("--touch"))) - touch = true; - - MainWindow mw(smallscreen, touch); - if (smallscreen) - mw.showMaximized(); - else - mw.show(); -#if defined(Q_WS_MAC) - mw.raise(); -#endif - return a.exec(); -} - -#include "main.moc" diff --git a/examples/scroller/plot/plot.pro b/examples/scroller/plot/plot.pro deleted file mode 100644 index 04fdf70..0000000 --- a/examples/scroller/plot/plot.pro +++ /dev/null @@ -1,13 +0,0 @@ -HEADERS = settingswidget.h \ - plotwidget.h -SOURCES = settingswidget.cpp \ - plotwidget.cpp \ - main.cpp - -QT += webkit - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/scroller/plot -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS plot.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/scroller/plot -INSTALLS += target sources diff --git a/examples/scroller/plot/plotwidget.cpp b/examples/scroller/plot/plotwidget.cpp deleted file mode 100644 index e600652..0000000 --- a/examples/scroller/plot/plotwidget.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QPushButton> -#include <QTextStream> -#include <QColor> -#include <QPainter> -#include <QLabel> -#include <QResizeEvent> -#include <QPlastiqueStyle> -#include <QAbstractScrollArea> - -#include "plotwidget.h" -#include "qscroller.h" - -PlotWidget::PlotWidget(bool /*smallscreen*/) - : QWidget(), m_widget(0) -{ - setWindowTitle(QLatin1String("Plot")); - m_clear = new QPushButton(QLatin1String("Clear"), this); -#if defined(Q_WS_MAEMO_5) - m_clear->setStyle(new QPlastiqueStyle()); - m_clear->setFixedHeight(55); -#endif - connect(m_clear, SIGNAL(clicked()), this, SLOT(reset())); - m_legend = new QLabel(this); - QString legend; - QTextStream ts(&legend); - // ok. this wouldn't pass the w3c html verification... - ts << "<table style=\"color:#000;\" border=\"0\">"; - ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).light().name() << "\" /><td>Velocity X</td></tr>"; - ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::red).dark().name() << "\" /><td>Velocity Y</td></tr>"; - ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::green).light().name() << "\" /><td>Content Position X</td></tr>"; - ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::green).dark().name() << "\" /><td>Content Position Y</td></tr>"; - ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::blue).light().name() << "\" /><td>Overshoot Position X</td></tr>"; - ts << "<tr><td width=\"30\" bgcolor=\"" << QColor(Qt::blue).dark().name() << "\" /><td>Overshoot Position Y</td></tr>"; - ts << "</table>"; - m_legend->setText(legend); -} - -void PlotWidget::setScroller(QWidget *widget) -{ - if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(widget)) - widget = area->viewport(); - - if (m_widget) - m_widget->removeEventFilter(this); - m_widget = widget; - reset(); - if (m_widget) - m_widget->installEventFilter(this); -} - -bool PlotWidget::eventFilter(QObject *obj, QEvent *ev) -{ - if (ev->type() == QEvent::Scroll) { - QScrollEvent *se = static_cast<QScrollEvent *>(ev); - QScroller *scroller = QScroller::scroller(m_widget); - - QPointF v = scroller->velocity(); - //v.rx() *= scroller->pixelPerMeter().x(); - //v.ry() *= scroller->pixelPerMeter().y(); - - PlotItem pi = { v, se->contentPos(), se->overshootDistance() }; - addPlotItem(pi); - } - - return QWidget::eventFilter(obj, ev); -} - -static inline void doMaxMin(const QPointF &v, qreal &minmaxv) -{ - minmaxv = qMax(minmaxv, qMax(qAbs(v.x()), qAbs(v.y()))); -} - -void PlotWidget::addPlotItem(const PlotItem &pi) -{ - m_plotitems.append(pi); - minMaxVelocity = minMaxPosition = 0; - - while (m_plotitems.size() > 500) - m_plotitems.removeFirst(); - - foreach (const PlotItem &pi, m_plotitems) { - doMaxMin(pi.velocity, minMaxVelocity); - doMaxMin(pi.contentPosition, minMaxPosition); - doMaxMin(pi.overshootPosition, minMaxPosition); - } - update(); -} - -void PlotWidget::reset() -{ - m_plotitems.clear(); - minMaxVelocity = minMaxPosition = 0; - update(); -} - -void PlotWidget::resizeEvent(QResizeEvent *) -{ - QSize cs = m_clear->sizeHint(); - QSize ls = m_legend->sizeHint(); - m_clear->setGeometry(4, 4, cs.width(), cs.height()); - m_legend->setGeometry(4, height() - ls.height() - 4, ls.width(), ls.height()); -} - -void PlotWidget::paintEvent(QPaintEvent *) -{ -#define SCALE(v, mm) ((qreal(1) - (v / mm)) * qreal(0.5) * height()) - - QColor rvColor = Qt::red; - QColor cpColor = Qt::green; - QColor opColor = Qt::blue; - - - QPainter p(this); - //p.setRenderHints(QPainter::Antialiasing); //too slow for 60fps - p.fillRect(rect(), Qt::white); - - p.setPen(Qt::black); - p.drawLine(0, SCALE(0, 1), width(), SCALE(0, 1)); - - if (m_plotitems.isEmpty()) - return; - - int x = 2; - int offset = m_plotitems.size() - width() / 2; - QList<PlotItem>::const_iterator it = m_plotitems.constBegin(); - if (offset > 0) - it += (offset - 1); - - const PlotItem *last = &(*it++); - - while (it != m_plotitems.constEnd()) { - p.setPen(rvColor.light()); - p.drawLine(qreal(x - 2), SCALE(last->velocity.x(), minMaxVelocity), - qreal(x), SCALE(it->velocity.x(), minMaxVelocity)); - p.setPen(rvColor.dark()); - p.drawLine(qreal(x - 2), SCALE(last->velocity.y(), minMaxVelocity), - qreal(x), SCALE(it->velocity.y(), minMaxVelocity)); - - p.setPen(cpColor.light()); - p.drawLine(qreal(x - 2), SCALE(last->contentPosition.x(), minMaxPosition), - qreal(x), SCALE(it->contentPosition.x(), minMaxPosition)); - p.setPen(cpColor.dark()); - p.drawLine(qreal(x - 2), SCALE(last->contentPosition.y(), minMaxPosition), - qreal(x), SCALE(it->contentPosition.y(), minMaxPosition)); - - p.setPen(opColor.light()); - p.drawLine(qreal(x - 2), SCALE(last->overshootPosition.x(), minMaxPosition), - qreal(x), SCALE(it->overshootPosition.x(), minMaxPosition)); - p.setPen(opColor.dark()); - p.drawLine(qreal(x - 2), SCALE(last->overshootPosition.y(), minMaxPosition), - qreal(x), SCALE(it->overshootPosition.y(), minMaxPosition)); - - last = &(*it++); - x += 2; - } - - QString toptext = QString("%1 [m/s] / %2 [pix]").arg(minMaxVelocity, 0, 'f', 2).arg(minMaxPosition, 0, 'f', 2); - QString bottomtext = QString("-%1 [m/s] / -%2 [pix]").arg(minMaxVelocity, 0, 'f', 2).arg(minMaxPosition, 0, 'f', 2); - - p.setPen(Qt::black); - p.drawText(rect(), Qt::AlignTop | Qt::AlignHCenter, toptext); - p.drawText(rect(), Qt::AlignBottom | Qt::AlignHCenter, bottomtext); -#undef SCALE -} diff --git a/examples/scroller/plot/plotwidget.h b/examples/scroller/plot/plotwidget.h deleted file mode 100644 index 3c36be9..0000000 --- a/examples/scroller/plot/plotwidget.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PLOTWIDGET_H -#define PLOTWIDGET_H - -#include <QWidget> -#include <QPointF> - -QT_BEGIN_NAMESPACE -class QPushButton; -class QLabel; -class QScroller; -QT_END_NAMESPACE - -class PlotWidget : public QWidget -{ - Q_OBJECT - -public: - PlotWidget(bool smallscreen = false); - - void setScroller(QWidget *widget); - -public slots: - void reset(); - -protected: - void resizeEvent(QResizeEvent *); - void paintEvent(QPaintEvent *); - - bool eventFilter(QObject *obj, QEvent *ev); - -private: - - struct PlotItem { - QPointF velocity; - QPointF contentPosition; - QPointF overshootPosition; - }; - - void addPlotItem(const PlotItem &pi); - - QWidget *m_widget; - QList<PlotItem> m_plotitems; - qreal minMaxVelocity, minMaxPosition; - QPushButton *m_clear; - QLabel *m_legend; -}; - -#endif diff --git a/examples/scroller/plot/settingswidget.cpp b/examples/scroller/plot/settingswidget.cpp deleted file mode 100644 index c9de008..0000000 --- a/examples/scroller/plot/settingswidget.cpp +++ /dev/null @@ -1,689 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QVariant> -#include <QSlider> -#include <QHBoxLayout> -#include <QLabel> -#include <QPushButton> -#include <QComboBox> -#include <QSpinBox> -#include <QGroupBox> -#include <QToolButton> -#include <QCheckBox> -#include <QScrollBar> -#include <QPainter> -#include <QScrollArea> -#include <QScrollPrepareEvent> -#include <QApplication> -#include <QPlainTextEdit> -#include <QTextBlock> -#include <qnumeric.h> - -#include <QEasingCurve> - -#include <QDebug> - -#include "math.h" - -#include "settingswidget.h" -#include "qscroller.h" -#include "qscrollerproperties.h" - -class SnapOverlay : public QWidget -{ - Q_OBJECT -public: - SnapOverlay(QWidget *w) - : QWidget(w) - { - setAttribute(Qt::WA_TransparentForMouseEvents); - - if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(w)) { - connect(area->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(update())); - connect(area->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(update())); - area->viewport()->installEventFilter(this); - } - } - void clear(Qt::Orientation o) - { - m_snap[o].clear(); - update(); - } - - void set(Qt::Orientation o, qreal first, qreal step) - { - m_snap[o] = QList<qreal>() << -Q_INFINITY << first << step; - update(); - } - - void set(Qt::Orientation o, const QList<qreal> &list) - { - m_snap[o] = list; - update(); - } - -protected: - bool eventFilter(QObject *o, QEvent *e) - { - if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(parentWidget())) { - if (area->viewport() == o) { - if (e->type() == QEvent::Move || e->type() == QEvent::Resize) { - setGeometry(area->viewport()->rect()); - } - } - } - return false; - } - - void paintEvent(QPaintEvent *e) - { - if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(parentWidget())) { - int dx = area->horizontalScrollBar()->value(); - int dy = area->verticalScrollBar()->value(); - - QPainter paint(this); - paint.fillRect(e->rect(), Qt::transparent); - paint.setPen(QPen(Qt::red, 9)); - - if (m_snap[Qt::Horizontal].isEmpty()) { - } else if (m_snap[Qt::Horizontal][0] == -Q_INFINITY) { - int start = int(m_snap[Qt::Horizontal][1]); - int step = int(m_snap[Qt::Horizontal][2]); - if (step > 0) { - for (int i = start; i < area->horizontalScrollBar()->maximum(); i += step) - paint.drawPoint(i - dx, 5); - } - } else { - foreach (qreal r, m_snap[Qt::Horizontal]) - paint.drawPoint(int(r) - dx, 5); - } - paint.setPen(QPen(Qt::green, 9)); - if (m_snap[Qt::Vertical].isEmpty()) { - } else if (m_snap[Qt::Vertical][0] == -Q_INFINITY) { - int start = int(m_snap[Qt::Vertical][1]); - int step = int(m_snap[Qt::Vertical][2]); - if (step > 0) { - for (int i = start; i < area->verticalScrollBar()->maximum(); i += step) - paint.drawPoint(5, i - dy); - } - } else { - foreach (qreal r, m_snap[Qt::Vertical]) - paint.drawPoint(5, int(r) - dy); - } - } - } - -private: - QMap<Qt::Orientation, QList<qreal> > m_snap; -}; - -struct MetricItem -{ - QScrollerProperties::ScrollMetric metric; - const char *name; - int scaling; - const char *unit; - QVariant min, max; - QVariant step; -}; - -class MetricItemUpdater : public QObject -{ - Q_OBJECT -public: - MetricItemUpdater(MetricItem *item) - : m_item(item) - , m_widget(0) - , m_slider(0) - , m_combo(0) - , m_valueLabel(0) - { - m_frameRateType = QVariant::fromValue(QScrollerProperties::Standard).userType(); - m_overshootPolicyType = QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable).userType(); - - if (m_item->min.type() == QVariant::EasingCurve) { - m_combo = new QComboBox(); - m_combo->addItem("OutQuad", QEasingCurve::OutQuad); - m_combo->addItem("OutCubic", QEasingCurve::OutCubic); - m_combo->addItem("OutQuart", QEasingCurve::OutQuart); - m_combo->addItem("OutQuint", QEasingCurve::OutQuint); - m_combo->addItem("OutExpo", QEasingCurve::OutExpo); - m_combo->addItem("OutSine", QEasingCurve::OutSine); - m_combo->addItem("OutCirc", QEasingCurve::OutCirc); - } else if (m_item->min.userType() == m_frameRateType) { - m_combo = new QComboBox(); - m_combo->addItem("Standard", QScrollerProperties::Standard); - m_combo->addItem("60 FPS", QScrollerProperties::Fps60); - m_combo->addItem("30 FPS", QScrollerProperties::Fps30); - m_combo->addItem("20 FPS", QScrollerProperties::Fps20); - } else if (m_item->min.userType() == m_overshootPolicyType) { - m_combo = new QComboBox(); - m_combo->addItem("When Scrollable", QScrollerProperties::OvershootWhenScrollable); - m_combo->addItem("Always On", QScrollerProperties::OvershootAlwaysOn); - m_combo->addItem("Always Off", QScrollerProperties::OvershootAlwaysOff); - } else { - m_slider = new QSlider(Qt::Horizontal); - m_slider->setSingleStep(1); - m_slider->setMinimum(-1); - m_slider->setMaximum(qRound((m_item->max.toReal() - m_item->min.toReal()) / m_item->step.toReal())); - m_slider->setValue(-1); - m_valueLabel = new QLabel(); - } - m_nameLabel = new QLabel(QLatin1String(m_item->name)); - if (m_item->unit && m_item->unit[0]) - m_nameLabel->setText(m_nameLabel->text() + QLatin1String(" [") + QLatin1String(m_item->unit) + QLatin1String("]")); - m_resetButton = new QToolButton(); - m_resetButton->setText(QLatin1String("Reset")); - m_resetButton->setEnabled(false); - - connect(m_resetButton, SIGNAL(clicked()), this, SLOT(reset())); - if (m_slider) { - connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(controlChanged(int))); - m_slider->setMinimum(0); - } else if (m_combo) { - connect(m_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(controlChanged(int))); - } - } - - void setScroller(QWidget *widget) - { - m_widget = widget; - QScroller *scroller = QScroller::scroller(widget); - QScrollerProperties properties = QScroller::scroller(widget)->scrollerProperties(); - - if (m_slider) - m_slider->setEnabled(scroller); - if (m_combo) - m_combo->setEnabled(scroller); - m_nameLabel->setEnabled(scroller); - if (m_valueLabel) - m_valueLabel->setEnabled(scroller); - m_resetButton->setEnabled(scroller); - - if (!scroller) - return; - - m_default_value = properties.scrollMetric(m_item->metric); - valueChanged(m_default_value); - } - - QWidget *nameLabel() { return m_nameLabel; } - QWidget *valueLabel() { return m_valueLabel; } - QWidget *valueControl() { if (m_combo) return m_combo; else return m_slider; } - QWidget *resetButton() { return m_resetButton; } - -private slots: - void valueChanged(const QVariant &v) - { - m_value = v; - if (m_slider) { - switch (m_item->min.type()) { - case QMetaType::Float: - case QVariant::Double: { - m_slider->setValue(qRound((m_value.toReal() * m_item->scaling - m_item->min.toReal()) / m_item->step.toReal())); - break; - } - case QVariant::Int: { - m_slider->setValue(qRound((m_value.toInt() * m_item->scaling - m_item->min.toInt()) / m_item->step.toInt())); - break; - } - default: break; - } - } else if (m_combo) { - if (m_item->min.type() == QVariant::EasingCurve) { - m_combo->setCurrentIndex(m_combo->findData(v.toEasingCurve().type())); - } else if (m_item->min.userType() == m_overshootPolicyType) { - m_combo->setCurrentIndex(m_combo->findData(v.value<QScrollerProperties::OvershootPolicy>())); - } else if (m_item->min.userType() == m_frameRateType) { - m_combo->setCurrentIndex(m_combo->findData(v.value<QScrollerProperties::FrameRates>())); - } - } - } - - void controlChanged(int value) - { - bool combo = (m_combo && (sender() == m_combo)); - QString text; - - if (m_slider && !combo) { - switch (m_item->min.type()) { - case QMetaType::Float: - case QVariant::Double: { - qreal d = m_item->min.toReal() + qreal(value) * m_item->step.toReal(); - text = QString::number(d); - m_value = d / qreal(m_item->scaling); - break; - } - case QVariant::Int: { - int i = m_item->min.toInt() + qRound(qreal(value) * m_item->step.toReal()); - text = QString::number(i); - m_value = i / m_item->scaling; - break; - } - default: break; - } - } else if (m_combo && combo) { - if (m_item->min.type() == QVariant::EasingCurve) { - m_value = QVariant(QEasingCurve(static_cast<QEasingCurve::Type>(m_combo->itemData(value).toInt()))); - } else if (m_item->min.userType() == m_overshootPolicyType) { - m_value = QVariant::fromValue(static_cast<QScrollerProperties::OvershootPolicy>(m_combo->itemData(value).toInt())); - } else if (m_item->min.userType() == m_frameRateType) { - m_value = QVariant::fromValue(static_cast<QScrollerProperties::FrameRates>(m_combo->itemData(value).toInt())); - } - } - if (m_valueLabel) - m_valueLabel->setText(text); - if (m_widget && QScroller::scroller(m_widget)) { - QScrollerProperties properties = QScroller::scroller(m_widget)->scrollerProperties(); - properties.setScrollMetric(m_item->metric, m_value); - QScroller::scroller(m_widget)->setScrollerProperties(properties); - } - - m_resetButton->setEnabled(m_value != m_default_value); - } - - void reset() - { - QScrollerProperties properties = QScroller::scroller(m_widget)->scrollerProperties(); - properties.setScrollMetric(m_item->metric, m_value); - QScroller::scroller(m_widget)->setScrollerProperties(properties); - valueChanged(m_default_value); - } - -private: - MetricItem *m_item; - int m_frameRateType; - int m_overshootPolicyType; - - QWidget *m_widget; - QSlider *m_slider; - QComboBox *m_combo; - QLabel *m_nameLabel, *m_valueLabel; - QToolButton *m_resetButton; - - QVariant m_value, m_default_value; -}; - -#define METRIC(x) QScrollerProperties::x, #x - -MetricItem items[] = { - { METRIC(MousePressEventDelay), 1000, "ms", qreal(0), qreal(2000), qreal(10) }, - { METRIC(DragStartDistance), 1000, "mm", qreal(1), qreal(20), qreal(0.1) }, - { METRIC(DragVelocitySmoothingFactor), 1, "", qreal(0), qreal(1), qreal(0.1) }, - { METRIC(AxisLockThreshold), 1, "", qreal(0), qreal(1), qreal(0.01) }, - - { METRIC(ScrollingCurve), 1, "", QEasingCurve(), 0, 0 }, - { METRIC(DecelerationFactor), 1, "", qreal(0), qreal(3), qreal(0.01) }, - - { METRIC(MinimumVelocity), 1, "m/s", qreal(0), qreal(7), qreal(0.01) }, - { METRIC(MaximumVelocity), 1, "m/s", qreal(0), qreal(7), qreal(0.01) }, - { METRIC(MaximumClickThroughVelocity), 1, "m/s", qreal(0), qreal(7), qreal(0.01) }, - - { METRIC(AcceleratingFlickMaximumTime), 1000, "ms", qreal(100), qreal(5000), qreal(100) }, - { METRIC(AcceleratingFlickSpeedupFactor), 1, "", qreal(1), qreal(7), qreal(0.1) }, - - { METRIC(SnapPositionRatio), 1, "", qreal(0.1), qreal(0.9), qreal(0.1) }, - { METRIC(SnapTime), 1000, "ms", qreal(0), qreal(2000), qreal(10) }, - - { METRIC(OvershootDragResistanceFactor), 1, "", qreal(0), qreal(1), qreal(0.01) }, - { METRIC(OvershootDragDistanceFactor), 1, "", qreal(0), qreal(1), qreal(0.01) }, - { METRIC(OvershootScrollDistanceFactor), 1, "", qreal(0), qreal(1), qreal(0.01) }, - { METRIC(OvershootScrollTime), 1000, "ms", qreal(0), qreal(2000), qreal(10) }, - - { METRIC(HorizontalOvershootPolicy), 1, "", QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable), 0, 0 }, - { METRIC(VerticalOvershootPolicy), 1, "", QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable), 0, 0 }, - { METRIC(FrameRate), 1, "", QVariant::fromValue(QScrollerProperties::Standard), 0, 0 }, -}; - -#undef METRIC - -void SettingsWidget::addToGrid(QGridLayout *grid, QWidget *label, int widgetCount, ...) -{ - va_list args; - va_start(args, widgetCount); - - int rows = grid->rowCount(); - int cols = grid->columnCount(); - - if (label) { - if (m_smallscreen) - grid->addWidget(label, rows++, 0, 1, qMax(cols, widgetCount)); - else - grid->addWidget(label, rows, 0); - } - for (int i = 0; i < widgetCount; i++) { - if (QWidget *w = va_arg(args, QWidget *)) - grid->addWidget(w, rows, m_smallscreen ? i : i + 1); - } - va_end(args); -} - -SettingsWidget::SettingsWidget(bool smallscreen) - : QScrollArea() - , m_widget(0) - , m_snapoverlay(0) - , m_smallscreen(smallscreen) -{ - setWindowTitle(QLatin1String("Settings")); - QWidget *view = new QWidget(); - QVBoxLayout *layout = new QVBoxLayout(view); - QGroupBox *grp; - QGridLayout *grid; - - // GROUP: SCROLL METRICS - - grp = new QGroupBox(QLatin1String("Scroll Metrics")); - grid = new QGridLayout(); - grid->setVerticalSpacing(m_smallscreen ? 4 : 2); - - for (int i = 0; i < int(sizeof(items) / sizeof(items[0])); i++) { - MetricItemUpdater *u = new MetricItemUpdater(items + i); - u->setParent(this); - addToGrid(grid, u->nameLabel(), 3, u->valueControl(), u->valueLabel(), u->resetButton()); - m_metrics.append(u); - } - grp->setLayout(grid); - layout->addWidget(grp); - - // GROUP: SCROLL TO - - grp = new QGroupBox(QLatin1String("Scroll To")); - grid = new QGridLayout(); - grid->setVerticalSpacing(m_smallscreen ? 4 : 2); - - m_scrollx = new QSpinBox(); - m_scrolly = new QSpinBox(); - m_scrolltime = new QSpinBox(); - m_scrolltime->setRange(0, 10000); - m_scrolltime->setValue(1000); - m_scrolltime->setSuffix(QLatin1String(" ms")); - QPushButton *go = new QPushButton(QLatin1String("Go")); - connect(go, SIGNAL(clicked()), this, SLOT(scrollTo())); - connect(m_scrollx, SIGNAL(editingFinished()), this, SLOT(scrollTo())); - connect(m_scrolly, SIGNAL(editingFinished()), this, SLOT(scrollTo())); - connect(m_scrolltime, SIGNAL(editingFinished()), this, SLOT(scrollTo())); - grid->addWidget(new QLabel(QLatin1String("X:")), 0, 0); - grid->addWidget(m_scrollx, 0, 1); - grid->addWidget(new QLabel(QLatin1String("Y:")), 0, 2); - grid->addWidget(m_scrolly, 0, 3); - int row = smallscreen ? 1 : 0; - int col = smallscreen ? 0 : 4; - grid->addWidget(new QLabel(QLatin1String("in")), row, col++); - grid->addWidget(m_scrolltime, row, col++); - if (smallscreen) { - grid->addWidget(go, row, col + 1); - } else { - grid->addWidget(go, row, col); - grid->setColumnStretch(5, 1); - grid->setColumnStretch(6, 1); - } - grid->setColumnStretch(1, 1); - grid->setColumnStretch(3, 1); - grp->setLayout(grid); - layout->addWidget(grp); - - QLayout *snapbox = new QHBoxLayout(); - - // GROUP: SNAP POINTS X - - grp = new QGroupBox(QLatin1String("Snap Positions X")); - QBoxLayout *vbox = new QVBoxLayout(); - vbox->setSpacing(m_smallscreen ? 4 : 2); - m_snapx = new QComboBox(); - m_snapx->addItem(QLatin1String("No Snapping"), NoSnap); - m_snapx->addItem(QLatin1String("Snap to Interval"), SnapToInterval); - m_snapx->addItem(QLatin1String("Snap to List"), SnapToList); - connect(m_snapx, SIGNAL(currentIndexChanged(int)), this, SLOT(snapModeChanged(int))); - vbox->addWidget(m_snapx); - - m_snapxinterval = new QWidget(); - grid = new QGridLayout(); - grid->setVerticalSpacing(m_smallscreen ? 4 : 2); - m_snapxfirst = new QSpinBox(); - connect(m_snapxfirst, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged())); - grid->addWidget(new QLabel("First:"), 0, 0); - grid->addWidget(m_snapxfirst, 0, 1); - m_snapxstep = new QSpinBox(); - connect(m_snapxstep, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged())); - grid->addWidget(new QLabel("Interval:"), 0, 2); - grid->addWidget(m_snapxstep, 0, 3); - m_snapxinterval->setLayout(grid); - vbox->addWidget(m_snapxinterval); - m_snapxinterval->hide(); - - m_snapxlist = new QPlainTextEdit(); - m_snapxlist->setToolTip(QLatin1String("One snap position per line. Empty lines are ignored.")); - m_snapxlist->installEventFilter(this); - connect(m_snapxlist, SIGNAL(textChanged()), this, SLOT(snapPositionsChanged())); - vbox->addWidget(m_snapxlist); - m_snapxlist->hide(); - - vbox->addStretch(100); - grp->setLayout(vbox); - snapbox->addWidget(grp); - - // GROUP: SNAP POINTS Y - - grp = new QGroupBox(QLatin1String("Snap Positions Y")); - vbox = new QVBoxLayout(); - vbox->setSpacing(m_smallscreen ? 4 : 2); - m_snapy = new QComboBox(); - m_snapy->addItem(QLatin1String("No Snapping"), NoSnap); - m_snapy->addItem(QLatin1String("Snap to Interval"), SnapToInterval); - m_snapy->addItem(QLatin1String("Snap to List"), SnapToList); - connect(m_snapy, SIGNAL(currentIndexChanged(int)), this, SLOT(snapModeChanged(int))); - vbox->addWidget(m_snapy); - - m_snapyinterval = new QWidget(); - grid = new QGridLayout(); - grid->setVerticalSpacing(m_smallscreen ? 4 : 2); - m_snapyfirst = new QSpinBox(); - connect(m_snapyfirst, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged())); - grid->addWidget(new QLabel("First:"), 0, 0); - grid->addWidget(m_snapyfirst, 0, 1); - m_snapystep = new QSpinBox(); - connect(m_snapystep, SIGNAL(valueChanged(int)), this, SLOT(snapPositionsChanged())); - grid->addWidget(new QLabel("Interval:"), 0, 2); - grid->addWidget(m_snapystep, 0, 3); - m_snapyinterval->setLayout(grid); - vbox->addWidget(m_snapyinterval); - m_snapyinterval->hide(); - - m_snapylist = new QPlainTextEdit(); - m_snapylist->setToolTip(QLatin1String("One snap position per line. Empty lines are ignored.")); - m_snapylist->installEventFilter(this); - connect(m_snapylist, SIGNAL(textChanged()), this, SLOT(snapPositionsChanged())); - vbox->addWidget(m_snapylist); - m_snapylist->hide(); - - vbox->addStretch(100); - grp->setLayout(vbox); - snapbox->addWidget(grp); - - layout->addLayout(snapbox); - - layout->addStretch(100); - setWidget(view); - setWidgetResizable(true); -} - -void SettingsWidget::setScroller(QWidget *widget) -{ - delete m_snapoverlay; - if (m_widget) - m_widget->removeEventFilter(this); - QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(widget); - if (area) - widget = area->viewport(); - m_widget = widget; - m_widget->installEventFilter(this); - m_snapoverlay = new SnapOverlay(area); - QScrollerProperties properties = QScroller::scroller(widget)->scrollerProperties(); - - QMutableListIterator<MetricItemUpdater *> it(m_metrics); - while (it.hasNext()) - it.next()->setScroller(widget); - - if (!widget) - return; - - updateScrollRanges(); -} - -bool SettingsWidget::eventFilter(QObject *o, QEvent *e) -{ - if (o == m_widget && e->type() == QEvent::Resize) - updateScrollRanges(); - return false; -} - -void SettingsWidget::updateScrollRanges() -{ - QScrollPrepareEvent spe(QPoint(0, 0)); - QApplication::sendEvent(m_widget, &spe); - - QSizeF vp = spe.viewportSize(); - QRectF maxc = spe.contentPosRange(); - - m_scrollx->setRange(qRound(-vp.width()), qRound(maxc.width() + vp.width())); - m_scrolly->setRange(qRound(-vp.height()), qRound(maxc.height() + vp.height())); - - m_snapxfirst->setRange(maxc.left(), maxc.right()); - m_snapxstep->setRange(0, maxc.width()); - m_snapyfirst->setRange(maxc.top(), maxc.bottom()); - m_snapystep->setRange(0, maxc.height()); -} - -void SettingsWidget::scrollTo() -{ - if (QApplication::activePopupWidget()) - return; - if ((sender() == m_scrollx) && !m_scrollx->hasFocus()) - return; - if ((sender() == m_scrolly) && !m_scrolly->hasFocus()) - return; - if ((sender() == m_scrolltime) && !m_scrolltime->hasFocus()) - return; - - if (QScroller *scroller = QScroller::scroller(m_widget)) - scroller->scrollTo(QPointF(m_scrollx->value(), m_scrolly->value()), m_scrolltime->value()); -} - -void SettingsWidget::snapModeChanged(int mode) -{ - if (sender() == m_snapx) { - m_snapxmode = static_cast<SnapMode>(mode); - m_snapxinterval->setVisible(mode == SnapToInterval); - m_snapxlist->setVisible(mode == SnapToList); - snapPositionsChanged(); - } else if (sender() == m_snapy) { - m_snapymode = static_cast<SnapMode>(mode); - m_snapyinterval->setVisible(mode == SnapToInterval); - m_snapylist->setVisible(mode == SnapToList); - snapPositionsChanged(); - } -} - -void SettingsWidget::snapPositionsChanged() -{ - QScroller *s = QScroller::scroller(m_widget); - if (!s) - return; - - switch (m_snapxmode) { - case NoSnap: - s->setSnapPositionsX(QList<qreal>()); - m_snapoverlay->clear(Qt::Horizontal); - break; - case SnapToInterval: - s->setSnapPositionsX(m_snapxfirst->value(), m_snapxstep->value()); - m_snapoverlay->set(Qt::Horizontal, m_snapxfirst->value(), m_snapxstep->value()); - break; - case SnapToList: - s->setSnapPositionsX(toPositionList(m_snapxlist, m_snapxfirst->minimum(), m_snapxfirst->maximum())); - m_snapoverlay->set(Qt::Horizontal, toPositionList(m_snapxlist, m_snapxfirst->minimum(), m_snapxfirst->maximum())); - break; - } - switch (m_snapymode) { - case NoSnap: - s->setSnapPositionsY(QList<qreal>()); - m_snapoverlay->clear(Qt::Vertical); - break; - case SnapToInterval: - s->setSnapPositionsY(m_snapyfirst->value(), m_snapystep->value()); - m_snapoverlay->set(Qt::Vertical, m_snapyfirst->value(), m_snapystep->value()); - break; - case SnapToList: - s->setSnapPositionsY(toPositionList(m_snapylist, m_snapyfirst->minimum(), m_snapyfirst->maximum())); - m_snapoverlay->set(Qt::Vertical, toPositionList(m_snapylist, m_snapyfirst->minimum(), m_snapyfirst->maximum())); - break; - } -} - -QList<qreal> SettingsWidget::toPositionList(QPlainTextEdit *list, int vmin, int vmax) -{ - QList<qreal> snaps; - QList<QTextEdit::ExtraSelection> extrasel; - QTextEdit::ExtraSelection uline; - uline.format.setUnderlineColor(Qt::red); - uline.format.setUnderlineStyle(QTextCharFormat::WaveUnderline); - int line = 0; - - foreach (const QString &str, list->toPlainText().split(QLatin1Char('\n'))) { - ++line; - if (str.isEmpty()) - continue; - bool ok = false; - double d = str.toDouble(&ok); - if (ok && d >= vmin && d <= vmax) { - snaps << d; - } else { - QTextEdit::ExtraSelection esel = uline; - esel.cursor = QTextCursor(list->document()->findBlockByLineNumber(line - 1)); - esel.cursor.select(QTextCursor::LineUnderCursor); - extrasel << esel; - } - } - list->setExtraSelections(extrasel); - return snaps; -} - -#include "settingswidget.moc" diff --git a/examples/scroller/plot/settingswidget.h b/examples/scroller/plot/settingswidget.h deleted file mode 100644 index fc0acff..0000000 --- a/examples/scroller/plot/settingswidget.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SETTINGSWIDGET_H -#define SETTINGSWIDGET_H - -#include <QScrollArea> - -QT_BEGIN_NAMESPACE -class QScroller; -class QGridLayout; -class QSpinBox; -class QComboBox; -class QCheckBox; -class QPlainTextEdit; -QT_END_NAMESPACE - -class MetricItemUpdater; -class SnapOverlay; - -class SettingsWidget : public QScrollArea -{ - Q_OBJECT - -public: - SettingsWidget(bool smallscreen = false); - - void setScroller(QWidget *widget); - -protected: - bool eventFilter(QObject *, QEvent *); - -private slots: - void scrollTo(); - void snapModeChanged(int); - void snapPositionsChanged(); - -private: - enum SnapMode { - NoSnap, - SnapToInterval, - SnapToList - }; - - void addToGrid(QGridLayout *grid, QWidget *label, int widgetCount, ...); - QList<qreal> toPositionList(QPlainTextEdit *list, int vmin, int vmax); - void updateScrollRanges(); - - QWidget *m_widget; - QSpinBox *m_scrollx, *m_scrolly, *m_scrolltime; - QList<MetricItemUpdater *> m_metrics; - - SnapMode m_snapxmode; - QComboBox *m_snapx; - QWidget *m_snapxinterval; - QPlainTextEdit *m_snapxlist; - QSpinBox *m_snapxfirst; - QSpinBox *m_snapxstep; - - SnapMode m_snapymode; - QComboBox *m_snapy; - QWidget *m_snapyinterval; - QPlainTextEdit *m_snapylist; - QSpinBox *m_snapyfirst; - QSpinBox *m_snapystep; - SnapOverlay *m_snapoverlay; - - bool m_smallscreen; -}; - -#endif diff --git a/examples/scroller/scroller.pro b/examples/scroller/scroller.pro deleted file mode 100644 index 9a9991a..0000000 --- a/examples/scroller/scroller.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = graphicsview - -contains(QT_CONFIG, webkit):SUBDIRS += plot wheel - -# install -sources.files = *.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/scroller -INSTALLS += sources - -symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/scroller/wheel/main.cpp b/examples/scroller/wheel/main.cpp deleted file mode 100644 index 4205baf..0000000 --- a/examples/scroller/wheel/main.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> -#include <qmath.h> - -#include "wheelwidget.h" - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - MainWindow(bool touch) - : QMainWindow() - { - makeSlotMachine(touch); - setCentralWidget(m_slotMachine); - } - - void makeSlotMachine(bool touch) - { - if (QApplication::desktop()->width() > 1000) { - QFont f = font(); - f.setPointSize(f.pointSize() * 2); - setFont(f); - } - - m_slotMachine = new QWidget(this); - QGridLayout *grid = new QGridLayout(m_slotMachine); - grid->setSpacing(20); - - QStringList colors; - colors << "Red" << "Magenta" << "Peach" << "Orange" << "Yellow" << "Citro" << "Green" << "Cyan" << "Blue" << "Violet"; - - m_wheel1 = new StringWheelWidget(touch); - m_wheel1->setItems( colors ); - grid->addWidget( m_wheel1, 0, 0 ); - - m_wheel2 = new StringWheelWidget(touch); - m_wheel2->setItems( colors ); - grid->addWidget( m_wheel2, 0, 1 ); - - m_wheel3 = new StringWheelWidget(touch); - m_wheel3->setItems( colors ); - grid->addWidget( m_wheel3, 0, 2 ); - - QPushButton *shakeButton = new QPushButton(tr("Shake")); - connect(shakeButton, SIGNAL(clicked()), this, SLOT(rotateRandom())); - - grid->addWidget( shakeButton, 1, 0, 1, 3 ); - } - -private slots: - void rotateRandom() - { - m_wheel1->scrollTo(m_wheel1->currentIndex() + (qrand() % 200)); - m_wheel2->scrollTo(m_wheel2->currentIndex() + (qrand() % 200)); - m_wheel3->scrollTo(m_wheel3->currentIndex() + (qrand() % 200)); - } - -private: - QWidget *m_slotMachine; - - StringWheelWidget *m_wheel1; - StringWheelWidget *m_wheel2; - StringWheelWidget *m_wheel3; -}; - -int main(int argc, char **argv) -{ - QApplication a(argc, argv); - bool touch = a.arguments().contains(QLatin1String("--touch")); - MainWindow mw(touch); -#ifdef Q_WS_S60 - mw.showMaximized(); -#else - mw.show(); -#endif -#ifdef Q_WS_MAC - mw.raise(); -#endif - return a.exec(); -} - -#include "main.moc" diff --git a/examples/scroller/wheel/wheel.pro b/examples/scroller/wheel/wheel.pro deleted file mode 100644 index 48fe171..0000000 --- a/examples/scroller/wheel/wheel.pro +++ /dev/null @@ -1,11 +0,0 @@ -HEADERS = wheelwidget.h -SOURCES = wheelwidget.cpp \ - main.cpp - -QT += webkit - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/scroller/wheel -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS wheel.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/scroller/wheel -INSTALLS += target sources diff --git a/examples/scroller/wheel/wheelwidget.cpp b/examples/scroller/wheel/wheelwidget.cpp deleted file mode 100644 index 10eaefb..0000000 --- a/examples/scroller/wheel/wheelwidget.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> - -#include "wheelwidget.h" - -#define WHEEL_SCROLL_OFFSET 50000.0 - -AbstractWheelWidget::AbstractWheelWidget(bool touch, QWidget *parent) - : QWidget(parent) - , m_currentItem(0) - , m_itemOffset(0) -{ -// ![0] - QScroller::grabGesture(this, touch ? QScroller::TouchGesture : QScroller::LeftMouseButtonGesture); -// ![0] -} - -AbstractWheelWidget::~AbstractWheelWidget() -{ } - -int AbstractWheelWidget::currentIndex() const -{ - return m_currentItem; -} - -void AbstractWheelWidget::setCurrentIndex(int index) -{ - if (index >= 0 && index < itemCount()) { - m_currentItem = index; - m_itemOffset = 0; - update(); - } -} - -bool AbstractWheelWidget::event(QEvent *e) -{ - switch (e->type()) { -// ![1] - case QEvent::ScrollPrepare: - { - // We set the snap positions as late as possible so that we are sure - // we get the correct itemHeight - QScroller *scroller = QScroller::scroller(this); - scroller->setSnapPositionsY( WHEEL_SCROLL_OFFSET, itemHeight() ); - - QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e); - se->setViewportSize(QSizeF(size())); - // we claim a huge scrolling area and a huge content position and - // hope that the user doesn't notice that the scroll area is restricted - se->setContentPosRange(QRectF(0.0, 0.0, 0.0, WHEEL_SCROLL_OFFSET * 2)); - se->setContentPos(QPointF(0.0, WHEEL_SCROLL_OFFSET + m_currentItem * itemHeight() + m_itemOffset)); - se->accept(); - return true; - } -// ![1] -// ![2] - case QEvent::Scroll: - { - QScrollEvent *se = static_cast<QScrollEvent *>(e); - - qreal y = se->contentPos().y(); - int iy = y - WHEEL_SCROLL_OFFSET; - int ih = itemHeight(); - -// ![2] - - // -- calculate the current item position and offset and redraw the widget - int ic = itemCount(); - if (ic>0) { - m_currentItem = iy / ih % ic; - m_itemOffset = iy % ih; - - // take care when scrolling backwards. Modulo returns negative numbers - if (m_itemOffset < 0) { - m_itemOffset += ih; - m_currentItem--; - } - - if (m_currentItem < 0) - m_currentItem += ic; - } - // -- repaint - update(); - - se->accept(); - return true; - } - default: - return QWidget::event(e); - } - return true; -} - -void AbstractWheelWidget::paintEvent(QPaintEvent* event) -{ - Q_UNUSED( event ); - - // -- first calculate size and position. - int w = width(); - int h = height(); - - QPainter painter(this); - QPalette palette = QApplication::palette(); - QPalette::ColorGroup colorGroup = isEnabled() ? QPalette::Active : QPalette::Disabled; - - // linear gradient brush - QLinearGradient grad(0.5, 0, 0.5, 1.0); - grad.setColorAt(0, palette.color(colorGroup, QPalette::ButtonText)); - grad.setColorAt(0.2, palette.color(colorGroup, QPalette::Button)); - grad.setColorAt(0.8, palette.color(colorGroup, QPalette::Button)); - grad.setColorAt(1.0, palette.color(colorGroup, QPalette::ButtonText)); - grad.setCoordinateMode( QGradient::ObjectBoundingMode ); - QBrush gBrush( grad ); - - // paint a border and background - painter.setPen(palette.color(colorGroup, QPalette::ButtonText)); - painter.setBrush(gBrush); - // painter.setBrushOrigin( QPointF( 0.0, 0.0 ) ); - painter.drawRect( 0, 0, w-1, h-1 ); - - // paint inner border - painter.setPen(palette.color(colorGroup, QPalette::Button)); - painter.setBrush(Qt::NoBrush); - painter.drawRect( 1, 1, w-3, h-3 ); - - // paint the items - painter.setClipRect( QRect( 3, 3, w-6, h-6 ) ); - painter.setPen(palette.color(colorGroup, QPalette::ButtonText)); - - int iH = itemHeight(); - int iC = itemCount(); - if (iC > 0) { - - m_itemOffset = m_itemOffset % iH; - - for (int i=-h/2/iH; i<=h/2/iH+1; i++) { - - int itemNum = m_currentItem + i; - while (itemNum < 0) - itemNum += iC; - while (itemNum >= iC) - itemNum -= iC; - - paintItem(&painter, itemNum, QRect(6, h/2 +i*iH - m_itemOffset - iH/2, w-6, iH )); - } - } - - // draw a transparent bar over the center - QColor highlight = palette.color(colorGroup, QPalette::Highlight); - highlight.setAlpha(150); - - QLinearGradient grad2(0.5, 0, 0.5, 1.0); - grad2.setColorAt(0, highlight); - grad2.setColorAt(1.0, highlight.lighter()); - grad2.setCoordinateMode( QGradient::ObjectBoundingMode ); - QBrush gBrush2( grad2 ); - - QLinearGradient grad3(0.5, 0, 0.5, 1.0); - grad3.setColorAt(0, highlight); - grad3.setColorAt(1.0, highlight.darker()); - grad3.setCoordinateMode( QGradient::ObjectBoundingMode ); - QBrush gBrush3( grad3 ); - - painter.fillRect( QRect( 0, h/2 - iH/2, w, iH/2 ), gBrush2 ); - painter.fillRect( QRect( 0, h/2, w, iH/2 ), gBrush3 ); -} - -/*! - Rotates the wheel widget to a given index. - You can also give an index greater than itemCount or less than zero in which - case the wheel widget will scroll in the given direction and end up with - (index % itemCount) -*/ -void AbstractWheelWidget::scrollTo(int index) -{ - QScroller *scroller = QScroller::scroller(this); - - scroller->scrollTo(QPointF(0, WHEEL_SCROLL_OFFSET + index * itemHeight()), 5000); -} - -/*! - \class StringWheelWidget - \brief The StringWheelWidget class is an implementation of the AbstractWheelWidget class that draws QStrings as items. - \sa AbstractWheelWidget -*/ - -StringWheelWidget::StringWheelWidget(bool touch) - : AbstractWheelWidget(touch) -{ } - -QStringList StringWheelWidget::items() const -{ - return m_items; -} - -void StringWheelWidget::setItems( const QStringList &items ) -{ - m_items = items; - if (m_currentItem >= items.count()) - m_currentItem = items.count()-1; - update(); -} - - -QSize StringWheelWidget::sizeHint() const -{ - // determine font size - QFontMetrics fm(font()); - - return QSize( fm.width("m") * 10 + 6, fm.height() * 7 + 6 ); -} - -QSize StringWheelWidget::minimumSizeHint() const -{ - QFontMetrics fm(font()); - - return QSize( fm.width("m") * 5 + 6, fm.height() * 3 + 6 ); -} - -void StringWheelWidget::paintItem(QPainter* painter, int index, const QRect &rect) -{ - painter->drawText(rect, Qt::AlignCenter, m_items.at(index)); -} - -int StringWheelWidget::itemHeight() const -{ - QFontMetrics fm(font()); - return fm.height(); -} - -int StringWheelWidget::itemCount() const -{ - return m_items.count(); -} - - diff --git a/examples/scroller/wheel/wheelwidget.h b/examples/scroller/wheel/wheelwidget.h deleted file mode 100644 index 96dcebf..0000000 --- a/examples/scroller/wheel/wheelwidget.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WHEELWIDGET_H -#define WHEELWIDGET_H - -#include <QWidget> -#include <QStringList> - -QT_BEGIN_NAMESPACE -class QPainter; -class QRect; -QT_END_NAMESPACE - -class AbstractWheelWidget : public QWidget { - Q_OBJECT - -public: - AbstractWheelWidget(bool touch, QWidget *parent = 0); - virtual ~AbstractWheelWidget(); - - int currentIndex() const; - void setCurrentIndex(int index); - - bool event(QEvent*); - void paintEvent(QPaintEvent *e); - virtual void paintItem(QPainter* painter, int index, const QRect &rect) = 0; - - virtual int itemHeight() const = 0; - virtual int itemCount() const = 0; - -public slots: - void scrollTo(int index); - -signals: - void stopped(int index); - -protected: - int m_currentItem; - int m_itemOffset; // 0-itemHeight() - qreal m_lastY; -}; - - -class StringWheelWidget : public AbstractWheelWidget { - Q_OBJECT - -public: - StringWheelWidget(bool touch); - - QStringList items() const; - void setItems( const QStringList &items ); - - QSize sizeHint() const; - QSize minimumSizeHint() const; - - void paintItem(QPainter* painter, int index, const QRect &rect); - - int itemHeight() const; - int itemCount() const; - -private: - QStringList m_items; -}; - -#endif // WHEELWIDGET_H diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index fbb08fa..a8cf5f1 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -231,8 +231,6 @@ QT_BEGIN_NAMESPACE \value WinIdChange The window system identifer for this native widget has changed \value Gesture A gesture was triggered (QGestureEvent) \value GestureOverride A gesture override was triggered (QGestureEvent) - \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent) - \value Scroll The object needs to scroll to the supplied position (QScrollEvent) User events should have values between \c User and \c{MaxUser}: diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index c9d311a..c151c5e 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -288,9 +288,6 @@ public: Gesture = 198, GestureOverride = 202, #endif - ScrollPrepare = 204, - Scroll = 205, - // 512 reserved for Qt Jambi's MetaCall event // 513 reserved for Qt Jambi's DeleteOnMainThread event diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index d671496..0bf85c6 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -62,9 +62,6 @@ #include <qaccessible.h> #endif #include <private/qsoftkeymanager_p.h> -#ifndef QT_NO_GESTURE -# include <qscroller.h> -#endif QT_BEGIN_NAMESPACE @@ -194,40 +191,6 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index } } -#ifndef QT_NO_GESTURES - -// stores and restores the selection and current item when flicking -void QAbstractItemViewPrivate::_q_scrollerStateChanged() -{ - Q_Q(QAbstractItemView); - - if (QScroller *scroller = QScroller::scroller(viewport)) { - switch (scroller->state()) { - case QScroller::Pressed: - // store the current selection in case we start scrolling - if (q->selectionModel()) { - oldSelection = q->selectionModel()->selection(); - oldCurrent = q->selectionModel()->currentIndex(); - } - break; - - case QScroller::Dragging: - // restore the old selection if we really start scrolling - if (q->selectionModel()) { - q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect); - q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate); - } - // fall through - - default: - oldSelection = QItemSelection(); - oldCurrent = QModelIndex(); - break; - } - } -} - -#endif // QT_NO_GESTURES /*! \class QAbstractItemView @@ -1662,13 +1625,6 @@ bool QAbstractItemView::viewportEvent(QEvent *event) case QEvent::WindowDeactivate: d->viewport->update(); break; - case QEvent::ScrollPrepare: - executeDelayedItemsLayout(); -#ifndef QT_NO_GESTURES - connect(QScroller::scroller(d->viewport), SIGNAL(stateChanged(QScroller::State)), this, SLOT(_q_scrollerStateChanged()), Qt::UniqueConnection); -#endif - break; - default: break; } diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h index f11f209..7043a5f 100644 --- a/src/gui/itemviews/qabstractitemview.h +++ b/src/gui/itemviews/qabstractitemview.h @@ -359,9 +359,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed()) Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged()) Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged()) -#ifndef QT_NO_GESTURES - Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged()) -#endif friend class QTreeViewPrivate; // needed to compile with MSVC friend class QAccessibleItemRow; diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 6041e5e..d5a0d37 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -114,7 +114,6 @@ public: virtual void _q_modelDestroyed(); virtual void _q_layoutChanged(); void _q_headerDataChanged() { doDelayedItemsLayout(); } - void _q_scrollerStateChanged(); void fetchMore(); @@ -415,12 +414,6 @@ public: QAbstractItemView::ScrollMode verticalScrollMode; QAbstractItemView::ScrollMode horizontalScrollMode; -#ifndef QT_NO_GESTURES - // the selection before the last mouse down. In case we have to restore it for scrolling - QItemSelection oldSelection; - QModelIndex oldCurrent; -#endif - bool currentIndexSet; bool wrapItemText; diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 20542ea..577d93b 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -2018,15 +2018,12 @@ void qt_init(QApplicationPrivate *priv, int, (PtrXRRRootToScreen) xrandrLib.resolve("XRRRootToScreen"); X11->ptrXRRQueryExtension = (PtrXRRQueryExtension) xrandrLib.resolve("XRRQueryExtension"); - X11->ptrXRRSizes = - (PtrXRRSizes) xrandrLib.resolve("XRRSizes"); } # else X11->ptrXRRSelectInput = XRRSelectInput; X11->ptrXRRUpdateConfiguration = XRRUpdateConfiguration; X11->ptrXRRRootToScreen = XRRRootToScreen; X11->ptrXRRQueryExtension = XRRQueryExtension; - X11->ptrXRRSizes = XRRSizes; # endif if (X11->ptrXRRQueryExtension diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 277a5e8..807c385 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4629,223 +4629,4 @@ const QGestureEventPrivate *QGestureEvent::d_func() const #endif // QT_NO_GESTURES -/*! - \class QScrollPrepareEvent - \since 4.8 - \ingroup events - - \brief The QScrollPrepareEvent class is send in preparation of a scrolling. - - The scroll prepare event is send before scrolling (usually by QScroller) is started. - The object receiving this event should set viewportSize, maxContentPos and contentPos. - It also should accept this event to indicate that scrolling should be started. - - It is not guaranteed that a QScrollEvent will be send after an acceepted - QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0). - - \sa QScrollEvent, QScroller -*/ - -/*! - Creates new QScrollPrepareEvent - The \a startPos is the position of a touch or mouse event that started the scrolling. -*/ -QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos) - : QEvent(QEvent::ScrollPrepare) -{ - d = reinterpret_cast<QEventPrivate *>(new QScrollPrepareEventPrivate()); - d_func()->startPos = startPos; -} - -/*! - Destroys QScrollEvent. -*/ -QScrollPrepareEvent::~QScrollPrepareEvent() -{ - delete reinterpret_cast<QScrollPrepareEventPrivate *>(d); -} - -/*! - Returns the position of the touch or mouse event that started the scrolling. -*/ -QPointF QScrollPrepareEvent::startPos() const -{ - return d_func()->startPos; -} - -/*! - Returns size of the area that is to be scrolled as set by setViewportSize - - \sa setViewportSize() -*/ -QSizeF QScrollPrepareEvent::viewportSize() const -{ - return d_func()->viewportSize; -} - -/*! - Returns the range of coordinates for the content as set by setContentPosRange(). -*/ -QRectF QScrollPrepareEvent::contentPosRange() const -{ - return d_func()->contentPosRange; -} - -/*! - Returns the current position of the content as set by setContentPos. -*/ -QPointF QScrollPrepareEvent::contentPos() const -{ - return d_func()->contentPos; -} - - -/*! - Sets the size of the area that is to be scrolled to \a size. - - \sa viewportSize() -*/ -void QScrollPrepareEvent::setViewportSize(const QSizeF &size) -{ - d_func()->viewportSize = size; -} - -/*! - Sets the range of content coordinates to \a rect. - - \sa contentPosRange() -*/ -void QScrollPrepareEvent::setContentPosRange(const QRectF &rect) -{ - d_func()->contentPosRange = rect; -} - -/*! - Sets the current content position to \a pos. - - \sa contentPos() -*/ -void QScrollPrepareEvent::setContentPos(const QPointF &pos) -{ - d_func()->contentPos = pos; -} - - -/*! - \internal -*/ -QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() -{ - return reinterpret_cast<QScrollPrepareEventPrivate *>(d); -} - -/*! - \internal -*/ -const QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() const -{ - return reinterpret_cast<const QScrollPrepareEventPrivate *>(d); -} - -/*! - \class QScrollEvent - \since 4.8 - \ingroup events - - \brief The QScrollEvent class is send when scrolling. - - The scroll event is send to indicate that the receiver should be scrolled. - Usually the receiver should be something visual like QWidget or QGraphicsObject. - - Some care should be taken that no conflicting QScrollEvents are sent from two - sources. Using QScroller::scrollTo is save however. - - \sa QScrollPrepareEvent, QScroller -*/ - -/*! - \enum QScrollEvent::ScrollState - - This enum describes the states a scroll event can have. - - \value ScrollStarted Set for the first scroll event of a scroll activity. - - \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity. - - \value ScrollFinished Set for the last scroll event of a scroll activity. - - \sa QScrollEvent::scrollState() -*/ - -/*! - Creates a new QScrollEvent - \a contentPos is the new content position, \a overshootDistance is the - new overshoot distance while \a scrollState indicates if this scroll - event is the first one, the last one or some event in between. -*/ -QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState) - : QEvent(QEvent::Scroll) -{ - d = reinterpret_cast<QEventPrivate *>(new QScrollEventPrivate()); - d_func()->contentPos = contentPos; - d_func()->overshoot= overshootDistance; - d_func()->state = scrollState; -} - -/*! - Destroys QScrollEvent. -*/ -QScrollEvent::~QScrollEvent() -{ - delete reinterpret_cast<QScrollEventPrivate *>(d); -} - -/*! - Returns the new scroll position. -*/ -QPointF QScrollEvent::contentPos() const -{ - return d_func()->contentPos; -} - -/*! - Returns the new overshoot distance. - See QScroller for an explanation of the term overshoot. - - \sa QScroller -*/ -QPointF QScrollEvent::overshootDistance() const -{ - return d_func()->overshoot; -} - -/*! - Returns the current scroll state as a combination of ScrollStateFlag values. - ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity. - Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent. - All other scroll events in between will have their state set to ScrollUpdated. - - A widget could for example revert selections when scrolling is started and stopped. -*/ -QScrollEvent::ScrollState QScrollEvent::scrollState() const -{ - return d_func()->state; -} - -/*! - \internal -*/ -QScrollEventPrivate *QScrollEvent::d_func() -{ - return reinterpret_cast<QScrollEventPrivate *>(d); -} - -/*! - \internal -*/ -const QScrollEventPrivate *QScrollEvent::d_func() const -{ - return reinterpret_cast<const QScrollEventPrivate *>(d); -} - QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 93c2bc5..830f037 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -889,52 +889,6 @@ private: }; #endif // QT_NO_GESTURES -class QScrollPrepareEventPrivate; -class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent -{ -public: - QScrollPrepareEvent(const QPointF &startPos); - ~QScrollPrepareEvent(); - - QPointF startPos() const; - - QSizeF viewportSize() const; - QRectF contentPosRange() const; - QPointF contentPos() const; - - void setViewportSize(const QSizeF &size); - void setContentPosRange(const QRectF &rect); - void setContentPos(const QPointF &pos); - -private: - QScrollPrepareEventPrivate *d_func(); - const QScrollPrepareEventPrivate *d_func() const; -}; - - -class QScrollEventPrivate; -class Q_GUI_EXPORT QScrollEvent : public QEvent -{ -public: - enum ScrollState - { - ScrollStarted, - ScrollUpdated, - ScrollFinished - }; - - QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState); - ~QScrollEvent(); - - QPointF contentPos() const; - QPointF overshootDistance() const; - ScrollState scrollState() const; - -private: - QScrollEventPrivate *d_func(); - const QScrollEventPrivate *d_func() const; -}; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index b79f372..36655e8 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -186,34 +186,6 @@ public: #endif }; - -class QScrollPrepareEventPrivate -{ -public: - inline QScrollPrepareEventPrivate() - : target(0) - { - } - - QObject* target; - QPointF startPos; - QSizeF viewportSize; - QRectF contentPosRange; - QPointF contentPos; -}; - -class QScrollEventPrivate -{ -public: - inline QScrollEventPrivate() - { - } - - QPointF contentPos; - QPointF overshoot; - QScrollEvent::ScrollState state; -}; - QT_END_NAMESPACE #endif // QEVENT_P_H diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index 69079cf..8ab129c 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -226,7 +226,6 @@ typedef void (*PtrXRRSelectInput)(Display *, Window, int); typedef int (*PtrXRRUpdateConfiguration)(XEvent *); typedef int (*PtrXRRRootToScreen)(Display *, Window); typedef Bool (*PtrXRRQueryExtension)(Display *, int *, int *); -typedef XRRScreenSize *(*PtrXRRSizes)(Display *, int, int *); #endif // QT_NO_XRANDR #ifndef QT_NO_XINPUT @@ -711,7 +710,6 @@ struct QX11Data PtrXRRUpdateConfiguration ptrXRRUpdateConfiguration; PtrXRRRootToScreen ptrXRRRootToScreen; PtrXRRQueryExtension ptrXRRQueryExtension; - PtrXRRSizes ptrXRRSizes; #endif // QT_NO_XRANDR }; diff --git a/src/gui/util/qflickgesture.cpp b/src/gui/util/qflickgesture.cpp deleted file mode 100644 index f87c84c..0000000 --- a/src/gui/util/qflickgesture.cpp +++ /dev/null @@ -1,715 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qgesture.h" -#include "qapplication.h" -#include "qevent.h" -#include "qwidget.h" -#include "qgraphicsitem.h" -#include "qgraphicsscene.h" -#include "qgraphicssceneevent.h" -#include "qgraphicsview.h" -#include "qscroller.h" -#include "private/qevent_p.h" -#include "private/qflickgesture_p.h" -#include "qdebug.h" - -#ifndef QT_NO_GESTURES - -QT_BEGIN_NAMESPACE - -//#define QFLICKGESTURE_DEBUG - -#ifdef QFLICKGESTURE_DEBUG -# define qFGDebug qDebug -#else -# define qFGDebug while (false) qDebug -#endif - -extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); - -static QMouseEvent *copyMouseEvent(QEvent *e) -{ - switch (e->type()) { - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: { - QMouseEvent *me = static_cast<QMouseEvent *>(e); - return new QMouseEvent(me->type(), QPoint(0, 0), me->globalPos(), me->button(), me->buttons(), me->modifiers()); - } -#ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseRelease: - case QEvent::GraphicsSceneMouseMove: { - QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(e); -#if 1 - QEvent::Type met = me->type() == QEvent::GraphicsSceneMousePress ? QEvent::MouseButtonPress : - (me->type() == QEvent::GraphicsSceneMouseRelease ? QEvent::MouseButtonRelease : QEvent::MouseMove); - return new QMouseEvent(met, QPoint(0, 0), me->screenPos(), me->button(), me->buttons(), me->modifiers()); -#else - QGraphicsSceneMouseEvent *copy = new QGraphicsSceneMouseEvent(me->type()); - copy->setPos(me->pos()); - copy->setScenePos(me->scenePos()); - copy->setScreenPos(me->screenPos()); - for (int i = 0x1; i <= 0x10; i <<= 1) { - Qt::MouseButton button = Qt::MouseButton(i); - copy->setButtonDownPos(button, me->buttonDownPos(button)); - copy->setButtonDownScenePos(button, me->buttonDownScenePos(button)); - copy->setButtonDownScreenPos(button, me->buttonDownScreenPos(button)); - } - copy->setLastPos(me->lastPos()); - copy->setLastScenePos(me->lastScenePos()); - copy->setLastScreenPos(me->lastScreenPos()); - copy->setButtons(me->buttons()); - copy->setButton(me->button()); - copy->setModifiers(me->modifiers()); - return copy; -#endif - } -#endif // QT_NO_GRAPHICSVIEW - default: - return 0; - } -} - -class PressDelayHandler : public QObject -{ -private: - PressDelayHandler(QObject *parent = 0) - : QObject(parent) - , pressDelayTimer(0) - , sendingEvent(false) - , mouseButton(Qt::NoButton) - , mouseTarget(0) - { } - - static PressDelayHandler *inst; - -public: - enum { - UngrabMouseBefore = 1, - RegrabMouseAfterwards = 2 - }; - - static PressDelayHandler *instance() - { - static PressDelayHandler *inst = 0; - if (!inst) - inst = new PressDelayHandler(QCoreApplication::instance()); - return inst; - } - - bool shouldEventBeIgnored(QEvent *) const - { - return sendingEvent; - } - - bool isDelaying() const - { - return !pressDelayEvent.isNull(); - } - - void pressed(QEvent *e, int delay) - { - if (!pressDelayEvent) { - pressDelayEvent.reset(copyMouseEvent(e)); - pressDelayTimer = startTimer(delay); - mouseTarget = QApplication::widgetAt(pressDelayEvent->globalPos()); - mouseButton = pressDelayEvent->button(); - qFGDebug() << "QFG: consuming/delaying mouse press"; - } else { - qFGDebug() << "QFG: NOT consuming/delaying mouse press"; - } - e->setAccepted(true); - } - - bool released(QEvent *e, bool scrollerWasActive, bool scrollerIsActive) - { - // consume this event if the scroller was or is active - bool result = scrollerWasActive || scrollerIsActive; - - // stop the timer - if (pressDelayTimer) { - killTimer(pressDelayTimer); - pressDelayTimer = 0; - } - // we still haven't even sent the press, so do it now - if (pressDelayEvent && mouseTarget && !scrollerIsActive) { - QScopedPointer<QMouseEvent> releaseEvent(copyMouseEvent(e)); - - qFGDebug() << "QFG: re-sending mouse press (due to release) for " << mouseTarget; - sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore); - - qFGDebug() << "QFG: faking mouse release (due to release) for " << mouseTarget; - sendMouseEvent(releaseEvent.data()); - - result = true; // consume this event - } else if (mouseTarget && scrollerIsActive) { - // we grabbed the mouse expicitly when the scroller became active, so undo that now - sendMouseEvent(0, UngrabMouseBefore); - } - pressDelayEvent.reset(0); - mouseTarget = 0; - return result; - } - - void scrollerWasIntercepted() - { - qFGDebug() << "QFG: deleting delayed mouse press, since scroller was only intercepted"; - if (pressDelayEvent) { - // we still haven't even sent the press, so just throw it away now - if (pressDelayTimer) { - killTimer(pressDelayTimer); - pressDelayTimer = 0; - } - pressDelayEvent.reset(0); - } - mouseTarget = 0; - } - - void scrollerBecameActive() - { - if (pressDelayEvent) { - // we still haven't even sent the press, so just throw it away now - qFGDebug() << "QFG: deleting delayed mouse press, since scroller is active now"; - if (pressDelayTimer) { - killTimer(pressDelayTimer); - pressDelayTimer = 0; - } - pressDelayEvent.reset(0); - mouseTarget = 0; - } else if (mouseTarget) { - // we did send a press, so we need to fake a release now - - // release all pressed mouse buttons - /* Qt::MouseButtons mouseButtons = QApplication::mouseButtons(); - for (int i = 0; i < 32; ++i) { - if (mouseButtons & (1 << i)) { - Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i); - mouseButtons &= ~b; - QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX); - - qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget; - QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, - b, mouseButtons, QApplication::keyboardModifiers()); - sendMouseEvent(&re); - } - }*/ - - QPoint farFarAway(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX); - - qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget; - QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, - mouseButton, QApplication::mouseButtons() & ~mouseButton, - QApplication::keyboardModifiers()); - sendMouseEvent(&re, RegrabMouseAfterwards); - // don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release! - } - } - -protected: - void timerEvent(QTimerEvent *e) - { - if (e->timerId() == pressDelayTimer) { - if (pressDelayEvent && mouseTarget) { - qFGDebug() << "QFG: timer event: re-sending mouse press to " << mouseTarget; - sendMouseEvent(pressDelayEvent.data(), UngrabMouseBefore); - } - pressDelayEvent.reset(0); - - if (pressDelayTimer) { - killTimer(pressDelayTimer); - pressDelayTimer = 0; - } - } - } - - void sendMouseEvent(QMouseEvent *me, int flags = 0) - { - if (mouseTarget) { - sendingEvent = true; - -#ifndef QT_NO_GRAPHICSVIEW - QGraphicsItem *grabber = 0; - if (mouseTarget->parentWidget()) { - if (QGraphicsView *gv = qobject_cast<QGraphicsView *>(mouseTarget->parentWidget())) { - if (gv->scene()) - grabber = gv->scene()->mouseGrabberItem(); - } - } - - if (grabber && (flags & UngrabMouseBefore)) { - // GraphicsView Mouse Handling Workaround #1: - // we need to ungrab the mouse before re-sending the press, - // since the scene had already set the mouse grabber to the - // original (and consumed) event's receiver - qFGDebug() << "QFG: ungrabbing" << grabber; - grabber->ungrabMouse(); - } -#endif // QT_NO_GRAPHICSVIEW - - if (me) { - QMouseEvent copy(me->type(), mouseTarget->mapFromGlobal(me->globalPos()), me->globalPos(), me->button(), me->buttons(), me->modifiers()); - qt_sendSpontaneousEvent(mouseTarget, ©); - } - -#ifndef QT_NO_GRAPHICSVIEW - if (grabber && (flags & RegrabMouseAfterwards)) { - // GraphicsView Mouse Handling Workaround #2: - // we need to re-grab the mouse after sending a faked mouse - // release, since we still need the mouse moves for the gesture - // (the scene will clear the item's mouse grabber status on - // release). - qFGDebug() << "QFG: re-grabbing" << grabber; - grabber->grabMouse(); - } -#endif - sendingEvent = false; - } - } - - -private: - int pressDelayTimer; - QScopedPointer<QMouseEvent> pressDelayEvent; - bool sendingEvent; - Qt::MouseButton mouseButton; - QPointer<QWidget> mouseTarget; -}; - - -/*! - \internal - \class QFlickGesture - \since 4.8 - \brief The QFlickGesture class describes a flicking gesture made by the user. - \ingroup gestures - The QFlickGesture is more complex than the QPanGesture that uses QScroller and QScrollerProperties - to decide if it is triggered. - This gesture is reacting on touch event as compared to the QMouseFlickGesture. - - \sa {Gestures Programming}, QScroller, QScrollerProperties, QMouseFlickGesture -*/ - -/*! - \internal -*/ -QFlickGesture::QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent) - : QGesture(*new QFlickGesturePrivate, parent) -{ - d_func()->q_ptr = this; - d_func()->receiver = receiver; - d_func()->receiverScroller = (receiver && QScroller::hasScroller(receiver)) ? QScroller::scroller(receiver) : 0; - d_func()->button = button; -} - -QFlickGesture::~QFlickGesture() -{ } - -QFlickGesturePrivate::QFlickGesturePrivate() - : receiverScroller(0), button(Qt::NoButton), macIgnoreWheel(false) -{ } - - -// -// QFlickGestureRecognizer -// - - -QFlickGestureRecognizer::QFlickGestureRecognizer(Qt::MouseButton button) -{ - this->button = button; -} - -/*! \reimp - */ -QGesture *QFlickGestureRecognizer::create(QObject *target) -{ -#ifndef QT_NO_GRAPHICSVIEW - QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target); - if (go && button == Qt::NoButton) { - go->setAcceptTouchEvents(true); - } -#endif - return new QFlickGesture(target, button); -} - -/*! \internal - The recognize function detects a touch event suitable to start the attached QScroller. - The QFlickGesture will be triggered as soon as the scroller is no longer in the state - QScroller::Inactive or QScroller::Pressed. It will be finished or canceled - at the next QEvent::TouchEnd. - Note that the QScroller might continue scrolling (kinetically) at this point. - */ -QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, - QObject *watched, - QEvent *event) -{ - Q_UNUSED(watched); - - static QElapsedTimer monotonicTimer; - if (!monotonicTimer.isValid()) - monotonicTimer.start(); - - QFlickGesture *q = static_cast<QFlickGesture *>(state); - QFlickGesturePrivate *d = q->d_func(); - - QScroller *scroller = d->receiverScroller; - if (!scroller) - return Ignore; // nothing to do without a scroller? - - QWidget *receiverWidget = qobject_cast<QWidget *>(d->receiver); -#ifndef QT_NO_GRAPHICSVIEW - QGraphicsObject *receiverGraphicsObject = qobject_cast<QGraphicsObject *>(d->receiver); -#endif - - // this is only set for events that we inject into the event loop via sendEvent() - if (PressDelayHandler::instance()->shouldEventBeIgnored(event)) { - //qFGDebug() << state << "QFG: ignored event: " << event->type(); - return Ignore; - } - - const QMouseEvent *me = 0; -#ifndef QT_NO_GRAPHICSVIEW - const QGraphicsSceneMouseEvent *gsme = 0; -#endif - const QTouchEvent *te = 0; - QPoint globalPos; - - // qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button; - - switch (event->type()) { - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - if (!receiverWidget) - return Ignore; - if (button != Qt::NoButton) { - me = static_cast<const QMouseEvent *>(event); - globalPos = me->globalPos(); - } - break; -#ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseRelease: - case QEvent::GraphicsSceneMouseMove: - if (!receiverGraphicsObject) - return Ignore; - if (button != Qt::NoButton) { - gsme = static_cast<const QGraphicsSceneMouseEvent *>(event); - globalPos = gsme->screenPos(); - } - break; -#endif - case QEvent::TouchBegin: - case QEvent::TouchEnd: - case QEvent::TouchUpdate: - if (button == Qt::NoButton) { - te = static_cast<const QTouchEvent *>(event); - if (!te->touchPoints().isEmpty()) - globalPos = te->touchPoints().at(0).screenPos().toPoint(); - } - break; - -#if defined(Q_WS_MAC) - // the only way to distinguish between real mouse wheels and wheel - // events generated by the native 2 finger swipe gesture is to listen - // for these events (according to Apple's Cocoa Event-Handling Guide) - - case QEvent::NativeGesture: { - QNativeGestureEvent *nge = static_cast<QNativeGestureEvent *>(event); - if (nge->gestureType == QNativeGestureEvent::GestureBegin) - d->macIgnoreWheel = true; - else if (nge->gestureType == QNativeGestureEvent::GestureEnd) - d->macIgnoreWheel = false; - break; - } -#endif - - // consume all wheel events if the scroller is active - case QEvent::Wheel: - if (d->macIgnoreWheel || (scroller->state() != QScroller::Inactive)) - return Ignore | ConsumeEventHint; - break; - - // consume all dbl click events if the scroller is active - case QEvent::MouseButtonDblClick: - if (scroller->state() != QScroller::Inactive) - return Ignore | ConsumeEventHint; - break; - - default: - break; - } - - if (!me -#ifndef QT_NO_GRAPHICSVIEW - && !gsme -#endif - && !te) // Neither mouse nor touch - return Ignore; - - // get the current pointer position in local coordinates. - QPointF point; - QScroller::Input inputType = (QScroller::Input) 0; - - switch (event->type()) { - case QEvent::MouseButtonPress: - if (me && me->button() == button && me->buttons() == button) { - point = me->globalPos(); - inputType = QScroller::InputPress; - } else if (me) { - scroller->stop(); - return CancelGesture; - } - break; - case QEvent::MouseButtonRelease: - if (me && me->button() == button) { - point = me->globalPos(); - inputType = QScroller::InputRelease; - } - break; - case QEvent::MouseMove: -#ifdef Q_OS_SYMBIAN - // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix - // relies on the windowing system to report the current buttons state. - if (me && (me->buttons() == button || !me->buttons())) { -#else - if (me && me->buttons() == button) { -#endif - point = me->globalPos(); - inputType = QScroller::InputMove; - } - break; - -#ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMousePress: - if (gsme && gsme->button() == button && gsme->buttons() == button) { - point = gsme->scenePos(); - inputType = QScroller::InputPress; - } else if (gsme) { - scroller->stop(); - return CancelGesture; - } - break; - case QEvent::GraphicsSceneMouseRelease: - if (gsme && gsme->button() == button) { - point = gsme->scenePos(); - inputType = QScroller::InputRelease; - } - break; - case QEvent::GraphicsSceneMouseMove: -#ifdef Q_OS_SYMBIAN - // Qt on Symbian tracks the button state internally, while Qt on Win/Mac/Unix - // relies on the windowing system to report the current buttons state. - if (gsme && (gsme->buttons() == button || !me->buttons())) { -#else - if (gsme && gsme->buttons() == button) { -#endif - point = gsme->scenePos(); - inputType = QScroller::InputMove; - } - break; -#endif - - case QEvent::TouchBegin: - inputType = QScroller::InputPress; - // fall through - case QEvent::TouchEnd: - if (!inputType) - inputType = QScroller::InputRelease; - // fallthrough - case QEvent::TouchUpdate: - if (!inputType) - inputType = QScroller::InputMove; - - if (te->deviceType() == QTouchEvent::TouchPad) { - if (te->touchPoints().count() != 2) // 2 fingers on pad - return Ignore; - - point = te->touchPoints().at(0).startScenePos() + - ((te->touchPoints().at(0).scenePos() - te->touchPoints().at(0).startScenePos()) + - (te->touchPoints().at(1).scenePos() - te->touchPoints().at(1).startScenePos())) / 2; - } else { // TouchScreen - if (te->touchPoints().count() != 1) // 1 finger on screen - return Ignore; - - point = te->touchPoints().at(0).scenePos(); - } - break; - - default: - break; - } - - // Check for an active scroller at globalPos - if (inputType == QScroller::InputPress) { - foreach (QScroller *as, QScroller::activeScrollers()) { - if (as != scroller) { - QRegion scrollerRegion; - - if (QWidget *w = qobject_cast<QWidget *>(as->target())) { - scrollerRegion = QRect(w->mapToGlobal(QPoint(0, 0)), w->size()); -#ifndef QT_NO_GRAPHICSVIEW - } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(as->target())) { - if (go->scene() && !go->scene()->views().isEmpty()) { - foreach (QGraphicsView *gv, go->scene()->views()) - scrollerRegion |= gv->mapFromScene(go->mapToScene(go->boundingRect())) - .translated(gv->mapToGlobal(QPoint(0, 0))); - } -#endif - } - // active scrollers always have priority - if (scrollerRegion.contains(globalPos)) - return Ignore; - } - } - } - - bool scrollerWasDragging = (scroller->state() == QScroller::Dragging); - bool scrollerWasScrolling = (scroller->state() == QScroller::Scrolling); - - if (inputType) { - if (QWidget *w = qobject_cast<QWidget *>(d->receiver)) - point = w->mapFromGlobal(point.toPoint()); -#ifndef QT_NO_GRAPHICSVIEW - else if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->receiver)) - point = go->mapFromScene(point); -#endif - - // inform the scroller about the new event - scroller->handleInput(inputType, point, monotonicTimer.elapsed()); - } - - // depending on the scroller state return the gesture state - Result result(0); - bool scrollerIsActive = (scroller->state() == QScroller::Dragging || - scroller->state() == QScroller::Scrolling); - - // Consume all mouse events while dragging or scrolling to avoid nasty - // side effects with Qt's standard widgets. - if ((me -#ifndef QT_NO_GRAPHICSVIEW - || gsme -#endif - ) && scrollerIsActive) - result |= ConsumeEventHint; - - // The only problem with this approach is that we consume the - // MouseRelease when we start the scrolling with a flick gesture, so we - // have to fake a MouseRelease "somewhere" to not mess with the internal - // states of Qt's widgets (a QPushButton would stay in 'pressed' state - // forever, if it doesn't receive a MouseRelease). - if (me -#ifndef QT_NO_GRAPHICSVIEW - || gsme -#endif - ) { - if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive) - PressDelayHandler::instance()->scrollerBecameActive(); - else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive)) - PressDelayHandler::instance()->scrollerWasIntercepted(); - } - - if (!inputType) { - result |= Ignore; - } else { - switch (event->type()) { - case QEvent::MouseButtonPress: -#ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMousePress: -#endif - if (scroller->state() == QScroller::Pressed) { - int pressDelay = int(1000 * scroller->scrollerProperties().scrollMetric(QScrollerProperties::MousePressEventDelay).toReal()); - if (pressDelay > 0) { - result |= ConsumeEventHint; - - PressDelayHandler::instance()->pressed(event, pressDelay); - event->accept(); - } - } - // fall through - case QEvent::TouchBegin: - q->setHotSpot(globalPos); - result |= scrollerIsActive ? TriggerGesture : MayBeGesture; - break; - - case QEvent::MouseMove: -#ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMouseMove: -#endif - if (PressDelayHandler::instance()->isDelaying()) - result |= ConsumeEventHint; - // fall through - case QEvent::TouchUpdate: - result |= scrollerIsActive ? TriggerGesture : Ignore; - break; - -#ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMouseRelease: -#endif - case QEvent::MouseButtonRelease: - if (PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive)) - result |= ConsumeEventHint; - // fall through - case QEvent::TouchEnd: - result |= scrollerIsActive ? FinishGesture : CancelGesture; - break; - - default: - result |= Ignore; - break; - } - } - return result; -} - - -/*! \reimp - */ -void QFlickGestureRecognizer::reset(QGesture *state) -{ - QGestureRecognizer::reset(state); -} - -QT_END_NAMESPACE - -#endif // QT_NO_GESTURES diff --git a/src/gui/util/qflickgesture_p.h b/src/gui/util/qflickgesture_p.h deleted file mode 100644 index 451b579..0000000 --- a/src/gui/util/qflickgesture_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFLICKGESTURE_P_H -#define QFLICKGESTURE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qevent.h" -#include "qgesturerecognizer.h" -#include "private/qgesture_p.h" -#include "qscroller.h" -#include "qscopedpointer.h" - -#ifndef QT_NO_GESTURES - -QT_BEGIN_NAMESPACE - -class QFlickGesturePrivate; -class QGraphicsItem; - -class Q_GUI_EXPORT QFlickGesture : public QGesture -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QFlickGesture) - -public: - QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = 0); - ~QFlickGesture(); - - friend class QFlickGestureRecognizer; -}; - -class PressDelayHandler; - -class QFlickGesturePrivate : public QGesturePrivate -{ - Q_DECLARE_PUBLIC(QFlickGesture) -public: - QFlickGesturePrivate(); - - QPointer<QObject> receiver; - QScroller *receiverScroller; - Qt::MouseButton button; // NoButton == Touch - bool macIgnoreWheel; - static PressDelayHandler *pressDelayHandler; -}; - -class QFlickGestureRecognizer : public QGestureRecognizer -{ -public: - QFlickGestureRecognizer(Qt::MouseButton button); - - QGesture *create(QObject *target); - QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event); - void reset(QGesture *state); - -private: - Qt::MouseButton button; // NoButton == Touch -}; - -QT_END_NAMESPACE - -#endif // QT_NO_GESTURES - -#endif // QFLICKGESTURE_P_H diff --git a/src/gui/util/qscroller.cpp b/src/gui/util/qscroller.cpp deleted file mode 100644 index 870d56f..0000000 --- a/src/gui/util/qscroller.cpp +++ /dev/null @@ -1,2056 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qevent.h" -#include "qwidget.h" -#include "qscroller.h" -#include "private/qflickgesture_p.h" -#include "private/qscroller_p.h" -#include "qscrollerproperties.h" -#include "private/qscrollerproperties_p.h" -#include "qnumeric.h" -#include "math.h" - -#include <QTime> -#include <QElapsedTimer> -#include <QMap> -#include <QApplication> -#include <QAbstractScrollArea> -#include <QGraphicsObject> -#include <QGraphicsScene> -#include <QGraphicsView> -#include <QDesktopWidget> -#include <QtCore/qmath.h> -#include <QtGui/qevent.h> -#include <qnumeric.h> - -#include <QtDebug> - -#if defined(Q_WS_X11) -# include "private/qt_x11_p.h" -#endif - - -QT_BEGIN_NAMESPACE - -bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); - -//#define QSCROLLER_DEBUG - -#ifdef QSCROLLER_DEBUG -# define qScrollerDebug qDebug -#else -# define qScrollerDebug while (false) qDebug -#endif - -QDebug &operator<<(QDebug &dbg, const QScrollerPrivate::ScrollSegment &s) -{ - dbg << "\n Time: start:" << s.startTime << " duration:" << s.deltaTime << " stop progress:" << s.stopProgress; - dbg << "\n Pos: start:" << s.startPos << " delta:" << s.deltaPos << " stop:" << s.stopPos; - dbg << "\n Curve: type:" << s.curve.type() << "\n"; - return dbg; -} - - -// a few helper operators to make the code below a lot more readable: -// otherwise a lot of ifs would have to be multi-line to check both the x -// and y coordinate separately. - -// returns true only if the abs. value of BOTH x and y are <= f -inline bool operator<=(const QPointF &p, qreal f) -{ - return (qAbs(p.x()) <= f) && (qAbs(p.y()) <= f); -} - -// returns true only if the abs. value of BOTH x and y are < f -inline bool operator<(const QPointF &p, qreal f) -{ - return (qAbs(p.x()) < f) && (qAbs(p.y()) < f); -} - -// returns true if the abs. value of EITHER x or y are >= f -inline bool operator>=(const QPointF &p, qreal f) -{ - return (qAbs(p.x()) >= f) || (qAbs(p.y()) >= f); -} - -// returns true if the abs. value of EITHER x or y are > f -inline bool operator>(const QPointF &p, qreal f) -{ - return (qAbs(p.x()) > f) || (qAbs(p.y()) > f); -} - -// returns a new point with both coordinates having the abs. value of the original one -inline QPointF qAbs(const QPointF &p) -{ - return QPointF(qAbs(p.x()), qAbs(p.y())); -} - -// returns a new point with all components of p1 multiplied by the corresponding components of p2 -inline QPointF operator*(const QPointF &p1, const QPointF &p2) -{ - return QPointF(p1.x() * p2.x(), p1.y() * p2.y()); -} - -// returns a new point with all components of p1 divided by the corresponding components of p2 -inline QPointF operator/(const QPointF &p1, const QPointF &p2) -{ - return QPointF(p1.x() / p2.x(), p1.y() / p2.y()); -} - -inline QPointF clampToRect(const QPointF &p, const QRectF &rect) -{ - qreal x = qBound(rect.left(), p.x(), rect.right()); - qreal y = qBound(rect.top(), p.y(), rect.bottom()); - return QPointF(x, y); -} - -// returns -1, 0 or +1 according to r being <0, ==0 or >0 -inline int qSign(qreal r) -{ - return (r < 0) ? -1 : ((r > 0) ? 1 : 0); -} - -// this version is not mathematically exact, but it just works for every -// easing curve type (even custom ones) - -static qreal differentialForProgress(const QEasingCurve &curve, qreal pos) -{ - const qreal dx = 0.01; - qreal left = (pos < qreal(0.5)) ? pos : pos - qreal(dx); - qreal right = (pos >= qreal(0.5)) ? pos : pos + qreal(dx); - qreal d = (curve.valueForProgress(right) - curve.valueForProgress(left)) / qreal(dx); - - //qScrollerDebug() << "differentialForProgress(type: " << curve.type() << ", pos: " << pos << ") = " << d; - - return d; -} - -// this version is not mathematically exact, but it just works for every -// easing curve type (even custom ones) - -static qreal progressForValue(const QEasingCurve &curve, qreal value) -{ - if (curve.type() >= QEasingCurve::InElastic && - curve.type() < QEasingCurve::Custom) { - qWarning("progressForValue(): QEasingCurves of type %d do not have an inverse, since they are not injective.", curve.type()); - return value; - } - if (value < qreal(0) || value > qreal(1)) - return value; - - qreal progress = value, left(0), right(1); - for (int iterations = 6; iterations; --iterations) { - qreal v = curve.valueForProgress(progress); - if (v < value) - left = progress; - else if (v > value) - right = progress; - else - break; - progress = (left + right) / qreal(2); - } - return progress; -} - - -#ifndef QT_NO_ANIMATION -class QScrollTimer : public QAbstractAnimation -{ -public: - QScrollTimer(QScrollerPrivate *_d) - : d(_d), ignoreUpdate(false), skip(0) - { } - - int duration() const - { - return -1; - } - - void start() - { - // QAbstractAnimation::start() will immediately call - // updateCurrentTime(), but our state is not set correctly yet - ignoreUpdate = true; - QAbstractAnimation::start(); - ignoreUpdate = false; - skip = 0; - } - -protected: - void updateCurrentTime(int /*currentTime*/) - { - if (!ignoreUpdate) { - if (++skip >= d->frameRateSkip()) { - skip = 0; - d->timerTick(); - } - } - } - -private: - QScrollerPrivate *d; - bool ignoreUpdate; - int skip; -}; -#endif // QT_NO_ANIMATION - -/*! - \class QScroller - \brief The QScroller class enables kinetic scrolling for any scrolling widget or graphics item. - \since 4.8 - - With kinetic scrolling, the user can push the widget in a given - direction and it will continue to scroll in this direction until it is - stopped either by the user or by friction. Aspects of inertia, friction - and other physical concepts can be changed in order to fine-tune an - intuitive user experience. - - The QScroller object is the object that stores the current position and - scrolling speed and takes care of updates. - QScroller can be triggered by a flick gesture - - \code - QWidget *w = ...; - QScroller::grabGesture(w, QScroller::LeftMouseButtonGesture); - \endcode - - or directly like this: - - \code - QWidget *w = ...; - QScroller *scroller = QScroller::scroller(w); - scroller->scrollTo(QPointF(100, 100)); - \endcode - - The scrolled QObjects receive a QScrollPrepareEvent whenever the scroller needs to - update its geometry information and a QScrollEvent whenever the content of the object should - actually be scrolled. - - The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This - can be changed with QScrollerProperties::FrameRate on a per-QScroller basis. - - Several examples in the \c scroller examples directory show how QScroller, - QScrollEvent and the scroller gesture can be used. - - Even though this kinetic scroller has a large number of settings available via - QScrollerProperties, we recommend that you leave them all at their default, platform optimized - values. Before changing them you can experiment with the \c plot example in - the \c scroller examples directory. - - \sa QScrollEvent, QScrollPrepareEvent, QScrollerProperties -*/ - -typedef QMap<QObject *, QScroller *> ScrollerHash; -typedef QSet<QScroller *> ScrollerSet; - -Q_GLOBAL_STATIC(ScrollerHash, qt_allScrollers) -Q_GLOBAL_STATIC(ScrollerSet, qt_activeScrollers) - -/*! - Returns \c true if a QScroller object was already created for \a target; \c false otherwise. - - \sa scroller() -*/ -bool QScroller::hasScroller(QObject *target) -{ - return (qt_allScrollers()->value(target)); -} - -/*! - Returns the scroller for the given \a target. - As long as the object exists this function will always return the same QScroller instance. - If no QScroller exists for the \a target, one will implicitly be created. - At no point more than one QScroller will be active on an object. - - \sa hasScroller(), target() -*/ -QScroller *QScroller::scroller(QObject *target) -{ - if (!target) { - qWarning("QScroller::scroller() was called with a null target."); - return 0; - } - - if (qt_allScrollers()->contains(target)) - return qt_allScrollers()->value(target); - - QScroller *s = new QScroller(target); - qt_allScrollers()->insert(target, s); - return s; -} - -/*! - \overload - This is the const version of scroller(). -*/ -const QScroller *QScroller::scroller(const QObject *target) -{ - return scroller(const_cast<QObject*>(target)); -} - -/*! - Returns an application wide list of currently active QScroller objects. - Active QScroller objects are in a state() that is not QScroller::Inactive. - This function is useful when writing your own gesture recognizer. -*/ -QList<QScroller *> QScroller::activeScrollers() -{ - return qt_activeScrollers()->toList(); -} - -/*! - Returns the target object of this scroller. - \sa hasScroller(), scroller() - */ -QObject *QScroller::target() const -{ - Q_D(const QScroller); - return d->target; -} - -/*! - \fn QScroller::scrollerPropertiesChanged(const QScrollerProperties &newProperties); - - QScroller emits this signal whenever its scroller properties change. - \a newProperties are the new scroller properties. - - \sa scrollerProperties -*/ - - -/*! \property QScroller::scrollerProperties - \brief The scroller properties of this scroller. - The properties are used by the QScroller to determine its scrolling behavior. -*/ -QScrollerProperties QScroller::scrollerProperties() const -{ - Q_D(const QScroller); - return d->properties; -} - -void QScroller::setScrollerProperties(const QScrollerProperties &sp) -{ - Q_D(QScroller); - if (d->properties != sp) { - d->properties = sp; - emit scrollerPropertiesChanged(sp); - - // we need to force the recalculation here, since the overshootPolicy may have changed and - // existing segments may include an overshoot animation. - d->recalcScrollingSegments(true); - } -} - -#ifndef QT_NO_GESTURES - -/*! - Registers a custom scroll gesture recognizer, grabs it for the \a - target and returns the resulting gesture type. If \a scrollGestureType is - set to TouchGesture the gesture triggers on touch events. If it is set to - one of LeftMouseButtonGesture, RightMouseButtonGesture or - MiddleMouseButtonGesture it triggers on mouse events of the - corresponding button. - - Only one scroll gesture can be active on a single object at the same - time. If you call this function twice on the same object, it will - ungrab the existing gesture before grabbing the new one. - - \note To avoid unwanted side-effects, mouse events are consumed while - the gesture is triggered. Since the initial mouse press event is - not consumed, the gesture sends a fake mouse release event - at the global position \c{(INT_MIN, INT_MIN)}. This ensures that - internal states of the widget that received the original mouse press - are consistent. - - \sa ungrabGesture, grabbedGesture -*/ -Qt::GestureType QScroller::grabGesture(QObject *target, ScrollerGestureType scrollGestureType) -{ - // ensure that a scroller for target is created - QScroller *s = scroller(target); - if (!s) - return Qt::GestureType(0); - - QScrollerPrivate *sp = s->d_ptr; - if (sp->recognizer) - ungrabGesture(target); // ungrab the old gesture - - Qt::MouseButton button; - switch (scrollGestureType) { - case LeftMouseButtonGesture : button = Qt::LeftButton; break; - case RightMouseButtonGesture : button = Qt::RightButton; break; - case MiddleMouseButtonGesture: button = Qt::MiddleButton; break; - default : - case TouchGesture : button = Qt::NoButton; break; // NoButton == Touch - } - - sp->recognizer = new QFlickGestureRecognizer(button); - sp->recognizerType = QGestureRecognizer::registerRecognizer(sp->recognizer); - - if (target->isWidgetType()) { - QWidget *widget = static_cast<QWidget *>(target); - widget->grabGesture(sp->recognizerType); - if (scrollGestureType == TouchGesture) - widget->setAttribute(Qt::WA_AcceptTouchEvents); -#ifndef QT_NO_GRAPHICSVIEW - } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) { - if (scrollGestureType == TouchGesture) - go->setAcceptTouchEvents(true); - go->grabGesture(sp->recognizerType); -#endif // QT_NO_GRAPHICSVIEW - } - return sp->recognizerType; -} - -/*! - Returns the gesture type currently grabbed for the \a target or 0 if no - gesture is grabbed. - - \sa grabGesture, ungrabGesture -*/ -Qt::GestureType QScroller::grabbedGesture(QObject *target) -{ - QScroller *s = scroller(target); - if (s && s->d_ptr) - return s->d_ptr->recognizerType; - else - return Qt::GestureType(0); -} - -/*! - Ungrabs the gesture for the \a target. - Does nothing if no gesture is grabbed. - - \sa grabGesture, grabbedGesture -*/ -void QScroller::ungrabGesture(QObject *target) -{ - QScroller *s = scroller(target); - if (!s) - return; - - QScrollerPrivate *sp = s->d_ptr; - if (!sp->recognizer) - return; // nothing to do - - if (target->isWidgetType()) { - QWidget *widget = static_cast<QWidget *>(target); - widget->ungrabGesture(sp->recognizerType); -#ifndef QT_NO_GRAPHICSVIEW - } else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(target)) { - go->ungrabGesture(sp->recognizerType); -#endif - } - - QGestureRecognizer::unregisterRecognizer(sp->recognizerType); - // do not delete the recognizer. The QGestureManager is doing this. - sp->recognizer = 0; -} - -#endif // QT_NO_GESTURES - -/*! - \internal -*/ -QScroller::QScroller(QObject *target) - : d_ptr(new QScrollerPrivate(this, target)) -{ - Q_ASSERT(target); // you can't create a scroller without a target in any normal way - Q_D(QScroller); - d->init(); -} - -/*! - \internal -*/ -QScroller::~QScroller() -{ - Q_D(QScroller); -#ifndef QT_NO_GESTURES - QGestureRecognizer::unregisterRecognizer(d->recognizerType); - // do not delete the recognizer. The QGestureManager is doing this. - d->recognizer = 0; -#endif - qt_allScrollers()->remove(d->target); - qt_activeScrollers()->remove(this); - - delete d_ptr; -} - - -/*! - \fn QScroller::stateChanged(QScroller::State newState); - - QScroller emits this signal whenever the state changes. \a newState is the new State. - - \sa state -*/ - -/*! - \property QScroller::state - \brief the state of the scroller - - \sa QScroller::State -*/ -QScroller::State QScroller::state() const -{ - Q_D(const QScroller); - return d->state; -} - -/*! - Stops the scroller and resets its state back to Inactive. -*/ -void QScroller::stop() -{ - Q_D(QScroller); - if (d->state != Inactive) { - QPointF here = clampToRect(d->contentPosition, d->contentPosRange); - qreal snapX = d->nextSnapPos(here.x(), 0, Qt::Horizontal); - qreal snapY = d->nextSnapPos(here.y(), 0, Qt::Vertical); - QPointF snap = here; - if (!qIsNaN(snapX)) - snap.setX(snapX); - if (!qIsNaN(snapY)) - snap.setY(snapY); - d->contentPosition = snap; - d->overshootPosition = QPointF(0, 0); - - d->setState(Inactive); - } -} - -/*! - Returns the pixel per meter metric for the scrolled widget. - - The value is reported for both the x and y axis separately by using a QPointF. - - \note Please note that this value should be physically correct. The actual DPI settings - that Qt returns for the display may be reported wrongly on purpose by the underlying - windowing system, for example on Mac OS X or Maemo 5. -*/ -QPointF QScroller::pixelPerMeter() const -{ - Q_D(const QScroller); - QPointF ppm = d->pixelPerMeter; - -#ifndef QT_NO_GRAPHICSVIEW - if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(d->target)) { - QTransform viewtr; - //TODO: the first view isn't really correct - maybe use an additional field in the prepare event? - if (go->scene() && !go->scene()->views().isEmpty()) - viewtr = go->scene()->views().first()->viewportTransform(); - QTransform tr = go->deviceTransform(viewtr); - if (tr.isScaling()) { - QPointF p0 = tr.map(QPointF(0, 0)); - QPointF px = tr.map(QPointF(1, 0)); - QPointF py = tr.map(QPointF(0, 1)); - ppm.rx() /= QLineF(p0, px).length(); - ppm.ry() /= QLineF(p0, py).length(); - } - } -#endif // QT_NO_GRAPHICSVIEW - return ppm; -} - -/*! - Returns the current scrolling velocity in meter per second when the state is Scrolling or Dragging. - Returns a zero velocity otherwise. - - The velocity is reported for both the x and y axis separately by using a QPointF. - - \sa pixelPerMeter() -*/ -QPointF QScroller::velocity() const -{ - Q_D(const QScroller); - const QScrollerPropertiesPrivate *sp = d->properties.d.data(); - - switch (state()) { - case Dragging: - return d->releaseVelocity; - case Scrolling: { - QPointF vel; - qint64 now = d->monotonicTimer.elapsed(); - - if (!d->xSegments.isEmpty()) { - const QScrollerPrivate::ScrollSegment &s = d->xSegments.head(); - qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); - qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); - vel.setX(v); - } - - if (!d->ySegments.isEmpty()) { - const QScrollerPrivate::ScrollSegment &s = d->ySegments.head(); - qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); - qreal v = qSign(s.deltaPos) * qreal(s.deltaTime) / qreal(1000) * sp->decelerationFactor * qreal(0.5) * differentialForProgress(s.curve, progress); - vel.setY(v); - } - return vel; - } - default: - return QPointF(0, 0); - } -} - -/*! - Returns the estimated final position for the current scroll movement. - Returns the current position if the scroller state is not Scrolling. - The result is undefined when the scroller state is Inactive. - - The target position is in pixel. - - \sa pixelPerMeter(), scrollTo() -*/ -QPointF QScroller::finalPosition() const -{ - Q_D(const QScroller); - return QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), - d->scrollingSegmentsEndPos(Qt::Vertical)); -} - -/*! - Starts scrolling the widget so that point \a pos is at the top-left position in - the viewport. - - The behaviour when scrolling outside the valid scroll area is undefined. - In this case the scroller might or might not overshoot. - - The scrolling speed will be calculated so that the given position will - be reached after a platform-defined time span. - - \a pos is given in viewport coordinates. - - \sa ensureVisible() -*/ -void QScroller::scrollTo(const QPointF &pos) -{ - // we could make this adjustable via QScrollerProperties - scrollTo(pos, 300); -} - -/*! \overload - - This version will reach its destination position in \a scrollTime milliseconds. -*/ -void QScroller::scrollTo(const QPointF &pos, int scrollTime) -{ - Q_D(QScroller); - - if (d->state == Pressed || d->state == Dragging ) - return; - - // no need to resend a prepare event if we are already scrolling - if (d->state == Inactive && !d->prepareScrolling(QPointF())) - return; - - QPointF newpos = clampToRect(pos, d->contentPosRange); - qreal snapX = d->nextSnapPos(newpos.x(), 0, Qt::Horizontal); - qreal snapY = d->nextSnapPos(newpos.y(), 0, Qt::Vertical); - if (!qIsNaN(snapX)) - newpos.setX(snapX); - if (!qIsNaN(snapY)) - newpos.setY(snapY); - - qScrollerDebug() << "QScroller::scrollTo(req:" << pos << " [pix] / snap:" << newpos << ", " << scrollTime << " [ms])"; - - if (newpos == d->contentPosition + d->overshootPosition) - return; - - QPointF vel = velocity(); - - if (scrollTime < 0) - scrollTime = 0; - qreal time = qreal(scrollTime) / 1000; - - d->createScrollToSegments(vel.x(), time, newpos.x(), Qt::Horizontal, QScrollerPrivate::ScrollTypeScrollTo); - d->createScrollToSegments(vel.y(), time, newpos.y(), Qt::Vertical, QScrollerPrivate::ScrollTypeScrollTo); - - if (!scrollTime) - d->setContentPositionHelperScrolling(); - d->setState(scrollTime ? Scrolling : Inactive); -} - -/*! - Starts scrolling so that the rectangle \a rect is visible inside the - viewport with additional margins specified in pixels by \a xmargin and \a ymargin around - the rect. - - In cases where it is not possible to fit the rect plus margins inside the viewport the contents - are scrolled so that as much as possible is visible from \a rect. - - The scrolling speed is calculated so that the given position is reached after a platform-defined - time span. - - This function performs the actual scrolling by calling scrollTo(). - - \sa scrollTo -*/ -void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin) -{ - // we could make this adjustable via QScrollerProperties - ensureVisible(rect, xmargin, ymargin, 1000); -} - -/*! \overload - - This version will reach its destination position in \a scrollTime milliseconds. -*/ -void QScroller::ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime) -{ - Q_D(QScroller); - - if (d->state == Pressed || d->state == Dragging ) - return; - - if (d->state == Inactive && !d->prepareScrolling(QPointF())) - return; - - // -- calculate the current pos (or the position after the current scroll) - QPointF startPos = d->contentPosition + d->overshootPosition; - startPos = QPointF(d->scrollingSegmentsEndPos(Qt::Horizontal), - d->scrollingSegmentsEndPos(Qt::Vertical)); - - QRectF marginRect(rect.x() - xmargin, rect.y() - ymargin, - rect.width() + 2 * xmargin, rect.height() + 2 * ymargin); - - QSizeF visible = d->viewportSize; - QRectF visibleRect(startPos, visible); - - qScrollerDebug() << "QScroller::ensureVisible(" << rect << " [pix], " << xmargin << " [pix], " << ymargin << " [pix], " << scrollTime << "[ms])"; - qScrollerDebug() << " --> content position:" << d->contentPosition; - - if (visibleRect.contains(marginRect)) - return; - - QPointF newPos = startPos; - - if (visibleRect.width() < rect.width()) { - // at least try to move the rect into view - if (rect.left() > visibleRect.left()) - newPos.setX(rect.left()); - else if (rect.right() < visibleRect.right()) - newPos.setX(rect.right() - visible.width()); - - } else if (visibleRect.width() < marginRect.width()) { - newPos.setX(rect.center().x() - visibleRect.width() / 2); - } else if (marginRect.left() > visibleRect.left()) { - newPos.setX(marginRect.left()); - } else if (marginRect.right() < visibleRect.right()) { - newPos.setX(marginRect.right() - visible.width()); - } - - if (visibleRect.height() < rect.height()) { - // at least try to move the rect into view - if (rect.top() > visibleRect.top()) - newPos.setX(rect.top()); - else if (rect.bottom() < visibleRect.bottom()) - newPos.setX(rect.bottom() - visible.height()); - - } else if (visibleRect.height() < marginRect.height()) { - newPos.setY(rect.center().y() - visibleRect.height() / 2); - } else if (marginRect.top() > visibleRect.top()) { - newPos.setY(marginRect.top()); - } else if (marginRect.bottom() < visibleRect.bottom()) { - newPos.setY(marginRect.bottom() - visible.height()); - } - - // clamp to maximum content position - newPos = clampToRect(newPos, d->contentPosRange); - if (newPos == startPos) - return; - - scrollTo(newPos, scrollTime); -} - -/*! This function resends the QScrollPrepareEvent. - Calling resendPrepareEvent triggers a QScrollPrepareEvent from the scroller. - This allows the receiver to re-set content position and content size while - scrolling. - Calling this function while in the Inactive state is useless as the prepare event - is sent again before scrolling starts. - */ -void QScroller::resendPrepareEvent() -{ - Q_D(QScroller); - d->prepareScrolling(d->pressPosition); -} - -/*! Set the snap positions for the horizontal axis to a list of \a positions. - This overwrites all previously set snap positions and also a previously - set snapping interval. - Snapping can be deactivated by setting an empty list of positions. - */ -void QScroller::setSnapPositionsX(const QList<qreal> &positions) -{ - Q_D(QScroller); - d->snapPositionsX = positions; - d->snapIntervalX = 0.0; - - d->recalcScrollingSegments(); -} - -/*! Set the snap positions for the horizontal axis to regular spaced intervals. - The first snap position is at \a first. The next at \a first + \a interval. - This can be used to implement a list header. - This overwrites all previously set snap positions and also a previously - set snapping interval. - Snapping can be deactivated by setting an interval of 0.0 - */ -void QScroller::setSnapPositionsX(qreal first, qreal interval) -{ - Q_D(QScroller); - d->snapFirstX = first; - d->snapIntervalX = interval; - d->snapPositionsX.clear(); - - d->recalcScrollingSegments(); -} - -/*! Set the snap positions for the vertical axis to a list of \a positions. - This overwrites all previously set snap positions and also a previously - set snapping interval. - Snapping can be deactivated by setting an empty list of positions. - */ -void QScroller::setSnapPositionsY(const QList<qreal> &positions) -{ - Q_D(QScroller); - d->snapPositionsY = positions; - d->snapIntervalY = 0.0; - - d->recalcScrollingSegments(); -} - -/*! Set the snap positions for the vertical axis to regular spaced intervals. - The first snap position is at \a first. The next at \a first + \a interval. - This overwrites all previously set snap positions and also a previously - set snapping interval. - Snapping can be deactivated by setting an interval of 0.0 - */ -void QScroller::setSnapPositionsY(qreal first, qreal interval) -{ - Q_D(QScroller); - d->snapFirstY = first; - d->snapIntervalY = interval; - d->snapPositionsY.clear(); - - d->recalcScrollingSegments(); -} - - - -// -------------- private ------------ - -QScrollerPrivate::QScrollerPrivate(QScroller *q, QObject *_target) - : target(_target) -#ifndef QT_NO_GESTURES - , recognizer(0) - , recognizerType(Qt::CustomGesture) -#endif - , state(QScroller::Inactive) - , firstScroll(true) - , pressTimestamp(0) - , lastTimestamp(0) - , snapFirstX(-1.0) - , snapIntervalX(0.0) - , snapFirstY(-1.0) - , snapIntervalY(0.0) -#ifndef QT_NO_ANIMATION - , scrollTimer(new QScrollTimer(this)) -#endif - , q_ptr(q) -{ - connect(target, SIGNAL(destroyed(QObject*)), this, SLOT(targetDestroyed())); -} - -void QScrollerPrivate::init() -{ - setDpiFromWidget(0); - monotonicTimer.start(); -} - -void QScrollerPrivate::sendEvent(QObject *o, QEvent *e) -{ - qt_sendSpontaneousEvent(o, e); -} - -const char *QScrollerPrivate::stateName(QScroller::State state) -{ - switch (state) { - case QScroller::Inactive: return "inactive"; - case QScroller::Pressed: return "pressed"; - case QScroller::Dragging: return "dragging"; - case QScroller::Scrolling: return "scrolling"; - default: return "(invalid)"; - } -} - -const char *QScrollerPrivate::inputName(QScroller::Input input) -{ - switch (input) { - case QScroller::InputPress: return "press"; - case QScroller::InputMove: return "move"; - case QScroller::InputRelease: return "release"; - default: return "(invalid)"; - } -} - -void QScrollerPrivate::targetDestroyed() -{ -#ifndef QT_NO_ANIMATION - scrollTimer->stop(); -#endif - delete q_ptr; -} - -void QScrollerPrivate::timerTick() -{ - struct timerevent { - QScroller::State state; - typedef void (QScrollerPrivate::*timerhandler_t)(); - timerhandler_t handler; - }; - - timerevent timerevents[] = { - { QScroller::Dragging, &QScrollerPrivate::timerEventWhileDragging }, - { QScroller::Scrolling, &QScrollerPrivate::timerEventWhileScrolling }, - }; - - for (int i = 0; i < int(sizeof(timerevents) / sizeof(*timerevents)); ++i) { - timerevent *te = timerevents + i; - - if (state == te->state) { - (this->*te->handler)(); - return; - } - } - -#ifndef QT_NO_ANIMATION - scrollTimer->stop(); -#endif -} - -/*! - This function is used by gesture recognizers to inform the scroller about a new input event. - The scroller changes its internal state() according to the input event and its attached - scroller properties. The scroller doesn't distinguish between the kind of input device the - event came from. Therefore the event needs to be split into the \a input type, a \a position and a - milli-second \a timestamp. The \a position needs to be in the target's coordinate system. - - The return value is \c true if the event should be consumed by the calling filter or \c false - if the event should be forwarded to the control. - - \note Using grabGesture() should be sufficient for most use cases. -*/ -bool QScroller::handleInput(Input input, const QPointF &position, qint64 timestamp) -{ - Q_D(QScroller); - - qScrollerDebug() << "QScroller::handleInput(" << input << ", " << d->stateName(d->state) << ", " << position << ", " << timestamp << ")"; - struct statechange { - State state; - Input input; - typedef bool (QScrollerPrivate::*inputhandler_t)(const QPointF &position, qint64 timestamp); - inputhandler_t handler; - }; - - statechange statechanges[] = { - { QScroller::Inactive, InputPress, &QScrollerPrivate::pressWhileInactive }, - { QScroller::Pressed, InputMove, &QScrollerPrivate::moveWhilePressed }, - { QScroller::Pressed, InputRelease, &QScrollerPrivate::releaseWhilePressed }, - { QScroller::Dragging, InputMove, &QScrollerPrivate::moveWhileDragging }, - { QScroller::Dragging, InputRelease, &QScrollerPrivate::releaseWhileDragging }, - { QScroller::Scrolling, InputPress, &QScrollerPrivate::pressWhileScrolling } - }; - - for (int i = 0; i < int(sizeof(statechanges) / sizeof(*statechanges)); ++i) { - statechange *sc = statechanges + i; - - if (d->state == sc->state && input == sc->input) - return (d->*sc->handler)(position - d->overshootPosition, timestamp); - } - return false; -} - -#if !defined(Q_WS_MAC) -// the Mac version is implemented in qscroller_mac.mm - -QPointF QScrollerPrivate::realDpi(int screen) -{ -# ifdef Q_WS_MAEMO_5 - Q_UNUSED(screen); - - // The DPI value is hardcoded to 96 on Maemo5: - // https://projects.maemo.org/bugzilla/show_bug.cgi?id=152525 - // This value (260) is only correct for the N900 though, but - // there's no way to get the real DPI at run time. - return QPointF(260, 260); - -# elif defined(Q_WS_X11) && !defined(QT_NO_XRANDR) - if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) { - int nsizes = 0; - // QDesktopWidget is based on Xinerama screens, which do not always - // correspond to RandR screens: NVidia's TwinView e.g. will show up - // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen. - // (although with the combined size of the Xinerama screens). - // Additionally, libXrandr will simply crash when calling XRRSizes - // for (the non-existent) screen 1 in this scenario. - Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen); - int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1; - - XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes); - if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) { - qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth), - qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight)); - return QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth), - qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight)); - } - } -# endif - - QWidget *w = QApplication::desktop()->screen(screen); - return QPointF(w->physicalDpiX(), w->physicalDpiY()); -} - -#endif // !Q_WS_MAC - - -/*! \internal - Returns the resolution of the used screen. -*/ -QPointF QScrollerPrivate::dpi() const -{ - return pixelPerMeter * qreal(0.0254); -} - -/*! \internal - Sets the resolution used for scrolling. - This resolution is only used by the kinetic scroller. If you change this - then the scroller will behave quite different as a lot of the values are - given in physical distances (millimeter). -*/ -void QScrollerPrivate::setDpi(const QPointF &dpi) -{ - pixelPerMeter = dpi / qreal(0.0254); -} - -/*! \internal - Sets the dpi used for scrolling to the value of the widget. -*/ -void QScrollerPrivate::setDpiFromWidget(QWidget *widget) -{ - QDesktopWidget *dw = QApplication::desktop(); - setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen())); -} - -/*! \internal - Updates the velocity during dragging. - Sets releaseVelocity. -*/ -void QScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime) -{ - if (deltaTime <= 0) - return; - - Q_Q(QScroller); - QPointF ppm = q->pixelPerMeter(); - const QScrollerPropertiesPrivate *sp = properties.d.data(); - QPointF deltaPixel = deltaPixelRaw; - - qScrollerDebug() << "QScroller::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])"; - - // faster than 2.5mm/ms seems bogus (that would be a screen height in ~20 ms) - if (((deltaPixelRaw / qreal(deltaTime)).manhattanLength() / ((ppm.x() + ppm.y()) / 2) * 1000) > qreal(2.5)) - deltaPixel = deltaPixelRaw * qreal(2.5) * ppm / 1000 / (deltaPixelRaw / qreal(deltaTime)).manhattanLength(); - - QPointF newv = -deltaPixel / qreal(deltaTime) * qreal(1000) / ppm; - // around 95% of all updates are in the [1..50] ms range, so make sure - // to scale the smoothing factor over that range: this way a 50ms update - // will have full impact, while 5ms update will only have a 10% impact. - qreal smoothing = sp->dragVelocitySmoothingFactor * qMin(qreal(deltaTime), qreal(50)) / qreal(50); - - // only smooth if we already have a release velocity and only if the - // user hasn't stopped to move his finger for more than 100ms - if ((releaseVelocity != QPointF(0, 0)) && (deltaTime < 100)) { - qScrollerDebug() << "SMOOTHED from " << newv << " to " << newv * smoothing + releaseVelocity * (qreal(1) - smoothing); - // smooth x or y only if the new velocity is either 0 or at least in - // the same direction of the release velocity - if (!newv.x() || (qSign(releaseVelocity.x()) == qSign(newv.x()))) - newv.setX(newv.x() * smoothing + releaseVelocity.x() * (qreal(1) - smoothing)); - if (!newv.y() || (qSign(releaseVelocity.y()) == qSign(newv.y()))) - newv.setY(newv.y() * smoothing + releaseVelocity.y() * (qreal(1) - smoothing)); - } else - qScrollerDebug() << "NO SMOOTHING to " << newv; - - releaseVelocity.setX(qBound(-sp->maximumVelocity, newv.x(), sp->maximumVelocity)); - releaseVelocity.setY(qBound(-sp->maximumVelocity, newv.y(), sp->maximumVelocity)); - - qScrollerDebug() << " --> new velocity:" << releaseVelocity; -} - -void QScrollerPrivate::pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation) -{ - if (startPos == stopPos || deltaPos == 0) - return; - - ScrollSegment s; - if (orientation == Qt::Horizontal && !xSegments.isEmpty()) - s.startTime = xSegments.last().startTime + xSegments.last().deltaTime * xSegments.last().stopProgress; - else if (orientation == Qt::Vertical && !ySegments.isEmpty()) - s.startTime = ySegments.last().startTime + ySegments.last().deltaTime * ySegments.last().stopProgress; - else - s.startTime = monotonicTimer.elapsed(); - - s.startPos = startPos; - s.deltaPos = deltaPos; - s.stopPos = stopPos; - s.deltaTime = deltaTime * 1000; - s.stopProgress = stopProgress; - s.curve.setType(curve); - s.type = type; - - if (orientation == Qt::Horizontal) - xSegments.enqueue(s); - else - ySegments.enqueue(s); - - qScrollerDebug() << "+++ Added a new ScrollSegment: " << s; -} - - -/*! \internal - Clears the old segments and recalculates them if the current segments are not longer valid -*/ -void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc) -{ - Q_Q(QScroller); - QPointF ppm = q->pixelPerMeter(); - - releaseVelocity = q->velocity(); - - if (forceRecalc || !scrollingSegmentsValid(Qt::Horizontal)) - createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal); - - if (forceRecalc || !scrollingSegmentsValid(Qt::Vertical)) - createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical); -} - -/*! \internal - Returns the end position after the current scroll has finished. -*/ -qreal QScrollerPrivate::scrollingSegmentsEndPos(Qt::Orientation orientation) const -{ - if (orientation == Qt::Horizontal) { - if (xSegments.isEmpty()) - return contentPosition.x() + overshootPosition.x(); - else - return xSegments.last().stopPos; - } else { - if (ySegments.isEmpty()) - return contentPosition.y() + overshootPosition.y(); - else - return ySegments.last().stopPos; - } -} - -/*! \internal - Checks if the scroller segment end in a valid position. -*/ -bool QScrollerPrivate::scrollingSegmentsValid(Qt::Orientation orientation) -{ - QQueue<ScrollSegment> *segments; - qreal minPos; - qreal maxPos; - - if (orientation == Qt::Horizontal) { - segments = &xSegments; - minPos = contentPosRange.left(); - maxPos = contentPosRange.right(); - } else { - segments = &ySegments; - minPos = contentPosRange.top(); - maxPos = contentPosRange.bottom(); - } - - if (segments->isEmpty()) - return true; - - const ScrollSegment &last = segments->last(); - qreal stopPos = last.stopPos; - - if (last.type == ScrollTypeScrollTo) - return true; // scrollTo is always valid - - if (last.type == ScrollTypeOvershoot && - (stopPos != minPos && stopPos != maxPos)) - return false; - - if (stopPos < minPos || stopPos > maxPos) - return false; - - if (stopPos == minPos || stopPos == maxPos) // the begin and the end of the list are always ok - return true; - - qreal nextSnap = nextSnapPos(stopPos, 0, orientation); - if (!qIsNaN(nextSnap) && stopPos != nextSnap) - return false; - - return true; -} - -/*! \internal - Creates the sections needed to scroll to the specific \a endPos to the segments queue. -*/ -void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type) -{ - Q_UNUSED(v); - - if (orientation == Qt::Horizontal) - xSegments.clear(); - else - ySegments.clear(); - - qScrollerDebug() << "+++ createScrollToSegments: t:" << deltaTime << "ep:" << endPos << "o:" << int(orientation); - - const QScrollerPropertiesPrivate *sp = properties.d.data(); - - qreal startPos = (orientation == Qt::Horizontal) ? contentPosition.x() + overshootPosition.x() - : contentPosition.y() + overshootPosition.y(); - qreal deltaPos = (endPos - startPos) / 2; - - pushSegment(type, deltaTime * qreal(0.3), qreal(1.0), startPos, deltaPos, startPos + deltaPos, QEasingCurve::InQuad, orientation); - pushSegment(type, deltaTime * qreal(0.7), qreal(1.0), startPos + deltaPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); -} - -/*! \internal -*/ -void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation) -{ - const QScrollerPropertiesPrivate *sp = properties.d.data(); - - QScrollerProperties::OvershootPolicy policy; - qreal minPos; - qreal maxPos; - qreal viewSize; - - if (orientation == Qt::Horizontal) { - xSegments.clear(); - policy = sp->hOvershootPolicy; - minPos = contentPosRange.left(); - maxPos = contentPosRange.right(); - viewSize = viewportSize.width(); - } else { - ySegments.clear(); - policy = sp->vOvershootPolicy; - minPos = contentPosRange.top(); - maxPos = contentPosRange.bottom(); - viewSize = viewportSize.height(); - } - - bool alwaysOvershoot = (policy == QScrollerProperties::OvershootAlwaysOn); - bool noOvershoot = (policy == QScrollerProperties::OvershootAlwaysOff) || !sp->overshootScrollDistanceFactor; - bool canOvershoot = !noOvershoot && (alwaysOvershoot || maxPos); - - qScrollerDebug() << "+++ createScrollingSegments: s:" << startPos << "maxPos:" << maxPos << "o:" << int(orientation); - - qScrollerDebug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type(); - - // This is only correct for QEasingCurve::OutQuad (linear velocity, - // constant deceleration), but the results look and feel ok for OutExpo - // and OutSine as well - - // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime) - // v(0) = vrelease - // v(deltaTime) = 0 - // deltaTime = (2 * vrelease) / (a * differntial(0)) - - // pos(t) = integrate(v(t)dt) - // pos(t) = vrelease * t - 0.5 * a * t * t - // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime - // deltaPos = pos(deltaTime) - - qreal deltaTime = (qreal(2) * qAbs(v)) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); - qreal deltaPos = qSign(v) * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor * ppm; - qreal endPos = startPos + deltaPos; - - qScrollerDebug() << " Real Delta:" << deltaPos; - - // -- determine snap points - qreal nextSnap = nextSnapPos(endPos, 0, orientation); - qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); - qreal higherSnapPos = nextSnapPos(startPos, 1, orientation); - - qScrollerDebug() << " Real Delta:" << lowerSnapPos <<"-"<<nextSnap <<"-"<<higherSnapPos; - - // - check if we can reach another snap point - if (nextSnap > higherSnapPos || qIsNaN(higherSnapPos)) - higherSnapPos = nextSnap; - if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos)) - lowerSnapPos = nextSnap; - - // -- check if are in overshoot and end in overshoot - if ((startPos < minPos && endPos < minPos) || - (startPos > maxPos && endPos > maxPos)) { - qreal stopPos = endPos < minPos ? minPos : maxPos; - qreal oDeltaTime = sp->overshootScrollTime; - - pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); - return; - } - - if (qAbs(v) < sp->minimumVelocity) { - - qScrollerDebug() << "### below minimum Vel" << orientation; - - // - no snap points or already at one - if (qIsNaN(nextSnap) || nextSnap == startPos) - return; // nothing to do, no scrolling needed. - - // - decide which point to use - - qreal snapDistance = higherSnapPos - lowerSnapPos; - - qreal pressDistance = (orientation == Qt::Horizontal) ? - lastPosition.x() - pressPosition.x() : - lastPosition.y() - pressPosition.y(); - - // if not dragged far enough, pick the next snap point. - if (sp->snapPositionRatio == 0.0 || qAbs(pressDistance / sp->snapPositionRatio) > snapDistance) - endPos = nextSnap; - else if (pressDistance < 0.0) - endPos = lowerSnapPos; - else - endPos = higherSnapPos; - - deltaPos = endPos - startPos; - qreal midPos = startPos + deltaPos * qreal(0.3); - pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.3), qreal(1.0), startPos, midPos - startPos, midPos, QEasingCurve::InQuad, orientation); - pushSegment(ScrollTypeFlick, sp->snapTime * qreal(0.7), qreal(1.0), midPos, endPos - midPos, endPos, sp->scrollingCurve.type(), orientation); - return; - } - - // - go to the next snappoint if there is one - if (v > 0 && !qIsNaN(higherSnapPos)) { - // change the time in relation to the changed end position - if (endPos - startPos) - deltaTime *= qAbs((higherSnapPos - startPos) / (endPos - startPos)); - if (deltaTime > sp->snapTime) - deltaTime = sp->snapTime; - endPos = higherSnapPos; - - } else if (v < 0 && !qIsNaN(lowerSnapPos)) { - // change the time in relation to the changed end position - if (endPos - startPos) - deltaTime *= qAbs((lowerSnapPos - startPos) / (endPos - startPos)); - if (deltaTime > sp->snapTime) - deltaTime = sp->snapTime; - endPos = lowerSnapPos; - - // -- check if we are overshooting - } else if (endPos < minPos || endPos > maxPos) { - qreal stopPos = endPos < minPos ? minPos : maxPos; - - qScrollerDebug() << "Overshoot: delta:" << (stopPos - startPos); - - qreal stopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos - startPos) / deltaPos)); - - if (!canOvershoot) { - qScrollerDebug() << "Overshoot stopp:" << stopProgress; - - pushSegment(ScrollTypeFlick, deltaTime, stopProgress, startPos, endPos, stopPos, sp->scrollingCurve.type(), orientation); - } else { - qreal oDeltaTime = sp->overshootScrollTime; - qreal oStopProgress = qMin(stopProgress + oDeltaTime * qreal(0.3) / deltaTime, qreal(1)); - qreal oDistance = startPos + deltaPos * sp->scrollingCurve.valueForProgress(oStopProgress) - stopPos; - qreal oMaxDistance = qSign(oDistance) * (viewSize * sp->overshootScrollDistanceFactor); - - qScrollerDebug() << "1 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress; - - if (qAbs(oDistance) > qAbs(oMaxDistance)) { - oStopProgress = progressForValue(sp->scrollingCurve, qAbs((stopPos + oMaxDistance - startPos) / deltaPos)); - oDistance = oMaxDistance; - qScrollerDebug() << "2 oDistance:" << oDistance << "Max:" << oMaxDistance << "stopP/oStopP" << stopProgress << oStopProgress; - } - - pushSegment(ScrollTypeFlick, deltaTime, oStopProgress, startPos, deltaPos, stopPos + oDistance, sp->scrollingCurve.type(), orientation); - pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), stopPos + oDistance, -oDistance, stopPos, sp->scrollingCurve.type(), orientation); - } - return; - } - - pushSegment(ScrollTypeFlick, deltaTime, qreal(1.0), startPos, deltaPos, endPos, sp->scrollingCurve.type(), orientation); -} - - -/*! \internal - Prepares scrolling by sending a QScrollPrepareEvent to the receiver widget. - Returns true if the scrolling was accepted and a target was returned. -*/ -bool QScrollerPrivate::prepareScrolling(const QPointF &position) -{ - QScrollPrepareEvent spe(position); - spe.ignore(); - sendEvent(target, &spe); - - qScrollerDebug() << "QScrollPrepareEvent returned from" << target << "with" << spe.isAccepted() << "mcp:" << spe.contentPosRange() << "cp:" << spe.contentPos(); - if (spe.isAccepted()) { - QPointF oldContentPos = contentPosition + overshootPosition; - QPointF contentDelta = spe.contentPos() - oldContentPos; - - viewportSize = spe.viewportSize(); - contentPosRange = spe.contentPosRange(); - if (contentPosRange.width() < 0) - contentPosRange.setWidth(0); - if (contentPosRange.height() < 0) - contentPosRange.setHeight(0); - contentPosition = clampToRect(spe.contentPos(), contentPosRange); - overshootPosition = spe.contentPos() - contentPosition; - - // - check if the content position was moved - if (contentDelta != QPointF(0, 0)) { - // need to correct all segments - for (int i = 0; i < xSegments.count(); i++) - xSegments[i].startPos -= contentDelta.x(); - - for (int i = 0; i < ySegments.count(); i++) - ySegments[i].startPos -= contentDelta.y(); - } - - if (QWidget *w = qobject_cast<QWidget *>(target)) - setDpiFromWidget(w); -#ifndef QT_NO_GRAPHICSVIEW - if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(target)) { - //TODO: the first view isn't really correct - maybe use an additional field in the prepare event? - if (go->scene() && !go->scene()->views().isEmpty()) - setDpiFromWidget(go->scene()->views().first()); - } -#endif - - if (state == QScroller::Scrolling) { - recalcScrollingSegments(); - } - return true; - } - - return false; -} - -void QScrollerPrivate::handleDrag(const QPointF &position, qint64 timestamp) -{ - const QScrollerPropertiesPrivate *sp = properties.d.data(); - - QPointF deltaPixel = position - lastPosition; - qint64 deltaTime = timestamp - lastTimestamp; - - if (sp->axisLockThreshold) { - int dx = qAbs(deltaPixel.x()); - int dy = qAbs(deltaPixel.y()); - if (dx || dy) { - bool vertical = (dy > dx); - qreal alpha = qreal(vertical ? dx : dy) / qreal(vertical ? dy : dx); - //qScrollerDebug() << "QScroller::handleDrag() -- axis lock:" << alpha << " / " << axisLockThreshold << "- isvertical:" << vertical << "- dx:" << dx << "- dy:" << dy; - if (alpha <= sp->axisLockThreshold) { - if (vertical) - deltaPixel.setX(0); - else - deltaPixel.setY(0); - } - } - } - - // calculate velocity (if the user would release the mouse NOW) - updateVelocity(deltaPixel, deltaTime); - - // restrict velocity, if content is not scrollable - QRectF max = contentPosRange; - bool canScrollX = (max.width() > 0) || (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); - bool canScrollY = (max.height() > 0) || (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); - - if (!canScrollX) { - deltaPixel.setX(0); - releaseVelocity.setX(0); - } - if (!canScrollY) { - deltaPixel.setY(0); - releaseVelocity.setY(0); - } - -// if (firstDrag) { -// // Do not delay the first drag -// setContentPositionHelper(q->contentPosition() - overshootDistance - deltaPixel); -// dragDistance = QPointF(0, 0); -// } else { - dragDistance += deltaPixel; -// } -//qScrollerDebug() << "######################" << deltaPixel << position.y() << lastPosition.y(); - if (canScrollX) - lastPosition.setX(position.x()); - if (canScrollY) - lastPosition.setY(position.y()); - lastTimestamp = timestamp; -} - -bool QScrollerPrivate::pressWhileInactive(const QPointF &position, qint64 timestamp) -{ - if (prepareScrolling(position)) { - const QScrollerPropertiesPrivate *sp = properties.d.data(); - - if (!contentPosRange.isNull() || - (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) || - (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn)) { - - lastPosition = pressPosition = position; - lastTimestamp = pressTimestamp = timestamp; - setState(QScroller::Pressed); - } - } - return false; -} - -bool QScrollerPrivate::releaseWhilePressed(const QPointF &, qint64) -{ - if (overshootPosition != QPointF(0.0, 0.0)) { - setState(QScroller::Scrolling); - return true; - } else { - setState(QScroller::Inactive); - return false; - } -} - -bool QScrollerPrivate::moveWhilePressed(const QPointF &position, qint64 timestamp) -{ - Q_Q(QScroller); - const QScrollerPropertiesPrivate *sp = properties.d.data(); - QPointF ppm = q->pixelPerMeter(); - - QPointF deltaPixel = position - pressPosition; - - bool moveAborted = false; - bool moveStarted = (((deltaPixel / ppm).manhattanLength()) > sp->dragStartDistance); - - // check the direction of the mouse drag and abort if it's too much in the wrong direction. - if (moveStarted) { - QRectF max = contentPosRange; - bool canScrollX = (max.width() > 0); - bool canScrollY = (max.height() > 0); - - if (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) - canScrollX = true; - if (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn) - canScrollY = true; - - if (qAbs(deltaPixel.x() / ppm.x()) < qAbs(deltaPixel.y() / ppm.y())) { - if (!canScrollY) - moveAborted = true; - } else { - if (!canScrollX) - moveAborted = true; - } - } - - if (moveAborted) { - setState(QScroller::Inactive); - moveStarted = false; - - } else if (moveStarted) { - setState(QScroller::Dragging); - - // subtract the dragStartDistance - deltaPixel = deltaPixel - deltaPixel * (sp->dragStartDistance / deltaPixel.manhattanLength()); - - if (deltaPixel != QPointF(0, 0)) { - // handleDrag updates lastPosition, lastTimestamp and velocity - handleDrag(pressPosition + deltaPixel, timestamp); - } - } - return moveStarted; -} - -bool QScrollerPrivate::moveWhileDragging(const QPointF &position, qint64 timestamp) -{ - // handleDrag updates lastPosition, lastTimestamp and velocity - handleDrag(position, timestamp); - return true; -} - -void QScrollerPrivate::timerEventWhileDragging() -{ - if (dragDistance != QPointF(0, 0)) { - qScrollerDebug() << "QScroller::timerEventWhileDragging() -- dragDistance:" << dragDistance; - - setContentPositionHelperDragging(-dragDistance); - dragDistance = QPointF(0, 0); - } -} - -bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 timestamp) -{ - Q_Q(QScroller); - const QScrollerPropertiesPrivate *sp = properties.d.data(); - - // handleDrag updates lastPosition, lastTimestamp and velocity - handleDrag(position, timestamp); - - // check if we moved at all - this can happen if you stop a running - // scroller with a press and release shortly afterwards - QPointF deltaPixel = position - pressPosition; - if (((deltaPixel / q->pixelPerMeter()).manhattanLength()) > sp->dragStartDistance) { - - // handle accelerating flicks - if ((oldVelocity != QPointF(0, 0)) && sp->acceleratingFlickMaximumTime && - ((timestamp - pressTimestamp) < qint64(sp->acceleratingFlickMaximumTime * 1000))) { - - // - determine if the direction was changed - int signX = 0, signY = 0; - if (releaseVelocity.x()) - signX = (releaseVelocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1; - if (releaseVelocity.y()) - signY = (releaseVelocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1; - - if (signX > 0) - releaseVelocity.setX(qBound(-sp->maximumVelocity, - oldVelocity.x() * sp->acceleratingFlickSpeedupFactor, - sp->maximumVelocity)); - if (signY > 0) - releaseVelocity.setY(qBound(-sp->maximumVelocity, - oldVelocity.y() * sp->acceleratingFlickSpeedupFactor, - sp->maximumVelocity)); - } - } - - QPointF ppm = q->pixelPerMeter(); - createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal); - createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical); - - qScrollerDebug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition; - - if (xSegments.isEmpty() && ySegments.isEmpty()) - setState(QScroller::Inactive); - else - setState(QScroller::Scrolling); - - return true; -} - -void QScrollerPrivate::timerEventWhileScrolling() -{ - qScrollerDebug() << "QScroller::timerEventWhileScrolling()"; - - setContentPositionHelperScrolling(); - if (xSegments.isEmpty() && ySegments.isEmpty()) - setState(QScroller::Inactive); -} - -bool QScrollerPrivate::pressWhileScrolling(const QPointF &position, qint64 timestamp) -{ - Q_Q(QScroller); - - if ((q->velocity() <= properties.d->maximumClickThroughVelocity) && - (overshootPosition == QPointF(0.0, 0.0))) { - setState(QScroller::Inactive); - return false; - } else { - lastPosition = pressPosition = position; - lastTimestamp = pressTimestamp = timestamp; - setState(QScroller::Pressed); - setState(QScroller::Dragging); - return true; - } -} - -/*! \internal - This function handles all state changes of the scroller. -*/ -void QScrollerPrivate::setState(QScroller::State newstate) -{ - Q_Q(QScroller); - bool sendLastScroll = false; - - if (state == newstate) - return; - - qScrollerDebug() << q << "QScroller::setState(" << stateName(newstate) << ")"; - - switch (newstate) { - case QScroller::Inactive: -#ifndef QT_NO_ANIMATION - scrollTimer->stop(); -#endif - - // send the last scroll event (but only after the current state change was finished) - if (!firstScroll) - sendLastScroll = true; - - releaseVelocity = QPointF(0, 0); - break; - - case QScroller::Pressed: -#ifndef QT_NO_ANIMATION - scrollTimer->stop(); -#endif - - oldVelocity = releaseVelocity; - releaseVelocity = QPointF(0, 0); - break; - - case QScroller::Dragging: - dragDistance = QPointF(0, 0); -#ifndef QT_NO_ANIMATION - if (state == QScroller::Pressed) - scrollTimer->start(); -#endif - break; - - case QScroller::Scrolling: -#ifndef QT_NO_ANIMATION - scrollTimer->start(); -#endif - break; - } - - qSwap(state, newstate); - - if (sendLastScroll) { - QScrollEvent se(contentPosition, overshootPosition, QScrollEvent::ScrollFinished); - sendEvent(target, &se); - firstScroll = true; - } - if (state == QScroller::Dragging || state == QScroller::Scrolling) - qt_activeScrollers()->insert(q); - else - qt_activeScrollers()->remove(q); - emit q->stateChanged(state); -} - - -/*! \internal - Helps when setting the content position. - It will try to move the content by the requested delta but stop in case - when we are coming back from an overshoot or a scrollTo. - It will also indicate a new overshooting condition by the overshootX and oversthootY flags. - - In this cases it will reset the velocity variables and other flags. - - Also keeps track of the current over-shooting value in overshootPosition. - - \a deltaPos is the amount of pixels the current content position should be moved -*/ -void QScrollerPrivate::setContentPositionHelperDragging(const QPointF &deltaPos) -{ - const QScrollerPropertiesPrivate *sp = properties.d.data(); - - if (sp->overshootDragResistanceFactor) - overshootPosition /= sp->overshootDragResistanceFactor; - - QPointF oldPos = contentPosition + overshootPosition; - QPointF newPos = oldPos + deltaPos; - - qScrollerDebug() << "QScroller::setContentPositionHelperDragging(" << deltaPos << " [pix])"; - qScrollerDebug() << " --> overshoot:" << overshootPosition << "- old pos:" << oldPos << "- new pos:" << newPos; - - QPointF oldClampedPos = clampToRect(oldPos, contentPosRange); - QPointF newClampedPos = clampToRect(newPos, contentPosRange); - - // --- handle overshooting and stop if the coordinate is going back inside the normal area - bool alwaysOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); - bool alwaysOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOn); - bool noOvershootX = (sp->hOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) || - ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) || - !sp->overshootDragDistanceFactor; - bool noOvershootY = (sp->vOvershootPolicy == QScrollerProperties::OvershootAlwaysOff) || - ((state == QScroller::Dragging) && !sp->overshootDragResistanceFactor) || - !sp->overshootDragDistanceFactor; - bool canOvershootX = !noOvershootX && (alwaysOvershootX || contentPosRange.width()); - bool canOvershootY = !noOvershootY && (alwaysOvershootY || contentPosRange.height()); - - qreal oldOvershootX = (canOvershootX) ? oldPos.x() - oldClampedPos.x() : 0; - qreal oldOvershootY = (canOvershootY) ? oldPos.y() - oldClampedPos.y() : 0; - - qreal newOvershootX = (canOvershootX) ? newPos.x() - newClampedPos.x() : 0; - qreal newOvershootY = (canOvershootY) ? newPos.y() - newClampedPos.y() : 0; - - qreal maxOvershootX = viewportSize.width() * sp->overshootDragDistanceFactor; - qreal maxOvershootY = viewportSize.height() * sp->overshootDragDistanceFactor; - - qScrollerDebug() << " --> noOs:" << noOvershootX << "drf:" << sp->overshootDragResistanceFactor << "mdf:" << sp->overshootScrollDistanceFactor << "ossP:"<<sp->hOvershootPolicy; - qScrollerDebug() << " --> canOS:" << canOvershootX << "newOS:" << newOvershootX << "maxOS:" << maxOvershootX; - - if (sp->overshootDragResistanceFactor) { - oldOvershootX *= sp->overshootDragResistanceFactor; - oldOvershootY *= sp->overshootDragResistanceFactor; - newOvershootX *= sp->overshootDragResistanceFactor; - newOvershootY *= sp->overshootDragResistanceFactor; - } - - // -- stop at the maximum overshoot distance - - newOvershootX = qBound(-maxOvershootX, newOvershootX, maxOvershootX); - newOvershootY = qBound(-maxOvershootY, newOvershootY, maxOvershootY); - - overshootPosition.setX(newOvershootX); - overshootPosition.setY(newOvershootY); - contentPosition = newClampedPos; - - QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); - sendEvent(target, &se); - firstScroll = false; - - qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition << - "- overshoot x/y?:" << overshootPosition; -} - - -qreal QScrollerPrivate::nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos) -{ - qreal pos = oldPos; - - // check the X segments for new positions - while (!segments.isEmpty()) { - const ScrollSegment s = segments.head(); - - if ((s.startTime + s.deltaTime * s.stopProgress) <= now) { - segments.dequeue(); - pos = s.stopPos; - } else if (s.startTime <= now) { - qreal progress = qreal(now - s.startTime) / qreal(s.deltaTime); - pos = s.startPos + s.deltaPos * s.curve.valueForProgress(progress); - if (s.deltaPos > 0 ? pos > s.stopPos : pos < s.stopPos) { - segments.dequeue(); - pos = s.stopPos; - } else { - break; - } - } else { - break; - } - } - return pos; -} - -void QScrollerPrivate::setContentPositionHelperScrolling() -{ - qint64 now = monotonicTimer.elapsed(); - QPointF newPos = contentPosition + overshootPosition; - - newPos.setX(nextSegmentPosition(xSegments, now, newPos.x())); - newPos.setY(nextSegmentPosition(ySegments, now, newPos.y())); - - // -- set the position and handle overshoot - qScrollerDebug() << "QScroller::setContentPositionHelperScrolling()"; - qScrollerDebug() << " --> overshoot:" << overshootPosition << "- new pos:" << newPos; - - QPointF newClampedPos = clampToRect(newPos, contentPosRange); - - overshootPosition = newPos - newClampedPos; - contentPosition = newClampedPos; - - QScrollEvent se(contentPosition, overshootPosition, firstScroll ? QScrollEvent::ScrollStarted : QScrollEvent::ScrollUpdated); - sendEvent(target, &se); - firstScroll = false; - - qScrollerDebug() << " --> new position:" << newClampedPos << "- new overshoot:" << overshootPosition; -} - -/*! \internal - Returns the next snap point in direction. - If \a direction >0 it will return the next snap point that is larger than the current position. - If \a direction <0 it will return the next snap point that is smaller than the current position. - If \a direction ==0 it will return the nearest snap point (or the current position if we are already - on a snap point. - Returns the nearest snap position or NaN if no such point could be found. - */ -qreal QScrollerPrivate::nextSnapPos(qreal p, int dir, Qt::Orientation orientation) -{ - qreal bestSnapPos = Q_QNAN; - qreal bestSnapPosDist = Q_INFINITY; - - qreal minPos; - qreal maxPos; - - if (orientation == Qt::Horizontal) { - minPos = contentPosRange.left(); - maxPos = contentPosRange.right(); - } else { - minPos = contentPosRange.top(); - maxPos = contentPosRange.bottom(); - } - - if (orientation == Qt::Horizontal) { - // the snap points in the list - foreach (qreal snapPos, snapPositionsX) { - qreal snapPosDist = snapPos - p; - if ((dir > 0 && snapPosDist < 0) || - (dir < 0 && snapPosDist > 0)) - continue; // wrong direction - if (snapPos < minPos || snapPos > maxPos ) - continue; // invalid - - if (qIsNaN(bestSnapPos) || - qAbs(snapPosDist) < bestSnapPosDist ) { - bestSnapPos = snapPos; - bestSnapPosDist = qAbs(snapPosDist); - } - } - - // the snap point interval - if (snapIntervalX > 0.0) { - qreal first = minPos + snapFirstX; - qreal snapPos; - if (dir > 0) - snapPos = qCeil((p - first) / snapIntervalX) * snapIntervalX + first; - else if (dir < 0) - snapPos = qFloor((p - first) / snapIntervalX) * snapIntervalX + first; - else if (p <= first) - snapPos = first; - else - { - qreal last = qFloor((maxPos - first) / snapIntervalX) * snapIntervalX + first; - if (p >= last) - snapPos = last; - else - snapPos = qRound((p - first) / snapIntervalX) * snapIntervalX + first; - } - - if (snapPos >= first && snapPos <= maxPos ) { - qreal snapPosDist = snapPos - p; - - if (qIsNaN(bestSnapPos) || - qAbs(snapPosDist) < bestSnapPosDist ) { - bestSnapPos = snapPos; - bestSnapPosDist = qAbs(snapPosDist); - } - } - } - - } else { // (orientation == Qt::Vertical) - // the snap points in the list - foreach (qreal snapPos, snapPositionsY) { - qreal snapPosDist = snapPos - p; - if ((dir > 0 && snapPosDist < 0) || - (dir < 0 && snapPosDist > 0)) - continue; // wrong direction - if (snapPos < minPos || snapPos > maxPos ) - continue; // invalid - - if (qIsNaN(bestSnapPos) || - qAbs(snapPosDist) < bestSnapPosDist) { - bestSnapPos = snapPos; - bestSnapPosDist = qAbs(snapPosDist); - } - } - - // the snap point interval - if (snapIntervalY > 0.0) { - qreal first = minPos + snapFirstY; - qreal snapPos; - if (dir > 0) - snapPos = qCeil((p - first) / snapIntervalY) * snapIntervalY + first; - else if (dir < 0) - snapPos = qFloor((p - first) / snapIntervalY) * snapIntervalY + first; - else if (p <= first) - snapPos = first; - else - { - qreal last = qFloor((maxPos - first) / snapIntervalY) * snapIntervalY + first; - if (p >= last) - snapPos = last; - else - snapPos = qRound((p - first) / snapIntervalY) * snapIntervalY + first; - } - - if (snapPos >= first && snapPos <= maxPos ) { - qreal snapPosDist = snapPos - p; - - if (qIsNaN(bestSnapPos) || - qAbs(snapPosDist) < bestSnapPosDist) { - bestSnapPos = snapPos; - bestSnapPosDist = qAbs(snapPosDist); - } - } - } - } - - return bestSnapPos; -} - -/*! - \enum QScroller::State - - This enum contains the different QScroller states. - - \value Inactive The scroller is not scrolling and nothing is pressed. - \value Pressed A touch event was received or the mouse button was pressed but the scroll area is currently not dragged. - \value Dragging The scroll area is currently following the touch point or mouse. - \value Scrolling The scroll area is moving on it's own. -*/ - -/*! - \enum QScroller::ScrollerGestureType - - This enum contains the different gesture types that are supported by the QScroller gesture recognizer. - - \value TouchGesture The gesture recognizer will only trigger on touch - events. Specifically it will react on single touch points when using a - touch screen and dual touch points when using a touchpad. - \value LeftMouseButtonGesture The gesture recognizer will only trigger on left mouse button events. - \value MiddleMouseButtonGesture The gesture recognizer will only trigger on middle mouse button events. - \value RightMouseButtonGesture The gesture recognizer will only trigger on right mouse button events. -*/ - -/*! - \enum QScroller::Input - - This enum contains an input device agnostic view of input events that are relevant for QScroller. - - \value InputPress The user pressed the input device (e.g. QEvent::MouseButtonPress, - QEvent::GraphicsSceneMousePress, QEvent::TouchBegin) - - \value InputMove The user moved the input device (e.g. QEvent::MouseMove, - QEvent::GraphicsSceneMouseMove, QEvent::TouchUpdate) - - \value InputRelease The user released the input device (e.g. QEvent::MouseButtonRelease, - QEvent::GraphicsSceneMouseRelease, QEvent::TouchEnd) - -*/ - -QT_END_NAMESPACE diff --git a/src/gui/util/qscroller.h b/src/gui/util/qscroller.h deleted file mode 100644 index 1599c7d..0000000 --- a/src/gui/util/qscroller.h +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSCROLLER_H -#define QSCROLLER_H - -#include <QtCore/QObject> -#include <QtCore/QPointF> -#include <QtGui/QScrollerProperties> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QWidget; -class QScrollerPrivate; -class QScrollerProperties; -#ifndef QT_NO_GESTURES -class QFlickGestureRecognizer; -class QMouseFlickGestureRecognizer; -#endif - -class Q_GUI_EXPORT QScroller : public QObject -{ - Q_OBJECT - Q_PROPERTY(State state READ state NOTIFY stateChanged) - Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged) - Q_ENUMS(State) - -public: - enum State - { - Inactive, - Pressed, - Dragging, - Scrolling - }; - - enum ScrollerGestureType - { - TouchGesture, - LeftMouseButtonGesture, - RightMouseButtonGesture, - MiddleMouseButtonGesture - }; - - enum Input - { - InputPress = 1, - InputMove, - InputRelease - }; - - static bool hasScroller(QObject *target); - - static QScroller *scroller(QObject *target); - static const QScroller *scroller(const QObject *target); - -#ifndef QT_NO_GESTURES - static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture); - static Qt::GestureType grabbedGesture(QObject *target); - static void ungrabGesture(QObject *target); -#endif - - static QList<QScroller *> activeScrollers(); - - QObject *target() const; - - State state() const; - - bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0); - - void stop(); - QPointF velocity() const; - QPointF finalPosition() const; - QPointF pixelPerMeter() const; - - QScrollerProperties scrollerProperties() const; - - void setSnapPositionsX( const QList<qreal> &positions ); - void setSnapPositionsX( qreal first, qreal interval ); - void setSnapPositionsY( const QList<qreal> &positions ); - void setSnapPositionsY( qreal first, qreal interval ); - -public Q_SLOTS: - void setScrollerProperties(const QScrollerProperties &prop); - void scrollTo(const QPointF &pos); - void scrollTo(const QPointF &pos, int scrollTime); - void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin); - void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime); - void resendPrepareEvent(); - -Q_SIGNALS: - void stateChanged(QScroller::State newstate); - void scrollerPropertiesChanged(const QScrollerProperties &); - -private: - QScrollerPrivate *d_ptr; - - QScroller(QObject *target); - virtual ~QScroller(); - - Q_DISABLE_COPY(QScroller) - Q_DECLARE_PRIVATE(QScroller) - -#ifndef QT_NO_GESTURES - friend class QFlickGestureRecognizer; -#endif -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSCROLLER_H diff --git a/src/gui/util/qscroller_mac.mm b/src/gui/util/qscroller_mac.mm deleted file mode 100644 index 4bf69c1..0000000 --- a/src/gui/util/qscroller_mac.mm +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/qglobal.h> - -#ifdef Q_WS_MAC - -#import <Cocoa/Cocoa.h> - -#include "qscroller_p.h" - -QPointF QScrollerPrivate::realDpi(int screen) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSArray *nsscreens = [NSScreen screens]; - - if (screen < 0 || screen >= int([nsscreens count])) - screen = 0; - - NSScreen *nsscreen = [nsscreens objectAtIndex:screen]; - CGDirectDisplayID display = [[[nsscreen deviceDescription] objectForKey:@"NSScreenNumber"] intValue]; - - CGSize mmsize = CGDisplayScreenSize(display); - if (mmsize.width > 0 && mmsize.height > 0) { - return QPointF(CGDisplayPixelsWide(display) / mmsize.width, - CGDisplayPixelsHigh(display) / mmsize.height) * qreal(25.4); - } else { - return QPointF(); - } - [pool release]; -} - -#endif diff --git a/src/gui/util/qscroller_p.h b/src/gui/util/qscroller_p.h deleted file mode 100644 index c119615..0000000 --- a/src/gui/util/qscroller_p.h +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSCROLLER_P_H -#define QSCROLLER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QObject> -#include <QPointer> -#include <QQueue> -#include <QSet> -#include <QEasingCurve> -#include <QElapsedTimer> -#include <QSizeF> -#include <QPointF> -#include <QRectF> -#include <qscroller.h> -#include <qscrollerproperties.h> -#include <private/qscrollerproperties_p.h> -#include <QAbstractAnimation> - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_GESTURES -class QFlickGestureRecognizer; -#endif - -#ifndef QT_NO_ANIMATION -class QScrollTimer; -#endif -class QScrollerPrivate : public QObject -{ - Q_OBJECT - Q_DECLARE_PUBLIC(QScroller) - -public: - QScrollerPrivate(QScroller *q, QObject *target); - void init(); - - void sendEvent(QObject *o, QEvent *e); - - void setState(QScroller::State s); - - enum ScrollType { - ScrollTypeFlick = 0, - ScrollTypeScrollTo, - ScrollTypeOvershoot - }; - - struct ScrollSegment { - qint64 startTime; - qint64 deltaTime; - qreal startPos; - qreal deltaPos; - QEasingCurve curve; - qreal stopProgress; // whatever is.. - qreal stopPos; // ..reached first - ScrollType type; - }; - - bool pressWhileInactive(const QPointF &position, qint64 timestamp); - bool moveWhilePressed(const QPointF &position, qint64 timestamp); - bool releaseWhilePressed(const QPointF &position, qint64 timestamp); - bool moveWhileDragging(const QPointF &position, qint64 timestamp); - bool releaseWhileDragging(const QPointF &position, qint64 timestamp); - bool pressWhileScrolling(const QPointF &position, qint64 timestamp); - - void timerTick(); - void timerEventWhileDragging(); - void timerEventWhileScrolling(); - - bool prepareScrolling(const QPointF &position); - void handleDrag(const QPointF &position, qint64 timestamp); - - QPointF realDpi(int screen); - QPointF dpi() const; - void setDpi(const QPointF &dpi); - void setDpiFromWidget(QWidget *widget); - - void updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime); - void pushSegment(ScrollType type, qreal deltaTime, qreal stopProgress, qreal startPos, qreal deltaPos, qreal stopPos, QEasingCurve::Type curve, Qt::Orientation orientation); - void recalcScrollingSegments(bool forceRecalc = false); - qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const; - bool scrollingSegmentsValid(Qt::Orientation orientation); - void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type); - void createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation); - - void setContentPositionHelperDragging(const QPointF &deltaPos); - void setContentPositionHelperScrolling(); - - qreal nextSnapPos(qreal p, int dir, Qt::Orientation orientation); - static qreal nextSegmentPosition(QQueue<ScrollSegment> &segments, qint64 now, qreal oldPos); - - inline int frameRateSkip() const { return properties.d.data()->frameRate; } - - static const char *stateName(QScroller::State state); - static const char *inputName(QScroller::Input input); - -public slots: - void targetDestroyed(); - -public: - // non static - QObject *target; - QScrollerProperties properties; -#ifndef QT_NO_GESTURES - QFlickGestureRecognizer *recognizer; - Qt::GestureType recognizerType; -#endif - - // scroller state: - - // QPointer<QObject> scrollTarget; - QSizeF viewportSize; - QRectF contentPosRange; - QPointF contentPosition; - QPointF overshootPosition; // the number of pixels we are overshooting (before overshootDragResistanceFactor) - - // state - - bool enabled; - QScroller::State state; - bool firstScroll; // true if we haven't already send a scroll event - - QPointF oldVelocity; // the release velocity of the last drag - - QPointF pressPosition; - QPointF lastPosition; - qint64 pressTimestamp; - qint64 lastTimestamp; - - QPointF dragDistance; // the distance we should move during the next drag timer event - - QQueue<ScrollSegment> xSegments; - QQueue<ScrollSegment> ySegments; - - // snap positions - QList<qreal> snapPositionsX; - qreal snapFirstX; - qreal snapIntervalX; - QList<qreal> snapPositionsY; - qreal snapFirstY; - qreal snapIntervalY; - - QPointF pixelPerMeter; - - QElapsedTimer monotonicTimer; - - QPointF releaseVelocity; // the starting velocity of the scrolling state -#ifndef QT_NO_ANIMATION - QScrollTimer *scrollTimer; -#endif - - QScroller *q_ptr; -}; - - -QT_END_NAMESPACE - -#endif // QSCROLLER_P_H - diff --git a/src/gui/util/qscrollerproperties.cpp b/src/gui/util/qscrollerproperties.cpp deleted file mode 100644 index 85e2e82..0000000 --- a/src/gui/util/qscrollerproperties.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QPointer> -#include <QObject> -#include <QtCore/qmath.h> -#ifdef Q_WS_WIN -# include <QLibrary> -#endif - -#include "qscrollerproperties.h" -#include "private/qscrollerproperties_p.h" - -QT_BEGIN_NAMESPACE - -static QScrollerPropertiesPrivate *userDefaults = 0; -static QScrollerPropertiesPrivate *systemDefaults = 0; - -QScrollerPropertiesPrivate *QScrollerPropertiesPrivate::defaults() -{ - if (!systemDefaults) { - QScrollerPropertiesPrivate spp; - spp.mousePressEventDelay = qreal(0.25); - spp.dragStartDistance = qreal(5.0 / 1000); - spp.dragVelocitySmoothingFactor = qreal(0.8); - spp.axisLockThreshold = qreal(0); - spp.scrollingCurve.setType(QEasingCurve::OutQuad); - spp.decelerationFactor = qreal(0.125); - spp.minimumVelocity = qreal(50.0 / 1000); - spp.maximumVelocity = qreal(500.0 / 1000); - spp.maximumClickThroughVelocity = qreal(66.5 / 1000); - spp.acceleratingFlickMaximumTime = qreal(1.25); - spp.acceleratingFlickSpeedupFactor = qreal(3.0); - spp.snapPositionRatio = qreal(0.5); - spp.snapTime = qreal(0.3); - spp.overshootDragResistanceFactor = qreal(0.5); - spp.overshootDragDistanceFactor = qreal(1); - spp.overshootScrollDistanceFactor = qreal(0.5); - spp.overshootScrollTime = qreal(0.7); -# ifdef Q_WS_WIN - if (QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback")) - spp.overshootScrollTime = qreal(0.35); -# endif - spp.hOvershootPolicy = QScrollerProperties::OvershootWhenScrollable; - spp.vOvershootPolicy = QScrollerProperties::OvershootWhenScrollable; - spp.frameRate = QScrollerProperties::Standard; - - systemDefaults = new QScrollerPropertiesPrivate(spp); - } - return new QScrollerPropertiesPrivate(userDefaults ? *userDefaults : *systemDefaults); -} - -/*! - \class QScrollerProperties - \brief The QScrollerProperties class stores the settings for a QScroller. - \since 4.8 - - The QScrollerProperties class stores the parameters used by QScroller. - - The default settings are platform dependent so that Qt emulates the - platform behaviour for kinetic scrolling. - - As a convention the QScrollerProperties are in physical units (meter, - seconds) and are converted by QScroller using the current DPI. - - \sa QScroller -*/ - -/*! - Constructs new scroller properties. -*/ -QScrollerProperties::QScrollerProperties() - : d(QScrollerPropertiesPrivate::defaults()) -{ -} - -/*! - Constructs a copy of \a sp. -*/ -QScrollerProperties::QScrollerProperties(const QScrollerProperties &sp) - : d(new QScrollerPropertiesPrivate(*sp.d)) -{ -} - -/*! - Assigns \a sp to these scroller properties and returns a reference to these scroller properties. -*/ -QScrollerProperties &QScrollerProperties::operator=(const QScrollerProperties &sp) -{ - *d.data() = *sp.d.data(); - return *this; -} - -/*! - Destroys the scroller properties. -*/ -QScrollerProperties::~QScrollerProperties() -{ -} - -/*! - Returns true if these scroller properties are equal to \a sp; otherwise returns false. -*/ -bool QScrollerProperties::operator==(const QScrollerProperties &sp) const -{ - return *d.data() == *sp.d.data(); -} - -/*! - Returns true if these scroller properties are different from \a sp; otherwise returns false. -*/ -bool QScrollerProperties::operator!=(const QScrollerProperties &sp) const -{ - return !(*d.data() == *sp.d.data()); -} - -bool QScrollerPropertiesPrivate::operator==(const QScrollerPropertiesPrivate &p) const -{ - bool same = true; - same &= (mousePressEventDelay == p.mousePressEventDelay); - same &= (dragStartDistance == p.dragStartDistance); - same &= (dragVelocitySmoothingFactor == p.dragVelocitySmoothingFactor); - same &= (axisLockThreshold == p.axisLockThreshold); - same &= (scrollingCurve == p.scrollingCurve); - same &= (decelerationFactor == p.decelerationFactor); - same &= (minimumVelocity == p.minimumVelocity); - same &= (maximumVelocity == p.maximumVelocity); - same &= (maximumClickThroughVelocity == p.maximumClickThroughVelocity); - same &= (acceleratingFlickMaximumTime == p.acceleratingFlickMaximumTime); - same &= (acceleratingFlickSpeedupFactor == p.acceleratingFlickSpeedupFactor); - same &= (snapPositionRatio == p.snapPositionRatio); - same &= (snapTime == p.snapTime); - same &= (overshootDragResistanceFactor == p.overshootDragResistanceFactor); - same &= (overshootDragDistanceFactor == p.overshootDragDistanceFactor); - same &= (overshootScrollDistanceFactor == p.overshootScrollDistanceFactor); - same &= (overshootScrollTime == p.overshootScrollTime); - same &= (hOvershootPolicy == p.hOvershootPolicy); - same &= (vOvershootPolicy == p.vOvershootPolicy); - same &= (frameRate == p.frameRate); - return same; -} - -/*! - Sets the scroller properties for all new QScrollerProperties objects to \a sp. - - Use this function to override the platform default properties returned by the default - constructor. If you only want to change the scroller properties of a single scroller, use - QScroller::setScrollerProperties() - - \note Calling this function will not change the content of already existing - QScrollerProperties objects. - - \sa unsetDefaultScrollerProperties() -*/ -void QScrollerProperties::setDefaultScrollerProperties(const QScrollerProperties &sp) -{ - if (!userDefaults) - userDefaults = new QScrollerPropertiesPrivate(*sp.d); - else - *userDefaults = *sp.d; -} - -/*! - Sets the scroller properties returned by the default constructor back to the platform default - properties. - - \sa setDefaultScrollerProperties() -*/ -void QScrollerProperties::unsetDefaultScrollerProperties() -{ - delete userDefaults; - userDefaults = 0; -} - -/*! - Query the \a metric value of the scroller properties. - - \sa setScrollMetric(), ScrollMetric -*/ -QVariant QScrollerProperties::scrollMetric(ScrollMetric metric) const -{ - switch (metric) { - case MousePressEventDelay: return d->mousePressEventDelay; - case DragStartDistance: return d->dragStartDistance; - case DragVelocitySmoothingFactor: return d->dragVelocitySmoothingFactor; - case AxisLockThreshold: return d->axisLockThreshold; - case ScrollingCurve: return d->scrollingCurve; - case DecelerationFactor: return d->decelerationFactor; - case MinimumVelocity: return d->minimumVelocity; - case MaximumVelocity: return d->maximumVelocity; - case MaximumClickThroughVelocity: return d->maximumClickThroughVelocity; - case AcceleratingFlickMaximumTime: return d->acceleratingFlickMaximumTime; - case AcceleratingFlickSpeedupFactor:return d->acceleratingFlickSpeedupFactor; - case SnapPositionRatio: return d->snapPositionRatio; - case SnapTime: return d->snapTime; - case OvershootDragResistanceFactor: return d->overshootDragResistanceFactor; - case OvershootDragDistanceFactor: return d->overshootDragDistanceFactor; - case OvershootScrollDistanceFactor: return d->overshootScrollDistanceFactor; - case OvershootScrollTime: return d->overshootScrollTime; - case HorizontalOvershootPolicy: return QVariant::fromValue(d->hOvershootPolicy); - case VerticalOvershootPolicy: return QVariant::fromValue(d->vOvershootPolicy); - case FrameRate: return QVariant::fromValue(d->frameRate); - case ScrollMetricCount: break; - } - return QVariant(); -} - -/*! - Set a specific value of the \a metric ScrollerMetric to \a value. - - \sa scrollMetric(), ScrollMetric -*/ -void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &value) -{ - switch (metric) { - case MousePressEventDelay: d->mousePressEventDelay = value.toReal(); break; - case DragStartDistance: d->dragStartDistance = value.toReal(); break; - case DragVelocitySmoothingFactor: d->dragVelocitySmoothingFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; - case AxisLockThreshold: d->axisLockThreshold = qBound(qreal(0), value.toReal(), qreal(1)); break; - case ScrollingCurve: d->scrollingCurve = value.toEasingCurve(); break; - case DecelerationFactor: d->decelerationFactor = value.toReal(); break; - case MinimumVelocity: d->minimumVelocity = value.toReal(); break; - case MaximumVelocity: d->maximumVelocity = value.toReal(); break; - case MaximumClickThroughVelocity: d->maximumClickThroughVelocity = value.toReal(); break; - case AcceleratingFlickMaximumTime: d->acceleratingFlickMaximumTime = value.toReal(); break; - case AcceleratingFlickSpeedupFactor:d->acceleratingFlickSpeedupFactor = value.toReal(); break; - case SnapPositionRatio: d->snapPositionRatio = qBound(qreal(0), value.toReal(), qreal(1)); break; - case SnapTime: d->snapTime = value.toReal(); break; - case OvershootDragResistanceFactor: d->overshootDragResistanceFactor = value.toReal(); break; - case OvershootDragDistanceFactor: d->overshootDragDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; - case OvershootScrollDistanceFactor: d->overshootScrollDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; - case OvershootScrollTime: d->overshootScrollTime = value.toReal(); break; - case HorizontalOvershootPolicy: d->hOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break; - case VerticalOvershootPolicy: d->vOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break; - case FrameRate: d->frameRate = value.value<QScrollerProperties::FrameRates>(); break; - case ScrollMetricCount: break; - } -} - -/*! - \enum QScrollerProperties::FrameRates - - This enum describes the available frame rates used while dragging or scrolling. - - \value Fps60 60 frames per second - \value Fps30 30 frames per second - \value Fps20 20 frames per second - \value Standard the default value is 60 frames per second (which corresponds to QAbstractAnimation). -*/ - -/*! - \enum QScrollerProperties::OvershootPolicy - - This enum describes the various modes of overshooting. - - \value OvershootWhenScrollable Overshooting is possible when the content is scrollable. This is the - default. - - \value OvershootAlwaysOff Overshooting is never enabled, even when the content is scrollable. - - \value OvershootAlwaysOn Overshooting is always enabled, even when the content is not - scrollable. -*/ - -/*! - \enum QScrollerProperties::ScrollMetric - - This enum contains the different scroll metric types. When not indicated otherwise the - setScrollMetric function expects a QVariant of type qreal. - - See the QScroller documentation for further details of the concepts behind the different - values. - - \value MousePressEventDelay This is the time a mouse press event is delayed when starting - a flick gesture in \c{[s]}. If the gesture is triggered within that time, no mouse press or - release is sent to the scrolled object. If it triggers after that delay the delayed - mouse press plus a faked release event at global postion \c{QPoint(-QWIDGETSIZE_MAX, - -QWIDGETSIZE_MAX)} is sent. If the gesture is canceled, then both the delayed mouse - press plus the real release event are delivered. - - \value DragStartDistance This is the minimum distance the touch or mouse point needs to be - moved before the flick gesture is triggered in \c m. - - \value DragVelocitySmoothingFactor A value that describes to which extent new drag velocities are - included in the final scrolling velocity. This value should be in the range between \c 0 and - \c 1. The lower the value, the more smoothing is applied to the dragging velocity. - - \value AxisLockThreshold Restricts the movement to one axis if the movement is inside an angle - around the axis. The threshold must be in the range \c 0 to \c 1. - - \value ScrollingCurve The QEasingCurve used when decelerating the scrolling velocity after an - user initiated flick. Please note that this is the easing curve for the positions, \bold{not} - the velocity: the default is QEasingCurve::OutQuad, which results in a linear decrease in - velocity (1st derivative) and a constant deceleration (2nd derivative). - - \value DecelerationFactor This factor influences how long it takes the scroller to decelerate - to 0 velocity. The actual value depends on the chosen ScrollingCurve. For most - types the value should be in the range from \c 0.1 to \c 2.0 - - \value MinimumVelocity The minimum velocity that is needed after ending the touch or releasing - the mouse to start scrolling in \c{m/s}. - - \value MaximumVelocity This is the maximum velocity that can be reached in \c{m/s}. - - \value MaximumClickThroughVelocity This is the maximum allowed scroll speed for a click-through - in \c{m/s}. This means that a click on a currently (slowly) scrolling object will not only stop - the scrolling but the click event will also be delivered to the UI control. This is - useful when using exponential-type scrolling curves. - - \value AcceleratingFlickMaximumTime This is the maximum time in \c seconds that a flick gesture - can take to be recognized as an accelerating flick. If set to zero no such gesture is - detected. An "accelerating flick" is a flick gesture executed on an already scrolling object. - In such cases the scrolling speed is multiplied by AcceleratingFlickSpeedupFactor in order to - accelerate it. - - \value AcceleratingFlickSpeedupFactor The current speed is multiplied by this number if an - accelerating flick is detected. Should be \c{>= 1}. - - \value SnapPositionRatio This is the distance that the user must drag the area beween two snap - points in order to snap it to the next position. \c{0.33} means that the scroll must only - reach one third of the distance between two snap points to snap to the next one. The ratio must - be between \c 0 and \c 1. - - \value SnapTime This is the time factor for the scrolling curve. A lower value means that the - scrolling will take longer. The scrolling distance is independet of this value. - - \value OvershootDragResistanceFactor This value is the factor between the mouse dragging and - the actual scroll area movement (during overshoot). The factor must be between \c 0 and \c 1. - - \value OvershootDragDistanceFactor This is the maximum distance for overshoot movements while - dragging. The actual overshoot distance is calculated by multiplying this value with the - viewport size of the scrolled object. The factor must be between \c 0 and \c 1. - - \value OvershootScrollDistanceFactor This is the maximum distance for overshoot movements while - scrolling. The actual overshoot distance is calculated by multiplying this value with the - viewport size of the scrolled object. The factor must be between \c 0 and \c 1. - - \value OvershootScrollTime This is the time in \c seconds that is used to play the - complete overshoot animation. - - \value HorizontalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy). - - \value VerticalOvershootPolicy This is the horizontal overshooting policy (see OvershootPolicy). - - \value FrameRate This is the frame rate which should be used while dragging or scrolling. - QScroller uses a QAbstractAnimation timer internally to sync all scrolling operations to other - animations that might be active at the same time. If the standard value of 60 frames per - second is too fast, it can be lowered with this setting, - while still being in-sync with QAbstractAnimation. Please note that only the values of the - FrameRates enum are allowed here. - - \value ScrollMetricCount This is always the last entry. -*/ - -QT_END_NAMESPACE diff --git a/src/gui/util/qscrollerproperties.h b/src/gui/util/qscrollerproperties.h deleted file mode 100644 index 75d8932..0000000 --- a/src/gui/util/qscrollerproperties.h +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSCROLLERPROPERTIES_H -#define QSCROLLERPROPERTIES_H - -#include <QtCore/QScopedPointer> -#include <QtCore/QMetaType> -#include <QtCore/QVariant> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QScroller; -class QScrollerPrivate; -class QScrollerPropertiesPrivate; - -class Q_GUI_EXPORT QScrollerProperties -{ -public: - QScrollerProperties(); - QScrollerProperties(const QScrollerProperties &sp); - QScrollerProperties &operator=(const QScrollerProperties &sp); - virtual ~QScrollerProperties(); - - bool operator==(const QScrollerProperties &sp) const; - bool operator!=(const QScrollerProperties &sp) const; - - static void setDefaultScrollerProperties(const QScrollerProperties &sp); - static void unsetDefaultScrollerProperties(); - - enum OvershootPolicy - { - OvershootWhenScrollable, - OvershootAlwaysOff, - OvershootAlwaysOn - }; - - enum FrameRates { - Standard, - Fps60, - Fps30, - Fps20 - }; - - enum ScrollMetric - { - MousePressEventDelay, // qreal [s] - DragStartDistance, // qreal [m] - DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF) - AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|) - - ScrollingCurve, // QEasingCurve - DecelerationFactor, // slope of the curve - - MinimumVelocity, // qreal [m/s] - MaximumVelocity, // qreal [m/s] - MaximumClickThroughVelocity, // qreal [m/s] - - AcceleratingFlickMaximumTime, // qreal [s] - AcceleratingFlickSpeedupFactor, // qreal [1..] - - SnapPositionRatio, // qreal [0..1] - SnapTime, // qreal [s] - - OvershootDragResistanceFactor, // qreal [0..1] - OvershootDragDistanceFactor, // qreal [0..1] - OvershootScrollDistanceFactor, // qreal [0..1] - OvershootScrollTime, // qreal [s] - - HorizontalOvershootPolicy, // enum OvershootPolicy - VerticalOvershootPolicy, // enum OvershootPolicy - FrameRate, // enum FrameRates - - ScrollMetricCount - }; - - QVariant scrollMetric(ScrollMetric metric) const; - void setScrollMetric(ScrollMetric metric, const QVariant &value); - -protected: - QScopedPointer<QScrollerPropertiesPrivate> d; - -private: - QScrollerProperties(QScrollerPropertiesPrivate &dd); - - friend class QScrollerPropertiesPrivate; - friend class QScroller; - friend class QScrollerPrivate; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QScrollerProperties::OvershootPolicy) -Q_DECLARE_METATYPE(QScrollerProperties::FrameRates) - -QT_END_HEADER - -#endif // QSCROLLERPROPERTIES_H diff --git a/src/gui/util/qscrollerproperties_p.h b/src/gui/util/qscrollerproperties_p.h deleted file mode 100644 index 76d8b0a..0000000 --- a/src/gui/util/qscrollerproperties_p.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSCROLLERPROPERTIES_P_H -#define QSCROLLERPROPERTIES_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QPointF> -#include <QEasingCurve> -#include <qscrollerproperties.h> - -QT_BEGIN_NAMESPACE - -class QScrollerPropertiesPrivate -{ -public: - static QScrollerPropertiesPrivate *defaults(); - - bool operator==(const QScrollerPropertiesPrivate &) const; - - qreal mousePressEventDelay; - qreal dragStartDistance; - qreal dragVelocitySmoothingFactor; - qreal axisLockThreshold; - QEasingCurve scrollingCurve; - qreal decelerationFactor; - qreal minimumVelocity; - qreal maximumVelocity; - qreal maximumClickThroughVelocity; - qreal acceleratingFlickMaximumTime; - qreal acceleratingFlickSpeedupFactor; - qreal snapPositionRatio; - qreal snapTime; - qreal overshootDragResistanceFactor; - qreal overshootDragDistanceFactor; - qreal overshootScrollDistanceFactor; - qreal overshootScrollTime; - QScrollerProperties::OvershootPolicy hOvershootPolicy; - QScrollerProperties::OvershootPolicy vOvershootPolicy; - QScrollerProperties::FrameRates frameRate; -}; - -QT_END_NAMESPACE - -#endif // QSCROLLERPROPERTIES_P_H - diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri index 2814a2d..f125f82 100644 --- a/src/gui/util/util.pri +++ b/src/gui/util/util.pri @@ -6,11 +6,6 @@ HEADERS += \ util/qcompleter_p.h \ util/qdesktopservices.h \ util/qsystemtrayicon_p.h \ - util/qscroller.h \ - util/qscroller_p.h \ - util/qscrollerproperties.h \ - util/qscrollerproperties_p.h \ - util/qflickgesture_p.h \ util/qundogroup.h \ util/qundostack.h \ util/qundostack_p.h \ @@ -20,9 +15,6 @@ SOURCES += \ util/qsystemtrayicon.cpp \ util/qcompleter.cpp \ util/qdesktopservices.cpp \ - util/qscroller.cpp \ - util/qscrollerproperties.cpp \ - util/qflickgesture.cpp \ util/qundogroup.cpp \ util/qundostack.cpp \ util/qundoview.cpp @@ -65,7 +57,3 @@ symbian { DEFINES += USE_SCHEMEHANDLER } } - -macx { - OBJECTIVE_SOURCES += util/qscroller_mac.mm -} diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index dabfec0..2503b99 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -53,8 +53,6 @@ #include "qpainter.h" #include "qmargins.h" -#include <QDebug> - #include "qabstractscrollarea_p.h" #include <qwidget.h> @@ -64,10 +62,6 @@ #include <private/qt_mac_p.h> #include <private/qt_cocoa_helpers_mac_p.h> #endif -#ifdef Q_WS_WIN -# include <qlibrary.h> -# include <windows.h> -#endif QT_BEGIN_NAMESPACE @@ -301,14 +295,9 @@ void QAbstractScrollAreaPrivate::init() q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layoutChildren(); #ifndef Q_WS_MAC -# ifndef QT_NO_GESTURES +#ifndef QT_NO_GESTURES viewport->grabGesture(Qt::PanGesture); -# endif #endif -#ifdef Q_WS_MAEMO_5 -# ifndef QT_NO_GESTURES - // viewport->grabGesture(Qt::TouchFlickGesture); -# endif #endif } @@ -563,11 +552,6 @@ void QAbstractScrollArea::setViewport(QWidget *widget) d->viewport->grabGesture(Qt::PanGesture); #endif #endif -#ifdef Q_WS_MAEMO_5 -#ifndef QT_NO_GESTURES -// d->viewport->grabGesture(Qt::TouchFlickGesture); -#endif -#endif d->layoutChildren(); if (isVisible()) d->viewport->show(); @@ -1002,66 +986,6 @@ bool QAbstractScrollArea::event(QEvent *e) return false; } #endif // QT_NO_GESTURES - case QEvent::ScrollPrepare: - { - QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e); - if (d->canStartScrollingAt(se->startPos().toPoint())) { - QScrollBar *hBar = horizontalScrollBar(); - QScrollBar *vBar = verticalScrollBar(); - - se->setViewportSize(QSizeF(viewport()->size())); - se->setContentPosRange(QRectF(0, 0, hBar->maximum(), vBar->maximum())); - se->setContentPos(QPointF(hBar->value(), vBar->value())); - se->accept(); - return true; - } - return false; - } - case QEvent::Scroll: - { - QScrollEvent *se = static_cast<QScrollEvent *>(e); - - QScrollBar *hBar = horizontalScrollBar(); - QScrollBar *vBar = verticalScrollBar(); - hBar->setValue(se->contentPos().x()); - vBar->setValue(se->contentPos().y()); - -#ifdef Q_WS_WIN - typedef BOOL (*PtrBeginPanningFeedback)(HWND); - typedef BOOL (*PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL); - typedef BOOL (*PtrEndPanningFeedback)(HWND, BOOL); - - static PtrBeginPanningFeedback ptrBeginPanningFeedback = 0; - static PtrUpdatePanningFeedback ptrUpdatePanningFeedback = 0; - static PtrEndPanningFeedback ptrEndPanningFeedback = 0; - - if (!ptrBeginPanningFeedback) - ptrBeginPanningFeedback = (PtrBeginPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "BeginPanningFeedback"); - if (!ptrUpdatePanningFeedback) - ptrUpdatePanningFeedback = (PtrUpdatePanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "UpdatePanningFeedback"); - if (!ptrEndPanningFeedback) - ptrEndPanningFeedback = (PtrEndPanningFeedback) QLibrary::resolve(QLatin1String("UxTheme"), "EndPanningFeedback"); - - if (ptrBeginPanningFeedback && ptrUpdatePanningFeedback && ptrEndPanningFeedback) { - WId wid = window()->winId(); - - if (!se->overshootDistance().isNull() && d->overshoot.isNull()) - ptrBeginPanningFeedback(wid); - if (!se->overshootDistance().isNull()) - ptrUpdatePanningFeedback(wid, -se->overshootDistance().x(), -se->overshootDistance().y(), false); - if (se->overshootDistance().isNull() && !d->overshoot.isNull()) - ptrEndPanningFeedback(wid, true); - } else -#endif - { - QPoint delta = d->overshoot - se->overshootDistance().toPoint(); - if (!delta.isNull()) - viewport()->move(viewport()->pos() + delta); - } - d->overshoot = se->overshootDistance().toPoint(); - - return true; - } case QEvent::StyleChange: case QEvent::LayoutDirectionChange: case QEvent::ApplicationLayoutDirectionChange: @@ -1123,9 +1047,6 @@ bool QAbstractScrollArea::viewportEvent(QEvent *e) case QEvent::GestureOverride: return event(e); #endif - case QEvent::ScrollPrepare: - case QEvent::Scroll: - return event(e); default: break; } @@ -1382,32 +1303,6 @@ void QAbstractScrollArea::scrollContentsBy(int, int) viewport()->update(); } -bool QAbstractScrollAreaPrivate::canStartScrollingAt( const QPoint &startPos ) -{ - Q_Q(QAbstractScrollArea); - -#ifndef QT_NO_GRAPHICSVIEW - // don't start scrolling when a drag mode has been set. - // don't start scrolling on a movable item. - if (QGraphicsView *view = qobject_cast<QGraphicsView *>(q)) { - if (view->dragMode() != QGraphicsView::NoDrag) - return false; - - QGraphicsItem *childItem = view->itemAt(startPos); - - if (childItem && (childItem->flags() & QGraphicsItem::ItemIsMovable)) - return false; - } -#endif - - // don't start scrolling on a QAbstractSlider - if (qobject_cast<QAbstractSlider *>(q->viewport()->childAt(startPos))) { - return false; - } - - return true; -} - void QAbstractScrollAreaPrivate::_q_hslide(int x) { Q_Q(QAbstractScrollArea); diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h index 76e1c34..85536e3 100644 --- a/src/gui/widgets/qabstractscrollarea_p.h +++ b/src/gui/widgets/qabstractscrollarea_p.h @@ -84,13 +84,11 @@ public: int left, top, right, bottom; // viewport margin int xoffset, yoffset; - QPoint overshoot; void init(); void layoutChildren(); // ### Fix for 4.4, talk to Bjoern E or Girish. virtual void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) {} - bool canStartScrollingAt( const QPoint &startPos ); void _q_hslide(int); void _q_vslide(int); diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index 22c5e51..0014b08 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -142,7 +142,6 @@ SUBDIRS=\ qregion \ qscrollarea \ qscrollbar \ - qscroller \ qsharedpointer_and_qwidget \ qshortcut \ qsidebar \ diff --git a/tests/auto/qscroller/qscroller.pro b/tests/auto/qscroller/qscroller.pro deleted file mode 100644 index 845dcb9..0000000 --- a/tests/auto/qscroller/qscroller.pro +++ /dev/null @@ -1,3 +0,0 @@ -load(qttest_p4) - -SOURCES += tst_qscroller.cpp diff --git a/tests/auto/qscroller/tst_qscroller.cpp b/tests/auto/qscroller/tst_qscroller.cpp deleted file mode 100644 index a9b3d9f..0000000 --- a/tests/auto/qscroller/tst_qscroller.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the $MODULE$ of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtGui> -#include <QtTest> -// #include <QDebug> - -class tst_QScrollerWidget : public QWidget -{ -public: - tst_QScrollerWidget() - : QWidget() - { - reset(); - } - - void reset() - { - receivedPrepare = false; - receivedScroll = false; - receivedFirst = false; - receivedLast = false; - receivedOvershoot = false; - } - - bool event(QEvent *e) - { - switch (e->type()) { - case QEvent::Gesture: - e->setAccepted(false); // better reject the event or QGestureManager will make trouble - return false; - - case QEvent::ScrollPrepare: - { - receivedPrepare = true; - QScrollPrepareEvent *se = static_cast<QScrollPrepareEvent *>(e); - se->setViewportSize(QSizeF(100,100)); - se->setContentPosRange(scrollArea); - se->setContentPos(scrollPosition); - se->accept(); - return true; - } - - case QEvent::Scroll: - { - receivedScroll = true; - QScrollEvent *se = static_cast<QScrollEvent *>(e); - // qDebug() << "Scroll for"<<this<<"pos"<<se->scrollPos()<<"ov"<<se->overshoot()<<"first"<<se->isFirst()<<"last"<<se->isLast(); - - if (se->scrollState() == QScrollEvent::ScrollStarted) - receivedFirst = true; - if (se->scrollState() == QScrollEvent::ScrollFinished) - receivedLast = true; - - currentPos = se->contentPos(); - overshoot = se->overshootDistance(); - if (!qFuzzyCompare( overshoot.x() + 1.0, 1.0 ) || - !qFuzzyCompare( overshoot.y() + 1.0, 1.0 )) - receivedOvershoot = true; - return true; - } - - default: - return QObject::event(e); - } - } - - - QRectF scrollArea; - QPointF scrollPosition; - - bool receivedPrepare; - bool receivedScroll; - bool receivedFirst; - bool receivedLast; - bool receivedOvershoot; - - QPointF currentPos; - QPointF overshoot; -}; - - -class tst_QScroller : public QObject -{ - Q_OBJECT -public: - tst_QScroller() { } - ~tst_QScroller() { } - -private: - void kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd); - void kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd); - -private slots: - void staticScrollers(); - void scrollerProperties(); - void scrollTo(); - void scroll(); - void overshoot(); -}; - -/*! \internal - Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling. - Tests some in between states but does not wait until scrolling is finished. -*/ -void tst_QScroller::kineticScroll( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd) -{ - sw->scrollPosition = from; - sw->currentPos= from; - - QScroller *s1 = QScroller::scroller(sw); - QCOMPARE( s1->state(), QScroller::Inactive ); - - QScrollerProperties sp1 = QScroller::scroller(sw)->scrollerProperties(); - int fps = 60; - - QTouchEvent::TouchPoint rawTouchPoint; - rawTouchPoint.setId(0); - - // send the touch begin event - QTouchEvent::TouchPoint touchPoint(0); - touchPoint.setState(Qt::TouchPointPressed); - touchPoint.setPos(touchStart); - touchPoint.setScenePos(touchStart); - touchPoint.setScreenPos(touchStart); - QTouchEvent touchEvent1(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - (QList<QTouchEvent::TouchPoint>() << touchPoint)); - QApplication::sendEvent(sw, &touchEvent1); - - QCOMPARE( s1->state(), QScroller::Pressed ); - - // send the touch update far enough to trigger a scroll - QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second. - touchPoint.setPos(touchUpdate); - touchPoint.setScenePos(touchUpdate); - touchPoint.setScreenPos(touchUpdate); - QTouchEvent touchEvent2(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointMoved, - (QList<QTouchEvent::TouchPoint>() << touchPoint)); - QApplication::sendEvent(sw, &touchEvent2); - - QCOMPARE( s1->state(), QScroller::Dragging ); - QCOMPARE( sw->receivedPrepare, true ); - - - QTest::qWait(1000 / fps * 2); // wait until the first scroll move - QCOMPARE( sw->receivedFirst, true ); - QCOMPARE( sw->receivedScroll, true ); - QCOMPARE( sw->receivedOvershoot, false ); - - // note that the scrolling goes in a different direction than the mouse move - QPoint calculatedPos = from.toPoint() - touchUpdate - touchStart; - QVERIFY(qAbs(sw->currentPos.x() - calculatedPos.x()) < 1.0); - QVERIFY(qAbs(sw->currentPos.y() - calculatedPos.y()) < 1.0); - - // send the touch end - touchPoint.setPos(touchEnd); - touchPoint.setScenePos(touchEnd); - touchPoint.setScreenPos(touchEnd); - QTouchEvent touchEvent5(QEvent::TouchEnd, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointReleased, - (QList<QTouchEvent::TouchPoint>() << touchPoint)); - QApplication::sendEvent(sw, &touchEvent5); -} - -/*! \internal - Generates touchBegin, touchUpdate and touchEnd events to trigger scrolling. - This function does not have any in between tests, it does not expect the scroller to actually scroll. -*/ -void tst_QScroller::kineticScrollNoTest( tst_QScrollerWidget *sw, QPointF from, QPoint touchStart, QPoint touchUpdate, QPoint touchEnd) -{ - sw->scrollPosition = from; - sw->currentPos = from; - - QScroller *s1 = QScroller::scroller(sw); - QCOMPARE( s1->state(), QScroller::Inactive ); - - QScrollerProperties sp1 = s1->scrollerProperties(); - int fps = 60; - - QTouchEvent::TouchPoint rawTouchPoint; - rawTouchPoint.setId(0); - - // send the touch begin event - QTouchEvent::TouchPoint touchPoint(0); - touchPoint.setState(Qt::TouchPointPressed); - touchPoint.setPos(touchStart); - touchPoint.setScenePos(touchStart); - touchPoint.setScreenPos(touchStart); - QTouchEvent touchEvent1(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - (QList<QTouchEvent::TouchPoint>() << touchPoint)); - QApplication::sendEvent(sw, &touchEvent1); - - // send the touch update far enough to trigger a scroll - QTest::qWait(200); // we need to wait a little or else the speed would be infinite. now we have around 500 pixel per second. - touchPoint.setPos(touchUpdate); - touchPoint.setScenePos(touchUpdate); - touchPoint.setScreenPos(touchUpdate); - QTouchEvent touchEvent2(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointMoved, - (QList<QTouchEvent::TouchPoint>() << touchPoint)); - QApplication::sendEvent(sw, &touchEvent2); - - QTest::qWait(1000 / fps * 2); // wait until the first scroll move - - // send the touch end - touchPoint.setPos(touchEnd); - touchPoint.setScenePos(touchEnd); - touchPoint.setScreenPos(touchEnd); - QTouchEvent touchEvent5(QEvent::TouchEnd, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointReleased, - (QList<QTouchEvent::TouchPoint>() << touchPoint)); - QApplication::sendEvent(sw, &touchEvent5); -} - - -void tst_QScroller::staticScrollers() -{ - // scrollers - { - QObject *o1 = new QObject(this); - QObject *o2 = new QObject(this); - - // get scroller for object - QScroller *s1 = QScroller::scroller(o1); - QScroller *s2 = QScroller::scroller(o2); - - QVERIFY(s1); - QVERIFY(s2); - QVERIFY(s1 != s2); - - QVERIFY(!QScroller::scroller(static_cast<const QObject*>(0))); - QCOMPARE(QScroller::scroller(o1), s1); - - delete o1; - delete o2; - } - - // the same for properties - { - QObject *o1 = new QObject(this); - QObject *o2 = new QObject(this); - - // get scroller for object - QScrollerProperties sp1 = QScroller::scroller(o1)->scrollerProperties(); - QScrollerProperties sp2 = QScroller::scroller(o2)->scrollerProperties(); - - // default properties should be the same - QVERIFY(sp1 == sp2); - - QCOMPARE(QScroller::scroller(o1)->scrollerProperties(), sp1); - - delete o1; - delete o2; - } -} - -void tst_QScroller::scrollerProperties() -{ - QObject *o1 = new QObject(this); - QScrollerProperties sp1 = QScroller::scroller(o1)->scrollerProperties(); - - QScrollerProperties::ScrollMetric metrics[] = - { - QScrollerProperties::MousePressEventDelay, // qreal [s] - QScrollerProperties::DragStartDistance, // qreal [m] - QScrollerProperties::DragVelocitySmoothingFactor, // qreal [0..1/s] (complex calculation involving time) v = v_new* DASF + v_old * (1-DASF) - QScrollerProperties::AxisLockThreshold, // qreal [0..1] atan(|min(dx,dy)|/|max(dx,dy)|) - - QScrollerProperties::DecelerationFactor, // slope of the curve - - QScrollerProperties::MinimumVelocity, // qreal [m/s] - QScrollerProperties::MaximumVelocity, // qreal [m/s] - QScrollerProperties::MaximumClickThroughVelocity, // qreal [m/s] - - QScrollerProperties::AcceleratingFlickMaximumTime, // qreal [s] - QScrollerProperties::AcceleratingFlickSpeedupFactor, // qreal [1..] - - QScrollerProperties::SnapPositionRatio, // qreal [0..1] - QScrollerProperties::SnapTime, // qreal [s] - - QScrollerProperties::OvershootDragResistanceFactor, // qreal [0..1] - QScrollerProperties::OvershootDragDistanceFactor, // qreal [0..1] - QScrollerProperties::OvershootScrollDistanceFactor, // qreal [0..1] - QScrollerProperties::OvershootScrollTime, // qreal [s] - }; - - for (unsigned int i = 0; i < sizeof(metrics) / sizeof(metrics[0]); i++) { - sp1.setScrollMetric(metrics[i], 0.9); - QCOMPARE(sp1.scrollMetric(metrics[i]).toDouble(), 0.9); - } - sp1.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutQuart)); - QCOMPARE(sp1.scrollMetric(QScrollerProperties::ScrollingCurve).toEasingCurve().type(), QEasingCurve::OutQuart); - - sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff)); - QCOMPARE(sp1.scrollMetric(QScrollerProperties::HorizontalOvershootPolicy).value<QScrollerProperties::OvershootPolicy>(), QScrollerProperties::OvershootAlwaysOff); - - sp1.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn)); - QCOMPARE(sp1.scrollMetric(QScrollerProperties::VerticalOvershootPolicy).value<QScrollerProperties::OvershootPolicy>(), QScrollerProperties::OvershootAlwaysOn); - - sp1.setScrollMetric(QScrollerProperties::FrameRate, QVariant::fromValue(QScrollerProperties::Fps20)); - QCOMPARE(sp1.scrollMetric(QScrollerProperties::FrameRate).value<QScrollerProperties::FrameRates>(), QScrollerProperties::Fps20); -} - -void tst_QScroller::scrollTo() -{ - { - tst_QScrollerWidget *sw = new tst_QScrollerWidget(); - sw->scrollArea = QRectF( 0, 0, 1000, 1000 ); - sw->scrollPosition = QPointF( 500, 500 ); - - QScroller *s1 = QScroller::scroller(sw); - QCOMPARE( s1->state(), QScroller::Inactive ); - - // a normal scroll - s1->scrollTo(QPointF(100,100), 100); - QTest::qWait(200); - - QCOMPARE( sw->receivedPrepare, true ); - QCOMPARE( sw->receivedScroll, true ); - QCOMPARE( sw->receivedFirst, true ); - QCOMPARE( sw->receivedLast, true ); - QCOMPARE( sw->receivedOvershoot, false ); - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 100 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 100 )); - - delete sw; - } -} - -void tst_QScroller::scroll() -{ -#if defined(Q_OS_MACX) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6) - QSKIP("Mac OS X < 10.6 does not support QTouchEvents", SkipAll); - return; -#endif - -#ifndef QT_NO_GESTURES - // -- good case. normal scroll - tst_QScrollerWidget *sw = new tst_QScrollerWidget(); - sw->scrollArea = QRectF(0, 0, 1000, 1000); - QScroller::grabGesture(sw, QScroller::TouchGesture); - sw->setGeometry(100, 100, 400, 300); - - QScroller *s1 = QScroller::scroller(sw); - kineticScroll(sw, QPointF(500, 500), QPoint(0, 0), QPoint(100, 100), QPoint(200, 200)); - // now we should be scrolling - QCOMPARE( s1->state(), QScroller::Scrolling ); - - // wait until finished, check that no further first scroll is send - sw->receivedFirst = false; - sw->receivedScroll = false; - while (s1->state() == QScroller::Scrolling) - QTest::qWait(100); - - QCOMPARE( sw->receivedFirst, false ); - QCOMPARE( sw->receivedScroll, true ); - QCOMPARE( sw->receivedLast, true ); - QVERIFY(sw->currentPos.x() < 400); - QVERIFY(sw->currentPos.y() < 400); - - // -- try to scroll when nothing to scroll - - sw->reset(); - sw->scrollArea = QRectF(0, 0, 0, 1000); - kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(100, 0), QPoint(200, 0)); - - while (s1->state() != QScroller::Inactive) - QTest::qWait(20); - - QCOMPARE(sw->currentPos.x(), 0.0); - QCOMPARE(sw->currentPos.y(), 500.0); - - delete sw; -#endif -} - -void tst_QScroller::overshoot() -{ -#if defined(Q_OS_MACX) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6) - QSKIP("Mac OS X < 10.6 does not support QTouchEvents", SkipAll); - return; -#endif - -#ifndef QT_NO_GESTURES - tst_QScrollerWidget *sw = new tst_QScrollerWidget(); - sw->scrollArea = QRectF(0, 0, 1000, 1000); - QScroller::grabGesture(sw, QScroller::TouchGesture); - sw->setGeometry(100, 100, 400, 300); - - QScroller *s1 = QScroller::scroller(sw); - QScrollerProperties sp1 = s1->scrollerProperties(); - - sp1.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.5); - sp1.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.2); - sp1.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.2); - - // -- try to scroll with overshoot (when scrollable good case) - - sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable)); - s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); - - while (s1->state() != QScroller::Inactive) - QTest::qWait(20); - - //qDebug() << "Overshoot fuzzy: "<<sw->currentPos; - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, true ); - - // -- try to scroll with overshoot (when scrollable bad case) - sw->reset(); - sw->scrollArea = QRectF(0, 0, 0, 1000); - - sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootWhenScrollable)); - s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); - - while (s1->state() != QScroller::Inactive) - QTest::qWait(20); - - //qDebug() << "Overshoot fuzzy: "<<sw->currentPos; - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, false ); - - // -- try to scroll with overshoot (always on) - sw->reset(); - sw->scrollArea = QRectF(0, 0, 0, 1000); - - sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn)); - s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(0, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); - - while (s1->state() != QScroller::Inactive) - QTest::qWait(20); - - //qDebug() << "Overshoot fuzzy: "<<sw->currentPos; - - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, true ); - - // -- try to scroll with overshoot (always off) - sw->reset(); - sw->scrollArea = QRectF(0, 0, 1000, 1000); - - sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff)); - s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); - - while (s1->state() != QScroller::Inactive) - QTest::qWait(20); - - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, false ); - - // -- try to scroll with overshoot (always on but max overshoot = 0) - sp1.setScrollMetric(QScrollerProperties::OvershootDragDistanceFactor, 0.0); - sp1.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.0); - sw->reset(); - sw->scrollArea = QRectF(0, 0, 1000, 1000); - - sp1.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue(QScrollerProperties::OvershootAlwaysOn)); - s1->setScrollerProperties(sp1); - kineticScrollNoTest(sw, QPointF(500, 500), QPoint(0, 0), QPoint(400, 0), QPoint(490, 0)); - - while (s1->state() != QScroller::Inactive) - QTest::qWait(20); - - QVERIFY(qFuzzyCompare( sw->currentPos.x(), 0 )); - QVERIFY(qFuzzyCompare( sw->currentPos.y(), 500 )); - QCOMPARE( sw->receivedOvershoot, false ); - - - delete sw; -#endif -} - - -QTEST_MAIN(tst_QScroller) - -#include "tst_qscroller.moc" diff --git a/tools/qml/texteditautoresizer_maemo5.h b/tools/qml/texteditautoresizer_maemo5.h index 71dbce0..e82d006 100644 --- a/tools/qml/texteditautoresizer_maemo5.h +++ b/tools/qml/texteditautoresizer_maemo5.h @@ -41,7 +41,7 @@ #include <QtGui/qplaintextedit.h> #include <QtGui/qtextedit.h> -#include <QtGui/qscroller.h> +#include <QtGui/qabstractkineticscroller.h> #include <QtGui/qscrollarea.h> #include <QtDebug> @@ -102,11 +102,11 @@ void TextEditAutoResizer::textEditChanged() QPoint scrollto = area->widget()->mapFrom(edit, cursor.center()); QPoint margin(10 + cursor.width(), 2 * cursor.height()); -#ifdef Q_WS_MAEMO_5 - QScroller::scroller(area)->ensureVisible(scrollto, margin.x(), margin.y()); -#else - area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y()); -#endif + if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) { + scroller->ensureVisible(scrollto, margin.x(), margin.y()); + } else { + area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y()); + } } } -- cgit v0.12