From 4f116f00fcd93decbf6fc01b61b0be7c293d3c39 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Mon, 5 Aug 2019 15:24:16 +0300 Subject: Fix GCC 4.8 build Change-Id: I4994146b359e8e37f6c0fa1b27f03fb9e800fdd5 Fixes: QTBUG-77218 Reviewed-by: Simon Hausmann --- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 3b387c9235..7ee085b81c 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -491,7 +491,7 @@ void tst_QApplication::lastWindowClosed() QPointer dialog = new QDialog; dialog->setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("Dialog")); QVERIFY(dialog->testAttribute(Qt::WA_QuitOnClose)); - QTimer::singleShot(1000, dialog, &QDialog::accept); + QTimer::singleShot(1000, dialog.data(), &QDialog::accept); dialog->exec(); QVERIFY(dialog); QCOMPARE(spy.count(), 0); -- cgit v1.2.3 From ca20b449592ed05eca0c476d2fcf5d0851d92c36 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Tue, 6 Aug 2019 10:50:52 +0300 Subject: A GCC 4.8 build fix Change-Id: Ic128486711118e1124739e8dca30547ab8ba9816 Reviewed-by: Simon Hausmann --- tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 5b4a5d30a5..d13c145189 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -486,7 +486,7 @@ void tst_QApplication::lastWindowClosed() QPointer dialog = new QDialog; dialog->setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1String("Dialog")); QVERIFY(dialog->testAttribute(Qt::WA_QuitOnClose)); - QTimer::singleShot(1000, dialog, &QDialog::accept); + QTimer::singleShot(1000, dialog.data(), &QDialog::accept); dialog->exec(); QVERIFY(dialog); QCOMPARE(spy.count(), 0); -- cgit v1.2.3 From 9bcbba36c73b8d03e8e58898629259489a24e040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 12 Jun 2019 15:29:31 +0200 Subject: QWizard: Account for missing background image on macOS 10.14+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were loading “Background.png” from the KeyboardSetupAssistant app bundle. As of macOS 10.14 that image is no longer there. Adjust auto tests and document the behavior. Change-Id: Icb4dd73b3fa88927e87bb86db2bc9f7b4a8094f7 Reviewed-by: Tor Arne Vestbø --- tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index 63f6e67a3e..da75e64d1e 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -417,20 +417,19 @@ void tst_QWizard::setPixmap() QVERIFY(wizard.pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull()); -#ifdef Q_OS_OSX - QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); -#else - QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull()); -#endif + if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13)) + QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); + else + QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull()); QVERIFY(page->pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull()); -#ifdef Q_OS_OSX - QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); -#else - QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); -#endif + if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13)) + QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); + else + QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); + wizard.setPixmap(QWizard::BannerPixmap, p1); wizard.setPixmap(QWizard::LogoPixmap, p2); wizard.setPixmap(QWizard::WatermarkPixmap, p3); -- cgit v1.2.3 From fcc5323a08f955bcedd8a8a9750173384fa7d71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 7 Jun 2019 16:04:23 +0200 Subject: Make test less dependent on moving the cursor The sendMouseMove() function calls QTest::mouseMove(), which again calls QCursor::setPos() to move the cursor. It then creates and sends a MouseMove event, using the constructor which picks up the global position by calling QCursor::pos(). On macOS 10.14, QCursor::setPos() may silently fail if the user does not grant the application permission to move the cursor (via a dialog). As result of this the mouse move event gets an incorrect global position. Provide the global position directly when creating the event to make sure it gets the correct value. Task-number: QTBUG-75786 Change-Id: I3e8df450fea802783a3d1dbe471753f502b42de3 Reviewed-by: Richard Moe Gustavsen --- tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 28df3a3c38..1456b9e35c 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -88,7 +88,7 @@ static void sendMousePress(QWidget *widget, const QPoint &point, Qt::MouseButton static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = 0) { QTest::mouseMove(widget, point); - QMouseEvent event(QEvent::MouseMove, point, button, buttons, 0); + QMouseEvent event(QEvent::MouseMove, point, widget->mapToGlobal(point), button, buttons, 0); QApplication::sendEvent(widget, &event); QApplication::processEvents(); } -- cgit v1.2.3 From 19b52e7c1dc2c447c1682f9438ebd37cbfc7d31d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 14 May 2019 15:03:24 +0200 Subject: tst_QFormLayout: use QAutoPointer to simplify test and avoid leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... in case of a test failure. QAutoPointer is private API, but here we can use it. Change-Id: I45b734385cd13fdea95d0100f2d8152f969612f9 Reviewed-by: Friedemann Kleint Reviewed-by: Jan Arve Sæther --- tests/auto/widgets/kernel/qformlayout/qformlayout.pro | 2 +- tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qformlayout/qformlayout.pro b/tests/auto/widgets/kernel/qformlayout/qformlayout.pro index 617183fee6..0766b50f68 100644 --- a/tests/auto/widgets/kernel/qformlayout/qformlayout.pro +++ b/tests/auto/widgets/kernel/qformlayout/qformlayout.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qformlayout -QT += widgets testlib testlib-private +QT += widgets widgets-private testlib testlib-private SOURCES += tst_qformlayout.cpp diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index ab32643061..c6760000f4 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -38,6 +38,9 @@ #include #include #include + +#include + #include #include @@ -1196,22 +1199,20 @@ void tst_QFormLayout::layoutAlone() void tst_QFormLayout::taskQTBUG_27420_takeAtShouldUnparentLayout() { QSharedPointer outer(new QFormLayout); - QPointer inner = new QFormLayout; + QAutoPointer holder{new QFormLayout}; + auto inner = holder.get(); outer->addRow(inner); QCOMPARE(outer->count(), 1); QCOMPARE(inner->parent(), outer.data()); QLayoutItem *item = outer->takeAt(0); - QCOMPARE(item->layout(), inner.data()); + QCOMPARE(item->layout(), inner); QVERIFY(!item->layout()->parent()); outer.reset(); - if (inner) - delete item; // success: a taken item/layout should not be deleted when the old parent is deleted - else - QVERIFY(!inner.isNull()); + QVERIFY(holder); // a taken item/layout should not be deleted when the old parent is deleted } void tst_QFormLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){ -- cgit v1.2.3 From de26ea6a7ff921995b6229f1f683821adb95e973 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 10 Aug 2019 18:21:59 +0200 Subject: QTree/TableView: allow to reset the sort order to natural sorting QTreeView allowed to set the sort column to -1 which shows the data in it's natural order (when the model supports it). This functionality was removed during the porting away from the deprecated sortByColumn(int) functionality done in d0f909f8dbdd8594b0d950822f0e7ab8728da513 Readd the functionality and also allow it for QTableView. Fixes: QTBUG-77419 Change-Id: I96b0c09ab9da36ca0a9de58fe0f37e2c56b1d51b Reviewed-by: Samuel Gaist Reviewed-by: David Faure --- .../itemviews/qtableview/tst_qtableview.cpp | 26 +++++++++----- .../widgets/itemviews/qtreeview/tst_qtreeview.cpp | 41 +++++++++++++++------- 2 files changed, 46 insertions(+), 21 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index b1ddc6e7a2..c8eecd3693 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -4248,32 +4248,42 @@ void tst_QTableView::task191545_dragSelectRows() void tst_QTableView::task234926_setHeaderSorting() { QStringListModel model; - QStringList data; - data << "orange" << "apple" << "banana" << "lemon" << "pumpkin"; + QSortFilterProxyModel sfpm; // default QStandardItemModel does not support 'unsorted' state + sfpm.setSourceModel(&model); + const QStringList data({"orange", "apple", "banana", "lemon", "pumpkin"}); QStringList sortedDataA = data; QStringList sortedDataD = data; std::sort(sortedDataA.begin(), sortedDataA.end()); std::sort(sortedDataD.begin(), sortedDataD.end(), std::greater()); model.setStringList(data); QTableView view; - view.setModel(&model); -// view.show(); + view.setModel(&sfpm); + QTRY_COMPARE(model.stringList(), data); view.setSortingEnabled(true); view.sortByColumn(0, Qt::AscendingOrder); - QTRY_COMPARE(model.stringList() , sortedDataA); + for (int i = 0; i < sortedDataA.size(); ++i) + QCOMPARE(view.model()->data(view.model()->index(i, 0)).toString(), sortedDataA.at(i)); view.horizontalHeader()->setSortIndicator(0, Qt::DescendingOrder); - QTRY_COMPARE(model.stringList() , sortedDataD); + for (int i = 0; i < sortedDataD.size(); ++i) + QCOMPARE(view.model()->data(view.model()->index(i, 0)).toString(), sortedDataD.at(i)); QHeaderView *h = new QHeaderView(Qt::Horizontal); h->setModel(&model); view.setHorizontalHeader(h); h->setSortIndicator(0, Qt::AscendingOrder); - QTRY_COMPARE(model.stringList() , sortedDataA); + for (int i = 0; i < sortedDataA.size(); ++i) + QCOMPARE(view.model()->data(view.model()->index(i, 0)).toString(), sortedDataA.at(i)); h->setSortIndicator(0, Qt::DescendingOrder); - QTRY_COMPARE(model.stringList() , sortedDataD); + for (int i = 0; i < sortedDataD.size(); ++i) + QCOMPARE(view.model()->data(view.model()->index(i, 0)).toString(), sortedDataD.at(i)); + + view.sortByColumn(-1, Qt::AscendingOrder); + QCOMPARE(view.horizontalHeader()->sortIndicatorSection(), -1); + for (int i = 0; i < data.size(); ++i) + QCOMPARE(view.model()->data(view.model()->index(i, 0)).toString(), data.at(i)); } void tst_QTableView::taskQTBUG_5062_spansInconsistency() diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index c31de2ba22..2a1163ec66 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -2783,25 +2783,40 @@ void tst_QTreeView::sortByColumn() QFETCH(bool, sortingEnabled); QTreeView view; QStandardItemModel model(4,2); - model.setItem(0,0,new QStandardItem("b")); - model.setItem(1,0,new QStandardItem("d")); - model.setItem(2,0,new QStandardItem("c")); - model.setItem(3,0,new QStandardItem("a")); - model.setItem(0,1,new QStandardItem("e")); - model.setItem(1,1,new QStandardItem("g")); - model.setItem(2,1,new QStandardItem("h")); - model.setItem(3,1,new QStandardItem("f")); + QSortFilterProxyModel sfpm; // default QStandardItemModel does not support 'unsorted' state + sfpm.setSourceModel(&model); + model.setItem(0, 0, new QStandardItem("b")); + model.setItem(1, 0, new QStandardItem("d")); + model.setItem(2, 0, new QStandardItem("c")); + model.setItem(3, 0, new QStandardItem("a")); + model.setItem(0, 1, new QStandardItem("e")); + model.setItem(1, 1, new QStandardItem("g")); + model.setItem(2, 1, new QStandardItem("h")); + model.setItem(3, 1, new QStandardItem("f")); view.setSortingEnabled(sortingEnabled); - view.setModel(&model); + view.setModel(&sfpm); + view.sortByColumn(1, Qt::DescendingOrder); QCOMPARE(view.header()->sortIndicatorSection(), 1); - QCOMPARE(view.model()->data(view.model()->index(0,1)).toString(), QString::fromLatin1("h")); - QCOMPARE(view.model()->data(view.model()->index(1,1)).toString(), QString::fromLatin1("g")); + QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("c")); + QCOMPARE(view.model()->data(view.model()->index(1, 0)).toString(), QString::fromLatin1("d")); + QCOMPARE(view.model()->data(view.model()->index(0, 1)).toString(), QString::fromLatin1("h")); + QCOMPARE(view.model()->data(view.model()->index(1, 1)).toString(), QString::fromLatin1("g")); + view.sortByColumn(0, Qt::AscendingOrder); QCOMPARE(view.header()->sortIndicatorSection(), 0); - QCOMPARE(view.model()->data(view.model()->index(0,0)).toString(), QString::fromLatin1("a")); - QCOMPARE(view.model()->data(view.model()->index(1,0)).toString(), QString::fromLatin1("b")); + QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("a")); + QCOMPARE(view.model()->data(view.model()->index(1, 0)).toString(), QString::fromLatin1("b")); + QCOMPARE(view.model()->data(view.model()->index(0, 1)).toString(), QString::fromLatin1("f")); + QCOMPARE(view.model()->data(view.model()->index(1, 1)).toString(), QString::fromLatin1("e")); + + view.sortByColumn(-1, Qt::AscendingOrder); + QCOMPARE(view.header()->sortIndicatorSection(), -1); + QCOMPARE(view.model()->data(view.model()->index(0, 0)).toString(), QString::fromLatin1("b")); + QCOMPARE(view.model()->data(view.model()->index(1, 0)).toString(), QString::fromLatin1("d")); + QCOMPARE(view.model()->data(view.model()->index(0, 1)).toString(), QString::fromLatin1("e")); + QCOMPARE(view.model()->data(view.model()->index(1, 1)).toString(), QString::fromLatin1("g")); } /* -- cgit v1.2.3 From 2e0b0be2ce30394269559590b42c81de27301ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 14 Aug 2019 12:39:27 +0200 Subject: Get rid of QWidgetBackingStoreTracker It was added for Symbian almost 10 years ago (d7057e7c1f1a), for a somewhat dubious use-case. The Symbian code is since long gone (ae30d7141), so the remaining pieces are just adding complexity to the already intricate workings of the QtWidgets backingstore/painting logic. Task-number: QTBUG-8697 Change-Id: I82af610a8ac26719c588ac63f06b4501f59b400d Reviewed-by: Paul Olav Tvete --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index bfc2631842..715bbbec0f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -9564,7 +9565,7 @@ void tst_QWidget::destroyBackingStore() QTRY_VERIFY(w.numPaintEvents > 0); w.reset(); w.update(); - qt_widget_private(&w)->topData()->backingStoreTracker.create(&w); + qt_widget_private(&w)->topData()->widgetBackingStore.reset(new QWidgetBackingStore(&w)); w.update(); QApplication::processEvents(); @@ -9584,7 +9585,7 @@ QWidgetBackingStore* backingStore(QWidget &widget) QWidgetBackingStore *backingStore = nullptr; #ifdef QT_BUILD_INTERNAL if (QTLWExtra *topExtra = qt_widget_private(&widget)->maybeTopData()) - backingStore = topExtra->backingStoreTracker.data(); + backingStore = topExtra->widgetBackingStore.get(); #endif return backingStore; } @@ -9784,12 +9785,12 @@ class scrollWidgetWBS : public QWidget public: void deleteBackingStore() { - static_cast(d_ptr.data())->topData()->backingStoreTracker.destroy(); + static_cast(d_ptr.data())->topData()->widgetBackingStore.reset(nullptr); } void enableBackingStore() { if (!static_cast(d_ptr.data())->maybeBackingStore()) { - static_cast(d_ptr.data())->topData()->backingStoreTracker.create(this); + static_cast(d_ptr.data())->topData()->widgetBackingStore.reset(new QWidgetBackingStore(this)); static_cast(d_ptr.data())->invalidateBackingStore(this->rect()); repaint(); } -- cgit v1.2.3 From 662fec6f0db32fb58b91357aa11c9d3be94f0c55 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Fri, 9 Aug 2019 11:04:27 +0200 Subject: Update for failures only on dev branch. Use general platform names This patch was generated with tooling from patchset 31 of https://codereview.qt-project.org/c/qt/qtqa/+/267034 in interactive mode. General platform names were chosen if greater than 60% of the currently active platforms of a given type in COIN recently failed. Change-Id: Ia4bde7f0ec422bbb727dc9d7151295159094f146 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST | 11 ++++------- tests/auto/widgets/dialogs/qmessagebox/BLACKLIST | 6 ++---- tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST | 2 -- tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST | 12 ++---------- tests/auto/widgets/itemviews/qheaderview/BLACKLIST | 1 - tests/auto/widgets/kernel/qapplication/BLACKLIST | 3 +-- tests/auto/widgets/kernel/qwidget/BLACKLIST | 10 ++-------- 7 files changed, 11 insertions(+), 34 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST index f2f0f8d26e..aae2cacc3b 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/BLACKLIST @@ -7,13 +7,10 @@ b2qt [specialFiles] b2qt [dirsBeforeFiles] -ubuntu-16.04 -rhel-7.6 -windows-10 msvc-2017 -ubuntu-18.04 -b2qt winrt -windows-10 msvc-2015 - +b2qt +ubuntu +windows-10 +rhel [drives] winrt diff --git a/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST b/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST index e633e7c0a3..8d8a7c2105 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST +++ b/tests/auto/widgets/dialogs/qmessagebox/BLACKLIST @@ -1,6 +1,4 @@ [defaultButton] -ubuntu-16.04 -rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 +rhel-7.6 +ubuntu diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST index a3c9e2e421..c3797c9d57 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST @@ -1,7 +1,5 @@ [isActive] opensuse-42.3 ci -[removeFullyTransparentItem] -osx-10.12 [tabFocus_sceneWithNestedFocusWidgets] opensuse-42.3 diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST index 22fce8620b..9b76ea02ff 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST @@ -1,24 +1,16 @@ [task255529_transformationAnchorMouseAndViewportMargins] opensuse-leap -rhel-7.4 -ubuntu-16.04 -opensuse-42.3 [cursor] opensuse-leap -ubuntu-16.04 -opensuse-42.3 [cursor2] ubuntu-16.04 [sendEvent] ubuntu-16.04 opensuse-42.3 [resizeAnchor] -ubuntu-16.04 -rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 -opensuse-42.3 +rhel-7.6 +ubuntu [update2] opensuse-42.3 [itemsInRect_cosmeticAdjust] diff --git a/tests/auto/widgets/itemviews/qheaderview/BLACKLIST b/tests/auto/widgets/itemviews/qheaderview/BLACKLIST index 297a6fe7b7..4eceaae0d3 100644 --- a/tests/auto/widgets/itemviews/qheaderview/BLACKLIST +++ b/tests/auto/widgets/itemviews/qheaderview/BLACKLIST @@ -1,3 +1,2 @@ [stretchAndRestoreLastSection] opensuse-leap -opensuse-42.3 diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST index ac65a97c40..c68c7d6b14 100644 --- a/tests/auto/widgets/kernel/qapplication/BLACKLIST +++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST @@ -1,4 +1,3 @@ [touchEventPropagation] -opensuse-leap # QTBUG-66745 -opensuse-42.3 +opensuse-leap diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 02e97e4b4e..26f9ce1b85 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -14,12 +14,9 @@ rhel-7.4 ubuntu-16.04 rhel-7.6 [focusProxyAndInputMethods] -ubuntu-16.04 rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 -opensuse-42.3 +ubuntu [raise] opensuse-leap # QTBUG-68175 @@ -45,12 +42,9 @@ opensuse-leap [moveInResizeEvent] ubuntu-16.04 [multipleToplevelFocusCheck] -ubuntu-16.04 rhel-7.6 opensuse-leap -ubuntu-18.04 -rhel-7.4 -opensuse-42.3 +ubuntu [windowState] # QTBUG-75270 winrt -- cgit v1.2.3 From f4db3811694fe032b9fbf237b869fa842e094883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 14 Aug 2019 12:39:27 +0200 Subject: Get rid of QWidgetBackingStoreTracker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was added for Symbian almost 10 years ago (d7057e7c1f1a), for a somewhat dubious use-case. The Symbian code is since long gone (ae30d7141), so the remaining pieces are just adding complexity to the already intricate workings of the QtWidgets backingstore/painting logic. Task-number: QTBUG-8697 Change-Id: I82af610a8ac26719c588ac63f06b4501f59b400d Reviewed-by: Paul Olav Tvete (cherry picked from commit 2e0b0be2ce30394269559590b42c81de27301ee6) Reviewed-by: Tor Arne Vestbø --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index bfc2631842..715bbbec0f 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -9564,7 +9565,7 @@ void tst_QWidget::destroyBackingStore() QTRY_VERIFY(w.numPaintEvents > 0); w.reset(); w.update(); - qt_widget_private(&w)->topData()->backingStoreTracker.create(&w); + qt_widget_private(&w)->topData()->widgetBackingStore.reset(new QWidgetBackingStore(&w)); w.update(); QApplication::processEvents(); @@ -9584,7 +9585,7 @@ QWidgetBackingStore* backingStore(QWidget &widget) QWidgetBackingStore *backingStore = nullptr; #ifdef QT_BUILD_INTERNAL if (QTLWExtra *topExtra = qt_widget_private(&widget)->maybeTopData()) - backingStore = topExtra->backingStoreTracker.data(); + backingStore = topExtra->widgetBackingStore.get(); #endif return backingStore; } @@ -9784,12 +9785,12 @@ class scrollWidgetWBS : public QWidget public: void deleteBackingStore() { - static_cast(d_ptr.data())->topData()->backingStoreTracker.destroy(); + static_cast(d_ptr.data())->topData()->widgetBackingStore.reset(nullptr); } void enableBackingStore() { if (!static_cast(d_ptr.data())->maybeBackingStore()) { - static_cast(d_ptr.data())->topData()->backingStoreTracker.create(this); + static_cast(d_ptr.data())->topData()->widgetBackingStore.reset(new QWidgetBackingStore(this)); static_cast(d_ptr.data())->invalidateBackingStore(this->rect()); repaint(); } -- cgit v1.2.3 From 6d9d4e6817b116676320a1aba0ea0af1633205bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 14 Aug 2019 14:07:55 +0200 Subject: Rename QWidgetBackingStore to QWidgetRepaintManager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quoting a blog from 2009, "this class is responsible for figuring out which parts of the window surface needs to be updated prior to showing it to screen, so it's really a repaint manager." https://blog.qt.io/blog/2009/12/16/qt-graphics-and-performance-an-overview/ What better time to do the rename than 10 years later! Change-Id: Ibf3c3bc8c7df64ac03d72e1f71d296b62d832fee Reviewed-by: Tor Arne Vestbø --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 715bbbec0f..22bb488b3d 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include #include @@ -9565,7 +9565,7 @@ void tst_QWidget::destroyBackingStore() QTRY_VERIFY(w.numPaintEvents > 0); w.reset(); w.update(); - qt_widget_private(&w)->topData()->widgetBackingStore.reset(new QWidgetBackingStore(&w)); + qt_widget_private(&w)->topData()->repaintManager.reset(new QWidgetRepaintManager(&w)); w.update(); QApplication::processEvents(); @@ -9580,14 +9580,14 @@ void tst_QWidget::destroyBackingStore() #endif // QT_BUILD_INTERNAL // Helper function -QWidgetBackingStore* backingStore(QWidget &widget) +QWidgetRepaintManager* repaintManager(QWidget &widget) { - QWidgetBackingStore *backingStore = nullptr; + QWidgetRepaintManager *repaintManager = nullptr; #ifdef QT_BUILD_INTERNAL if (QTLWExtra *topExtra = qt_widget_private(&widget)->maybeTopData()) - backingStore = topExtra->widgetBackingStore.get(); + repaintManager = topExtra->repaintManager.get(); #endif - return backingStore; + return repaintManager; } // Tables of 5000 elements do not make sense on Windows Mobile. @@ -9785,12 +9785,12 @@ class scrollWidgetWBS : public QWidget public: void deleteBackingStore() { - static_cast(d_ptr.data())->topData()->widgetBackingStore.reset(nullptr); + static_cast(d_ptr.data())->topData()->repaintManager.reset(nullptr); } void enableBackingStore() { - if (!static_cast(d_ptr.data())->maybeBackingStore()) { - static_cast(d_ptr.data())->topData()->widgetBackingStore.reset(new QWidgetBackingStore(this)); + if (!static_cast(d_ptr.data())->maybeRepaintManager()) { + static_cast(d_ptr.data())->topData()->repaintManager.reset(new QWidgetRepaintManager(this)); static_cast(d_ptr.data())->invalidateBackingStore(this->rect()); repaint(); } -- cgit v1.2.3 From aa6e0e3e30ec7f330e2fbc02fc9fbe55ef0b6432 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 20 Aug 2019 12:44:41 +0200 Subject: Remove the usage of deprecated APIs from QSysInfo Replaced: QSysInfo::macVersion() -> QOperatingSystemVersion::current() Q_MV_OSX(10, 13) -> QOperatingSystemVersion::MacOSHighSierra Task-number: QTBUG-76491 Change-Id: Iae4f9c319ff16314fb04bbefaa48935a0f618007 Reviewed-by: Volker Hilsheimer --- tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp index da75e64d1e..243cb6483e 100644 --- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp +++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp @@ -417,7 +417,7 @@ void tst_QWizard::setPixmap() QVERIFY(wizard.pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(wizard.pixmap(QWizard::WatermarkPixmap).isNull()); - if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13)) + if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::MacOSHighSierra) QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); else QVERIFY(wizard.pixmap(QWizard::BackgroundPixmap).isNull()); @@ -425,7 +425,7 @@ void tst_QWizard::setPixmap() QVERIFY(page->pixmap(QWizard::BannerPixmap).isNull()); QVERIFY(page->pixmap(QWizard::LogoPixmap).isNull()); QVERIFY(page->pixmap(QWizard::WatermarkPixmap).isNull()); - if (QSysInfo::macVersion() <= Q_MV_OSX(10, 13)) + if (QOperatingSystemVersion::current() <= QOperatingSystemVersion::MacOSHighSierra) QVERIFY(!wizard.pixmap(QWizard::BackgroundPixmap).isNull()); else QVERIFY(page->pixmap(QWizard::BackgroundPixmap).isNull()); -- cgit v1.2.3 From ce73b4db62574fc966192e6a4f65b7e2b2280e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 20 Aug 2019 14:26:05 +0200 Subject: Remove dead code from Qt 4 times MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The benefit of keeping this code around was to inspire or inform changes in the areas to take into account possibly missing features in Qt 5, but at this point that benefit is questionable. We can always use the history to learn about missing pieces if needed. Change-Id: I87a02dc451e9027be9b97554427bf8a1c6b2c025 Reviewed-by: Tor Arne Vestbø --- .../graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 3 --- .../auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp | 3 --- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 3 --- tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp | 2 -- 4 files changed, 11 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 39aa65a478..a437b05479 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -2768,9 +2768,6 @@ void tst_QGraphicsProxyWidget::windowOpacity() // disabled on platforms without alpha channel support in QPixmap (e.g., // X11 without XRender). int paints = 0; -#if 0 // Used to be included in Qt4 for Q_WS_X11 - paints = !X11->use_xrender; -#endif QTRY_COMPARE(eventSpy.counts[QEvent::UpdateRequest], 0); QTRY_COMPARE(eventSpy.counts[QEvent::Paint], paints); diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 6f7dca86eb..bcfc477733 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -1024,9 +1024,6 @@ void tst_QAbstractItemView::setItemDelegate() centerOnScreen(&v); moveCursorAway(&v); v.show(); -#if 0 // Used to be included in Qt4 for Q_WS_X11 - QCursor::setPos(v.geometry().center()); -#endif QApplication::setActiveWindow(&v); QVERIFY(QTest::qWaitForWindowActive(&v)); diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index b8abd78657..6d38dc262f 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -479,9 +479,6 @@ void tst_QMdiArea::subWindowActivated2() // Check that we only emit _one_ signal and the active window // is unchanged after hide/show. mdiArea.hide(); -#if 0 // Used to be included in Qt4 for Q_WS_X11 - qt_x11_wait_for_window_manager(&mdiArea); -#endif QTest::qWait(100); QTRY_COMPARE(spy.count(), 1); QVERIFY(!mdiArea.activeSubWindow()); diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index b8891fab95..3ee9c72209 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -52,9 +52,7 @@ #include QT_BEGIN_NAMESPACE -#if 1 // Used to be excluded in Qt4 for Q_WS_WIN extern bool qt_tab_all_widgets(); -#endif QT_END_NAMESPACE static inline bool tabAllWidgets() -- cgit v1.2.3 From b455a863a1df61337f36f2e8b43101ca21514697 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Apr 2019 14:20:06 +0200 Subject: Add screen() accessor to QWidget Base it on QWidgetPrivate::associatedScreen(), but make a larger effort to find a screen in case the widget is not shown yet. Rename QDesktopScreenWidget::screen() to something else to avoid clashes. Task-number: QTBUG-62094 Task-number: QTBUG-53022 Change-Id: I36ba5ef5f0645a4ac89da0b38a391f7057b2f49c Reviewed-by: Shawn Rutledge --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 22bb488b3d..51049ecd81 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -1139,6 +1139,7 @@ void tst_QWidget::visible() QVERIFY( !childWidget->isVisible() ); testWidget->show(); + QVERIFY(testWidget->screen()); QVERIFY( testWidget->isVisible() ); QVERIFY( childWidget->isVisible() ); -- cgit v1.2.3 From 45f681e8183fc876f5943495edb18edf78f29158 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Aug 2019 10:11:26 +0200 Subject: tst_QStyle: Remove unused baseline images (Windows Vista/macOS) The test contained outdated baseline images for 1) Windows Vista: They were only used for OS version Vista and do not match any more. 2) macOS: They were apparently were not in use any more Remove the testing and image comparison code. Task-number: QTBUG-76493 Change-Id: I91cec5113db8d1845b43f97ad2987e63d9f86ac7 Reviewed-by: Christian Ehrlicher --- .../widgets/styles/qstyle/images/mac/button.png | Bin 1785 -> 0 bytes .../widgets/styles/qstyle/images/mac/combobox.png | Bin 1808 -> 0 bytes .../widgets/styles/qstyle/images/mac/lineedit.png | Bin 953 -> 0 bytes .../auto/widgets/styles/qstyle/images/mac/mdi.png | Bin 3092 -> 0 bytes .../auto/widgets/styles/qstyle/images/mac/menu.png | Bin 1139 -> 0 bytes .../styles/qstyle/images/mac/radiobutton.png | Bin 1498 -> 0 bytes .../widgets/styles/qstyle/images/mac/slider.png | Bin 1074 -> 0 bytes .../widgets/styles/qstyle/images/mac/spinbox.png | Bin 1299 -> 0 bytes .../widgets/styles/qstyle/images/vista/button.png | Bin 722 -> 0 bytes .../styles/qstyle/images/vista/combobox.png | Bin 809 -> 0 bytes .../styles/qstyle/images/vista/lineedit.png | Bin 530 -> 0 bytes .../widgets/styles/qstyle/images/vista/menu.png | Bin 646 -> 0 bytes .../styles/qstyle/images/vista/radiobutton.png | Bin 844 -> 0 bytes .../widgets/styles/qstyle/images/vista/slider.png | Bin 575 -> 0 bytes .../widgets/styles/qstyle/images/vista/spinbox.png | Bin 583 -> 0 bytes tests/auto/widgets/styles/qstyle/qstyle.pro | 5 - tests/auto/widgets/styles/qstyle/testdata.qrc | 19 --- tests/auto/widgets/styles/qstyle/tst_qstyle.cpp | 127 --------------------- 18 files changed, 151 deletions(-) delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/button.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/combobox.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/lineedit.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/mdi.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/menu.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/radiobutton.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/slider.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/mac/spinbox.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/vista/button.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/vista/combobox.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/vista/lineedit.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/vista/menu.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/vista/radiobutton.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/vista/slider.png delete mode 100644 tests/auto/widgets/styles/qstyle/images/vista/spinbox.png delete mode 100644 tests/auto/widgets/styles/qstyle/testdata.qrc (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/styles/qstyle/images/mac/button.png b/tests/auto/widgets/styles/qstyle/images/mac/button.png deleted file mode 100644 index 7b11325e87..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/button.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/mac/combobox.png b/tests/auto/widgets/styles/qstyle/images/mac/combobox.png deleted file mode 100644 index ded0b11f29..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/combobox.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/mac/lineedit.png b/tests/auto/widgets/styles/qstyle/images/mac/lineedit.png deleted file mode 100644 index 8d2861b65b..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/lineedit.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/mac/mdi.png b/tests/auto/widgets/styles/qstyle/images/mac/mdi.png deleted file mode 100644 index 8c09ae4338..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/mdi.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/mac/menu.png b/tests/auto/widgets/styles/qstyle/images/mac/menu.png deleted file mode 100644 index 5dd9111d69..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/menu.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/mac/radiobutton.png b/tests/auto/widgets/styles/qstyle/images/mac/radiobutton.png deleted file mode 100644 index 8828e220a2..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/radiobutton.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/mac/slider.png b/tests/auto/widgets/styles/qstyle/images/mac/slider.png deleted file mode 100644 index fc65035631..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/slider.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/mac/spinbox.png b/tests/auto/widgets/styles/qstyle/images/mac/spinbox.png deleted file mode 100644 index ee88441ecb..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/mac/spinbox.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/vista/button.png b/tests/auto/widgets/styles/qstyle/images/vista/button.png deleted file mode 100644 index a6c45276ca..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/vista/button.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/vista/combobox.png b/tests/auto/widgets/styles/qstyle/images/vista/combobox.png deleted file mode 100644 index 9b82f64d32..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/vista/combobox.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/vista/lineedit.png b/tests/auto/widgets/styles/qstyle/images/vista/lineedit.png deleted file mode 100644 index b2c6ac1ae4..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/vista/lineedit.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/vista/menu.png b/tests/auto/widgets/styles/qstyle/images/vista/menu.png deleted file mode 100644 index b114099cc3..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/vista/menu.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/vista/radiobutton.png b/tests/auto/widgets/styles/qstyle/images/vista/radiobutton.png deleted file mode 100644 index c8aa7864df..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/vista/radiobutton.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/vista/slider.png b/tests/auto/widgets/styles/qstyle/images/vista/slider.png deleted file mode 100644 index 7c156ded9d..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/vista/slider.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/images/vista/spinbox.png b/tests/auto/widgets/styles/qstyle/images/vista/spinbox.png deleted file mode 100644 index b8d0823ab2..0000000000 Binary files a/tests/auto/widgets/styles/qstyle/images/vista/spinbox.png and /dev/null differ diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 9ad0940245..4dc0525c49 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -2,8 +2,3 @@ CONFIG += testcase TARGET = tst_qstyle QT += widgets testlib testlib-private SOURCES += tst_qstyle.cpp - -android:!android-embedded { - RESOURCES += \ - testdata.qrc -} diff --git a/tests/auto/widgets/styles/qstyle/testdata.qrc b/tests/auto/widgets/styles/qstyle/testdata.qrc deleted file mode 100644 index 29bb46726e..0000000000 --- a/tests/auto/widgets/styles/qstyle/testdata.qrc +++ /dev/null @@ -1,19 +0,0 @@ - - - images/mac/button.png - images/mac/combobox.png - images/mac/lineedit.png - images/mac/mdi.png - images/mac/menu.png - images/mac/radiobutton.png - images/mac/slider.png - images/mac/spinbox.png - images/vista/button.png - images/vista/combobox.png - images/vista/lineedit.png - images/vista/menu.png - images/vista/radiobutton.png - images/vista/slider.png - images/vista/spinbox.png - - diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 68e672e16d..ae084310b1 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -73,7 +73,6 @@ public: private: bool testAllFunctions(QStyle *); bool testScrollBarSubControls(); - void testPainting(QStyle *style, const QString &platform); private slots: void drawItemPixmap(); void init(); @@ -333,141 +332,15 @@ void tst_QStyle::testWindowsStyle() delete wstyle; } -void writeImage(const QString &fileName, QImage image) -{ - QImageWriter imageWriter(fileName); - imageWriter.setFormat("png"); - qDebug() << "result " << imageWriter.write(image); -} - -QImage readImage(const QString &fileName) -{ - QImageReader reader(fileName); - return reader.read(); -} - - #if defined(Q_OS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA) && !defined(Q_OS_WINRT) void tst_QStyle::testWindowsVistaStyle() { QStyle *vistastyle = QStyleFactory::create("WindowsVista"); QVERIFY(testAllFunctions(vistastyle)); - - if (QOperatingSystemVersion::current().majorVersion() - == QOperatingSystemVersion::WindowsVista.majorVersion() - && QOperatingSystemVersion::current().minorVersion() - == QOperatingSystemVersion::WindowsVista.minorVersion()) - testPainting(vistastyle, "vista"); delete vistastyle; } #endif -void comparePixmap(const QString &filename, const QPixmap &pixmap) -{ - QImage oldFile = readImage(filename); - QPixmap oldPixmap = QPixmap::fromImage(oldFile); - if (!oldFile.isNull()) - QCOMPARE(pixmap, oldPixmap); - else - writeImage(filename, pixmap.toImage()); -} - -void tst_QStyle::testPainting(QStyle *style, const QString &platform) -{ -qDebug("TEST PAINTING"); - //Test Menu - QString fileName = "images/" + platform + "/menu.png"; - QMenu menu; - menu.setStyle(style); - menu.show(); - menu.addAction(new QAction("Test 1", &menu)); - menu.addAction(new QAction("Test 2", &menu)); - QPixmap pixmap = menu.grab(); - comparePixmap(fileName, pixmap); - - //Push button - fileName = "images/" + platform + "/button.png"; - QPushButton button("OK"); - button.setStyle(style); - button.show(); - pixmap = button.grab(); - button.hide(); - comparePixmap(fileName, pixmap); - - //Push button - fileName = "images/" + platform + "/radiobutton.png"; - QRadioButton radiobutton("Check"); - radiobutton.setStyle(style); - radiobutton.show(); - pixmap = radiobutton.grab(); - radiobutton.hide(); - comparePixmap(fileName, pixmap); - - //Combo box - fileName = "images/" + platform + "/combobox.png"; - QComboBox combobox; - combobox.setStyle(style); - combobox.addItem("Test 1"); - combobox.addItem("Test 2"); - combobox.show(); - pixmap = combobox.grab(); - combobox.hide(); - comparePixmap(fileName, pixmap); - - //Spin box - fileName = "images/" + platform + "/spinbox.png"; - QDoubleSpinBox spinbox; - spinbox.setLocale(QLocale(QLocale::English, QLocale::UnitedStates)); - spinbox.setStyle(style); - spinbox.show(); - pixmap = spinbox.grab(); - spinbox.hide(); - comparePixmap(fileName, pixmap); - QLocale::setDefault(QLocale::system()); - - //Slider - fileName = "images/" + platform + "/slider.png"; - QSlider slider; - slider.setStyle(style); - slider.show(); - pixmap = slider.grab(); - slider.hide(); - comparePixmap(fileName, pixmap); - - //Line edit - fileName = "images/" + platform + "/lineedit.png"; - QLineEdit lineedit("Test text"); - lineedit.setStyle(style); - lineedit.show(); - pixmap = lineedit.grab(); - lineedit.hide(); - comparePixmap(fileName, pixmap); - - //MDI - fileName = "images/" + platform + "/mdi.png"; - QMdiArea mdiArea; - mdiArea.addSubWindow(new QWidget(&mdiArea)); - mdiArea.resize(200, 200); - mdiArea.setStyle(style); - mdiArea.show(); - pixmap = mdiArea.grab(); - mdiArea.hide(); - comparePixmap(fileName, pixmap); - - // QToolButton - fileName = "images/" + platform + "/toolbutton.png"; - QToolButton tb; - tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - tb.setText("AaQqPpXx"); - tb.setIcon(style->standardPixmap(QStyle::SP_DirHomeIcon)); - tb.setStyle(style); - tb.show(); - pixmap = tb.grab(); - tb.hide(); - comparePixmap(fileName, pixmap); - -} - #ifdef Q_OS_MAC void tst_QStyle::testMacStyle() { -- cgit v1.2.3 From a4a11987089b1558b5b50a0d38c3263bb25818d7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 14 Aug 2019 15:55:31 +0200 Subject: Windows: Fix some widget tests to pass on High DPI screens For tst_QFrame and tst_QOpenGLWidget, force scaling off since they do screen captures which would fail with scaling activated due to different device pixel ratios. For tst_QGraphicsItem and tst_QHeaderView, force scaling on for Windows since some tests otherwise fail due to violation of the minimum size constraints of framed windows on Windows. The tests will then pass regardless of any environment setting of the scaling variables on a developer machine. Change-Id: Iefa4e84b433f7e51dce4e416546a9eda8ee6d0f1 Reviewed-by: Edward Welbourne Reviewed-by: Oliver Wolff --- .../widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 11 +++++++++++ tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 9 +++++++++ tests/auto/widgets/widgets/qframe/tst_qframe.cpp | 4 ++++ .../auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp | 3 +++ 4 files changed, 27 insertions(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 7b914512ab..72ea2ae31a 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -272,6 +272,9 @@ class tst_QGraphicsItem : public QObject { Q_OBJECT +public: + static void initMain(); + private slots: void construction(); void constructionWithParent(); @@ -474,6 +477,14 @@ private: QTouchDevice *m_touchDevice = nullptr; }; +void tst_QGraphicsItem::initMain() +{ +#ifdef Q_OS_WIN + // Ensure minimum size constraints of framed windows on High DPI screens + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif +} + void tst_QGraphicsItem::construction() { for (int i = 0; i < 7; ++i) { diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index f247889d55..df02815eb2 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -106,6 +106,7 @@ class tst_QHeaderView : public QObject public: tst_QHeaderView(); + static void initMain(); private slots: void initTestCase(); @@ -265,6 +266,14 @@ protected: QElapsedTimer timer; }; +void tst_QHeaderView::initMain() +{ +#ifdef Q_OS_WIN + // Ensure minimum size constraints of framed windows on High DPI screens + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif +} + class QtTestModel: public QAbstractTableModel { diff --git a/tests/auto/widgets/widgets/qframe/tst_qframe.cpp b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp index 432f4474c5..05f9cd2e4a 100644 --- a/tests/auto/widgets/widgets/qframe/tst_qframe.cpp +++ b/tests/auto/widgets/widgets/qframe/tst_qframe.cpp @@ -37,6 +37,10 @@ class tst_QFrame : public QObject { Q_OBJECT + +public: + static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } + private slots: void testDefaults(); void testInitStyleOption_data(); diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index 21c9f41646..76f8ebc804 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -49,6 +49,9 @@ class tst_QOpenGLWidget : public QObject { Q_OBJECT +public: + static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } + private slots: void initTestCase(); void create(); -- cgit v1.2.3 From ab55046862644441ade0fa1dc4aba98b32796877 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 15 Aug 2019 14:44:27 +0200 Subject: Brush up tst_QGraphicsScene - Fix includes - Add window titles - Introduce nullptr - Remove unneeded C-style casts in QCOMPARE - Replace remaining C-style casts - Use range-based for - Fix static invocation - Fix class structure, add override, use member initialization - Fix top level widget leaks and add a check - Silence debug output by using a logging category - Use Qt 5 connection syntax Task-number: QTBUG-76497 Change-Id: I77532a517353d04d1da43ce844988ee0ac2ffc7d Reviewed-by: Oliver Wolff --- .../qgraphicsscene/tst_qgraphicsscene.cpp | 669 +++++++++++---------- 1 file changed, 354 insertions(+), 315 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 46f1d5df5c..cc6ed2f80e 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -26,11 +26,24 @@ ** ****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include -#include -#include +#include +#include + #include #include #include @@ -39,7 +52,7 @@ #include #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -#include +#include #define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ QSKIP("The Graphics View doesn't get the paint events"); @@ -51,6 +64,7 @@ Q_DECLARE_METATYPE(Qt::FocusReason) Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(Qt::AspectRatioMode) Q_DECLARE_METATYPE(Qt::ItemSelectionMode) +Q_DECLARE_METATYPE(QGraphicsItem::GraphicsItemFlags) static const int randomX[] = {276, 40, 250, 864, -56, 426, 855, 825, 184, 955, -798, -804, 773, 282, 489, 686, 780, -220, 50, 749, -856, -205, 81, 492, -819, 518, @@ -95,14 +109,16 @@ static const int randomY[] = {603, 70, -318, 843, 450, -637, 199, -527, 407, 964 -588, 864, 234, 225, -303, 493, 246, 153, 338, -378, 377, -819, 140, 136, 467, -849, -326, -533, 166, 252, -994, -699, 904, -566, 621, -752}; +Q_LOGGING_CATEGORY(lcTests, "qt.widgets.tests") + class HoverItem : public QGraphicsRectItem { public: HoverItem() - : QGraphicsRectItem(QRectF(-10, -10, 20, 20)), isHovered(false) + : QGraphicsRectItem(QRectF(-10, -10, 20, 20)) { setAcceptHoverEvents(true); } - bool isHovered; + bool isHovered = false; protected: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) @@ -128,13 +144,13 @@ class EventSpy : public QGraphicsWidget Q_OBJECT public: EventSpy(QObject *watched, QEvent::Type type) - : _count(0), spied(type) + : spied(type) { watched->installEventFilter(this); } EventSpy(QGraphicsScene *scene, QGraphicsItem *watched, QEvent::Type type) - : _count(0), spied(type) + : spied(type) { scene->addItem(this); watched->installSceneEventFilter(this); @@ -143,7 +159,7 @@ public: int count() const { return _count; } protected: - bool eventFilter(QObject *watched, QEvent *event) + bool eventFilter(QObject *watched, QEvent *event) override { Q_UNUSED(watched); if (event->type() == spied) @@ -151,7 +167,7 @@ protected: return false; } - bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) + bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override { Q_UNUSED(watched); if (event->type() == spied) @@ -159,8 +175,8 @@ protected: return false; } - int _count; - QEvent::Type spied; + int _count = 0; + const QEvent::Type spied; }; class tst_QGraphicsScene : public QObject @@ -273,8 +289,10 @@ private slots: void tst_QGraphicsScene::cleanup() { // ensure not even skipped tests with custom input context leave it dangling - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; + QInputMethodPrivate *inputMethodPrivate = + QInputMethodPrivate::get(QGuiApplication::inputMethod()); + inputMethodPrivate->testContext = nullptr; + QTRY_VERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QGraphicsScene::construction() @@ -287,7 +305,7 @@ void tst_QGraphicsScene::construction() QVERIFY(scene.items(QPolygonF()).isEmpty()); QVERIFY(scene.items(QPainterPath()).isEmpty()); QTest::ignoreMessage(QtWarningMsg, "QGraphicsScene::collidingItems: cannot find collisions for null item"); - QVERIFY(scene.collidingItems(0).isEmpty()); + QVERIFY(scene.collidingItems(nullptr).isEmpty()); QVERIFY(scene.items(QPointF()).isEmpty()); QVERIFY(scene.selectedItems().isEmpty()); QVERIFY(!scene.focusItem()); @@ -301,7 +319,7 @@ static inline const QGraphicsItem *itemAt(const QGraphicsScene &scene, qreal x, void tst_QGraphicsScene::sceneRect() { QGraphicsScene scene; - QSignalSpy sceneRectChanged(&scene, SIGNAL(sceneRectChanged(QRectF))); + QSignalSpy sceneRectChanged(&scene, &QGraphicsScene::sceneRectChanged); QCOMPARE(scene.sceneRect(), QRectF()); QCOMPARE(sceneRectChanged.count(), 0); @@ -435,9 +453,9 @@ void tst_QGraphicsScene::items() scene.removeItem(items.at(5)); delete items.at(5); - QVERIFY(!scene.items().contains(0)); + QVERIFY(!scene.items().contains(nullptr)); delete items.at(7); - QVERIFY(!scene.items().contains(0)); + QVERIFY(!scene.items().contains(nullptr)); } { QGraphicsScene scene; @@ -516,7 +534,7 @@ void tst_QGraphicsScene::itemsBoundingRect() QGraphicsScene scene; - foreach (QRectF rect, rects) { + for (const auto &rect : qAsConst(rects)) { QPainterPath path; path.addRect(rect); QGraphicsPathItem *item = scene.addPath(path); @@ -581,7 +599,7 @@ void tst_QGraphicsScene::items_QPointF() int n = 0; QList addedItems; - foreach(QRectF rect, items) { + for (const auto &rect : qAsConst(items)) { QPainterPath path; path.addRect(0, 0, rect.width(), rect.height()); @@ -593,7 +611,8 @@ void tst_QGraphicsScene::items_QPointF() } QList itemIndexes; - foreach (QGraphicsItem *item, scene.items(point)) + const auto &actualItemsAtPoint = scene.items(point); + for (QGraphicsItem *item : actualItemsAtPoint) itemIndexes << addedItems.indexOf(item); QCOMPARE(itemIndexes, itemsAtPoint); @@ -912,12 +931,11 @@ void tst_QGraphicsScene::items_QPainterPath_2() class CustomView : public QGraphicsView { public: - CustomView() : repaints(0) - { } + using QGraphicsView::QGraphicsView; - int repaints; + int repaints = 0; protected: - void paintEvent(QPaintEvent *event) + void paintEvent(QPaintEvent *event) override { ++repaints; QGraphicsView::paintEvent(event); @@ -927,7 +945,7 @@ protected: void tst_QGraphicsScene::selectionChanged() { QGraphicsScene scene(0, 0, 1000, 1000); - QSignalSpy spy(&scene, SIGNAL(selectionChanged())); + QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); QCOMPARE(spy.count(), 0); QPainterPath path; @@ -997,7 +1015,7 @@ void tst_QGraphicsScene::selectionChanged() void tst_QGraphicsScene::selectionChanged2() { QGraphicsScene scene; - QSignalSpy spy(&scene, SIGNAL(selectionChanged())); + QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); QGraphicsItem *item1 = scene.addRect(0, 0, 100, 100); QGraphicsItem *item2 = scene.addRect(100, 100, 100, 100); @@ -1009,13 +1027,13 @@ void tst_QGraphicsScene::selectionChanged2() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -1024,13 +1042,13 @@ void tst_QGraphicsScene::selectionChanged2() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(150, 150)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } { QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); event.setScenePos(QPointF(150, 150)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); @@ -1040,7 +1058,7 @@ void tst_QGraphicsScene::selectionChanged2() event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); event.setModifiers(Qt::ControlModifier); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(!item1->isSelected()); QVERIFY(item2->isSelected()); @@ -1049,7 +1067,7 @@ void tst_QGraphicsScene::selectionChanged2() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease); event.setScenePos(QPointF(50, 50)); event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); } QVERIFY(item1->isSelected()); QVERIFY(!item2->isSelected()); @@ -1065,10 +1083,11 @@ void tst_QGraphicsScene::addItem() QGraphicsScene scene; CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); view.setScene(&scene); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - qApp->processEvents(); + QCoreApplication::processEvents(); view.repaints = 0; scene.addItem(path); @@ -1115,14 +1134,14 @@ void tst_QGraphicsScene::addEllipse() QCOMPARE(ellipse->pen(), QPen(Qt::red)); QCOMPARE(ellipse->brush(), QBrush(Qt::blue)); QCOMPARE(ellipse->rect(), QRectF(-10, -10, 20, 20)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, 0, 0), ellipse); QVERIFY(scene.items(QPointF(-10, -10)).isEmpty()); - QCOMPARE(itemAt(scene, -9.9, 0), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, -9.9, 0), ellipse); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); - QCOMPARE(itemAt(scene, 0, -9.9), (QGraphicsItem *)ellipse); - QCOMPARE(itemAt(scene, 0, 9.9), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, 0, -9.9), ellipse); + QCOMPARE(itemAt(scene, 0, 9.9), ellipse); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); - QCOMPARE(itemAt(scene, 9.9, 0), (QGraphicsItem *)ellipse); + QCOMPARE(itemAt(scene, 9.9, 0), ellipse); QVERIFY(scene.items(QPointF(10, 10)).isEmpty()); } @@ -1136,15 +1155,15 @@ void tst_QGraphicsScene::addLine() QCOMPARE(line->pos(), QPointF()); QCOMPARE(line->pen(), pen); QCOMPARE(line->line(), QLineF(-10, -10, 20, 20)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)line); - QCOMPARE(itemAt(scene, -10, -10), (QGraphicsItem *)line); + QCOMPARE(itemAt(scene, 0, 0), line); + QCOMPARE(itemAt(scene, -10, -10), line); QVERIFY(scene.items(QPointF(-9.9, 0)).isEmpty()); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); QVERIFY(scene.items(QPointF(0, -9.9)).isEmpty()); QVERIFY(scene.items(QPointF(0, 9.9)).isEmpty()); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); QVERIFY(scene.items(QPointF(9.9, 0)).isEmpty()); - QCOMPARE(itemAt(scene, 10, 10), (QGraphicsItem *)line); + QCOMPARE(itemAt(scene, 10, 10), line); } void tst_QGraphicsScene::addPath() @@ -1162,16 +1181,16 @@ void tst_QGraphicsScene::addPath() path->setPen(QPen(Qt::red, 0)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, -9.9, 0), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 9.9, 0), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, -9.9), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 9.9), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 30), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, -9.9, 30), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 9.9, 30), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 20.1), (QGraphicsItem *)path); - QCOMPARE(itemAt(scene, 0, 39.9), (QGraphicsItem *)path); + QCOMPARE(itemAt(scene, 0, 0), path); + QCOMPARE(itemAt(scene, -9.9, 0), path); + QCOMPARE(itemAt(scene, 9.9, 0), path); + QCOMPARE(itemAt(scene, 0, -9.9), path); + QCOMPARE(itemAt(scene, 0, 9.9), path); + QCOMPARE(itemAt(scene, 0, 30), path); + QCOMPARE(itemAt(scene, -9.9, 30), path); + QCOMPARE(itemAt(scene, 9.9, 30), path); + QCOMPARE(itemAt(scene, 0, 20.1), path); + QCOMPARE(itemAt(scene, 0, 39.9), path); QVERIFY(scene.items(QPointF(-10, -10)).isEmpty()); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); @@ -1193,10 +1212,10 @@ void tst_QGraphicsScene::addPixmap() QCOMPARE(pixmap->pos(), QPointF()); QCOMPARE(pixmap->pixmap(), pix); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)pixmap); - QCOMPARE(itemAt(scene, pix.width() - 1, 0), (QGraphicsItem *)pixmap); - QCOMPARE(itemAt(scene, 0, pix.height() - 1), (QGraphicsItem *)pixmap); - QCOMPARE(itemAt(scene, pix.width() - 1, pix.height() - 1), (QGraphicsItem *)pixmap); + QCOMPARE(itemAt(scene, 0, 0), pixmap); + QCOMPARE(itemAt(scene, pix.width() - 1, 0), pixmap); + QCOMPARE(itemAt(scene, 0, pix.height() - 1), pixmap); + QCOMPARE(itemAt(scene, pix.width() - 1, pix.height() - 1), pixmap); QVERIFY(scene.items(QPointF(-1, -1)).isEmpty()); QVERIFY(scene.items(QPointF(pix.width() - 1, -1)).isEmpty()); @@ -1218,14 +1237,14 @@ void tst_QGraphicsScene::addRect() rect->setPen(QPen(Qt::red, 0)); - QCOMPARE(itemAt(scene, 0, 0), (QGraphicsItem *)rect); - QCOMPARE(itemAt(scene, -10, -10), (QGraphicsItem *)rect); - QCOMPARE(itemAt(scene, -9.9, 0), (QGraphicsItem *)rect); + QCOMPARE(itemAt(scene, 0, 0),rect); + QCOMPARE(itemAt(scene, -10, -10), rect); + QCOMPARE(itemAt(scene, -9.9, 0), rect); QVERIFY(scene.items(QPointF(-10, 10)).isEmpty()); - QCOMPARE(itemAt(scene, 0, -9.9), (QGraphicsItem *)rect); - QCOMPARE(itemAt(scene, 0, 9.9), (QGraphicsItem *)rect); + QCOMPARE(itemAt(scene, 0, -9.9), rect); + QCOMPARE(itemAt(scene, 0, 9.9), rect); QVERIFY(scene.items(QPointF(10, -10)).isEmpty()); - QCOMPARE(itemAt(scene, 9.9, 0), (QGraphicsItem *)rect); + QCOMPARE(itemAt(scene, 9.9, 0), rect); QVERIFY(scene.items(QPointF(10, 10)).isEmpty()); } @@ -1271,6 +1290,7 @@ void tst_QGraphicsScene::removeItem() scene.setSceneRect(-50, -50, 100, 100); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setFixedSize(150, 150); view.show(); QApplication::setActiveWindow(&view); @@ -1342,7 +1362,7 @@ void tst_QGraphicsScene::focusItem() class FocusItem : public QGraphicsTextItem { protected: - void focusOutEvent(QFocusEvent *) + void focusOutEvent(QFocusEvent *) override { QVERIFY(!scene()->focusItem()); } @@ -1359,14 +1379,14 @@ void tst_QGraphicsScene::focusItemLostFocus() scene.addItem(item); item->setFocus(); - QCOMPARE(scene.focusItem(), (QGraphicsItem *)item); + QCOMPARE(scene.focusItem(), item); item->clearFocus(); } class ClearTestItem : public QGraphicsRectItem { public: - ClearTestItem(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {} + using QGraphicsRectItem::QGraphicsRectItem; ~ClearTestItem() { qDeleteAll(items); } QList items; }; @@ -1389,7 +1409,7 @@ void tst_QGraphicsScene::clear() scene.setItemIndexMethod(QGraphicsScene::NoIndex); scene.addItem(firstItem); scene.addItem(secondItem); - QCOMPARE(scene.items().at(0), (QGraphicsItem*)firstItem); + QCOMPARE(scene.items().at(0), firstItem); QCOMPARE(scene.items().at(1), secondItem); ClearTestItem *thirdItem = new ClearTestItem(firstItem); @@ -1441,7 +1461,7 @@ void tst_QGraphicsScene::setFocusItem() QVERIFY(item->hasFocus()); QVERIFY(!item2->hasFocus()); - scene.setFocusItem(0); + scene.setFocusItem(nullptr); QVERIFY(!item->hasFocus()); QVERIFY(!item2->hasFocus()); @@ -1562,26 +1582,26 @@ void tst_QGraphicsScene::hoverEvents_siblings() Q_CHECK_PAINTEVENTS QGraphicsScene scene; - QGraphicsItem *lastItem = 0; + QGraphicsItem *lastItem = nullptr; QList items; for (int i = 0; i < 15; ++i) { - QGraphicsItem *item = new HoverItem; + auto item = new HoverItem; scene.addItem(item); - items << (HoverItem *)item; - if (lastItem) { + items << item; + if (lastItem) item->setPos(lastItem->pos() + QPointF(sin(i / 3.0) * 17, cos(i / 3.0) * 17)); - } item->setZValue(i); lastItem = item; } QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setRenderHint(QPainter::Antialiasing, true); view.setMinimumSize(400, 300); view.rotate(10); view.scale(1.7, 1.7); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); view.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1604,8 +1624,8 @@ void tst_QGraphicsScene::hoverEvents_siblings() mouseEvent.setScenePos(items.at(i)->mapToScene(0, 0)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here QTRY_VERIFY(items.at(i)->isHovered); if (j && i > 0) @@ -1621,8 +1641,8 @@ void tst_QGraphicsScene::hoverEvents_siblings() mouseEvent.setScenePos(QPointF(-1000, -1000)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here } } @@ -1631,12 +1651,12 @@ void tst_QGraphicsScene::hoverEvents_parentChild() Q_CHECK_PAINTEVENTS QGraphicsScene scene; - QGraphicsItem *lastItem = 0; + QGraphicsItem *lastItem = nullptr; QList items; for (int i = 0; i < 15; ++i) { - QGraphicsItem *item = new HoverItem; + auto item = new HoverItem; scene.addItem(item); - items << (HoverItem *)item; + items << item; if (lastItem) { item->setParentItem(lastItem); item->setPos(sin(i / 3.0) * 17, cos(i / 3.0) * 17); @@ -1645,12 +1665,13 @@ void tst_QGraphicsScene::hoverEvents_parentChild() } QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setRenderHint(QPainter::Antialiasing, true); view.setMinimumSize(400, 300); view.rotate(10); view.scale(1.7, 1.7); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); @@ -1669,8 +1690,8 @@ void tst_QGraphicsScene::hoverEvents_parentChild() mouseEvent.setScenePos(items.at(i)->mapToScene(0, 0)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here QTRY_VERIFY(items.at(i)->isHovered); if (i < 14) @@ -1683,8 +1704,8 @@ void tst_QGraphicsScene::hoverEvents_parentChild() mouseEvent.setScenePos(QPointF(-1000, -1000)); QApplication::sendEvent(&scene, &mouseEvent); - qApp->processEvents(); // this posts updates from the scene to the view - qApp->processEvents(); // which trigger a repaint here + QCoreApplication::processEvents(); // this posts updates from the scene to the view + QCoreApplication::processEvents(); // which trigger a repaint here } } @@ -1712,23 +1733,23 @@ void tst_QGraphicsScene::createItemGroup() // All items in children1 are children of parent1 QGraphicsItem *parent1 = scene.addRect(QRectF(-10, -10, 20, 20)); - foreach (QGraphicsItem *item, children1) + for (QGraphicsItem *item : qAsConst(children1)) item->setParentItem(parent1); QGraphicsItemGroup *group = scene.createItemGroup(children1); QCOMPARE(group->parentItem(), parent1); - QCOMPARE(children1.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children1.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children1.first()->parentItem(), parent1); group = scene.createItemGroup(children1); QCOMPARE(group->parentItem(), parent1); - QCOMPARE(children1.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children1.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children1.first()->parentItem(), parent1); // All items in children2 are children of parent2 QGraphicsItem *parent2 = scene.addRect(QRectF(-10, -10, 20, 20)); - foreach (QGraphicsItem *item, children2) + for (QGraphicsItem *item : qAsConst(children2)) item->setParentItem(parent2); // Now make parent2 a child of parent1, so all children2 are also children @@ -1738,21 +1759,21 @@ void tst_QGraphicsScene::createItemGroup() // The children2 group should still have parent2 as their common ancestor. group = scene.createItemGroup(children2); QCOMPARE(group->parentItem(), parent2); - QCOMPARE(children2.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children2.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children2.first()->parentItem(), parent2); // But the set of both children2 and children1 share only parent1. group = scene.createItemGroup(children2 + children1); QCOMPARE(group->parentItem(), parent1); - QCOMPARE(children1.first()->parentItem(), (QGraphicsItem *)group); - QCOMPARE(children2.first()->parentItem(), (QGraphicsItem *)group); + QCOMPARE(children1.first()->parentItem(), group); + QCOMPARE(children2.first()->parentItem(), group); scene.destroyItemGroup(group); QCOMPARE(children1.first()->parentItem(), parent1); QCOMPARE(children2.first()->parentItem(), parent1); // Fixup the parent-child chain - foreach (QGraphicsItem *item, children2) + for (QGraphicsItem *item : qAsConst(children2)) item->setParentItem(parent2); // These share no common parent @@ -1762,7 +1783,7 @@ void tst_QGraphicsScene::createItemGroup() // Make children3 children of parent3 QGraphicsItem *parent3 = scene.addRect(QRectF(-10, -10, 20, 20)); - foreach (QGraphicsItem *item, children3) + for (QGraphicsItem *item : qAsConst(children3)) item->setParentItem(parent3); // These should have parent3 as a parent @@ -1794,15 +1815,14 @@ void tst_QGraphicsScene::createItemGroup() class EventTester : public QGraphicsEllipseItem { public: - EventTester() - : QGraphicsEllipseItem(QRectF(-10, -10, 20, 20)), ignoreMouse(false) + EventTester() : QGraphicsEllipseItem(QRectF(-10, -10, 20, 20)) { } - bool ignoreMouse; - QList eventTypes; + bool ignoreMouse = false; + QVector eventTypes; protected: - bool sceneEvent(QEvent *event) + bool sceneEvent(QEvent *event) override { eventTypes << QEvent::Type(event->type()); switch (event->type()) { @@ -1813,6 +1833,7 @@ protected: event->ignore(); return true; } + break; default: break; } @@ -1867,7 +1888,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.size(), 0); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)d); + QCOMPARE(scene.mouseGrabberItem(), d); // Send a move QApplication::sendEvent(&scene, &moveEvent); @@ -1876,7 +1897,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.size(), 0); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)d); + QCOMPARE(scene.mouseGrabberItem(), d); // Send a release QApplication::sendEvent(&scene, &releaseEvent); @@ -1898,7 +1919,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(1), QEvent::GraphicsSceneMousePress); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Send another press, with a button that isn't actually accepted QApplication::sendEvent(&scene, &pressEvent); @@ -1908,7 +1929,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(2), QEvent::GraphicsSceneMousePress); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Send a move QApplication::sendEvent(&scene, &moveEvent); @@ -1917,7 +1938,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(3), QEvent::GraphicsSceneMouseMove); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Send a release QApplication::sendEvent(&scene, &releaseEvent); @@ -1950,7 +1971,7 @@ void tst_QGraphicsScene::mouseEventPropagation() QCOMPARE(c->eventTypes.at(7), QEvent::GraphicsSceneMousePress); QCOMPARE(b->eventTypes.size(), 0); QCOMPARE(a->eventTypes.size(), 0); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)c); + QCOMPARE(scene.mouseGrabberItem(), c); // Clicking outside the items removes the mouse grabber } @@ -1999,7 +2020,7 @@ void tst_QGraphicsScene::mouseEventPropagation_ignore() QCOMPARE(d->eventTypes.at(0), QEvent::GrabMouse); QCOMPARE(d->eventTypes.at(1), QEvent::GraphicsSceneMousePress); QCOMPARE(d->eventTypes.at(2), QEvent::UngrabMouse); - QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)a); + QCOMPARE(scene.mouseGrabberItem(), a); a->ignoreMouse = true; @@ -2115,7 +2136,7 @@ public: QVector mouseMovePoints; protected: - void mouseMoveEvent(QGraphicsSceneMouseEvent *event) + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override { mouseMovePoints << event->scenePos(); } @@ -2140,22 +2161,17 @@ void tst_QGraphicsScene::mouseEventPropagation_mouseMove() class DndTester : public QGraphicsEllipseItem { public: - DndTester(const QRectF &rect) - : QGraphicsEllipseItem(rect), lastEvent(0), - ignoresDragEnter(false), ignoresDragMove(false) - - { - } + using QGraphicsEllipseItem::QGraphicsEllipseItem; ~DndTester() { delete lastEvent; } - QGraphicsSceneDragDropEvent *lastEvent; + QGraphicsSceneDragDropEvent *lastEvent = nullptr; QList eventList; - bool ignoresDragEnter; - bool ignoresDragMove; + bool ignoresDragEnter = false; + bool ignoresDragMove = false; protected: void dragEnterEvent(QGraphicsSceneDragDropEvent *event) @@ -2218,21 +2234,21 @@ void tst_QGraphicsScene::dragAndDrop_simple() QMimeData mimeData; // Initial drag enter for the scene - QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragEnter); QVERIFY(dragEnter.isAccepted()); QCOMPARE(dragEnter.dropAction(), Qt::CopyAction); { // Move outside the item - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); } { // Move inside the item without setAcceptDrops - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2241,7 +2257,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() item->setAcceptDrops(true); { // Move inside the item with setAcceptDrops - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2255,7 +2271,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Another move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->mapToScene(5, 5)), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->mapToScene(5, 5)), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2268,7 +2284,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Move outside the item - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2281,7 +2297,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Move inside the item again - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2295,7 +2311,7 @@ void tst_QGraphicsScene::dragAndDrop_simple() } { // Drop inside the item - QDropEvent drop(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent drop(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &drop); QVERIFY(drop.isAccepted()); QCOMPARE(drop.dropAction(), Qt::CopyAction); @@ -2322,13 +2338,13 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() QMimeData mimeData; // Initial drag enter for the scene - QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragEnter); QVERIFY(dragEnter.isAccepted()); QCOMPARE(dragEnter.dropAction(), Qt::CopyAction); { // Move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2338,7 +2354,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() } { // Move outside the item - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2353,7 +2369,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() { // Move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2369,7 +2385,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() { // Move inside the item - QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(item->scenePos()), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2378,7 +2394,7 @@ void tst_QGraphicsScene::dragAndDrop_disabledOrInvisible() } // Dummy drop event to keep the Mac from crashing. - QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dropEvent); } @@ -2405,14 +2421,14 @@ void tst_QGraphicsScene::dragAndDrop_propagate() QMimeData mimeData; // Initial drag enter for the scene - QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragEnterEvent dragEnter(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragEnter); QVERIFY(dragEnter.isAccepted()); QCOMPARE(dragEnter.dropAction(), Qt::CopyAction); { // Move outside the items - QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2421,7 +2437,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } { // Move inside item1 - QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2432,7 +2448,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() { // Move into the intersection item1-item2 - QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); // move does not propagate, (ignoresDragMove = true) QCOMPARE(item1->eventList.size(), 3); @@ -2443,7 +2459,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } { // Move into the item2 - QDragMoveEvent dragMove(view.mapFromScene(15, 15), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(15, 15), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(!dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::CopyAction); @@ -2453,7 +2469,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } { // Move inside item1 - QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(-5, -5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2467,7 +2483,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() { item2->ignoresDragEnter = true; // Move into the intersection item1-item2 - QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDragMoveEvent dragMove(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dragMove); QVERIFY(dragMove.isAccepted()); // dragEnter propagates down to item1, which then accepts the move event. QCOMPARE(dragMove.dropAction(), Qt::IgnoreAction); @@ -2480,7 +2496,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() { item2->ignoresDragEnter = false; // Drop on the intersection item1-item2 - QDropEvent drop(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent drop(view.mapFromScene(5, 5), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &drop); QVERIFY(drop.isAccepted()); QCOMPARE(drop.dropAction(), Qt::CopyAction); @@ -2491,7 +2507,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() } // Dummy drop event to keep the Mac from crashing. - QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); + QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, {}); QApplication::sendEvent(view.viewport(), &dropEvent); } #endif @@ -2580,6 +2596,7 @@ void tst_QGraphicsScene::render() pix.fill(Qt::blue); QGraphicsView view; + view.setWindowTitle(QTest::currentTestFunction()); QGraphicsScene scene(&view); scene.addEllipse(QRectF(-10, -10, 20, 20), QPen(Qt::black, 0), QBrush(Qt::white)); scene.addEllipse(QRectF(-2, -7, 4, 4), QPen(Qt::black, 0), QBrush(Qt::yellow))->setZValue(1); @@ -2642,6 +2659,7 @@ void tst_QGraphicsScene::render() gridLayout->addWidget(newLabel, 2, 0); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(gridLayout); widget.show(); @@ -2676,6 +2694,7 @@ void tst_QGraphicsScene::renderItemsWithNegativeWidthOrHeight() scene.addItem(item2); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.setFrameStyle(QFrame::NoFrame); view.resize(150, 150); view.show(); @@ -2710,6 +2729,7 @@ void tst_QGraphicsScene::contextMenuEvent() QVERIFY(scene.hasFocus()); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.show(); view.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -2730,7 +2750,7 @@ public: { setBrush(Qt::red); } protected: - void contextMenuEvent(QGraphicsSceneContextMenuEvent *) + void contextMenuEvent(QGraphicsSceneContextMenuEvent *) override { /* just accept */ } }; @@ -2746,6 +2766,7 @@ void tst_QGraphicsScene::contextMenuEvent_ItemIgnoresTransformations() scene.addItem(item); QWidget topLevel; + topLevel.setWindowTitle(QTest::currentTestFunction()); QGraphicsView view(&scene, &topLevel); view.resize(200, 200); topLevel.show(); @@ -2790,14 +2811,14 @@ void tst_QGraphicsScene::update() QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 100, 100); rect->setPen(QPen(Qt::black, 0)); scene.addItem(rect); - qApp->processEvents(); + QCoreApplication::processEvents(); rect->setPos(-100, -100); // This function forces indexing itemAt(scene, 0, 0); qRegisterMetaType >("QList"); - QSignalSpy spy(&scene, SIGNAL(changed(QList))); + QSignalSpy spy(&scene, &QGraphicsScene::changed); // We update the scene. scene.update(); @@ -2806,12 +2827,13 @@ void tst_QGraphicsScene::update() itemAt(scene, 0, 0); // This will process the pending update - QApplication::instance()->processEvents(); + QCoreApplication::processEvents(); // Check that the update region is correct QCOMPARE(spy.count(), 1); QRectF region; - foreach (QRectF rectF, qvariant_cast >(spy.at(0).at(0))) + const auto &rects = qvariant_cast >(spy.at(0).at(0)); + for (const auto &rectF : rects) region |= rectF; QCOMPARE(region, QRectF(-100, -100, 200, 200)); } @@ -2821,9 +2843,10 @@ void tst_QGraphicsScene::update2() QGraphicsScene scene; scene.setSceneRect(-200, -200, 200, 200); CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); view.setScene(&scene); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); QTRY_VERIFY(view.repaints >= 1); view.repaints = 0; @@ -2831,13 +2854,13 @@ void tst_QGraphicsScene::update2() // Make sure QGraphicsScene::update only requires one event-loop iteration // before the view is updated. scene.update(); - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_COMPARE(view.repaints, 1); view.repaints = 0; // The same for partial scene updates. scene.update(QRectF(-100, -100, 100, 100)); - qApp->processEvents(); + QCoreApplication::processEvents(); QCOMPARE(view.repaints, 1); } @@ -2853,7 +2876,7 @@ void tst_QGraphicsScene::views() QCOMPARE(scene.views().size(), 2); QVERIFY(scene.views().contains(&view1)); - view.setScene(0); + view.setScene(nullptr); QCOMPARE(scene.views().size(), 1); QCOMPARE(scene.views().at(0), &view1); @@ -2871,12 +2894,12 @@ void tst_QGraphicsScene::views() class CustomScene : public QGraphicsScene { public: - CustomScene() : gotTimerEvent(false) + CustomScene() { startTimer(10); } - bool gotTimerEvent; + bool gotTimerEvent = false; protected: - void timerEvent(QTimerEvent *) + void timerEvent(QTimerEvent *) override { gotTimerEvent = true; } @@ -2893,7 +2916,7 @@ void tst_QGraphicsScene::testEvent() class DisabledItemTester : public QGraphicsRectItem { public: - DisabledItemTester(const QRectF &rect, QGraphicsItem *parent = 0) + DisabledItemTester(const QRectF &rect, QGraphicsItem *parent = nullptr) : QGraphicsRectItem(rect, parent) { } @@ -2901,13 +2924,13 @@ public: QList receivedSceneEventFilters; protected: - bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) + bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override { receivedSceneEventFilters << event->type(); return QGraphicsRectItem::sceneEventFilter(watched, event); } - bool sceneEvent(QEvent *event) + bool sceneEvent(QEvent *event) override { receivedSceneEvents << event->type(); return QGraphicsRectItem::sceneEvent(event); @@ -2965,11 +2988,9 @@ void tst_QGraphicsScene::eventsToDisabledItems() class ExposedPixmapItem : public QGraphicsPixmapItem { public: - ExposedPixmapItem(QGraphicsItem *item = 0) - : QGraphicsPixmapItem(item) - { } + using QGraphicsPixmapItem::QGraphicsPixmapItem; - void paint(QPainter *, const QStyleOptionGraphicsItem *option, QWidget *) + void paint(QPainter *, const QStyleOptionGraphicsItem *option, QWidget *) override { exposed = option->exposedRect; } @@ -3013,8 +3034,9 @@ void tst_QGraphicsScene::tabFocus_emptyScene() QWidget widget; widget.setLayout(layout); + widget.setWindowTitle(QTest::currentTestFunction()); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3060,9 +3082,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems() layout->addWidget(dial2); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(layout); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3112,18 +3135,18 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusableItems() QVERIFY(!view->viewport()->hasFocus()); QVERIFY(!scene.hasFocus()); QVERIFY(!item->hasFocus()); - QCOMPARE(scene.focusItem(), static_cast(item)); + QCOMPARE(scene.focusItem(), item); // Check that the correct item regains focus. widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); QVERIFY(view->hasFocus()); QTRY_VERIFY(scene.isActive()); QVERIFY(view->viewport()->hasFocus()); QVERIFY(scene.hasFocus()); - QCOMPARE(scene.focusItem(), static_cast(item)); + QCOMPARE(scene.focusItem(), item); QVERIFY(item->hasFocus()); } @@ -3131,14 +3154,13 @@ class FocusWidget : public QGraphicsWidget { Q_OBJECT public: - FocusWidget(QGraphicsItem *parent = 0) - : QGraphicsWidget(parent), tabs(0), backTabs(0) + FocusWidget(QGraphicsItem *parent = nullptr) : QGraphicsWidget(parent) { setFocusPolicy(Qt::StrongFocus); resize(100, 100); } - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) override { if (option->state & QStyle::State_HasFocus) { painter->fillRect(rect(), Qt::blue); @@ -3152,11 +3174,11 @@ public: } } - int tabs; - int backTabs; + int tabs = 0; + int backTabs = 0; protected: - bool sceneEvent(QEvent *event) + bool sceneEvent(QEvent *event) override { if (event->type() == QEvent::KeyPress) { QKeyEvent *k = static_cast(event); @@ -3168,9 +3190,9 @@ protected: return QGraphicsWidget::sceneEvent(event); } - void focusInEvent(QFocusEvent *) + void focusInEvent(QFocusEvent *) override { update(); } - void focusOutEvent(QFocusEvent *) + void focusOutEvent(QFocusEvent *) override { update(); } }; @@ -3195,9 +3217,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusWidgets() layout->addWidget(dial2); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(layout); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3236,7 +3259,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithFocusWidgets() widget.hide(); QTest::qWait(15); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); QTRY_VERIFY(widget1->hasFocus()); @@ -3279,9 +3302,10 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets() layout->addWidget(dial2); QWidget widget; + widget.setWindowTitle(QTest::currentTestFunction()); widget.setLayout(layout); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); @@ -3366,7 +3390,7 @@ void tst_QGraphicsScene::tabFocus_sceneWithNestedFocusWidgets() widget.hide(); QTest::qWait(12); widget.show(); - qApp->setActiveWindow(&widget); + QApplication::setActiveWindow(&widget); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); QTRY_VERIFY(widget1->hasFocus()); @@ -3390,11 +3414,11 @@ void tst_QGraphicsScene::style() QCOMPARE(sceneSpy.count(), 1); QCOMPARE(proxySpy.count(), 1); QCOMPARE(editSpy.count(), 1); - QCOMPARE(scene.style(), (QStyle *)windowsStyle); - QCOMPARE(proxy->style(), (QStyle *)windowsStyle); - QCOMPARE(edit->style(), (QStyle *)windowsStyle); + QCOMPARE(scene.style(), windowsStyle.data()); + QCOMPARE(proxy->style(), windowsStyle.data()); + QCOMPARE(edit->style(), windowsStyle.data()); - scene.setStyle(0); + scene.setStyle(nullptr); QCOMPARE(sceneSpy.count(), 2); QCOMPARE(proxySpy.count(), 2); QCOMPARE(editSpy.count(), 2); @@ -3411,11 +3435,12 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() for (int i = 0; i < 2; ++i) { // trigger delayed item indexing - qApp->processEvents(); + QCoreApplication::processEvents(); scene.setSceneRect(0, 0, 10000, 10000); // delete all items in the scene - pointers are now likely to be recycled - foreach (QGraphicsItem *item, scene.items()) { + const auto &items = scene.items(); + for (QGraphicsItem *item : items) { scene.removeItem(item); delete item; } @@ -3427,7 +3452,7 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() } // trigger delayed item indexing for the first 1000 items - qApp->processEvents(); + QCoreApplication::processEvents(); // add 1000 more items - the BSP tree is now resized for (int i = 0; i < 1000; ++i) { @@ -3437,7 +3462,8 @@ void tst_QGraphicsScene::task139710_bspTreeCrash() // get items from the BSP tree and use them. there was junk in the tree // the second time this happened. - foreach (QGraphicsItem *item, scene.items(QRectF(0, 0, 1000, 1000))) + const auto &itemsWithin = scene.items(QRectF(0, 0, 1000, 1000)); + for (QGraphicsItem *item : itemsWithin) item->moveBy(0, 0); } } @@ -3446,7 +3472,7 @@ void tst_QGraphicsScene::task139782_containsItemBoundingRect() { // The item in question has a scene bounding rect of (10, 10, 50, 50) QGraphicsScene scene(0.0, 0.0, 200.0, 200.0); - QGraphicsRectItem *item = new QGraphicsRectItem(0.0, 0.0, 50.0, 50.0, 0); + QGraphicsRectItem *item = new QGraphicsRectItem(0.0, 0.0, 50.0, 50.0, nullptr); scene.addItem(item); item->setPos(10.0, 10.0); @@ -3476,7 +3502,8 @@ void tst_QGraphicsScene::task160653_selectionChanged() QGraphicsScene scene(0, 0, 100, 100); scene.addItem(new QGraphicsRectItem(0, 0, 20, 20)); scene.addItem(new QGraphicsRectItem(30, 30, 20, 20)); - foreach (QGraphicsItem *item, scene.items()) { + const auto &items = scene.items(); + for (QGraphicsItem *item : items) { item->setFlags( item->flags() | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable); item->setSelected(true); @@ -3484,12 +3511,13 @@ void tst_QGraphicsScene::task160653_selectionChanged() QVERIFY(scene.items().size() > 1); QCOMPARE(scene.items().size(), scene.selectedItems().size()); - QSignalSpy spy(&scene, SIGNAL(selectionChanged())); + QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); view.show(); QVERIFY(QTest::qWaitForWindowActive(&view)); QTest::mouseClick( - view.viewport(), Qt::LeftButton, 0, view.mapFromScene(scene.items().first()->scenePos())); + view.viewport(), Qt::LeftButton, {}, view.mapFromScene(scene.items().first()->scenePos())); QCOMPARE(spy.count(), 1); } @@ -3574,17 +3602,21 @@ void tst_QGraphicsScene::sorting() scene.addItem(t_1); - foreach (QGraphicsItem *item, scene.items()) + const auto &items = scene.items(); + for (QGraphicsItem *item : items) item->setFlag(QGraphicsItem::ItemIsSelectable); // QGraphicsView view(&scene); // view.setDragMode(QGraphicsView::RubberBandDrag); // view.show(); - qDebug() << "items: {"; - foreach (QGraphicsItem *item, scene.items(QRectF(32, 31, 4, 55))) - qDebug() << "\t" << item->data(0).toString(); - qDebug() << "}"; + if (lcTests().isDebugEnabled()) { + qCDebug(lcTests) << "items: {"; + const auto &itemsWithin = scene.items(QRectF(32, 31, 4, 55)); + for (QGraphicsItem *item : itemsWithin) + qCDebug(lcTests).nospace() << '\t' << item->data(0).toString(); + qCDebug(lcTests) << '}'; + } QCOMPARE(scene.items(QRectF(32, 31, 4, 55)), QList() @@ -3664,11 +3696,11 @@ void tst_QGraphicsScene::changedSignal() QFETCH(bool, withView); QGraphicsScene scene; ChangedListener cl; - connect(&scene, SIGNAL(changed(QList)), &cl, SLOT(changed(QList))); + connect(&scene, &QGraphicsScene::changed, &cl, &ChangedListener::changed); - QGraphicsView *view = 0; + QScopedPointer view; if (withView) - view = new QGraphicsView(&scene); + view.reset(new QGraphicsView(&scene)); QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 10, 10); rect->setPen(QPen(Qt::black, 0)); @@ -3682,16 +3714,13 @@ void tst_QGraphicsScene::changedSignal() rect->setPos(20, 0); QCOMPARE(cl.changes.size(), 1); - qApp->processEvents(); + QCoreApplication::processEvents(); QCOMPARE(cl.changes.size(), 2); QCOMPARE(cl.changes.at(1).size(), 2); QCOMPARE(cl.changes.at(1).first(), QRectF(0, 0, 10, 10)); QCOMPARE(cl.changes.at(1).last(), QRectF(20, 0, 10, 10)); QCOMPARE(scene.sceneRect(), QRectF(0, 0, 30, 10)); - - if (withView) - delete view; } void tst_QGraphicsScene::stickyFocus_data() @@ -3718,7 +3747,7 @@ void tst_QGraphicsScene::stickyFocus() QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); event.setScenePos(QPointF(-10, -10)); // outside item event.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); QCOMPARE(text->hasFocus(), sticky); } @@ -3736,43 +3765,50 @@ void tst_QGraphicsScene::sendEvent() void tst_QGraphicsScene::inputMethod_data() { - QTest::addColumn("flags"); + QTest::addColumn("flags"); QTest::addColumn("callFocusItem"); - QTest::newRow("0") << 0 << false; - QTest::newRow("1") << (int)QGraphicsItem::ItemAcceptsInputMethod << false; - QTest::newRow("2") << (int)QGraphicsItem::ItemIsFocusable << false; + QTest::newRow("0") << QGraphicsItem::GraphicsItemFlags() << false; + QTest::newRow("1") << QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemAcceptsInputMethod) << false; + QTest::newRow("2") << QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemIsFocusable) << false; QTest::newRow("3") << - (int)(QGraphicsItem::ItemAcceptsInputMethod|QGraphicsItem::ItemIsFocusable) << true; + (QGraphicsItem::ItemAcceptsInputMethod|QGraphicsItem::ItemIsFocusable) << true; } class InputMethodTester : public QGraphicsRectItem { - void inputMethodEvent(QInputMethodEvent *) { ++eventCalls; } - QVariant inputMethodQuery(Qt::InputMethodQuery) const { ++queryCalls; return QVariant(); } + void inputMethodEvent(QInputMethodEvent *) override { ++eventCalls; } + QVariant inputMethodQuery(Qt::InputMethodQuery) const override + { + ++queryCalls; + return QVariant(); + } + public: - int eventCalls; - mutable int queryCalls; + int eventCalls = 0; + mutable int queryCalls = 0; }; void tst_QGraphicsScene::inputMethod() { PlatformInputContext inputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + QInputMethodPrivate *inputMethodPrivate = + QInputMethodPrivate::get(QGuiApplication::inputMethod()); inputMethodPrivate->testContext = &inputContext; - QFETCH(int, flags); + QFETCH(QGraphicsItem::GraphicsItemFlags, flags); QFETCH(bool, callFocusItem); InputMethodTester *item = new InputMethodTester; - item->setFlags((QGraphicsItem::GraphicsItemFlags)flags); + item->setFlags(flags); QGraphicsScene scene; QGraphicsView view(&scene); view.show(); + view.setWindowTitle(QTest::currentTestFunction()); QApplication::setActiveWindow(&view); view.setFocus(); QVERIFY(QTest::qWaitForWindowActive(&view)); - QCOMPARE(QApplication::activeWindow(), static_cast(&view)); + QCOMPARE(QApplication::activeWindow(), &view); inputContext.m_resetCallCount = 0; inputContext.m_commitCallCount = 0; @@ -3784,25 +3820,25 @@ void tst_QGraphicsScene::inputMethod() QCOMPARE(inputContext.m_resetCallCount, 0); item->eventCalls = 0; - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); QCOMPARE(item->eventCalls, callFocusItem ? 1 : 0); item->queryCalls = 0; - scene.inputMethodQuery((Qt::InputMethodQuery)0); + scene.inputMethodQuery(Qt::InputMethodQuery(0)); QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); - scene.setFocusItem(0); + scene.setFocusItem(nullptr); // the input context is reset twice, once because an item has lost focus and again because // the Qt::WA_InputMethodEnabled flag is cleared because no item has focus. QCOMPARE(inputContext.m_resetCallCount + inputContext.m_commitCallCount, callFocusItem ? 2 : 0); QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); // verify that value is unaffected item->eventCalls = 0; - qApp->sendEvent(&scene, &event); + QCoreApplication::sendEvent(&scene, &event); QCOMPARE(item->eventCalls, 0); item->queryCalls = 0; - scene.inputMethodQuery((Qt::InputMethodQuery)0); + scene.inputMethodQuery(Qt::InputMethodQuery(0)); QCOMPARE(item->queryCalls, 0); } @@ -3826,18 +3862,18 @@ void tst_QGraphicsScene::dispatchHoverOnPress() me.setButtons(Qt::LeftButton); QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease); me2.setButton(Qt::LeftButton); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - QCOMPARE(tester1->eventTypes, QList() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QVector() << QEvent::GraphicsSceneHoverEnter << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress << QEvent::UngrabMouse); tester1->eventTypes.clear(); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - QCOMPARE(tester1->eventTypes, QList() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + QCOMPARE(tester1->eventTypes, QVector() << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress @@ -3852,21 +3888,21 @@ void tst_QGraphicsScene::dispatchHoverOnPress() me2.setScenePos(QPointF(30, 30)); me2.setButton(Qt::LeftButton); tester1->eventTypes.clear(); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - qDebug() << tester1->eventTypes; - QCOMPARE(tester1->eventTypes, QList() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + qCDebug(lcTests) << tester1->eventTypes; + QCOMPARE(tester1->eventTypes, QVector() << QEvent::GraphicsSceneHoverLeave); - QCOMPARE(tester2->eventTypes, QList() + QCOMPARE(tester2->eventTypes, QVector() << QEvent::GraphicsSceneHoverEnter << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress << QEvent::UngrabMouse); tester2->eventTypes.clear(); - qApp->sendEvent(&scene, &me); - qApp->sendEvent(&scene, &me2); - QCOMPARE(tester2->eventTypes, QList() + QCoreApplication::sendEvent(&scene, &me); + QCoreApplication::sendEvent(&scene, &me2); + QCOMPARE(tester2->eventTypes, QVector() << QEvent::GraphicsSceneHoverMove << QEvent::GrabMouse << QEvent::GraphicsSceneMousePress @@ -3915,7 +3951,7 @@ void tst_QGraphicsScene::initialFocus() if (activeScene) { QEvent windowActivate(QEvent::WindowActivate); - qApp->sendEvent(&scene, &windowActivate); + QCoreApplication::sendEvent(&scene, &windowActivate); scene.setFocus(); } @@ -3923,7 +3959,7 @@ void tst_QGraphicsScene::initialFocus() if (!activeScene) { QEvent windowActivate(QEvent::WindowActivate); - qApp->sendEvent(&scene, &windowActivate); + QCoreApplication::sendEvent(&scene, &windowActivate); scene.setFocus(); } @@ -3933,14 +3969,13 @@ void tst_QGraphicsScene::initialFocus() class PolishItem : public QGraphicsTextItem { public: - PolishItem(QGraphicsItem *parent = 0) - : QGraphicsTextItem(parent), polished(false), deleteChildrenInPolish(true), addChildrenInPolish(false) { } + using QGraphicsTextItem::QGraphicsTextItem; - bool polished; - bool deleteChildrenInPolish; - bool addChildrenInPolish; + bool polished = false; + bool deleteChildrenInPolish = true; + bool addChildrenInPolish = false; protected: - QVariant itemChange(GraphicsItemChange change, const QVariant& value) + QVariant itemChange(GraphicsItemChange change, const QVariant& value) override { if (change == ItemVisibleChange) { polished = true; @@ -3979,19 +4014,19 @@ void tst_QGraphicsScene::polishItems2() // Wait for the polish event to be delivered. QVERIFY(!item->polished); - QApplication::sendPostedEvents(&scene, QEvent::MetaCall); + QCoreApplication::sendPostedEvents(&scene, QEvent::MetaCall); QVERIFY(item->polished); // We deleted the children we added above, but we also // added 10 new children. These should be polished in the next // event loop iteration. - QList children = item->childItems(); + const QList children = item->childItems(); QCOMPARE(children.count(), 10); - foreach (QGraphicsItem *child, children) + for (QGraphicsItem *child : children) QVERIFY(!static_cast(child)->polished); - QApplication::sendPostedEvents(&scene, QEvent::MetaCall); - foreach (QGraphicsItem *child, children) + QCoreApplication::sendPostedEvents(&scene, QEvent::MetaCall); + for (QGraphicsItem *child : children) QVERIFY(static_cast(child)->polished); } @@ -4008,6 +4043,7 @@ void tst_QGraphicsScene::isActive() { QWidget toplevel1; + toplevel1.setWindowTitle(QTest::currentTestFunction()); QHBoxLayout *layout = new QHBoxLayout; toplevel1.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4075,6 +4111,7 @@ void tst_QGraphicsScene::isActive() { const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QWidget toplevel2; + toplevel2.setWindowTitle(QTest::currentTestFunction()); QHBoxLayout *layout = new QHBoxLayout; toplevel2.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4141,7 +4178,7 @@ void tst_QGraphicsScene::isActive() QApplication::setActiveWindow(&topLevelView); topLevelView.setFocus(); QVERIFY(QTest::qWaitForWindowActive(&topLevelView)); - QCOMPARE(QApplication::activeWindow(), static_cast(&topLevelView)); + QCOMPARE(QApplication::activeWindow(), &topLevelView); QVERIFY(!scene1.isActive()); QVERIFY(!scene2.isActive()); @@ -4211,7 +4248,7 @@ void tst_QGraphicsScene::isActive() QVERIFY(scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); - view1->setParent(0); + view1->setParent(nullptr); QVERIFY(!scene1.isActive()); QVERIFY(scene2.isActive()); QVERIFY(!scene1.hasFocus()); @@ -4243,7 +4280,7 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() scene.addItem(parent2); //Then we make the child a top level - child->setParentItem(0); + child->setParentItem(nullptr); //This is trigerred by a repaint... QGraphicsScenePrivate::get(&scene)->index->estimateTopLevelItems(QRectF(), Qt::AscendingOrder); @@ -4259,6 +4296,7 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() scene2.setItemIndexMethod(QGraphicsScene::NoIndex); QGraphicsView view2(&scene2); + view2.setWindowTitle(QTest::currentTestFunction()); // first add the blue rect QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 )); @@ -4302,9 +4340,10 @@ void tst_QGraphicsScene::removeFullyTransparentItem() child->setParentItem(parent); CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); view.setScene(&scene); view.show(); - qApp->setActiveWindow(&view); + QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); QCoreApplication::processEvents(); // Process all queued paint events @@ -4353,33 +4392,34 @@ void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() { // Test using DeviceCoordinateCache and opaque item - QWidget *w = new QWidget(); + QScopedPointer w(new QWidget); w->setPalette(QColor(0, 0, 255)); w->setGeometry(0, 0, 50, 50); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.setScene(scene); - QGraphicsProxyWidget *proxy = scene->addWidget(w); + QGraphicsProxyWidget *proxy = scene->addWidget(w.data()); proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); proxy->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; proxy->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(proxy); - QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view->viewport()).key, &pix)); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view.viewport()).key, &pix)); QTransform t = proxy->sceneTransform(); // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(proxy->boundingRect().toRect()).left(); + const int adjust = t.mapRect(proxy->boundingRect().toRect()).left(); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4388,8 +4428,6 @@ void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() for(int j = 0; j < im.height(); j++) QCOMPARE(qAlpha(im.pixel(i, j)), 255); } - - delete w; } void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() @@ -4403,28 +4441,29 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() rectItem->setParentItem(backItem); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.setScene(scene); scene->addItem(backItem); rectItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); backItem->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; rectItem->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); - QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view->viewport()).key, &pix)); + QTRY_VERIFY(QPixmapCache::find(itemp->extraItemCache()->deviceData.value(view.viewport()).key, &pix)); QTransform t = rectItem->sceneTransform(); // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + const int adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4434,8 +4473,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() QCOMPARE(qAlpha(im.pixel(i, j)), 125); } } - - delete view; } // Test using ItemCoordinateCache and opaque item @@ -4444,18 +4481,19 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() rectItem->setBrush(QColor(0, 0, 255)); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.setScene(scene); scene->addItem(rectItem); rectItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); rectItem->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; rectItem->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); @@ -4465,7 +4503,7 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + const int adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4474,8 +4512,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() for(int j = 0; j < im.height(); j++) QCOMPARE(qAlpha(im.pixel(i, j)), 255); } - - delete view; } // Test using ItemCoordinateCache and semi-transparent item @@ -4484,18 +4520,19 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() rectItem->setBrush(QColor(0, 0, 255, 125)); QGraphicsScene *scene = new QGraphicsScene(); - CustomView *view = new CustomView; - view->setScene(scene); + CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); + view.setScene(scene); scene->addItem(rectItem); rectItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); rectItem->setTransform(QTransform().rotate(15), true); - view->show(); - QVERIFY(QTest::qWaitForWindowExposed(view)); - view->repaints = 0; + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + view.repaints = 0; rectItem->update(10, 10, 10, 10); - QTRY_VERIFY(view->repaints > 0); + QTRY_VERIFY(view.repaints > 0); QPixmap pix; QGraphicsItemPrivate* itemp = QGraphicsItemPrivate::get(rectItem); @@ -4505,7 +4542,7 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() // Map from scene coordinates to pixmap coordinates. // X origin in the pixmap is the most-left point // of the item's boundingRect in the scene. - qreal adjust = t.mapRect(rectItem->boundingRect().toRect()).left(); + const int adjust = int(t.mapRect(rectItem->boundingRect().toRect()).left()); QRect rect = t.mapRect(QRect(10, 10, 10, 10)).adjusted(-adjust, 0, -adjust + 1, 1); QPixmap subpix = pix.copy(rect); @@ -4514,8 +4551,6 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() for(int j = 0; j < im.height(); j++) QCOMPARE(qAlpha(im.pixel(i, j)), 125); } - - delete view; } } @@ -4546,7 +4581,7 @@ void tst_QGraphicsScene::zeroScale() QGraphicsView view(&scene); ChangedListener cl; - connect(&scene, SIGNAL(changed(QList)), &cl, SLOT(changed(QList))); + connect(&scene, &QGraphicsScene::changed, &cl, &ChangedListener::changed); QGraphicsRectItem *rect1 = new QGraphicsRectItem(0, 0, 0.0000001, 0.00000001); scene.addItem(rect1); @@ -4569,13 +4604,13 @@ void tst_QGraphicsScene::focusItemChangedSignal() qRegisterMetaType("Qt::FocusReason"); QGraphicsScene scene; - QSignalSpy spy(&scene, SIGNAL(focusItemChanged(QGraphicsItem *, QGraphicsItem *, Qt::FocusReason))); + QSignalSpy spy(&scene, &QGraphicsScene::focusItemChanged); QVERIFY(spy.isValid()); QCOMPARE(spy.count(), 0); scene.setFocus(); QCOMPARE(spy.count(), 0); QEvent activateEvent(QEvent::WindowActivate); - qApp->sendEvent(&scene, &activateEvent); + QCoreApplication::sendEvent(&scene, &activateEvent); QCOMPARE(spy.count(), 0); QGraphicsRectItem *topLevelItem1 = new QGraphicsRectItem; @@ -4592,7 +4627,7 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(spy.count(), 1); QList arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast(arguments.at(0)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast(arguments.at(0)), topLevelItem2); QCOMPARE(qvariant_cast(arguments.at(1)), nullptr); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::OtherFocusReason); QVERIFY(topLevelItem2->hasFocus()); @@ -4602,14 +4637,14 @@ void tst_QGraphicsScene::focusItemChangedSignal() arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); QCOMPARE(qvariant_cast(arguments.at(0)), nullptr); - QCOMPARE(qvariant_cast(arguments.at(1)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast(arguments.at(1)), topLevelItem2); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::OtherFocusReason); scene.setFocus(Qt::MenuBarFocusReason); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast(arguments.at(0)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast(arguments.at(0)), topLevelItem2); QCOMPARE(qvariant_cast(arguments.at(1)), nullptr); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::MenuBarFocusReason); @@ -4617,15 +4652,15 @@ void tst_QGraphicsScene::focusItemChangedSignal() topLevelItem1->setFocus(Qt::TabFocusReason); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast(arguments.at(0)), (QGraphicsItem *)topLevelItem1); - QCOMPARE(qvariant_cast(arguments.at(1)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast(arguments.at(0)), topLevelItem1); + QCOMPARE(qvariant_cast(arguments.at(1)), topLevelItem2); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::TabFocusReason); topLevelItem2->setFocus(Qt::TabFocusReason); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast(arguments.at(0)), (QGraphicsItem *)topLevelItem2); - QCOMPARE(qvariant_cast(arguments.at(1)), (QGraphicsItem *)topLevelItem1); + QCOMPARE(qvariant_cast(arguments.at(0)), topLevelItem2); + QCOMPARE(qvariant_cast(arguments.at(1)), topLevelItem1); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::TabFocusReason); } @@ -4633,10 +4668,10 @@ void tst_QGraphicsScene::focusItemChangedSignal() // when the scene activation changes) breaks quite a few tests so leave this fix // for some future release. See QTBUG-28346. QEvent deactivateEvent(QEvent::WindowDeactivate); - qApp->sendEvent(&scene, &deactivateEvent); + QCoreApplication::sendEvent(&scene, &deactivateEvent); QEXPECT_FAIL("", "QTBUG-28346", Continue); QCOMPARE(spy.count(), 1); - qApp->sendEvent(&scene, &activateEvent); + QCoreApplication::sendEvent(&scene, &activateEvent); QEXPECT_FAIL("", "QTBUG-28346", Continue); QCOMPARE(spy.count(), 1); @@ -4647,8 +4682,8 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast(arguments.at(0)), (QGraphicsItem *)panel1); - QCOMPARE(qvariant_cast(arguments.at(1)), (QGraphicsItem *)topLevelItem2); + QCOMPARE(qvariant_cast(arguments.at(0)), panel1); + QCOMPARE(qvariant_cast(arguments.at(1)), topLevelItem2); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::ActiveWindowFocusReason); QGraphicsRectItem *panel2 = new QGraphicsRectItem; @@ -4661,16 +4696,16 @@ void tst_QGraphicsScene::focusItemChangedSignal() QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast(arguments.at(0)), (QGraphicsItem *)panel2); - QCOMPARE(qvariant_cast(arguments.at(1)), (QGraphicsItem *)panel1); + QCOMPARE(qvariant_cast(arguments.at(0)), panel2); + QCOMPARE(qvariant_cast(arguments.at(1)), panel1); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::ActiveWindowFocusReason); scene.setActivePanel(panel1); QCOMPARE(spy.count(), 1); arguments = spy.takeFirst(); QCOMPARE(arguments.size(), 3); - QCOMPARE(qvariant_cast(arguments.at(0)), (QGraphicsItem *)panel1); - QCOMPARE(qvariant_cast(arguments.at(1)), (QGraphicsItem *)panel2); + QCOMPARE(qvariant_cast(arguments.at(0)), panel1); + QCOMPARE(qvariant_cast(arguments.at(1)), panel2); QCOMPARE(qvariant_cast(arguments.at(2)), Qt::ActiveWindowFocusReason); } @@ -4679,14 +4714,15 @@ void tst_QGraphicsScene::focusItemChangedSignal() class ItemCountsPaintCalls : public QGraphicsRectItem { public: - ItemCountsPaintCalls(const QRectF & rect, QGraphicsItem *parent = 0) - : QGraphicsRectItem(rect, parent), repaints(0) {} - void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) + using QGraphicsRectItem::QGraphicsRectItem; + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget = nullptr) override { QGraphicsRectItem::paint(painter, option, widget); ++repaints; } - int repaints; + int repaints = 0; }; void tst_QGraphicsScene::minimumRenderSize() @@ -4700,10 +4736,11 @@ void tst_QGraphicsScene::minimumRenderSize() scene.addItem(bigParent); CustomView view; + view.setWindowTitle(QTest::currentTestFunction()); view.setScene(&scene); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - qApp->processEvents(); + QCoreApplication::processEvents(); // Initially, everything should be repainted the same number of times int viewRepaints = 0; @@ -4716,7 +4753,7 @@ void tst_QGraphicsScene::minimumRenderSize() // Setting a minimum render size should cause a repaint scene.setMinimumRenderSize(0.5); - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; @@ -4727,7 +4764,7 @@ void tst_QGraphicsScene::minimumRenderSize() // Scaling should cause a repaint of big items only. view.scale(0.1, 0.1); - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; @@ -4738,7 +4775,7 @@ void tst_QGraphicsScene::minimumRenderSize() // Scaling further should cause even fewer items to be repainted view.scale(0.1, 0.1); // Stacks with previous scale - qApp->processEvents(); + QCoreApplication::processEvents(); QTRY_VERIFY(view.repaints > viewRepaints); viewRepaints = view.repaints; @@ -4752,6 +4789,7 @@ void tst_QGraphicsScene::focusOnTouch() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); scene.setSceneRect(0, 0, 100, 100); QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100); rect->setFlag(QGraphicsItem::ItemIsFocusable, true); @@ -4839,6 +4877,7 @@ void tst_QGraphicsScene::taskQTBUG_42915_focusNextPrevChild() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); scene.setSceneRect(1, 1, 198, 198); view.setFocus(); -- cgit v1.2.3 From c2aaa9e18ecc62cb399010f063c6938771a92563 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 16 Aug 2019 10:06:56 +0200 Subject: tst_QGraphicsScene: Pass on High DPI screens The test requires High DPI scaling to be disabled since it captures widgets. Turn it off initially and introduce a member variable containing a suitable size depending on the screen to make the test pass on High DPI screens without violating minimum window widths on Windows. Change-Id: Ida9f306cff6abd48ee5de7001c7670a0da60c6c2 Reviewed-by: Oliver Wolff --- .../qgraphicsscene/tst_qgraphicsscene.cpp | 75 ++++++++++++++++------ 1 file changed, 55 insertions(+), 20 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index cc6ed2f80e..950f3ef670 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -182,6 +182,10 @@ protected: class tst_QGraphicsScene : public QObject { Q_OBJECT +public: + tst_QGraphicsScene(); + static void initMain() { QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); } + public slots: void cleanup(); @@ -284,8 +288,19 @@ private slots: void taskQTBUG_15977_renderWithDeviceCoordinateCache(); void taskQTBUG_16401_focusItem(); void taskQTBUG_42915_focusNextPrevChild(); + +private: + QRect m_availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + QSize m_testSize; }; +tst_QGraphicsScene::tst_QGraphicsScene() +{ + const int testSize = qMax(200, m_availableGeometry.width() / 10); + m_testSize.setWidth(testSize); + m_testSize.setHeight(testSize); +} + void tst_QGraphicsScene::cleanup() { // ensure not even skipped tests with custom input context leave it dangling @@ -1085,6 +1100,7 @@ void tst_QGraphicsScene::addItem() CustomView view; view.setWindowTitle(QTest::currentTestFunction()); view.setScene(&scene); + view.resize(m_testSize); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); QCoreApplication::processEvents(); @@ -2597,6 +2613,7 @@ void tst_QGraphicsScene::render() QGraphicsView view; view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); QGraphicsScene scene(&view); scene.addEllipse(QRectF(-10, -10, 20, 20), QPen(Qt::black, 0), QBrush(Qt::white)); scene.addEllipse(QRectF(-2, -7, 4, 4), QPen(Qt::black, 0), QBrush(Qt::yellow))->setZValue(1); @@ -2678,34 +2695,32 @@ void tst_QGraphicsScene::renderItemsWithNegativeWidthOrHeight() #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) || defined(Q_OS_WINRT) QSKIP("Test only works on platforms with resizable windows"); #endif - - QGraphicsScene scene(0, 0, 150, 150); + QGraphicsScene scene(0, 0, m_testSize.width(), m_testSize.height()); // Add item with negative width. - QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, -150, 50); + QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, -m_testSize.width(), 50); item1->setBrush(Qt::red); - item1->setPos(150, 50); + item1->setPos(m_testSize.width(), 50); scene.addItem(item1); // Add item with negative height. - QGraphicsRectItem *item2 = new QGraphicsRectItem(0, 0, 50, -150); + QGraphicsRectItem *item2 = new QGraphicsRectItem(0, 0, 50, -m_testSize.height()); item2->setBrush(Qt::blue); - item2->setPos(50, 150); + item2->setPos(50, m_testSize.height()); scene.addItem(item2); QGraphicsView view(&scene); view.setWindowTitle(QTest::currentTestFunction()); view.setFrameStyle(QFrame::NoFrame); - view.resize(150, 150); view.show(); - QCOMPARE(view.viewport()->size(), QSize(150, 150)); + QTRY_COMPARE(view.viewport()->size(), m_testSize); QImage expected(view.viewport()->size(), QImage::Format_RGB32); view.viewport()->render(&expected); // Make sure the scene background is the same as the viewport background. scene.setBackgroundBrush(view.viewport()->palette().brush(view.viewport()->backgroundRole())); - QImage actual(150, 150, QImage::Format_RGB32); + QImage actual(m_testSize, QImage::Format_RGB32); QPainter painter(&actual); scene.render(&painter); painter.end(); @@ -2730,6 +2745,7 @@ void tst_QGraphicsScene::contextMenuEvent() QGraphicsView view(&scene); view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.show(); view.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -2746,7 +2762,7 @@ void tst_QGraphicsScene::contextMenuEvent() class ContextMenuItem : public QGraphicsRectItem { public: - ContextMenuItem() : QGraphicsRectItem(0, 0, 100, 100) + ContextMenuItem(const QSize &s) : QGraphicsRectItem(0, 0, s.width(), s.height()) { setBrush(Qt::red); } protected: @@ -2760,27 +2776,30 @@ void tst_QGraphicsScene::contextMenuEvent_ItemIgnoresTransformations() QSKIP("Test fails on some Android devices (QTBUG-44430)"); #endif - QGraphicsScene scene(0, 0, 200, 200); - ContextMenuItem *item = new ContextMenuItem; + QGraphicsScene scene(0, 0, m_testSize.width(), m_testSize.height()); + const QSize itemSize = m_testSize / 2; + ContextMenuItem *item = new ContextMenuItem(itemSize); item->setFlag(QGraphicsItem::ItemIgnoresTransformations); scene.addItem(item); QWidget topLevel; topLevel.setWindowTitle(QTest::currentTestFunction()); + topLevel.resize(m_testSize); QGraphicsView view(&scene, &topLevel); - view.resize(200, 200); topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + + { - QPoint pos(50, 50); + QPoint pos(itemSize.width() / 2, itemSize.height() / 2); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } { - QPoint pos(150, 150); + QPoint pos(itemSize.width() * 3 / 2, itemSize.height() * 3 / 2); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); @@ -2788,14 +2807,14 @@ void tst_QGraphicsScene::contextMenuEvent_ItemIgnoresTransformations() } view.scale(1.5, 1.5); { - QPoint pos(25, 25); + QPoint pos(itemSize.width() / 4, itemSize.height() / 4); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } { - QPoint pos(55, 55); + QPoint pos(itemSize.width() / 2 + 5, itemSize.height() / 2 + 5); QContextMenuEvent event(QContextMenuEvent::Keyboard, pos, view.viewport()->mapToGlobal(pos)); event.ignore(); QApplication::sendEvent(view.viewport(), &event); @@ -2844,6 +2863,7 @@ void tst_QGraphicsScene::update2() scene.setSceneRect(-200, -200, 200, 200); CustomView view; view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(&scene); view.show(); QApplication::setActiveWindow(&view); @@ -3514,6 +3534,7 @@ void tst_QGraphicsScene::task160653_selectionChanged() QSignalSpy spy(&scene, &QGraphicsScene::selectionChanged); QGraphicsView view(&scene); view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.show(); QVERIFY(QTest::qWaitForWindowActive(&view)); QTest::mouseClick( @@ -3803,6 +3824,7 @@ void tst_QGraphicsScene::inputMethod() QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(m_testSize); view.show(); view.setWindowTitle(QTest::currentTestFunction()); QApplication::setActiveWindow(&view); @@ -4044,6 +4066,7 @@ void tst_QGraphicsScene::isActive() { QWidget toplevel1; toplevel1.setWindowTitle(QTest::currentTestFunction()); + toplevel1.resize(m_testSize); QHBoxLayout *layout = new QHBoxLayout; toplevel1.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4109,9 +4132,9 @@ void tst_QGraphicsScene::isActive() { - const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QWidget toplevel2; toplevel2.setWindowTitle(QTest::currentTestFunction()); + toplevel2.resize(m_testSize); QHBoxLayout *layout = new QHBoxLayout; toplevel2.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4124,7 +4147,7 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene1.hasFocus()); QVERIFY(!scene2.hasFocus()); - toplevel2.move(availableGeometry.topLeft() + QPoint(50, 50)); + toplevel2.move(m_availableGeometry.topLeft() + QPoint(50, 50)); toplevel2.show(); QApplication::setActiveWindow(&toplevel2); QVERIFY(QTest::qWaitForWindowActive(&toplevel2)); @@ -4173,7 +4196,8 @@ void tst_QGraphicsScene::isActive() QVERIFY(!scene2.hasFocus()); QGraphicsView topLevelView; - topLevelView.move(availableGeometry.topLeft() + QPoint(500, 50)); + topLevelView.move(toplevel2.geometry().topRight() + QPoint(100, 50)); + topLevelView.resize(m_testSize); topLevelView.show(); QApplication::setActiveWindow(&topLevelView); topLevelView.setFocus(); @@ -4219,6 +4243,7 @@ void tst_QGraphicsScene::isActive() { QWidget toplevel3; + toplevel3.resize(m_testSize); QHBoxLayout *layout = new QHBoxLayout; toplevel3.setLayout(layout); QGraphicsView *view1 = new QGraphicsView(&scene1); @@ -4297,6 +4322,7 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid() QGraphicsView view2(&scene2); view2.setWindowTitle(QTest::currentTestFunction()); + view2.resize(m_testSize); // first add the blue rect QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 )); @@ -4341,6 +4367,7 @@ void tst_QGraphicsScene::removeFullyTransparentItem() CustomView view; view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(&scene); view.show(); QApplication::setActiveWindow(&view); @@ -4398,6 +4425,7 @@ void tst_QGraphicsScene::taskQT657_paintIntoCacheWithTransparentParts() QGraphicsScene *scene = new QGraphicsScene(); CustomView view; + view.resize(m_testSize); view.setWindowTitle(QTest::currentTestFunction()); view.setScene(scene); @@ -4442,6 +4470,7 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() QGraphicsScene *scene = new QGraphicsScene(); CustomView view; + view.resize(m_testSize); view.setWindowTitle(QTest::currentTestFunction()); view.setScene(scene); @@ -4483,6 +4512,7 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() QGraphicsScene *scene = new QGraphicsScene(); CustomView view; view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(scene); scene->addItem(rectItem); @@ -4522,6 +4552,7 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts() QGraphicsScene *scene = new QGraphicsScene(); CustomView view; view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(scene); scene->addItem(rectItem); @@ -4737,6 +4768,7 @@ void tst_QGraphicsScene::minimumRenderSize() CustomView view; view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); view.setScene(&scene); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); @@ -4790,6 +4822,7 @@ void tst_QGraphicsScene::focusOnTouch() QGraphicsScene scene; QGraphicsView view(&scene); view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); scene.setSceneRect(0, 0, 100, 100); QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100); rect->setFlag(QGraphicsItem::ItemIsFocusable, true); @@ -4847,6 +4880,7 @@ void tst_QGraphicsScene::taskQTBUG_16401_focusItem() { QGraphicsScene scene; QGraphicsView view(&scene); + view.resize(m_testSize); QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100); rect->setFlag(QGraphicsItem::ItemIsFocusable); @@ -4878,6 +4912,7 @@ void tst_QGraphicsScene::taskQTBUG_42915_focusNextPrevChild() QGraphicsScene scene; QGraphicsView view(&scene); view.setWindowTitle(QTest::currentTestFunction()); + view.resize(m_testSize); scene.setSceneRect(1, 1, 198, 198); view.setFocus(); -- cgit v1.2.3 From 2faa6cafa91b4478d129ec570d1cd8e6ed2f147d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 8 Aug 2019 15:27:11 +0200 Subject: Pass QDate, QTime as value classes, rather than by const reference This can, of course, only be done in private APIs - but comment on public APIs to do the same at Qt 6. Change-Id: I3c79951572be3c37b0b0c5b1b05bced051a40964 Reviewed-by: Volker Hilsheimer Reviewed-by: Paul Wicking --- tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index 810f081b73..26b4b7d020 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -348,8 +348,7 @@ static QLatin1String sectionToName(const QDateTimeEdit::Section section) } } -static QDate stepDate(const QDate& startDate, const QDateTimeEdit::Section section, - const int steps) +static QDate stepDate(QDate startDate, const QDateTimeEdit::Section section, const int steps) { switch (section) { case QDateTimeEdit::DaySection: @@ -364,8 +363,7 @@ static QDate stepDate(const QDate& startDate, const QDateTimeEdit::Section secti } } -static QTime stepTime(const QTime& startTime, const QDateTimeEdit::Section section, - const int steps) +static QTime stepTime(QTime startTime, const QDateTimeEdit::Section section, const int steps) { switch (section) { case QDateTimeEdit::SecondSection: -- cgit v1.2.3