summaryrefslogtreecommitdiffstats
path: root/tests/auto
Commit message (Collapse)AuthorAgeFilesLines
...
* Rename QMetaSequence's "elements" to "values"Ulf Hermann2020-09-112-45/+45
| | | | | | | | | | This is so that they are in line with the "value_type" usually found in containers. Associative containers have "key_type" and "mapped_type" and we will use those names for access to elements in QMetaAssociation. Using "value" as name for sequential containers improves consistency. Change-Id: I628b7e1446bb2d56843b843bca72d279a6b247e6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QNetworkReply: Avoid race in ioGetFromHttpWithAuthMårten Nordheim2020-09-111-1/+5
| | | | | | | | | | | | | | | | | | | | | Our authentication code is race-y by design: 1. When two requests are fired off and queued at the same time in the same QHttpNetworkConnection then if one of them encounters "authentication required" then it will copy whatever credentials it got to all the other channels in the connection. This is likely what the first part of the test is testing. 2. If a later request is fired off and it includes credentials in the url then the newly included credentials should be used instead of the cached ones. The race here can occurr when one socket either takes too long to connect or the connected signal is not received early enough. Then the first socket is used for both requests and then we can hit case #2 when the url contains credentials. Pick-to: 5.15 Change-Id: I646a5378d8c1256b2de98b51912953df29f68cb2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Interbase: Add support for the boolean typeAndy Shaw2020-09-112-4/+9
| | | | | | | | | | | | | This is added to Interbase in v7 and Firebird in v3 which has been available for sometime now. This means the minimum supported for Interbase is now v7. [ChangeLog][QtSQL][Interbase] The minimum required version for Interbase is now v7. Fixes: QTBUG-83401 Change-Id: I9927fd962f25c935be8ed5d2b7c76c00fb88cd8c Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* macos: Rename macos style to macOSRichard Moe Gustavsen2020-09-111-1/+1
| | | | | | | | | This change shouldn't matter much to widgets, since style names there are case insensitive. But for controls style names are case sensitive, and in that case, "macOS" looks more correct. Change-Id: Ia1d442bce465692ff58fecba1cc68ecbb2e52549 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* [QtCore] QDateTime: switch from newRow to addRow in unit testsAndreas Buhr2020-09-111-4/+4
| | | | | | | | | Instead of doing string formating first and then using QTest::newRow, we can do both at the same time using QTest::addRow Change-Id: Ia5c90eb705a806e37b96a1fa174a6557f91bee6d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* [QtCore] Adapt QDateTime unit tests to use QByteArrayAndreas Buhr2020-09-111-8/+8
| | | | | | | | | | | To not have to bother with encodings, a few QStrings are changed to QByteArrays. This way, a few calls to QString::fromLatin1 and to QString::toLocal8Bit can be removed Change-Id: Ia0cf27fc2a86f9842ed0f3ebe47b050bb8a3f4e6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Remove most compiler warnings about missing overridesLars Knoll2020-09-11151-772/+808
| | | | | | | | | | | | Remove around 1000 compiler warnings about missing overrides in our auto tests. This significantly reduce the compiler warning noise in our auto tests, so that one can actually better see the real problems inbetween. Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_QTimer::remainingTime(): get rid of QTest::currentTestFailed()Jarek Kobus2020-09-101-8/+11
| | | | | | | | | | | | | Looks this is redundant in fact and unneeded. The check can never be evaluated to true, since if so, it would mean it had failed in the previous iteration, in which we already handled the exit from the loop. Fixed also some comments. Task-number: QTBUG-83419 Change-Id: I4fe56bfac39cd58b1166967f3ccb80cdff882748 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce QProcess::startCommand(QString, OpenMode)Joerg Bornemann2020-09-101-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The removal of the QProcess::start(QString, OpenMode) leads to more porting work than anticipated. A call like QProcess p; p.start(cmdline); must be transformed in the following cumbersome way: QProcess p; QStringList args = QProcess::splitCommand(cmdline); QString program = args.takeFirst(); p.start(program, args); This patch revives QProcess::start(QString, OpenMode) and renames it to QProcess::startCommand. This is still source-incompatible, but the transformation is much simpler: QProcess p; p.startCommand(cmdline); [ChangeLog][QtCore][QProcess] Added QProcess::startCommand(QString, OpenMode) as replacement for the removed QProcess::start(QString, OpenMode). Change-Id: I5499bbb39a025e115042c43a4cc63affddae585c Reviewed-by: hjk <hjk@qt.io>
* Fix a rather sloppy test case in tst_QSslKeyTimur Pocheptsov2020-09-101-6/+51
| | | | | | | | | | | | It's not guaranteed that all curves we want to use are supported by a specific build of OpenSSL library we have to link with. Filter out files that contain EC, which is not among the curves, reported by QSslConfiguration::supportedEllipticCurves. Fixes: QTBUG-46203 Pick-to: 5.15 Change-Id: I70d7e6fcacb3d81f8c771e4a8d6cca06295e7474 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Remove '\0' space reservation logic in QStringAndrei Golubev2020-09-101-1/+2
| | | | | | | | | Changed QString to use implicit element reserved by QArrayData Task-number: QTBUG-84320 Change-Id: If517500b3f0e71bb8d2989c64815a634aa8dd554 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove obsolete APIs and comments from QAbstractPrintDialogVolker Hilsheimer2020-09-102-55/+58
| | | | | | | | | | | | | Merging QAbstractPrintDialog with QPrintDialog, as proposed in the removed comment, seems to have little value, given that the platform specific implementations rely on the current abstraction. Adjust examples and tests; with the QAbstractPrintDialog test now testing the QPrintDialog::options API, the corresponding test function can be removed from the QPrinter test. Change-Id: Ia8906627898332e8590ea9b27e3d71dfcc6e8d71 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Adapt QDate unit tests to not take into account system localeAndreas Buhr2020-09-101-14/+13
| | | | | | | | | | | | QDate was changed to consistently use the C local in serialization and parsing in git commit 5ba66c5622e9e0da87a5037399b375d7e8cee554. This commit reflects this change in the unit tests. Task-number: QTBUG-80441 Change-Id: Ib21a215ef0e36c9eaa2c161b92c6877a50ae6f06 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Port from devicePixelRatioF() to devicePixelRatio()Morten Johan Sørvig2020-09-105-12/+12
| | | | | | | This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix possible corner cases in qarraydataops.hAndrei Golubev2020-09-101-4/+217
| | | | | | | | | | | | | | | Updated moveNonPod function to behave correctly under exceptions being thrown. This is the version that was implemented at some point but then got changed prior to merge. Added tests for moveInGrowthDirection (which uses moveNonPod in general case) to verify that range movements are correctly done Updated QCommonArrayOps access modifier from private to protected to allow testing of internal stuff by subclassing Task-number: QTBUG-84320 Change-Id: Idb994a72ee601762e32248670cdc7819aaca0088 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make Q*ArrayOps erase aligned with std::vector::eraseAndrei Golubev2020-09-101-11/+7
| | | | | | | | | | | Scoped GrowsBackwards-optimized erase to only be applied when erase starts at the beginning of the element range. In other cases, old "left-shifting" erase is used to align with std::vector::erase invalidation policy Task-number: QTBUG-84320 Change-Id: I2e7f3b96b056bc371119eb2d36cc7c74af52c394 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cleanup QAction::visible propertyAllan Sandfeld Jensen2020-09-101-0/+3
| | | | | | | | Gives it its own changed signal, and simplifies setting from group, while fixing an inconsistency in propagation. Change-Id: I22b243210260a8878144fa4b60204df46f847f37 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Give QEventPoint a d-pointer after allShawn Rutledge2020-09-101-0/+2
| | | | | | | | | | I still have doubts that QEventPoint can't be made small enough that copying would be cheaper than reference-counting and all the indirections in now-noninline accessors, but this gives us the usual freedom to change the data members later on. Change-Id: I792f7fc85ac3a9538589da9d7618b647edf0e70c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix flaky QTimer::remainingTime() testJarek Kobus2020-09-101-18/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before, we used not so accurate QTest::qWait(50) to measure the accuracy of more precise timer's interval. In addition, the checked range for remainingTime (50, 200) was probably wrong, since by definition it couldn't be more than 150, as we started the timer with interval of 200 and waited at least 50. In this fix we have additional "tester" timer to measure remainingTime of "tested" timer. The "tester" is a singleShot timer with interval of 50, and is started together with "tested" timer. Whenever the "tested" timer timeouts, it restarts the "tester" timer - this is done desired number of times (2 by default, like in the original test). The test itself lies now inside tester's lambda. We fix the tested range (at least 1, no more than 150). The minimum value could in theory be greater, but it's enough to test that it's not overdue. Finally, we wait for expected number of test runs. We give it twice as much time as is in theory needed. Task-number: QTBUG-83419 Task-number: QTBUG-58519 Change-Id: I43836d787d804f22bb66515ebb215d040189c4f3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Blacklist tst_qcolumnview::scrollTo on macOSUlf Hermann2020-09-091-0/+3
| | | | | | | | | It flaky fails for both normal and reverse cases. Pick-to: 5.15 Task-number: QTBUG-41341 Change-Id: If6ecd6dc58f131bb67d46a5d508f59b6bb0fd962 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QProcess/Unix: introduce setChildProcessModifier()Thiago Macieira2020-09-082-43/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][Source-Incompatible Changes] QProcess::setupChildProcess() was removed. To execute code in a child process, use QProcess::setChildProcessModifier() [ChangeLog][QtCore][QProcess] Added setChildProcessModifier() function with which one can provide code to be run in the Unix child process between fork() and execve(). With this function, it is no longer necessary to derive from QProcess in order to execute actions in the child process. Another reason is that we can tell whether the std::function carries a valid target much more easily than we can tell whether QProcess was overridden. The setupChildProcess() virtual function does not need to be marked final, since no overrider could ever return an inaccessible private class. This also makes sure the error presented to the user is about the return type, not about attempting to override a final. Clang: error: virtual function 'f' has a different return type ('void') than the function it overrides (which has return type 'QProcess::Use_setChildProcessModifier_Instead') GCC: error: conflicting return type specified for 'virtual void MyProcess::setupChildProcess()' note: overridden function is 'virtual QProcess::Use_setChildProcessModifier_Instead QProcess::setupChildProcess()' ICC: error: return type is neither identical to nor covariant with return type "QProcess::Use_setChildProcessModifier_Instead" of overridden virtual function "QProcess::setupChildProcess" MSVC is not relevant since it doesn't compile to Unix. Change-Id: Ia8b65350cd5d49debca9fffd15f801161363aea7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Fix failures in tst_qdatetime under non-english localesMarcel Krems2020-09-091-2/+2
| | | | | | | | | QDateTime::toString uses the C locale since 5ba66c5622e9e0da87a5037399b375d7e8cee554 So don't expect locale specific day- and month-names. Task-number: QTBUG-80441 Change-Id: I08f53b6b33ed9e7eaaa58df4ca6a966c4ba9ef24 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Create consistent sets of QImage methodsAllan Sandfeld Jensen2020-09-091-7/+7
| | | | | | | Adds consistently named inplace and imperative methods. Change-Id: I8739c1c4585d2ba4aa181bb9a681255d76c120d7 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Refactor testlib touch functions into qtestsupport_gui and _widgetsShawn Rutledge2020-09-082-11/+11
| | | | | | | | | | | | | Because we removed public setters from QTouchEvent and QEventPoint in 4e400369c08db251cd489fec1229398c224d02b4 and now it's proposed to give QEventPoint a d-pointer again, the implementation of QTouchEventSequence needs to start using QMutableEventPoint: being a friend will no longer be enough, because the member variables won't be accessible in the future. But because we have separate test libs for Gui and Widgets, it needs to be further refactored into two classes. Change-Id: I0bfc0978fc4187348ac872e1330d95259d557b69 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Interbase: Correctly read/write arrays to the databaseAndy Shaw2020-09-081-0/+29
| | | | | | | | | | | The fix ensures that it can find the column for the array correctly when reading/writing and also handles the integer typed arrays correctly too. Pick-to: 5.15 Fixes: QTBUG-83409 Change-Id: I92d982bdf0927e6ebc6dce84fec9ad6c44c26c25 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* tst_qmenubar: stop doing math on an enumGiuseppe D'Angelo2020-09-071-1/+1
| | | | | | | Cast to the right datatypes. Change-Id: Ia1ba9be1b0530263e810b50408f432dca485744c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qshortcut (x2): use op | instead of op + to combine keysGiuseppe D'Angelo2020-09-072-54/+54
| | | | | | | | | | | | | | Following the introduction of QKeyCombination, reduce the number of warnings raised by the test. Drive-by, remove some pointless math like Qt::SHIFT+0, which does not make any sense and would actually fail to compile (shortly). Refactoring the test to fully use QKeyCombination (instead of ints) is left as a future exercise; some QKeyCombination->int warnings are still around. Change-Id: If825bc4c369986623447927bb11493c4f58b544f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deliver Quit event when calling QCoreApplication::quit()Tor Arne Vestbø2020-09-073-1/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of QCoreApplication::quit() directly calling exit(0), which would leave QGuiApplication and client code out of the loop, we now send the Quit event, and let it pass through event delivery, before finally ending up in QCoreApplication::event(), where we call exit(0). This has the advantage that QGuiApplication can ensure all windows are closed before quitting, and if any of those windows ignore the close event the quit will be aborted. This aligns the behavior of synthetic quits via QCoreApplication::quit() with spontaneous quits from the platform via QGuiApplicationPrivate::processApplicationTermination. Clients who wish to exit the application without any event delivery or potential user interaction can call the lower level exit() function directly. [ChangeLog][QtGui] Application termination via qApp->quit() will now deliver Quit events to the application, which in turn will result in application windows being closed as part of the application quit, with an option to cancel the application quit by ignoring the close event. Clients who explicitly want to exit the application without any user interaction should call QCoreApplication::exit() explicitly. Task-number: QTBUG-45262 Task-number: QTBUG-33235 Task-number: QTBUG-72013 Task-number: QTBUG-59782 Change-Id: Id4b3907e329b9ecfd936fe9a5f8a70cb66b76bb7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up QTextBoundaryFinder and qunicodetoolsLars Knoll2020-09-071-2/+0
| | | | | | | | | | | Make QTBF ready for Qt6 by using qsizetype in the API and use QStringView where it makes sense. Change the exported API of qunicodetools to use QStringView as well and use char16_t internally. Change-Id: I853537bcabf40546a8e60fdf2ee7d751bc371761 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove deprecated method QQuaternion::conjugateMarcel Krems2020-09-071-7/+4
| | | | | Change-Id: If539e47618357ef329925033842f266447632e6f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QStyleOptionGraphicsItem: remove deprecated member matrix/levelOfDetailChristian Ehrlicher2020-09-061-1/+0
| | | | | | | | QStyleOptionGraphicsItem::matrix and levelOfDetail are deprecated and not used anywhere anymore. Change-Id: Id4b0fa8ac3ac53d771e858ecda5524a5e690342d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Round float->qfloat16 to evenAllan Sandfeld Jensen2020-09-061-2/+68
| | | | | | | | Calibrated to match F16C and ARM-FP16 hardware conversions. Change-Id: I3bdd4d3db3046fee4aeb24e4ce8b9bc9a06e0397 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of hasPendingEvents() and flush()Lars Knoll2020-09-064-12/+0
| | | | | | | They are unused. Change-Id: I77383f2be45551401ed9c2f88285511134cc8b0d Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* tst_qdbuscpp2xml: stop doing math on enumerationsGiuseppe D'Angelo2020-09-051-1/+1
| | | | | | | Cast it to int to do math. Change-Id: Ia553cccb7e160df50e77fba63d66d0ed45c246c2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make test pass on machines with many coresLars Knoll2020-09-051-1/+1
| | | | | | | | | | Just starting 20 threads to test this won't cut it if the machine you're testing on has an ideal thread count of 16 or larger. Change-Id: Icba8f00aa836fec6da41c71b318e9e17bdd47c0e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Change QWidget::enterEvent signature to take a QEnterEventVolker Hilsheimer2020-09-052-4/+4
| | | | | | | | | | | | | | | | | | | This is a source incompatible change for widget implementors. Leaving the old enterEvent as a virtual overload is problematic due to shadowing. Best to make a clean cut, widget reimplementors will get a compile time warning if they mark their override as such, or if they try to call the parent class implementation. Addresses ### Qt 6 comment. [ChangeLog][QtWidgets][QWidget] The virtual enterEvent handler now receives a QEnterEvent, which contains information about mouse position and button states, rather than a plain QEvent. Change-Id: I233f594fd79c0c090983b3db8532913d00132fde Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove deprecated QPrinter and QPagedPaintDevice APIsVolker Hilsheimer2020-09-043-501/+288
| | | | | | | | | | | Adjusting the QPrinter test case - some use cases no longer exist, or are already tested in QPageSize and QPageLayout tests. Adjust examples and manual tests. Change-Id: I01cbc65f3d8031aea2dac86dd942126ba708b111 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix flaky QFutureWatcher::startFinish() testJarek Kobus2020-09-031-11/+22
| | | | | | | | | | | | | | | | | | Since waiting for a spy employs polling, it may happen that while waiting for a startedSpy we had received already a signal for finishedSpy. This explains current flakiness. The fix is to connect to lambdas instead and update the hit count accordingly. Inside lambdas we also ensure the correct order for started / finised signals. After waitForFinished() unblocks we ensure that possible pending asynchronous signals (started / finished) are processed and check the final state. Task-number: QTBUG-83076 Change-Id: I16963ef9c011cb613d7b409d3e3032303a942336 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove timeStep parameter from QAnimationDrive::advanceAnimationVolker Hilsheimer2020-09-031-2/+2
| | | | | | | | | | | | | | Addresses ### Qt 6 comment, and documentation pointing out that the parameter value is ignored. It wasn't ignored in the code, but that's the kind of change we can make now. With this change, QUnifiedTimer::updateAnimationTimers is only called with -1 as the currentTick input parameter, also from Qt Declarative. Make it default, so that leaf modules can be fixed. Once that it done, the parameter can be removed completely. Change-Id: I80c57ff92f3b615b932dd73d711cf6397347efd8 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Extend test blacklisting from Ubuntu 18.04 to 20.04Tor Arne Vestbø2020-09-034-0/+4
| | | | | | Task-number: QTBUG-86187 Change-Id: I3ac3233f7355d1c16bc9bf6e052fdf4bd9ea90de Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Reimplement QSequentialIterable using QMetaSequenceUlf Hermann2020-09-032-33/+50
| | | | | Change-Id: Ie721a5f0caa697c4bf15a81f3762cf79d3c54f5a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Ignore weight in .ui files instead of converting itEskil Abrahamsen Blomfeldt2020-09-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | In 3558704ed5c3d2c6dc6d024dfa454997469ca75f, we added code to support old .ui files which used the old integer scale for font weights by checking for a special attribute which would help separate new and old files. Since then, it has become apparent that the weight element in .ui is not actually used for anything, since it is only emitted when the bold flag is set and always has to match QFont::Bold in these cases. So instead of converting, we simply ignore it now, and respect the bold flag instead. This also reverts the changes to ui4.* in uic, since the scale attribute is no longer needed. Task-number: QTBUG-42248 Change-Id: I1898868b58004099590f4eaf01f24c57bd34d779 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Long live QKeyCombination!Giuseppe D'Angelo2020-09-037-2/+338
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 via P1120 is deprecating arithmetic operations between unrelated enumeration types, and GCC 10 is already complaining. Hence, these operations might become illegal in C++23 or C++26 at the latest. A case of this that affects Qt is in key combinations: a QKeySequence can be constructed by summing / ORing modifiers and a key, for instance: Qt::CTRL + Qt::Key_A Qt::SHIFT | Qt::CTRL | Qt::Key_G (recommended, see below) The problem is that the modifiers and the key belong to different enumerations (and there's 2 enumerations for the modifier, and one for the key). To solve this: add a dedicated class to represent a combination of keys, and operators between those enumerations to build instances of this class. I would've simply defined operator|, but again docs and pre-existing code use operator+ as well, so added both to at least tackle simple cases (modifier + key). Multiple modifiers create a problem: operator+ between them yields int, not the corresponding flags type (because operator+ is not overloaded for this use case): Qt::CTRL + Qt::SHIFT + Qt::Key_A \__________________/ / int / \______________/ int Not only this loses track of the datatypes involved, but it would also then "add" the key (with NO warnings, now its int + enum, so it's not mixing enums!) and yielding int again. I don't want to special-case this; the point of the class is that int is the wrong datatype. Everything works just fine when using operator| instead: Qt::CTRL | Qt::SHIFT | Qt::Key_A \__________________/ / Qt::Modifiers / \______________/ QKeyCombination So I'm defining operator+ so that the simple cases still work, but also deprecating it. Port some code around Qt to the new class. In certain cases, it's a huge win for clarity. In some others, I've just added the necessary casts to make it still compile without warnings, without attempting refactorings. [ChangeLog][QtCore][QKeyCombination] New class to represent a combination of a key and zero or more modifiers, to be used when defining shortcuts or similar. [ChangeLog][Potentially Source-Incompatible Changes] A keyboard modifier (such as Qt::CTRL, Qt::AltModifier, etc.) should be combined with a key (such as Qt::Key_A, Qt::Key_F1, etc.) by using operator|, not operator+. The result is now an object of type QKeyCombination, that stores the key and the modifiers. Change-Id: I657a3a328232f059023fff69c5031ee31cc91dd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* pro2cmake: Fix qmake parser's line continuation handlingJoerg Bornemann2020-09-022-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | The qmake parser of pro2cmake handles completely commented lines to make assignments like this work: SUBDIRS = \ foo \ # bar \ bar However, assignments like SUBDIRS = \ foo \ #bar \ bar were cut off at the commented line. Fix this by allowing leading whitespace for "fully commented lines". Change-Id: Ib5de850a02fd9b9ebb7c056c2f64f9d684334b08 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QByteArray: Disregard space at front during ::reserve(...)Mårten Nordheim2020-09-021-0/+8
| | | | | | | | | | | | Traditionally when calling reserve it's because you expect to append up to X amount of bytes. We should keep that behavior the same. With another patch still in the works current behavior caused an issue with QStringBuilder in QNAM, as mirrored in the testcase attached. Change-Id: I9792a8f158fc9235e3de48ac8b06ac2c10e7f3dc Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live QAIM::multiData!Giuseppe D'Angelo2020-09-021-0/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Views / delegates absolutely *adore* hammering data(). A simple QListView showing a couple of dozens entries can call data() a hundred of times on the first show. Back of the hand calculation, * 2 times per visible item (sizeHint() + paint()), * times 9 roles used by the default delegate, * times 20 visible items = 360 as a bare minimum, assuming the view doesn't redraw twice accidentally. Move the mouse over the view, and that'll cause a full update with certain styles: 360 calls to data() per update. This has an overhead visible in profilers. The model's data() has to re-fetch the index from its data structure and extract the requested field every time. Also, QVariant is used for the data interexchange, meaning anything that won't fit in one is also a memory allocation. This problem will likely be gone in Qt6Variant as that will store sizeof(void*) * 3, meaning QImage/QPixmap and similar polymorphic classes will fit in a QVariant now... So I'm trying to to remove part of that overhead by allowing views to request all the data they need in one go. For now, one index a a time. A view might also store the data returned. The idea is that the same role on different indexes will _very likely_ return variants of the same type. So a model could move-assign the data into the variant, avoiding the memory allocation /deallocation for the variant's private. This patch: 1) Introduces QModelRoleData as a holder for role+data. 2) Introduces QModelRoleDataSpan as a span over QModelRoleData. The idea of a span type is twofold. First and foremost, we are in no position to choose which kind of container a view should use to store the QModelRoleData objects for a multiData() call; a span abstracts any contiguous sequence, leaving the view free to do whatever it wants (statically allocate, use a vector, etc.). It also solves the problem of efficient passing the roles and gathering the returned variants from multiData(). 3) Add multiData(), which populates a span of roles for a given model index. The main advantage here is that a model can fetch all the needed information for a given index just once, then iterate on the span and provide data for each requested role. Cf. this with data(), where every call has to re-fetch the information for the index. A couple of models have been ported to multiData(), as well as QStyledItemDelegate. [ChangeLog][QtCore][QModelRoleData] New class. [ChangeLog][QtCore][QModelRoleDataSpan] New class. [ChangeLog][QtCore][QAbstractItemModel] Added the multiData() function. Change-Id: Icce0d108ad4e156c9fb05c83ce6df5f58f99f118 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QVariant: Fix conversion codeFabian Kosmale2020-09-021-0/+38
| | | | | | Fixes: QTBUG-86330 Change-Id: Ib89dcf1195e0081b4c4e2845f90c52c612e5911a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QTable/TreeView: fix sortByColumn() when view is already sortedChristian Ehrlicher2020-09-022-0/+69
| | | | | | | | | | | | | When the view was already sorted by the column and order given to sortByColumn(), a resort was not triggered which is a regression since d0f909f8dbdd8594b0d950822f0e7ab8728da513. Therefore don't rely on sortIndicatorChanged() in this case and trigger an explicit sort as it's done when no user-triggered sorting is enabled Fixes: QTBUG-86268 Change-Id: I3ec30ab81f304d5a19cef6d67b8a81c21b4a112d Pick-to: 5.15 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix QPropertyAlias to work with all kinds of propertiesLars Knoll2020-09-021-0/+37
| | | | | | | | | | So far QPropertyAlias was limited to working with QProperty<T>. Change the implementation, so it can be constructed from any property or even a QBindable<T>. Change-Id: I175cffe94a9ef332367d39faa976eb065b0e6ffe Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make bindings introspectable through mocLars Knoll2020-09-023-143/+151
| | | | | | | | | | | | | | | Add a new BINDABLE declaration to the Q_PROPERTY() macro that tells moc where to find the QBindable for the property. Add a QUntypedBindable base class to QBindable<T> that gives access to generic functionality and checks argument compatibility at runtime. QBindable<T> will still do static checking at compile time. Add QMetaProperty::isBindable() and QMetaProperty::bindable() to be able to dynamically access the binding functionality. Change-Id: Ic7b08ae2cde83fd43e627d813a886e1de01fa3dc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>