summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
Commit message (Collapse)AuthorAgeFilesLines
* Send accessible focus event after list view has focusFushan Wen2022-11-101-1/+1
| | | | | | | | | | | | | | QListView::currentChanged sends an accessible focus event even if the list view doesn't have focus. For screen readers like Orca, accessible focus events will be ignored if the target item does not have focus when screen reader receives the event. This corrects the behavior by calling QAbstractItemView::currentChanged before sending an accessible focus event. Pick-to: 6.4 Change-Id: I71732f62e2f27d7856b4781b268495b88b24b715 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-0310-42/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QTreeView: fix drawing of background for alternate rowsVolker Hilsheimer2022-10-241-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After f4976f86cd265d7505da449dafe15c51e3c8cdc0 we never called the style to draw the background of rows, unless ShowDecorationSelected was set. This broke rendering of alternate row backgrounds, as painting that background for the item's decoration was done by the style function that was no longer called. QStyleOptionViewItem::showDecorationSelected should store the value from the widget's style and be used by the style when rendering. This avoids that a style sheet is ignored when we are already in the virtual table of the parent style. However, in that style option we conflate both the style hint, and whether the entire row should be selected when the selection behavior is SelectRow (as we then need to draw selection in the first column all the way to the second column, not just around the text). To fix this, override the showDecorationSelected back to the style hint value while we are only painting the background, and reset it back before calling the delegate to draw the rest (including the selection). This reverts f4976f86cd265d7505da449dafe15c51e3c8cdc0. Fixes: QTBUG-106227 Pick-to: 6.4 6.2 Change-Id: I5c1ecdf0a0e07b156f35f4e5614593a984754a34 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* 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-113-4/+4
| | | | | | | | | | | | | | | | 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-0415-247/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* QAbstractItemDelegate: tolerate that editor gets reparentedVolker Hilsheimer2022-08-251-2/+3
| | | | | | | | | | | | | | | | | | | An item delegate might override destroyEditor to merely reparent the existing editor out of the item view for later reuse, rather than actually destroying the editor. As of d0dffdfc012574da4a75241097b667d09bb39ba2, the code calling closeEditor() - which calls destroyEditor - might explicitly set focus back to the item view parent of the editor. This needs to handle that the parent of the editor might no longer be valid after the closeEditor call returns, and rather store the old parent widget explicitly. Add a test case that segfaults with nullptr access without the fix. Fixes: QTBUG-105231 Pick-to: 6.4 6.3 6.2 Change-Id: I04a355673823c4941865f7a575864e991ceeb5f0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@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>
* Doc: Format certain operators in textPaul Wicking2022-08-231-2/+2
| | | | | | | | | | Use correct text formatting; this ensures e.g. the decrement operator isn't converted to an en dash in the docs. Apply to increment operator docs also for consistency. Task-number: QTBUG-105729 Change-Id: I5f126b90bc1d1b91d86e1f87c9b17a583841adb6 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: Drop parentheses around \since commandPaul Wicking2022-08-091-2/+2
| | | | | | | | | | | The closing parenthesis ends up in the output. As the fix to QDoc is rather involved, clean up the docs to fix the symptom. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-105339 Change-Id: I35a1e7615125781d950649213c08e5760b0235e7 Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
* Add -Wshorten-64-to-32 to headerscleanTor Arne Vestbø2022-07-211-3/+3
| | | | | | | | Fix existing warnings by casting to the appropriate type. Change-Id: Ic44d2a71e1a2e508199dbb46bea7a19e183ec42c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Improve widget painting under dpr>1 by enabling smooth pixmap scalingEirik Aavitsland2022-07-121-4/+4
| | | | | | | | | | | | | | | | | Smooth scaling of icons etc. give far better visual results, particularly with fractional dpr scaling. So enable this generally in QStylePainter, and make more of the relevant widgets use QStylePainter instead of QPainter directly. Differences can be seen in the widgets examples, e.g. textedit, gallery, stylesheet (Pagefold), mdi. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-96223 Fixes: QTBUG-101058 Change-Id: I3c34a455d097e5f6a6a09d3b020528b4fbda4d85 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QListview: PageDown/Up infinite loopTang Haixiang2022-07-051-3/+9
| | | | | | | | | | | When item.height > viewport.height, the next item is not found correctly, resulting in an infinite loop. In this case, move directly to the next item. Pick-to: 6.4 6.3 6.2 Change-Id: I67a40a079ca9dd9189bf84ae550758c685b83d75 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Don't trigger qBound assert in QExpandingLineEditVolker Hilsheimer2022-06-291-1/+1
| | | | | | | | | | | Ignore the original width if it's larger than maximum. Fixes: QTBUG-104383 Fixes: QTBUG-104565 Pick-to: 6.4 6.3 6.2 Change-Id: Id86d4f5bd1d50304d95c4711f1989f4dae416b69 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QStyledItemDelegate: Fix the event filter docLaszlo Papp2022-06-281-2/+3
| | | | | | | | | | | | The class actually also avoids filtering the tab and backtab keys for the mentioned classes: QTextEdit and QPlainTextEdit. So, the documentation needs to be extended to cover the hidden gems. Pick-to: 6.4 6.3 6.2 Change-Id: Id993b055a105c6cfe5ee57be3863ce8bff448396 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemDelegate: Remove a duplicate doc entryLaszlo Papp2022-06-201-2/+2
| | | | | | Pick-to: 6.4 6.3 6.2 Change-Id: I02887e6bf5892b4697af2aabcd1f1335e15b4f06 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableView: set correct clip on QPainter when using spansRichard Moe Gustavsen2022-06-201-4/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it stood, QTableView would sometimes show drawing artifacts when sections (rows or columns) where rearranged, in combination with spans. The reason is that the current code would go through the currently visible cells in the viewport to check if any of them where affected by a span. But the stored spans (in QSpanCollection) is kept in sync with the column layout in the model, and doesn't know anything about the rearranged columns in the view. But a column with spans that is moved to the left of the viewport can affect the painting of the viewport as well, and needs to be taken into consideration. For that reason, the current solution that uses QSpanCollection::spanAt(x, y), will in that case fail. Since it seems sensible that QSpanCollection is kept in sync with the model (it makes model changes that affect spans easier to handle), this patch will not change QSpanCollection. Instead, it will iterate through all the spans (which is assumed to normally be a limited size), convert them to the column layout of the view (visual instead of logical), and find the ones that overlap. Overlapping spans will, like before, be added as clip rects to the QPainter. Fixes: QTBUG-91896 Pick-to: 6.4 6.3 6.2 Change-Id: Iabe20df13cbd41a68f1104d3d9e24b89c4b88913 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Provide overload for Qt::AlignmentFlags in item widget itemsVolker Hilsheimer2022-06-176-0/+21
| | | | | | | | | | | | | | | | Amends 53ee4c8b1f7ae72e7005166e1c0dbc4659f2ab32, which deprecated QListWidgetItem::setTextAlignment(int) etc and provided a typesafe Qt::Alignment overload instead. However, Qt::AlignLeft by itself is of type Qt::AlignmentFlag, it only becomes a Qt::Alignment when or'ed with another alignment flag. So the deprecated int-overload was taken by the compiler, resulting in a deprecation warning. Add a Qt::AlignmentFlag overload in addition, and document it as \internal since it is just a C++ technicality that we need both. Pick-to: 6.4 Change-Id: Ide97eed7f6d1f89a5f955b2ed45167e771bd8c81 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)Allan Sandfeld Jensen2022-06-154-17/+17
| | | | | | | Pick-to: 6.4 Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@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-1650-1901/+101
| | | | | | | | | | | | | 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>
* Item widgets: clean up treatment of Qt::TextAlignmentRole / CheckStateRoleGiuseppe D'Angelo2022-05-166-8/+112
| | | | | | | | | | | | | | | | | | | | | | | The item widgets all have an API flaw: getters and setters for the text alignment deal with int instead of Qt::Alignment. Deprecate the existing setters and introduce others taking Qt::Alignment. Store the alignment directly into the item widget (now that views know how to handle it). We can't change the getters without cluttering the API, so make that a Qt 7 change. Users can prepare by forcibly casting the return value to Qt::Alignment; this is going to work in Qt 6 and 7. While at it: streamline the handling of Qt::CheckStateRole as well, avoiding to rely on a pointless Qt::CheckState to int conversion through QVariant (the setter stores a Qt::CheckState, but the getter retrieves an int and converts it to a Qt::CheckState). Task-number: QTBUG-75172 Change-Id: I9f29e818e93cb2dc1d8e042bc320162c2f692112 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemDelegate: fix rect given to tooltip handingDavid Faure2022-05-091-6/+1
| | | | | | | | | | | | | | | | | | | * The rect passed to QToolTip::showText() is in view coordinates, not in global coordinates. * Determining this rect in the first place doesn't need calling view->visualRect(index) The view already did this before calling this method, and stored it in option.rect, so just use that. * The widget passed to QToolTip::showText() should be the viewport, that's what option.rect is relative to (thanks Giuseppe!). Found these issues when implementing my own tooltip handing (for a subrect of a delegate) by looking at this code. Pick-to: 6.3 6.2 5.15 Change-Id: I852e5409def28da98137cd0c4c996083e5e45706 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QAbstractItemView: check the index emitted by the delegate's sizeHintChangedGiuseppe D'Angelo2022-04-283-6/+18
| | | | | | | | The index in question has to belong to the view's model. An erroneous emission shouldn't be silently ignored. Change-Id: I7e037e72affb210f609a9a1029777acafae041f1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemView: warn in some erroneous conditionsGiuseppe D'Angelo2022-04-271-2/+6
| | | | | | | | | | | | | If a user or a delegate asks a view to act on an editor that does not belong to the view, report a warning instead of silently ignoring the problem. This erroneous condition can happen for instance if a user installs the same delegate on multiple views (something that the documentation says _not_ to do) and the delegate indeed emits signals related to the editors of one view -- the other views don't know about that editor. Change-Id: I2d10582ebb7aefca4acea306b8a57bcc3162050a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-262-2/+2
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I133b80334b66e0a5ab9546dd8e1ff0631e79601e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableView: Document the customizations applied to QHeaderViewSze Howe Koh2022-03-291-0/+2
| | | | | | | | | | | These are non-default options which the user needs to manually set when applying a custom QHeaderView. Task-number: QTBUG-102034 Pick-to: 6.3 6.2 5.15 Change-Id: Ib3396f0a82c358c71a8501fc2d71158f725bc228 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* QAbstractItemView: with single selection, deselect on Ctrl+ReleaseVolker Hilsheimer2022-03-241-9/+22
| | | | | | | | | | | | | | | | | After cbf1b4bc60bca3994b8f8685ee922e53a6b4eed2 the selected item got deselected on Ctrl+Press, which made Ctrl+dragging a selected item impossible. Only deselect on Ctrl+Release. Add scenario to existing test case, and update the documentation to clarify the properties involved, and to point out that the event parameter might be nullptr. Fixes: QTBUG-101647 Pick-to: 6.3 6.2 Change-Id: I749b1cb1a0a311f5c1d4c333984716f05f2c90b5 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Enderlein <volker.enderlein@ifm-chemnitz.de> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Itemviews: start fixing mixups of int/enum for Qt's item rolesGiuseppe D'Angelo2022-03-234-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Make sure all qtbase private headers include at least one otherThiago Macieira2022-02-241-0/+1
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Core: Remove 'properties' featureKai Köhne2022-02-142-22/+0
| | | | | | | | | | | | | Even QtCore alone cannot be built without the properties feature since Qt 5.5. While fixing this is easy, other modules like dbus, networking are also using QObject::property() and friends liberally. All in all I doubt that anybody will miss the feature (otherwise it would have been fixed in the last decade). Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Always update pressedPosition when drag was enabledZhang Hao2022-02-101-12/+13
| | | | | | | | | | | | | | | | | | | | | | | Since e02293a76d21e7077f1952d4ed8af6c6d1970190 and 2e0c29a4bbe2b3ae427137e65f179b0550dcf169 was committed, If a item width more than others,the selectionRect.x() always consist of currentStartSelection item's rect.center().x(),this will cause selectionRect size is not right. Because the code of 2e0c29a4bbe2b3ae427137e65f179b0550dcf169 is to fix the new bug introduced by e02293a76d21e7077f1952d4ed8af6c6d1970190, we need to use a better way to solve QTBUG-78797. When itemview enable drag,we need always update pressedPosition because pressedPosition was used to determine the drag distance, otherwise keep previous logic. Fixes: QTBUG-78797 Fixes: QTBUG-81542 Fixes: QTBUG-99512 Pick-to: 6.2 6.3 Change-Id: Ibc5020e35b0eb319e4b5546bdba39ff527c209a6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QAbstractItemView: do not access invalid model indices (3/N)Giuseppe D'Angelo2022-02-021-7/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | The slots connected to rowsAboutToBeRemoved and columnsAboutToBeRemoved attempt to find a new current index by scanning the model around the existing current index -- in case that index is indeed about to be removed. The problem is that the scanning was done without any sorts of bounds checking; instead it was relying on the model's index() to return an invalid index for an out of bounds request. Fix that by adding bounds checking. Since models are not supposed to return invalid indices for in-bounds index() calls, added some warnings if that happens. For some reason, the code handling rows and columns isn't perfectly symmetrical. Rows are searched both forwards and backwards, while columns only backwards, and the related code is slightly different. Filed QTBUG-100273 to try and understand what's going on. Change-Id: I7452d8c521e74daa4408e6cc969ce5a6059f53ea Pick-to: 5.15 6.2 6.3 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QAbstractItemView: do not access invalid model indices (2/N)Giuseppe D'Angelo2022-02-011-0/+2
| | | | | | | | | Similar to the parent patch, the private selectAll() was doing two out of bounds accesses on an empty model. Guard it. Change-Id: If0f3ce1e6c44a152791313e47db79985e71ef955 Pick-to: 5.15 6.2 6.3 Reviewed-by: David Faure <david.faure@kdab.com>
* QAbstractItemView: do not access invalid model indices (1/N)Giuseppe D'Angelo2022-02-011-1/+2
| | | | | | | | | | Calling selectAll() on a view with an empty model, with the view in ContiguousSelection, causes an out of bounds access into the model. Guard the access. Change-Id: I3830a979bad760e9e1526c1c8b12d9767d41fc99 Pick-to: 5.15 6.2 6.3 Reviewed-by: David Faure <david.faure@kdab.com>
* QAbstractItemView: code tidiesGiuseppe D'Angelo2022-02-011-4/+12
| | | | | | | | | In preparation for an upcoming fix, refactor an if over an enumerator to a switch (which is how this code should've been to begin with). Change-Id: I11a2de6d66f0359b985b587b7fd37022a7bf56e6 Pick-to: 5.15 6.2 6.3 Reviewed-by: David Faure <david.faure@kdab.com>
* QTableWidgetSelectionRange: make relational operators noexceptMarc Mutz2022-01-211-4/+4
| | | | | | | | Also remove the superfluous inline keyword. Pick-to: 6.3 Change-Id: I2cd2fc46687626a6f9eab60553bc3022c7eed6de Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtWidgets: auto-test-export private classes, unbreaking ubsan buildsMarc Mutz2021-12-161-1/+1
| | | | | | | | | | | | These classes are used in their respective tests, but since these only seem to access data members, the missing export macro was never detected. UBSan, however, checks the type_info on each access, so it needs the (polymorphic) class exported. Do so (for -developer-builds). Change-Id: I97b41cfb5dd7f1665cdf4f7a819a42fbf0388621 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix item view auto-scrolling during drag'n'dropVolker Hilsheimer2021-12-101-8/+24
| | | | | | | | | | | | | | | | | | | | Amends 71aaf831d175a164b508ce169131a794d55d6fb0, which wrongly assumed that dragMoveEvent will be called and update the dragged position as we scroll the viewport. This is not the case, so we have to do so manually when the view is in DraggingState. Since dragMoveEvent cannot be faked, and since we cannot fake a mouseMoveEvent (it would throw off the drag'n'drop state machine), calculate the new draggedPosition based on old position and the new offset. As with all drag'n'drop, we cannot test this using an auto test. Task-number: QTBUG-96124 Fixes: QTBUG-98961 Change-Id: Ifcfc1a11aa7258ec4610a548a276b4dd4a814590 Reviewed-by: Zhang Hao <zhanghao@uniontech.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QTableWidget doc: remove wrong comment for itemExpanded()Christian Ehrlicher2021-12-081-3/+0
| | | | | | | | | | Since Qt5.1 (80fa4b6c8ef) expandAll() emits expanded() but within this change, the comment in itemExpanded() was forgotten. Pick-to: 6.2 Pick-to: 5.15 Change-Id: Ic487e5f8999d6af27a4747b861464058faf03889 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QListView: fix a broken qBoundGiuseppe D'Angelo2021-12-061-1/+1
| | | | | | | | | | | | | | | | | If a QListView's model is reset to an empty one, its columnCount() below the root is going to be 0. Therefore, the code was doing a qBound(0, d->column, -1) which is meaningless (high < low). Instead, do the two logical operations explicitly: first do an upper bound on d->column (using qMin) and then lower bound the result by 0 (using qMax). The code worked by chance, because 0 was eventually the correct number to use as a bound for d->column. Change-Id: Ic32077cdab01eaa715137c05ed1f9d66c8eb2f67 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableView: correctly toggle column selection when scrolledVolker Hilsheimer2021-12-021-1/+1
| | | | | | | | | | | | | | | | We need to check whether the horizontal header's selection includes the index for the row at the top, rather than for row 0, as the index we check is based on the scrolled position of the header, so would never be included in the top row when the view is scrolled. This is correctly done in selectRow already. Add a test case that simulates selection of rows and columns by clicking on the header. Fixes: QTBUG-98444 Pick-to: 6.2 Change-Id: I2fa1b32bf75dc96225b40145b713bf7e2ffc29dd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Draw QTableView grid lines centered between table cellsTor Arne Vestbø2021-11-081-3/+5
| | | | | | | | | | | | | | | | We were reserving space between table cells corresponding to one logical pixel, which on retina screen results in two device pixels. By drawing the grid line with a cosmetic pen, we were only filling one of these pixels, leaving space for leftover pixel dust from earlier blits. By drawing with a non-cosmetic pen of size 1, and ensuring that the grid line is drawn at the center of the grid, we end up filling the entire grid line, without overdrawing the table cells. Pick-to: 6.2 Change-Id: I7f4d2b27380e5a3d221e265a25f7531fdc4a02b3 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QAIV: Reset double-click flag in mousePressEventVolker Hilsheimer2021-11-051-0/+1
| | | | | | | | | | | | | | | Amends 17c1ebf8bfd254ff75cc55e335d1c1fb01da547f, which introduced logic that recognizes double clicks to avoid duplicate clicked() emits. If a slot connected to doubleClicked opens a dialog, then the release-event will not be seen by the item view, leaving the flag incorrectly set and preventing the next clicked signal. Fixes: QTBUG-97853 Pick-to: 6.2 5.15 Change-Id: Iced83e8c66a763672f522265435dc52a745227e4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QAbstractItemView: auto-scroll with selection rectangleVolker Hilsheimer2021-10-222-10/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some item views, such as QListView in icon mode, implement a selection rectangle with which the user can "lasso" items. So far, dragging that rectangle did not trigger auto scroll, so unless an item near the edge was selected, the user had to stop the lassoing and scroll manually to reach more items. Since QAbtractItemView implements auto scrolling for drag'n'drop, we can use that mechanism also when the selection rectangle is dragged. This requires some modifications: We need to make sure that scrolling the view during a drag-selection generates mouse move events so that the selection is extended and the rectangle is updated in subclasses. And we need to stop using QCursor::pos to get the position of the mouse pointer, as this makes the auto-scrolling untestable. Instead, record the mouse position last seen during a mouseMove or dragMoveEvent in content-coordinates (identical to pressedPosition). As a drive-by, fix some coding-style issues in nearby code. Done-with: Zhang Hao <zhanghao@uniontech.com> Fixes: QTBUG-96124 Change-Id: I426f786e5842ae9f9fb04e9d34dc6d3379a6207f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* widgets: Fix typos in source code commentsJonas Kvinge2021-10-154-10/+10
| | | | | | Pick-to: 6.2 Change-Id: I22f71a53b0f7f0698450123343e25548c889c3e2 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* widgets: Fix typos in documentationJonas Kvinge2021-10-122-2/+2
| | | | | | Pick-to: 5.15 6.2 Change-Id: I6b77f0ec043d08da3b7958d780dce9595daf97a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Select a single range of cells in QTableView, away from merged cellsShawn Rutledge2021-10-121-7/+17
| | | | | | | | | | | | | | | | | | | | | - when there is no intersection between the current selection and the spans collection, get ranges for all cells, just as if no span exists - when there is an intersection between the current selection and the spans collection, get separate ranges for each cell (as before) This fixes the regular case of selecting multiple non-spanned cells after some cells are merged (get a single range for all cells instead of separate range for each cell). However, when selecting together a group of spanned and non-spanned cells, you still get a separate range for each cell. But this is normal behavior in similar applications; for example in LibreOffice, you cannot select and merge spanned and non-spanned cells: an error dialog tells you that it's not allowed. Done-with: Christos Kokkinidis Pick-to: 6.2 Fixes: QTBUG-255 Change-Id: Ic38f9a064a1f499825e7f750668013fc2dc564ba Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableWidgetSelectionRange: Make it possible to compare for equalityVolker Hilsheimer2021-10-122-0/+22
| | | | | | | | | Add operators as hidden friends, add test case to make sure that basic value-type operations are possible with this type. Task-number: QTBUG-255 Change-Id: I7fbf453aa16084c0b2a0079487cacb4e092ff664 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>