summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels
Commit message (Collapse)AuthorAgeFilesLines
* QModelIndex: use std::less to compare pointersGiuseppe D'Angelo2017-09-011-1/+1
| | | | | | | | Comparing pointers not belonging to the same array requires using std::less. Change-Id: I2725aa0899f6b9fece73dadd9ee5c10242d50ae1 Reviewed-by: David Faure <david.faure@kdab.com>
* Convert features.itemviews to QT_[REQUIRE_]CONFIGStephan Binner2017-07-253-11/+0
| | | | | | | The QT_NO_ITEMVIEWS queries in corelib/ seem to had no effect at all. Change-Id: I494ee2309a96b0cf25de18781fc9a675878a2ee9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* QAbstractItemModel::supportedDragActions: fix regressionDavid Faure2017-05-311-1/+1
| | | | | | | | | | | This method now returns -1 by default, due to commit 6255cb893d which mistakenly replaced -1 with Qt::IgnoreAction (0x0). As a result, dropping is forbidden in a number of applications (I detected this in zanshin). Change-Id: I4922451216e08d5d3fe36f8ba87364a361b691bf Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QItemSelection: fix a quadratic loopMarc Mutz2017-05-221-12/+20
| | | | | | | | | | | | | | | | | | | | QList::erase(it) is a linear operation. Calling it in a loop constitutes quadratic behavior. Fix by using the erase-remove idiom. Write a generic function object QtFunctionObjects::IsNotValid, instead of a lambda, because I am building up a collection of such function objects in my tree, to be submitted any time now™, so this will reduce the churn once that gets merged. Wrap it in the unnamed namespace to avoid ODR violations in case this pattern repeats. Replace an existing erase-remove idiom's isNotValid lambda function with the new function object. Change-Id: I4f0af04e7b201eb168e79beeda332eee3c6f33c3 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/5.9.0' into 5.9Liang Qi2017-05-191-1/+4
|\ | | | | | | Change-Id: Ia8ac1960387c0f78c32f9d0385bb0aa9a8209af1
| * QItemSelectionRange: don't compare pointers with op<Marc Mutz2017-04-301-1/+4
| | | | | | | | | | | | | | | | ... use std::less<> to avoid undefined behavior. Change-Id: Ib6736f86359c4a16fd90ca63b57a8517c6137ead Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | Fix missing handling of columns when merging selection rangesFilippo Cucchetto2017-05-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes two bugs: 1) Two ranges should not be merged if they are of different columns. The old code would have merged (0,0) with (1, 1). Tranforming a selection of just two indexes in a rectangle of four indexes. 2) The QItemSelectionRange appended had wrong column and worked only for indexes of the first column. For example if 'tl' was (0, 1) than br was (0, 1) so the QItemSelectionRange would have be ((0,1), (0, 1-1)) so ((0,1), (0,0)). This QItemSelectionRange is invalid because topLeft columns is greater than bottomRight column. The fix take in consideration the bottomRight column. Task-number: QTBUG-58871 Change-Id: I591ef0bcc63926f24a7b1ced002af9b7737a4b6e Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | QtCore: include mocsThiago Macieira2017-05-052-0/+4
|/ | | | | | | | | | | | | | | | | | | Compilation and link times in CPU seconds with GCC 7, using precompiled headers (not including moc, rcc, uic, etc. steps or headersclean): Before After Debug -O0 198,1 180,3 Debug -Og 240,7 229,2 Release -O3 267,1 249,2 Release LTO 239,4 229,8 QtCore required a little manual adjusting because some files are bootstrapped into moc itself and into qmake. Change-Id: I84e363d735b443cb9beefffd14b8b57c10e7da36 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-131-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/network.pro mkspecs/features/mac/default_post.prf src/corelib/io/qfilesystemengine_win.cpp src/corelib/io/qprocess.cpp src/corelib/io/qprocess.h src/corelib/io/qprocess_p.h src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/corelib/thread/qmutex.cpp src/platformsupport/fontdatabases/windows/windows.pri src/plugins/platforms/eglfs/eglfsdeviceintegration.pro tests/auto/corelib/io/io.pro Change-Id: I8a27e0e141454818bba9c433200a4e84a88d147e
| * Fix documentation typosChristian Gagneraud2017-02-251-1/+1
| | | | | | | | | | | | | | | | | | | | This patch fixes 2 simple typos in QGraphicsItem and QPainter documentation and a copy/paste error between QAbstractItemModel's beginRemoveColumns and beginRemoveRows documentation. Change-Id: I32bdc4dc69154a40fe30a5b8c08d0c3a001853f8 Reviewed-by: Harri Porten <porten@froglogic.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2017-01-253-84/+50
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf mkspecs/common/msvc-desktop.conf mkspecs/common/msvc-version.conf mkspecs/common/winrt_winphone/qmake.conf mkspecs/features/mac/default_post.prf mkspecs/features/mac/sdk.prf mkspecs/features/qt.prf mkspecs/features/uikit/default_post.prf mkspecs/features/winrt/default_pre.prf mkspecs/winphone-arm-msvc2013/qmake.conf mkspecs/winphone-x86-msvc2013/qmake.conf mkspecs/winrt-arm-msvc2013/qmake.conf mkspecs/winrt-x64-msvc2013/qmake.conf mkspecs/winrt-x86-msvc2013/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/gui/kernel/qwindowsysteminterface.cpp src/network/kernel/qhostaddress.cpp src/plugins/platforms/mirclient/qmirclientplugin.cpp src/plugins/platforms/mirclient/qmirclientplugin.h src/widgets/util/qsystemtrayicon.cpp tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp tools/configure/Makefile.mingw tools/configure/Makefile.win32 Done-with: Jake Petroules <jake.petroules@qt.io> Done-with: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Change-Id: I4be3262d3994e11929d3b1ded2c3379783797dbe
| * Merge remote-tracking branch 'origin/5.8.0' into 5.8Liang Qi2017-01-141-0/+18
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/gui/painting/qcoregraphics.mm Change-Id: I4d49535cd75f2cdf0151c1dbff312cce5e159760
| | * Work around MSVC ABI stupidity in exporting inline members of base classThiago Macieira2017-01-031-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this case, the issue was ICC, when compiling QtQml: qv4sequenceobject.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QList<class QItemSelectionRange>::replace(int,class QItemSelectionRange const &)" (__imp_?replace@?$QList@VQItemSelectionRange@@@@QEAAXHAEBVQItemSelectionRange@@@Z) referenced in function "public: static bool __cdecl QV4::QQmlSequence<class QItemSelection>::deleteIndexedProperty(struct QV4::Managed *,unsigned int)" (?deleteIndexedProperty@?$QQmlSequence@VQItemSelection@@@QV4@@SA_NPEAUManaged@2@I@Z) This applies the same fix as qvector.h has had for ages due to QPolygon. Change-Id: I15b62e0f9cec482fbb40fffd1490d791db5056bc Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * | QIPM: Persist model indexes after emitting layoutChange, not beforeStephen Kelly2016-12-211-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Callers can persist a QModelIndex which was not persisted before in a slot connected to the signal, and such a persisted index must be updated in the course of the layoutChange. Store the indexes to persist after emitting the signal. Task-number: QTBUG-32981 Change-Id: Ibee4c0d84817d72603a03fe5b22fdeefeac0695e Reviewed-by: David Faure <david.faure@kdab.com>
| * | QSFPM: Remove data manipulation from move handlersStephen Kelly2016-12-211-55/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to the fix in the parent commit, incorrect updating of the internal data structures during layout changes can lead to dangling pointers being dereferenced later. Moves are treated as layoutChanges by this proxy by forwarding to the appropriate method. However, data is incorrectly cleared prior to that forwarding. Remove that, and let the layoutChange handling take appropriate action. Change-Id: Iee951e37152328a4e6a5fb8e5385c32a2fe4c0bd Reviewed-by: David Faure <david.faure@kdab.com>
| * | QSFPM: Fix handling of source model layout changeStephen Kelly2016-12-211-20/+11
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In sourceLayoutAboutToBeChanged the source model update is ignored if the affected parents are filtered out anyway. The same logic is attempted in the sourceLayoutChanged slot, but there the early-return logic is applied too late - the mapping is cleared before performing the early-return. Because pointers into the mapping are used in the internalPointer of QModelIndexes in this class, persistent indexes used later will segfault when attempting to dereference it. Additionally, if a parent becomes invalid as a result of the layoutChange, it would be filtered out by the condition in the loop, resulting in a different result in the comparison of emptiness of the parents container. Fix that by persisting the parent's container, and performing the test for early-return before clearing the mapping. Task-number: QTBUG-47711 Task-number: QTBUG-32981 Change-Id: If45e8a1c97d39454160f52041bc9ae7e337dce97 Reviewed-by: David Faure <david.faure@kdab.com>
* | QStringListModel: default data()s 'role' argumentMarc Mutz2017-01-191-1/+1
| | | | | | | | | | | | | | | | | | ... the way it's done elsewhere, too. Change-Id: Icbb6802c2244469cda7db7eb9e088cf3b7729c89 Task-number: QTBUG-58160 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Remove qtypetraits.h's contents altogetherGiuseppe D'Angelo2017-01-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So that QFlags can use an (un)signed int matching the underlying type as identified by the compiler and not by us. Requires fixing a few warnings about sign conversion due to QFlags misusages in qtbase that were either plain wrong, or were relying on the enum being backed by an (un)signed int when it wasn't. Keep qtypetraits.h in the source tree in order to prevent source breaks if some downstream #includes it (note however that it did not contain any public API). Change-Id: Ib3a92b98db7031e793a088fb2a3b306eff4d7a3c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QItemSelectionRange: de-inline op<Marc Mutz2016-12-022-26/+28
|/ | | | | | | | | It's a bit large for an inline function. Note for Qt 6 that this function is nonsense. Change-Id: If6af5d3538aac86d55313ba6accdb13f892e6564 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-221-1/+1
|\ | | | | | | | | | | | | Conflicts: src/plugins/platforms/ios/qiosviewcontroller.mm Change-Id: I2dda31867cbc79ea7fe965f52afb518aefa4ad20
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-211-1/+1
| |\ | | | | | | | | | Change-Id: I9cfefaf22b010fca937be77979f5fb50574bb71e
| | * QAbstractProxyModel: fix sentence structure in apidocFrederik Schwarzer2016-09-191-1/+1
| | | | | | | | | | | | | | | Change-Id: Ib3371549ecb80da326260b1df431f20e7a04f07e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | | fix build with various QT_NO_* definesNick Shaforostoff2016-08-261-5/+6
| | | | | | | | | | | | | | | | | | | | | Done-with: Andriy Gerasika <andriy.gerasika@gmail.com> Change-Id: I90883a491dbddb005c3d756c339e42285d50e437 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Deprecate Q(Persistent)ModelIndex::childGiuseppe D'Angelo2016-08-162-7/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to how invalid model indices are handled in Qt, child() is unsuitable for general purpose usage. In particular you can never get a top level item in the model because the root model index by definition hasn't got a pointer to the model it belongs. That makes child() useless for anything but tree models (and even there you'd need to special case your code anyhow). [ChangeLog][QtCore][QModelIndex] QModelIndex::child has been deprecated due to its lack of generality. Use model->index(row, column, index) instead. [ChangeLog][QtCore][QPersistentModelIndex] QPersistentModelIndex::child has been deprecated due to its lack of generality. Use model->index(row, column, index) instead. Change-Id: Ice73c17133aaf71355fa2af1eacfe64da01bd456 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: David Faure <david.faure@kdab.com>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-161-1/+7
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/global/qglobal.cpp src/corelib/tools/qstring.cpp src/network/socket/qabstractsocket.cpp src/network/socket/qnativesocketengine_unix.cpp src/plugins/platforms/eglfs/api/qeglfsglobal.h Change-Id: Id5dfdbd30fa996f9b4b66a0b030b7d3b8c0ef288
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-131-1/+7
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.cpp src/corelib/io/qsettings.cpp src/corelib/itemmodels/qstringlistmodel.cpp tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp Change-Id: I1c6c306ef42c3c0234b19907914b19da706b4a03
| | * QStringListModel: fix dataChanged's roles parameterMarc Mutz2016-08-121-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In QStringListModel, the display and the edit roles are synonyms, so when one is changed, the other changes with it. However, in setData() we only emitted a vector with just the role that was passed in by the user. Fix by always passing both roles, regardless of which one was used to set the data. Change-Id: I498e7cb33796fae266901817b01ad85d861d4bb4 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-092-4/+6
|\| | | | | | | | | | | Change-Id: I36e6b890b65d12bf6931757540bcc9c553b5eb8f
| * | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-052-4/+6
| |\| | | | | | | | | | | | | | | | | | | Conflicts: tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: I6f3878b204464313aa2f9d988d3b35121d4d9867
| | * QStringListModel: begin/endResetModel() are no signalsMarc Mutz2016-08-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | ... so don't use emit on them. Just confuses readers. Change-Id: I24365fc533b5b35f8942d6014dbc68387aa23e22 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
| | * QSortFilterProxyModel: Don't forward the hint from source's layoutChanged signalOlivier Goffart2016-08-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't forward a VerticalSortHint or HorizontalSortHint hint, because we might be filtering extra items. The documentation of QAbstractItemModel::LayoutChangeHint states: Note that VerticalSortHint and HorizontalSortHint carry the meaning that items are being moved within the same parent, not moved to a different parent in the model, and not filtered out or in. And some of the views rely on this assumption (QQmlDelegateModel for example) What happens in the test is the following: - 'model' emit the dataChanged signal when its data is changed. - 'proxi1' QSortFilterProxyModelPrivate::_q_sourceDataChanged does not forward the dataChanged signal imediatly, it will instead first re-sort the model and call layoutAboutToBeChanged / layouChanged with the VerticalSortHint - 'proxy2' would forward the layoutAboutToBeChanged with the hint, but in QSortFilterProxyModelPrivate::_q_sourceLayoutChanged, it will redo the mapping which will cause the changed data to be filtered. So proxy2 can't forward the VerticalSortHint as it removed rows in the process. Change-Id: I20b6983e9d18bf7509fe6144c74f37d24e4a18c2 Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com> Reviewed-by: David Faure <david.faure@kdab.com>
* | | ItemModel: Extract Method isVariantLessThan()Anton Kudryavtsev2016-07-023-34/+41
|/ / | | | | | | | | | | | | | | | | | | | | | | | | As noted in comments, QSortFilterProxyModel and QStandardItemModel duplicate code to compare QVariant; extract this into a separate method they can share. Since there is only one common suitable header for both files, the method was placed in qabstractitemmodel.cpp Change-Id: I82bb4a2d6084059b8a70a8d556c16f1a29f4f686 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-191-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp src/network/access/qnetworkaccessmanager.cpp src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h src/widgets/widgets/qlineedit_p.cpp src/widgets/widgets/qlineedit_p.h src/winmain/winmain.pro tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp tools/configure/configureapp.cpp Change-Id: Ib9997b0d0f91946e4081d36c0c6b696c5c983b2a
| * Doc: Remove references to obsolete reset() functionLeena Miettinen2016-05-121-2/+2
| | | | | | | | | | | | | | | | ...from the docs of the signals it emits. Task-number: QTBUG-53228 Change-Id: Ifdd91404cae9dd6480ae29b31f2a48fa024df442 Reviewed-by: Nico Vertriest <nico.vertriest@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-291-0/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/qml_module.prf mkspecs/features/qt_common.prf src/gui/text/qzip.cpp src/plugins/platforms/cocoa/qnsview.mm src/plugins/platforms/windows/array.h src/testlib/qtestcase.cpp src/widgets/dialogs/qfilesystemmodel.h Change-Id: Ie41c5868415b81f7693c80e045497035504bb210
| * Unhide QObject::parent() from QFileSystemModel and QIdentityProxyModelAlexander Volkov2016-04-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | It was hidden by overridden parent(const QModelIndex &) methods. See also 63b5082ea8e3e750af986f815474f7207006cb46 (Unhide QObject::parent() from QAbstract{Table,List}model). Change-Id: I8b6d4d4175e4d43ff269eaeb0b2b1a9fb8f44bab Task-number: QTBUG-45393 Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QStringListModel: proper construction of vectorAnton Kudryavtsev2016-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | ... with known size and known value by corresponding ctor. Don't use appending for this case. Change-Id: I70f5b943cda7e55eeb45becf439f79c9aee77278 Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | CoreLib: use const (and const APIs) moreAnton Kudryavtsev2016-04-183-10/+10
| | | | | | | | | | | | | | | | | | | | For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QtBase: use erase and std::remove_if with QList and QVectorAnton Kudryavtsev2016-04-081-7/+7
| | | | | | | | | | | | | | ... instead of using removeAt in a loop, with quadratic complexity. Change-Id: I38b49e56b12c396db9fc0f1b75d8fb43c503a7f6 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-071-1/+1
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/network/access/qftp.cpp src/widgets/itemviews/qheaderview.cpp src/widgets/itemviews/qlistview.cpp tests/auto/network/access/qftp/tst_qftp.cpp Change-Id: I9f928f25d45d8944dd60bb583f649fc1615bc5d9
| * Fix UB (shift of negative number) in qHash(QModelIndex)Marc Mutz2016-04-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by UBSan: itemmodels/qabstractitemmodel.h:426:28: runtime error: left shift of negative value -1 Fix by casting the lhs of the left-shift operator to uint before shifting. Since Qt assumes two's complement repre- sentation of signed integers, this should yield the same result as the old code, but without UBs. It is critically important that the result is identical to the old code (modulo the compiler exploiting the UB, which this patch aims to prevent even in future compilers), because the function is inline, and changing the hash value would mean changing the layout of a QHash<QModelIndex,.> between users compiled against the old and new libraries. Change-Id: I7b826a34fb78b02021e40c3f85fd11af398dbec4 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QItemSelectionModel: refactoring of internal functionsAnton Kudryavtsev2016-03-111-16/+12
| | | | | | | | | | | | | | | | | | | | | | | | Introduce template helper function qSelectionIndexes(). Template argument is container. Now we have the same code for QVector and QList. Also it's needed for a follow-up change in this file: add method QModelIndex QItemSelection::index(). Change-Id: I7f86a9b96e5feac9873cf0df7a1cbca74f9191ec Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QtCore: use printf-style qWarning/qDebug where possible (I)Marc Mutz2016-03-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this first part, replace qWarning() << "" with qWarning("..."). Saves ~750b in text size on optimized GCC 5.3 AMD64 builds. Change-Id: I8bf3e46cd5a6b2cae0ceb3e355a50f61925c63d3 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
* | ItemModels: replace QLatin1String with QStringLiteralAnton Kudryavtsev2016-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | ... wherever it allocates memory. Since the string literal is used in more than one function, to avoid duplication of .rodata, wrap the QStringLiteral in an inline function. Change-Id: If4fca7443b3150b1c8360c850da32f5c567c1065 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QStringListModel: optimize container usage.Anton Kudryavtsev2016-02-121-4/+4
| | | | | | | | | | | | | | | | - don't call QList::removeAt() in loop. Just call erase() with two iterators. - don't re-evaluate QList::count() because of result is already cached. Change-Id: I4b3596df4a388f1d39b523c27decad612044cec6 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-02-111-1/+3
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qfilesystemwatcher_win.cpp src/corelib/plugin/plugin.pri src/plugins/platforms/cocoa/qcocoaaccessibility.mm tests/auto/corelib/tools/qlocale/tst_qlocale.cpp Change-Id: Id6824631252609a75eff8b68792e4d10095c8fc1
| * Reduce allocations by using reserve()Sérgio Martins2016-02-071-1/+3
| | | | | | | | | | Change-Id: If34fa53402985f6b3c5e7217bce4a1177af835b6 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QtCore: replace uses of inefficient QList<QPair>s with QVectors [itemmodels]Marc Mutz2016-01-152-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | These QPairs are larger than a void*, so holding them in QLists is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by holding them in QVector instead. Change-Id: Ie8d8eff3448ada7aef5dfba7fc701a59821f5b54 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Updated license headersJani Heikkinen2016-01-1515-208/+298
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | QtCore: eradicate all Q_FOREACH loops [itemmodels]Marc Mutz2016-01-045-9/+10
| | | | | | | | | | | | | | | | Saves more than 4KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: Ice3fe915622a399d1ed10e0ce364cf54b4b835fe Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>