summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qheaderview.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "QHeaderView: relayout on resetDefaultSectionSize"Jonas Karlsson2024-02-261-11/+12
| | | | | | | | | | | | This reverts commit a8df174369cecd90f14dac85bf162353b7cb25d1. Reason for revert: Caused QTBUG-122109 Pick-to: 6.5 6.6 6.7 Fixes: QTBUG-122109 Fixes: QTBUG-120699 Change-Id: Iea185c00f35e17d8eb8e8da70dc2d808ea274b04 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QHeaderView: make sectionsMovable/sectionsClickable propertiesChristian Ehrlicher2024-02-091-26/+16
| | | | | | | | | When those two attributes were added in Qt5 they were not marked as property for unknown reason. Therefore propagate them now. Fixes: QTBUG-1639 Change-Id: If9f0def2eb680c9c9e8a04b101768d87885d542b Reviewed-by: David Faure <david.faure@kdab.com>
* QHeaderView: fix calculating dragPositionChristian Ehrlicher2023-12-161-1/+1
| | | | | | | | | | | | The dragPosition was calculated without taking the scroll offset into account as it's done within QAIV. Amends 787b4c1506aba7e83d861e178329a18c6ec34322 Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-120055 Task-number: QTBUG-113573 Change-Id: I0e20065f797a1a3f7df07583fccfa029b636fead Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QHeaderView: rename private 'offset' to avoid clash with QAIVP::offset()Christian Ehrlicher2023-12-161-12/+12
| | | | | | | | | QAIVP has a function named 'offset()' which is hidden by QHVP::offset variable. Therefore rename the QHVP::offset to headerOffset Pick-to: 6.7 6.6 6.5 Change-Id: Iadb18b8f18197925daa72af243483a044c1d94e7 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QHeaderView: relayout on resetDefaultSectionSizeJonas Karlsson2023-11-081-12/+11
| | | | | | | | | | | We now call setDefaultSectionSize with the new default section size. This clamps the value to min/max section size and it will resize affected sections. Pick-to: 6.5 6.6 Fixes: QTBUG-116013 Change-Id: I39849aca8d0672629ce0b3ca244038c27e045d4b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QHeaderView: Fix columsMoved/rowsMoved connection to item modelAxel Spoerl2023-10-021-1/+1
| | | | | | | | | | Amends f8fc93fdef5f65d9ee359abf84f37ecc43ab3c1a and corrects wiring to wrong slot. Found-by: Marten Nordheim <marten.nordheim@qt.io> Task-number: QTBUG-117698 Change-Id: I9833f7abc190e2f89b534ad5761db83ba5b895a3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHeaderView: rename private functions (remove _q_ prefix)Christian Ehrlicher2023-10-011-16/+20
| | | | | | | | | Cleanup the private function names after the change to pmf-style connections. Task-number: QTBUG-117698 Change-Id: I9a5e178af997bfcfef78f7a3b9b84da6d653186d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Widgets/Itemviews: use pmf-style connect in QHeaderViewChristian Ehrlicher2023-10-011-60/+29
| | | | | | | | | | Replace all connect() calls with pmf-style connection syntax. This also means that we have to properly disconnect everything in the ctor to not trigger an assertion in QtPrivate::assertObjectType(). Task-number: QTBUG-117698 Change-Id: Ia0745dc10a917f3af4b448b3156d66bdb5d6ce64 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* QHeaderView: Don't add new sections on no-opAxel Spoerl2023-06-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | When a table view adds its first row, QHeaderView::initializeSections() is called. It initializes the vertical header view with the number of added sections. Subsequently QHeaderView::sectionsInserted() is called with the same amount of newly added rows/sections. That leads to the initial amount of sections being 2x the number of rows added in the first go. In other words, the table view will display at least one row more than the underlying table model has. This patch adds an OR condition to the early return check at the beginning of QHeaderView::sectionsInserted(). The method returns early if the number of sections equals the number of respective sections (rows in this case) in the model. An autotest is added in tst_QTableView::rowsInVerticalHeader(). Fixes: QTBUG-114225 Pick-to: 6.6 6.5 Change-Id: I895444f025591981965562e54e2335391db52357 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QHeaderView: use correct mouse position for auto scrollAxel Spoerl2023-06-141-6/+4
| | | | | | | | | | | | | | | | | QHeaderView::mouseMoveEvent started autoscroll without propagating the event's mouse position to QAbstractItemViewPrivate::draggedPosition. This data member always containing QPoint() has lead to right drags not causing an autoscroll at all. Left drags with a scroll offset just kept scrolling until the offset was 0. The missing propagation has been added. As a drive by, dead code has been removed and the local variable pos has been constified. Fixes: QTBUG-113573 Pick-to: 6.6 6.5 Change-Id: I7b194dfc71abea6f2bbaaae18270c80eb15afb4d Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* Remove flattreeview exampleVolker Hilsheimer2023-06-121-0/+5
| | | | | | | | The relevant bits are a two-line snippet. Pick-to: 6.6 6.5 Change-Id: Id1731e5bc6585b1d1fd684817b39d19ad0a8a9cc Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Make QHeaderView restore state from different stream versionsAxel Spoerl2022-08-241-14/+28
| | | | | | | | | | | | | | | | | | | If restoring a QHeaderView state from a data stream with version Qt_5_0, check alignment and resize mode properites for out-of-bound values. If out of bounds, try QDataStream version Qt_6_0, which is used by KDE apps compiled with 5.15.2 or 6.2.3. QFileDialog stores settings in the same settings file across different Qt versions, using different QDataStream versions. That makes QFileDialog vulnerable to the issue (QTBUG-104962). A respective auto test is added with this patch. Fixes: QTBUG-104962 Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-104425 Change-Id: I666207fca7ab837ad27a247e504a40757ee8afab Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: restore Qt 5 compatibility for save/restore stateGiuseppe D'Angelo2022-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Several classes in QWidget use QDataStream internally in order to save and restore state. These QDataStream usages were not versioned, meaning that if Qt changes the serialization for some datatype, then the data saved between different Qt versions becomes incompatible. Note that the save/restore API in question just produce opaque blobs as QByteArrays -- the user has no control over the QDataStream objects and thus versions. Fix by version the usages. In QHeaderView this has caused a regression because QBitArray *did* change version between Qt 5 and 6. In general, using QDataStream without explicit versioning is a mistake, so deploy the same fix elsewhere as well. Fixes: QTBUG-99487 Pick-to: 5.15 6.2 6.3 Change-Id: I82bb5c266f4e5dedc0887cbef855dccab1015e29 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: <doctor.whom@gmail.com>
* 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>
* Itemviews: start fixing mixups of int/enum for Qt's item rolesGiuseppe D'Angelo2022-03-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | A model is supposed to return a Qt::CheckState for a CheckStateRole, and a Qt::Alignment for a Qt::TextAlignmentRole. This is what the documentation says (and what makes sense), but unfortunately Qt's default delegate expected a plain `int` instead. This sometimes worked (via QVariant conversions, e.g. when using a plain enum) and sometimes didn't (e.g. when using a flag type). This is confusing for end-users (and type unsafe, killing the whole point of using enums and flags in the first place). Adding some automatic flags<->int conversions through QVariant is frowned upon, so I don't want to go there. Instead, add some private convenience functions that extract either the right type from a variant, or try to extract an `int` and convert it to the expected type. Use these from within itemviews code. Change-Id: I44bee98c4a26a1ef6c3b2fa1b8de2edfee7aef32 Pick-to: 6.2 6.3 Fixes: QTBUG-75172 Task-number: QTBUG-74639 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Unbreak binary compatibility in QStyleOptionHeaderVolker Hilsheimer2021-02-191-4/+7
| | | | | | | | | | | | | | | | | 4d943846128118e1b9932a17ce6f977a0f4127a5 introduced a new data member to QStyleOptionHeader, and reduced the size of the orientation member. This changed the binary layout of class instances, and breaks ABI. 180c662b0790c6eceffdcb4661681d7df1541a2d added another member within the new bitfield. Introduce a new QStyleOptionHeaderV2 class instead with the new members, and use that in QHeaderView, and the styles using the new members. Fixes: QTBUG-91224 Pick-to: 6.1 Change-Id: I47e6841e6652e4b67f247b7b4514e90be5609156 Reviewed-by: David Faure <david.faure@kdab.com>
* QHeaderView: pass sectionSize to createSectionItems()Christian Ehrlicher2021-02-121-7/+4
| | | | | | | | | | | | .. instead complete size for the affected range. The complete size was calculated before for every call of createSectionItems() and then the function calculated the size per section back for no reason. Passing the sum of all sections is therefore not needed and may lead to an integer overflow for big datasets. Task-number: QTBUG-88728 Change-Id: I8af0b0c3e97021ff0637fe1ee3ca3adfa23a2d0e Reviewed-by: David Faure <david.faure@kdab.com>
* QHeaderView: Mark the drop section during section moveChristian Ehrlicher2021-01-291-1/+27
| | | | | | | | | | | Currently there is no visual feedback where the section move will end up. Therefore mark the drop section to show where the dragged section will be inserted. Fixes: QTBUG-673 Fixes: QTBUG-1114 Change-Id: I3e45a9a9c0604342bb0286fc7cd4c89c757c28cd Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QHeaderView: fix moving sections with mouse in RTL modeChristian Ehrlicher2021-01-171-3/+4
| | | | | | | | | | | Moving sections in RTL mode did not work correctly - in contrast to LTR mode the secion must be moved much further to the left or right to actually move it. Found while implementing an indicator for QTBUG-673 Task-number: QTBUG-673 Change-Id: I5a82d3cdb39415a408b2884d0ee302e0547e884f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QHeaderView: respect the font role while calculating the elided textChristian Ehrlicher2020-12-101-10/+0
| | | | | | | | | | | | | Amends 4d943846128118e1b9932a17ce6f977a0f4127a5: - The macOS style must now elide the text by it's own since it is no longer done by QHeaderView - Add documentation of QStyleOptionHeader::textElideMode - Remove unused variables from QHeaderView::initStyleOptionForIndex() Task-number: QTBUG-86426 Change-Id: I98fc6771c0cd56d6002390125ffbab1269f6dd39 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QHeaderView: respect the font role while calculating the elided textChristian Ehrlicher2020-12-081-4/+5
| | | | | | | | | | | | | | | | | The font role in the header view was not taken into account when the text for an item should be elided. This leads to a wrongly elided text esp. visible when the font size is different to the font of QHeaderView. Fix it by passing the elide mode to the style since only the style knows the used font (e.g. bold or not bold) and available rect. This is now in sync with CE_ItemViewItem where the eliding is also done by the style and not by the item view. [ChangeLog][QtWidgets][QHeaderView] QStyleOptionHeader got a new member textElideMode. Fixes: QTBUG-86426 Change-Id: If6914fe5aaa5d285e6da55d2129f9249d90da3d7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QHeaderView: fix spurious sortingGiuseppe D'Angelo2020-12-011-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QHeaderView sorting may be triggered when the user performs some mouse interactions that should really not result in sorting. Generally speaking, this happens when the user: * presses on a non-movable section (A) * moves on another section (B) * releases on that section resulting in B becoming sorted / flipping sorting. (Non-movable is required, otherwise dragging would cause section moving, not sorting.) To make the matter worse, QHeaderView doesn't check that the release happens within its geometry. This makes sense when moving sections: one is able to drag a section horizontally/vertically even if the mouse leaves the QHeaderView. But when not moving sections, this means that one can * press on section (A), * move the mouse anywhere vertically (for a horizontal bar, mut.mut for a vertical) above or below another section (B), that is, outside QHeaderView's geometry * release the mouse and cause B to be sorted. Fix it by 1) remembering which one was the section that the user originally clicked on; that's the only one that can possibly become sorted (if we're not moving and other conditions hold). No other variable seemed to remember this. 2) on release, check that it happens within that section's geometry. If so, sort. Pick-to: 6.0 5.15 Change-Id: Icfb67662221efbde019711f933781ee1e7d9ac43 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QHeaderView: allow un-sorting of modelsGiuseppe D'Angelo2020-11-301-6/+73
| | | | | | | | | | | | | | | | | | | | | | If one clicks on a QHeaderView's section, the header view will sort the view by the respective column/row. By clicking multiple times, one is able to toggle the sorting between ascending and descending. Something that is NOT possible to do however is to un-sort the view -- that is, to restore the model's original sorting. This must be done via code, by asking the header or the view to sort by section -1. This commit adds new property to QHeaderView to make it possible to unsort models. Basically, the sort indicator becomes a tri-state: sort ascending, sort descending, unsort (sort by column -1). [ChangeLog][QtWidgets][QHeaderView] Added the sortIndicatorClearable property. Setting this property allows the user to clear the sort indicator on a section, resetting the model to its default ordering. Change-Id: Ibf4e280b2086b75ccd64d619ea4d70816dc3529f Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* Port from devicePixelRatioF() to devicePixelRatio()Morten Johan Sørvig2020-09-101-1/+1
| | | | | | | This ports all of QtBase. Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Deprecate int based convert/canConvertLars Knoll2020-08-241-1/+1
| | | | | | | Better to provide the correct meta type to convert to. Change-Id: I8e0d46e4ba482186201c157e302c03874bd38e7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix a number of qdoc warningsFriedemann Kleint2020-08-201-1/+1
| | | | | | | | | | | - Remove obsolete functions and enumeration values - Remove QObject * parameter from QMetaProperty accessors - Fix renamed enumerations in QSsl - Fix list items to be \li - Fix function signatures and variable names Change-Id: I37c7e6bf2c8ff92bc7b82620bae0a27796f866ab Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QHeaderView: create virutal initStyleOptionForIndex functionThorbjørn Lund Martsum2020-08-131-19/+49
| | | | | | | | | | | | The paintSection was very long and thus difficult to override. This change makes it far more easy to do custom section painting or styling in the headerview. [ChangeLog][QtWidgets][QHeaderView] Introduced QHeaderView::initStyleOptionForIndex to make it easier to reimplement custom styling and painting of sections. Change-Id: I99e5fe8d70485a4650ab33e3d3eb4a46d6468326 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Make initStyleOption virtual for various classesThorbjørn Lund Martsum2020-07-311-0/+8
| | | | | | | | | | | | | | | | | | | | Often a simple change in the styleoptions is needed in e.g a paintEvent, but it was impossible without copying the whole paint-function which is not always trivial and also wouldn't be kept up-to-date if it was changed in Qt. The initStyleOption is similar to viewOptions in QAbstractTableView and it is handy that this function is virtual. Furthermore QStyledItemDelegate::initStyleOption is already virtual. This change only makes initStyleOption virtual for public classes. [ChangeLog][QtWidgets] InitStyleOption has been made virtual in public Qt classes to make override of stylebehavior more simple. Change-Id: I38974c6d4dd0793ca5976ecf3aa28892215a1579 Task-number: QTBUG-77642 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
* Use qsizetype in QListLars Knoll2020-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | The change creates a slight source incompatibility. The main things to take care of are * code using printf statements on list.size(). Using qsizetype in printf statements will always require a cast to work on both 32 and 64 bit. * A few places where overloads now get ambiguous. One example is QRandomGenerator::bounded() that has overloads for int, uint and double, but not int64. * Streaming list.size() to a QDataStream will change the format depending on the architecture. [ChangeLog][QtCore][QList] QList now uses qsizetype to index into elements. Change-Id: Iaff562a4d072b97f458417b670f95971bd47cbc6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use QList instead of QVector in widgetsJarek Kobus2020-07-021-12/+13
| | | | | | Task-number: QTBUG-84469 Change-Id: I3007734f8e4f164ece9dd8850ef007cbef9e12ef Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* Remove deprecated QStyleOption::init()Christian Ehrlicher2020-06-211-1/+1
| | | | | | | | Even it was not marked as deprecated the replacement function initFrom() is available since Qt4 times (and init() is deprecated since then) Change-Id: I09a4ebbf66b01fbe7aec67691dc68d2e42d1cd78 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Replace calls to deprecated QEvent accessor functionsShawn Rutledge2020-06-081-8/+8
| | | | | | | Many of these were generated by clazy using the new qevent-accessors check. Change-Id: Ie17af17f50fdc9f47d7859d267c14568cc350fd0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port QT_NO_TOOLTIP to QT_CONFIG(tooltip)Joerg Bornemann2020-04-211-1/+3
| | | | | | | | | | | | We remove the QT_NO_TOOLTIP check from qstandarditemmodel.h, because as the 'tooltip' feature is in QtWidgets, we cannot use it properly in QtGui. Also this affects just two non-virtual inline methods, i.e. it has no effect on library size. Task-number: QTBUG-82785 Change-Id: Ic166f14fb1cf3e9dd789573a6b9db6a87fb50e10 Reviewed-by: Tasuku Suzuki <tasuku.suzuki@kdab.com> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QApplication: remove obsolete globalStrut functionalityVolker Hilsheimer2020-04-101-5/+3
| | | | | | Change-Id: If56873f86f5291264cac720f8db7dbd4db756f49 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Replace most use of QVariant::type and occurrences of QVariant::TypeOlivier Goffart2020-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-9/+9
| | | | | | | | | | | 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>
* Remove dead code from Qt 4 timesTor Arne Vestbø2019-08-201-2/+0
| | | | | | | | | | 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ø <tor.arne.vestbo@qt.io>
* Remove usages of deprecated APIs of qtbase/widgetsSona Kurazyan2019-08-011-75/+5
| | | | | | | | | | | | | | | | | | | | | | - Replace the usages of deprecated APIs by corresponding alternatives in the library code and documentation. - Build docs for deprecated APIs conditionally, based on deprecation version. Remove the docs of methods deprecated since 5.0.0, these methods are not compiled anymore. - Modify the tests to make them build when deprecated APIs disabled: * Make the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, add tests for the replacement Task-number: QTBUG-76491 Task-number: QTBUG-76540 Task-number: QTBUG-76541 Change-Id: I6aaf0a1369c479fb880369a38f2b8e1e86b46934 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: Fix static method invocationsFriedemann Kleint2019-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | Apply fixits by Creator and results of manual search focusing on QCore/Gui/Applicaton(Private) methods and variables to prepare for splitting out some classes. Task-number: QTBUG-69478 Task-number: QTBUG-76497 Task-number: QTBUG-76493 Change-Id: Iaf468166793e0cabb514b51c827b30317bf45a2d Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-06-071-1/+4
|\ | | | | | | | | | | | | | | | | | | Conflicts: qmake/generators/makefile.cpp src/plugins/platforms/cocoa/qcocoaintegration.h src/plugins/platforms/cocoa/qcocoaintegration.mm Done-With: Jörg Bornemann <joerg.bornemann@qt.io> Change-Id: I5a61e161784cc6f947abe370aab8f2971a9cbe78
| * Document that QHeaderView rendered with themed style might ignore rolesVolker Hilsheimer2019-06-051-1/+4
| | | | | | | | | | | | | | | | | | While this is generally true for widgets, QHeaderView's documentation about how appearance related data roles are respected can be misleading. Fixes: QTBUG-31804 Change-Id: I93c6562e59ecf771d938d282723169202ac15bc2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* | QHeaderView: fix assert when restoring section sizes over less columnsDavid Faure2019-04-231-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | If columns are removed and we get notified via layoutChanged, the code tries to restore old section sizes, and went out of bounds, leading to an assert in QVector. Simply add an if() to skip restoring out-of-bounds columns. This comes from https://bugs.kde.org/show_bug.cgi?id=395181, which translates into the unittest that is part of this commit. Change-Id: Ide42176a758f87b21957c40508127d67f1d5a2d9 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
* | QHeaderView: check for changed roles in dataChanged()Christian Ehrlicher2018-11-081-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QHeaderView::dataChanged() did not check for the modified roles which lead to unneeded size calculations even if the size did not change. Avoid it by only looking at the relevant roles (DisplayRole, DecorationRole, SizeHintRole and FontRole). [ChangeLog][QtWidgets][QHeaderView] dataChanged now respects the given roles to avoid useless recomputations Fixes: QTBUG-71172 Change-Id: I0de53897347a72bddc425ae1fae8f2560ad0e977 Reviewed-by: David Faure <david.faure@kdab.com>
* | QHeaderView: Fix updating hidden sections during initializeSections()Christian Ehrlicher2018-11-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | QHeaderView::initializeSections() was calling updateHiddenSections() with wrong parameters which lead to an inconsistency in the hidden section handling. updateHiddenSections() needs the first and last index which got removed. Therefore we must pass the new section count for logicalFirst. Fixes: QTBUG-55461 Change-Id: Ica06125cf19bdd500f55fd9cd59ace1795f3703f Reviewed-by: David Faure <david.faure@kdab.com>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-09-291-3/+0
|\| | | | | | | Change-Id: I6083c3e61b7dbe188f83676f7e7bb268e5ccf2f3
| * Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-09-271-3/+0
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qconfig-bootstrapped.h src/widgets/util/qcompleter.cpp Change-Id: I4f44f0f074982530f2f2e750ce696230b2754cf3