summaryrefslogtreecommitdiffstats
path: root/src/gui/util/qgridlayoutengine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Layouts: Compile fix #ifdeffed out debug codeJan Arve Sæther2024-04-251-2/+2
| | | | | Change-Id: I1e7ffe1b27688e6d2258af4dcea1b32f02f73923 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* QGridLayoutEngine: print stringified layout item in warningsMitch Curtis2024-04-081-2/+5
| | | | | | | | | | | This provides a way for the user to identify any items involved in warnings we may print, as e.g. their objectName will be included. Qt Quick's Layout types can use this to stringify the QQuickItem, which will result in the type and objectName being printed. Change-Id: I3d6b6ea0315df98629992afd29e4bf2aad847e22 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Do not assert when preferred{Width|Height} is infinityJan Arve Sæther2023-12-201-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | There's two alternative strategies for fixing this: 1. When fetching the preferred sizes from an item, the number is bounded to a smaller (but still very large) value - not subject to overflow. In practice this will result in the correct layout, but the consequence is a small inconsistency: The preferred size of the layout will be less than infinite despite that one of its items have a preferred size of infinite. 2. Do not bound the fetched preferred sizes from items, but instead let the rest of the code handle infinity. This will result in the correct layout, and also a correct preferred size of the layout. This patch uses the second strategy, by applying a bound when needed. Autotest will be submitted to qtdeclarative, since QGraphicsLayouts are not affected by this. Pick-to: 6.7 6.6 6.5 6.2 Task-number: QTBUG-116577 Change-Id: I49f79d288370bd93831ac9eda623ce4bbf587796 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
* Add uniformCellWidths and uniformCellHeights to QGridLayoutEngineMatthias Rauter2023-05-311-0/+51
| | | | | | | | | | | | | | Some users wish to make layouts with uniform column widths or uniform row heights, ignoring the sizeHints of individual items. This patch enables this mode in the QGridLayoutEngine, used by the QuickLayout. The sizeHints are aggregated and their average preferred size and extreme minimum and maximum sizes are respected in the layout. Change-Id: Ibb9409eb0a11a1ce8bb305f44a4cb0071c871ec9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtGui: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-281-2/+4
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-3/+3
| | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Another round of 0->nullptr cleanupAllan Sandfeld Jensen2020-07-311-2/+2
| | | | | Change-Id: Ic8db7dc252f8fea46eb5a4f334726d6c7f4645a6 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Use QList instead of QVector in gui implementationJarek Kobus2020-07-071-8/+8
| | | | | | | Task-number: QTBUG-84469 Change-Id: I366e845249203d80d640355a7780ac2f91a762f1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QGridLayoutEngine: port to QHVContainerMarc Mutz2020-05-051-74/+69
| | | | | | Change-Id: Iadb069ecdf67d72fa1b3be9198e90eeda8e98d54 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Long live QHVContainer!Marc Mutz2020-05-051-22/+19
| | | | | | | | | | | | | | | | | | Various places in Qt use arrays indexed by some function of Qt::Orientation input. None document their dependence on the numerical values of the Qt::Orientation enum, some waste space, none is type-safe. QHVContainer is a private container of two values, one for Qt::Horizontal and one for Qt::Vertical. Its salient API is the indexing operator, taking Qt::Orientation, thus making the class type-safe. Use it to port QGridLayoutItem and QAbstractScrollAreaPrivate. Change-Id: I0d9f17431a5eb141bfb0763c83155710bb82a537 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Introduce QGraphicsLayoutItem::isEmpty()Jan Arve Sæther2020-02-251-1/+1
| | | | | | | | | | | | | This change does basically two things: * Renames QGraphicsGridLayoutEngineItem::isIgnored() to QGraphicsGridLayoutEngineItem::isEmpty() to be consistent with QLayoutItem::isEmpty() * Creates a new public API function QGraphicsLayoutItem::isEmpty() so that there is a public method of overriding the behavior. Change-Id: I771a8fb429f9764a75e220f0ff9d07f578f981d3 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-091-13/+13
|\ | | | | | | Change-Id: Ia24cc8b86def0d9d9c17d6775cc519e491b860b1
| * Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-13/+13
| | | | | | | | | | | | | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-11-251-1/+1
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qhash.h src/gui/kernel/qevent.h src/widgets/kernel/qshortcut.cpp src/widgets/kernel/qshortcut.h Change-Id: If61c206ee43ad1d97f5b07f58ac93c4583ce5620
| * Deprecate constructing QFlags from a pointerAllan Sandfeld Jensen2019-11-201-1/+1
| | | | | | | | | | | | | | | | | | This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Don't try to insert items out of boundsLars Knoll2019-10-301-1/+1
|/ | | | | | | | | | | | | The q_items list is only used to hold a full list of all items in the layout. They are kept in order for a linear layout, so that users see them in the right order, but there's no real guarantee for that anyway if combined with spacers and other non-items. Continue to try keeping the order, but ensure indices that are out of bounds are treated as appends to the list. Change-Id: I22721c1fa8b329c5d16ad00c5cb780e099693cda Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Prevent changing the width for layout item's rectMika Salmela2017-10-061-2/+4
| | | | | | | | | | For gridlayout items the x position is rounded, but the QRectF changes the width to keep the right edge. The width is yet calculated exactly for the text so we need to preserve it. Task-number: QTBUG-61244 Change-Id: I823ba742c9ab299740232b5d9b4ad5713e1782c4 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Gui: use const (and const APIs) moreAnton Kudryavtsev2016-06-011-9/+10
| | | | | | | For CoW types, prefer const methods to avoid needless detach()ing. Change-Id: I88d08d499e1be72c1f6d983fecdcee513df18aa2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Adjust sizes when snapping layout items to pixel gridJan Arve Sæther2016-03-021-12/+31
| | | | | | | | | When "importing" the size hints into the cells, make sure that the cells minimum sizes are ceiled up to the closest integer. Change-Id: Id00177468e8b1e12bc1231c7351b2136f94f7300 Task-number: QTBUG-41216 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | 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>
* Fix undefined symbols in grid layout engine with -no-widgets optionJoni Poikelin2015-03-161-4/+0
| | | | | | Task-number: QTBUG-44980 Change-Id: I2bf7a3f8814e10daafb703ed365caac1e13d3704 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Use C++ <cmath> instead of <math.h>Allan Sandfeld Jensen2015-02-161-2/+2
| | | | | | | | | | | | | | Including math.h can pollute the default namespace, and break some compilers if cmath versions of the method are declared as using. Switching to C++ math functions also greatly simplifies handling of float qreal as C++ automatically chooses the right method. [ChangeLog][QtCore][QtMath] qmath.h no longer includes math.h, so any sources depending on that indirect inclusion may fail to build. Change-Id: I4d0e331dafba354ec05dc5052e61ef4ff8d387fe Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Add support for snapping to pixel gridJan Arve Saether2015-02-091-18/+41
| | | | | | | | | | | | | | | | | | | | | This enables us to do more intelligent distribution than simply doing the rounding on each individual items geometry (which often leads to larger spacings than specified). Instead of doing the rounding on the output geometries, we now do the snapping inside the layout engine. This allows us to do more intelligent distribution of items, and spacings should always be respected. There are some cases where items with fractional size hints might overlap with less than a pixel. This was also the case before this patch. Those cases are impossible to fix properly, since fractional size hints conflicts with the snapping in some cases. (Fractional size hints is normal for Text items.) Task-number: QTBUG-41216 Change-Id: I01a8bc3529f0b8b028d6eb0a530c751b67ac6f4e Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
* Remove unnecessary math.h and limits.h includesAllan Sandfeld Jensen2015-02-041-2/+0
| | | | | Change-Id: I28c898f869ed3f03b08ff55f2972a38667c755ad Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Fixed a bug where spans did not always work in layouts.Jan Arve Saether2014-12-091-1/+1
| | | | | | | | | | | | | | | | The problem was that the span we stored in the multiCellMap was the "effective" span (i.e. the given span subtracted with the number of ignored rows it would span). Later we used that span to distribute its size across all its cells. However, since the span now could be smaller that the given span, we could sometimes fail to distribute to the last span(s). [ChangeLog][QtWidgets][layouts] Fixed a bug where spans sometimes didn't distribute themselves to the last cells they covered. Change-Id: I31db3d850484dc8b70d62c5f02f680740578c661 Task-number: QTBUG-43099 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
* Don't rely on hasChanged() in ensureGeometriesJan Arve Saether2014-12-011-1/+1
| | | | | | | | | | | | It can be removed now because we now have a better caching mechanism than before. It should therefore not be needed anymore. Since nothing else calls hasChanged, we can finally get rid of it. This simplifies the code and enables us to further improvements to the code. Change-Id: I51afe5a97311e3e361ae8b491ecbcd21bbedacd1 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
* Adjust the layout if a QGraphicsWidget is explicitly hiddenJan Arve Saether2014-10-231-1/+1
| | | | | | | | | Since layout items can now be hidden, this also makes sure we respect the QSizePolicy::retainSizeWhenHidden Task-number: QTBUG-20132 Change-Id: Iab59fc9b61d4ca1bb2208c479a027da6eb0283a9 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Also cache totalBoxes if we have HFW/WFHJan Arve Saether2014-03-021-11/+15
| | | | | Change-Id: Iea71c11b88df84b9c0949b1020a6bcc5395d62de Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
* Don't ignore horizontal alignment for items with baseline alignmentsJan Arve Saether2014-02-141-43/+43
| | | | | | | | | Horizontal alignment were ignored when an item had baseline alignment specified. Change-Id: I2df526dc830952cdc26e1973d4787e9457c94edd Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Support negative layout spacings (do not assert)Jan Arve Saether2014-01-221-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | This tests * default spacing * explicit positive spacing * negative spacings Negative spacings that causes the layout to shrink down to 0 or a negative spacing are not supported. (But make sure they don't crash the whole engine) This is a partial cherry picked from qtquickcontrols.git/bc973dcf2163b25f2db74d974b252384bbee8d80) Only the Q_ASSERT had to be cherry-picked. This is because of that the qgridlayoutengine* is moved to qtbase. Therefore, any changes to qgridlayoutengine* won't be merged properly to dev (they will be lost). Task-number: QTBUG-35741 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Change-Id: I834f1efc11aca59a93c8d870f1a776f2f8810485 Reviewed-by: Caroline Chao <caroline.chao@digia.com>
* Improve caching in ensureColumnAndRowData()Jan Arve Saether2014-01-181-1/+13
| | | | | Change-Id: I02d9f818f8e1d6fcb8c25d1b73c08171cfc1f74d Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
* Improve code in sizeHint()Jan Arve Saether2014-01-171-30/+9
| | | | | | | | The plan is to do better caching in ensureColumnAndRowData(), and this patch will benefit for any such changes later Change-Id: Id1662e3fe7f70079e29ddb6e3d64e6e580ad9e0f Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
* constify some functions to improve readabilityJan Arve Saether2014-01-151-2/+2
| | | | | Change-Id: I4a5e68367f281f743a631272f57a848dc2833d12 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
* Add baseline support to QGridLayoutEngineJan Arve Saether2013-12-201-6/+10
| | | | | | | (Picked from QGridLayoutEngine in qtquickcontrols) Change-Id: Ifc912c3c90127edfeae2f874e0a061227371d01f Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
* Move QGridLayoutEngine to QtGui moduleJan Arve Saether2013-12-091-0/+1641
For MacOS 10.6 the exported symbols must be the same regardless of debug/release configuration, because for debug builds it will by default link to a release library. We therefore cannot let some exported symbols depend on if QT_DEBUG is defined or not. We therefore introduce QGRIDLAYOUTENGINE_DEBUG, which is independent of debug/release configuration. The whole dump() function concept should probably be revisited, but I don't want to clutter this commit too much with such unrelated things. Change-Id: I7086f31e2c36fe22ce9c9a3eda37ea25302459a9 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>