summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* QAbstractItemView: fix crash if setData() does a model resetDavid Faure2021-10-011-3/+10
| | | | | | | Task-number: QTBUG-96654 Pick-to: 6.2 Change-Id: I2dca4af387ef5ad549a1a41fba2bc6de217f4ea9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QAbstractItemView: Fix IM input starting edit sessionVolker Hilsheimer2021-10-012-21/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | Item views can open an editor widget on the first key press, and need to take special care not to break input methods. The initial key press starts compositing by the system input method, which is then interrupted by the focus transfer to the editor. To solve this problem, the widget needs to keep focus while the initial composition is ongoing, and only transfer focus to the editor once the composition is either accepted or cancelled by the user. Add a state flag that is set during this initial preedit phase. During this initial composition, the item view will receive all input method events, and needs to forward these to the open, but not yet focused editor for the user to get the correct visual feedback during the preedit phase. The item view also needs to report to input method queries on behalf of the editor to make sure that the IM UI is correctly positioned without covering the user input. Implement a test that simulates the sequences through synthesized QInputMethodEvents; we can't simulate the entire system input stack. Fixes: QTBUG-54848 Change-Id: Ief3fe349f9d7542949032905c7f9ca2beb197611 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix QListView assert when the last row is moved in IconModeChunLin Wang2021-09-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | After the last row is moved, 0 will be returned when obtaining row and column data. At this time, QListView::doitemslayout will not call d->doitemslayout, so the QBspTree data structure will not be cleaned up, leaving a stale tree structure behind. This will trigger an assert during paintEvent handling if QListView is set to IconMode In QListView::ListMode the test for a valid model index doesn't use an assert. Call QListViewPrivate::clear explicitly if the column count is 0 so that the QBspTree and other data structures are cleared. Add a test case that simulates this scenario by implementing a model that returns a 0 column count for an index after the model structure was changed through a move of rows. Done-with: Volker Hilsheimer Fixes: QTBUG-95463 Pick-to: 5.15 6.1 6.2 Change-Id: I36419be5459b8ced930c619f538482ea1db4ad03 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Port to QImage and QPixmap deviceIndependentSize()Morten Sørvig2021-09-012-4/+4
| | | | | | | | | Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QListView: fix AdjustToContents (sizeAdjustPolicy)Thorbjørn Lund Martsum2021-08-101-1/+41
| | | | | | | | | | | | | | | | | | | | Unlike an acceptable effect in QTableView + QTreeView setAdjustPolicy(QAbstractScrollArea::AdjustToContents) unfortunately didn't work for QListViews (and QListWidget). This patch corrects QListViews AdjustToContents behavior. [ChangeLog][QtWidgets][QListView] A more correct implementation of QListView::viewportSizeHint has been made. That implies that setting the sizeAdjustPolicy to AdjustToContent on QListView and QListWidget will now cause the view to size after the contents and avoid scrollbars. Pick-to: 6.2 Task-number: QTBUG-58749 Change-Id: I1675115f2348e2fcf0b2c39b451ef337e10eb872 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Doc: Fix typo Ctr -> CtrlAlexander Volkov2021-07-281-1/+1
| | | | | | Pick-to: 6.1 6.2 Change-Id: I89c9526aa74b312dd67a6d194395b3298bbc31fe Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* emit layoutAboutToBeChanged timelyLuca Beldi2021-07-201-4/+8
| | | | | | | | | | | layoutAboutToBeChanged must be called before persistentIndexList as the user might create persistent indexes as a response to the signal Fixes: QTBUG-93466 Pick-to: 6.2 5.15 Change-Id: I73c24501f536ef9b6092c3374821497f0a8f0de4 Reviewed-by: David Faure <david.faure@kdab.com>
* QListView: don't scroll if selected items are removedVolker Hilsheimer2021-07-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | For SingleSelection, removing the selected item will select the nearest item and, if autoScroll is enabled, ensures that the newly selected item is visible in the viewport. This may result in scrolling. For Multi- or ExtendedSelection, this should not happen, as having no selection is perfectly fine in those modes. However, QListView still tried to scroll to the current item in response to the currentIndexChanged signal. Since the currentIndex is at this point already hidden, the rectangle for it became invalid, and the attempt to scroll resulted in a one-pixel up-movement of the viewport (since the invalid rectangle has width == height == -1). Fix this by not scrolling if the rect for the index is invalid. Note that the index is still valid at this point, so we can't shortcut the call stack earlier. Add test that exercises the different combinations of ViewMode and SelectionMode, and demonstrates the one-pixel movement without the fix. Fixes: QTBUG-94788 Pick-to: 6.2 6.1 5.15 Change-Id: I1f36973eadb46e8c9b8b8068bc76ee09e9f490dd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Consistent handling of disabled items in QItemSelectionModelAndreas Buhr2021-07-152-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | In QItemSelectionModel, items which are disabled or marked as not selectable should not be considered as selected. But this was not handled consistently. The following methods considered only items which are enabled and marked selectable: selectedIndexes(), rowIntersectsSelection(), and columnIntersectsSelection(). The following methods considered only items which are marked selectable, but did not check whether they are enabled: selectedRows(), selectedColumns(), isRowSelected(), isColumnSelected(), isSelected(). Finally there is hasSelection(), which did not check for enabled nor for selectable. This patch introduces consistent behavior. All methods check both whether the items are enabled and whether they are selectable now. [ChangeLog][QtCore][QItemSelectionModel][Important Behavior Changes] All methods in QItemSelectionModel now consider only items which are marked as enabled and selectable as part of the selection. Fixes: QTBUG-93829 Pick-to: 6.2 Change-Id: I4725243ea6b0db4f289ce34ada22c7a9d3282713 Reviewed-by: David Faure <david.faure@kdab.com>
* Initialize class members of QTreeWidgetItem at declarationAndreas Buhr2021-07-152-57/+15
| | | | | | | | | The members view, par, and itemFlags were initialized in each of its nine constructors. This patch moves the initilaization to the declaration to prevent this repetition. Change-Id: I71d136e7615dca5d87e8a4dc161c877633017ad0 Reviewed-by: David Faure <david.faure@kdab.com>
* Point out that QTreeView's expandAll/expandToDepth don't fetch dataVolker Hilsheimer2021-07-141-2/+11
| | | | | | | | | | | They will only expand what's currently in the model. As a drive-by, remove superfluous : after the \warning macro. Fixes: QTBUG-94981 Pick-to: 6.2 6.1 5.15 Change-Id: I85d38373fb7edf5a5407622b32870e7bcd5d9aeb Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QDuplicateTracker: accept the number of elements to reserve as a ctor argumentMarc Mutz2021-07-141-2/+1
| | | | | | | | | | | | This prevents us from first reserve()ing Prealloc elements, and then possibly reserve()ing a larger number, which leaves the first bucket list's memory unused. Consequently, deprecate reserve(). Change-Id: Ifc0a5a021097f4589557e7b5e45d9d0892797ade Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use RAII object to skip pending sorts in QTreeWidgetAndreas Buhr2021-07-122-19/+9
| | | | | | | | | | | | | Cleanup: This patch does not change functionality. In several places, sorting inside of the QTreeModel is disabled and afterwards restored. There is a RAII class for this, which is used in some places, but not in others. This patch introduces more consistent usage of this RAII object. Change-Id: I9802998ad31d0f9d4417824f72ff0abbb0c38a17 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTableView: fix selection with rows and cells in ExtendedSelection modeChristian Ehrlicher2021-07-122-5/+4
| | | | | | | | | | | | QTableView stored the current row/column selection start in an own variable instead using currentSelectionStartIndex. This leads to an inconsistent behavior when the selection is done with a click on the header and then in a cell (and the other way round) Fixes: QTBUG-92561 Change-Id: I4c8bda3a938de451b6eff2819141e86a6870fbef Pick-to: 6.1 6.2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* add todo comment for Qt 7Andreas Buhr2021-07-091-0/+2
| | | | | | Task-number: QTBUG-94546 Change-Id: I86a40dcb2b6e33140c31acc450bcd47fa6ff3f2d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Consistent indentation for all Q_PROPERTYsAndreas Buhr2021-06-243-7/+14
| | | | | | | | Task-number: QTBUG-94407 Pick-to: 6.2 Change-Id: I8c97a0b2de2bed78456322be271724fc47479d83 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add a style hint to draw the left/top border lines when header is hiddenAndy Shaw2021-06-161-0/+22
| | | | | | | | | | | | Since there is no header then the cells appear with no actual border so it can look a bit strange without it. This ensures that the border is at least shown when there is no header to represent it if the style hint is turned on. This gives an option for those who want it to have it turned on. Fixes: QTBUG-85523 Change-Id: Ib94874bddddd31738fbcd41c6f77a2e0fa2ef443 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAIV: Don't open editor on release when press closed editorVolker Hilsheimer2021-06-142-2/+18
| | | | | | | | | | | | | | | | | A mouse press that transfers focus from an open editor back to the view will close the editor. To prevent that the corresponding release then opens the same editor again we need to know that the closeEditor call was caused by the mouse press. Since Qt first generates the focusOut event, and then delivers the mouse press, we have to start a zero-timer to check whether we are in the same event delivery process. If so, ignore the corresponding release. Add test case that simulates that chain of events. Fixes: QTBUG-20456 Pick-to: 6.2 6.1 Change-Id: I28fa32bfbc776db207c594c329961f575ae58ea9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* Check scrollbar ScrollBarOverlap when computing QListView marginsZhang Hao2021-06-101-0/+1
| | | | | | | | | | | | | | | | | When the listview setWordWrap is true and ScrollBarPolicy is ScrollBarAsNeeded, if QStyle::PM_ScrollView_ScrollBarOverlap returns true, the text displayed an empty line. Fix this by not reserving the width of the vertical scrollbar if the flow is TopToBottom and the vertical scrollbar, and QStyle returns true for PM_ScrollView_ScrollBarOverlap. Amends aeef92c3c33e4ebcb7e5d8dd955020f4f4600e84 Pick-to: 6.1 6.2 Fixes: QTBUG-94248 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I4d47c7e86bbb86474cb1a99bb26d8b67f0e8a7e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractItemView: block autoScroll from interfering with QScrollerVolker Hilsheimer2021-06-091-0/+4
| | | | | | | | | | | | | | | | When pressing an index in order to start a flick gesture, QAIV sets the current index. When QScroller changes state to Dragging, then QAIV restores the current index to what it was before the press, as the user is clearly scrolling the view. With autoScroll enabled, this will produce an ugly jump if the old current index is no longer in the viewport. To prevent this, disable autoScroll before restoring the currentIndex. Fixes: QTBUG-64543 Pick-to: 6.2 6.1 5.15 Change-Id: I3e0a18a6a179d80b9d810fce5aa658f0cfff9a29 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* QListView: add assert for static analyzerVolker Hilsheimer2021-06-081-0/+2
| | | | | | | | | | | | The loop that initializes the item should execute at least once, so the pointer should be pointing to something valid. The static analyzer doesn't see that, and warns about unguarded access to the item pointer in report with hash d008dbef4573afca54be0139e2971a4a. Add asserts for both the condition that makes the loop run at least once, and for the item pointer not being nullptr. Pick-to: 6.1 Change-Id: I94b9f3db3b3ce3d82445cf66788c05854b441aaf Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix rearranging of icons in listview via drag'n'dropVolker Hilsheimer2021-06-081-0/+2
| | | | | | | | | | | | | | | | | | | | Since 0f1008a5936c903ca9448193df7df6117e2c617b, views record if they moved the item in the model, and prevent the deletion of the source item in QAbstractItemView by setting the dropEventMoved private data member. However, QListView in icon mode is special: it doesn't rearrange the model, it repositions the icons in the view. While the dropEventMoved logic was applied to the drag event filter to prevent deletion, the variable was never set in the filterDropEvent handler. The drop event got ignored, breaking rearranging of icons. Fix this by setting the dropEventMoved member in filterDropEvent. Fixes: QTBUG-94226 Pick-to: 5.15 6.1 Change-Id: I963f5db0f81bcd0d25eef05d9a265be00a5871f6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* QAItemView: in MultiSelection, press deselects only if no drag can startVolker Hilsheimer2021-06-081-3/+10
| | | | | | | | | | | | | | | | | | | | In MultiSelection mode, items are by default toggled on press, which follows the example of standard Windows controls. However, when dragging is enabled, then the press might be the beginning of a drag'n'drop operation, and deselecting the item on press breaks the selection and user experience. Don't toggle the selection for presses on an already selected item that might get dragged; instead, wait for the release event. Extend the test case slightly to cover the special case. Dragging a selection in a drag-enabled and MultiSelection item view wasn't possible before either. Fixes: QTBUG-59888 Change-Id: Ibd3e95a71ea63dd1e9bc3c8a723eafa9a1c21afa Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* QAbstractItemView: don't toggle extended selection on Ctrl+PressVolker Hilsheimer2021-06-071-0/+9
| | | | | | | | | | | | | | | | | | | In ExtendedSelection mode, a Ctrl+Press might be both the start of a selection toggle, or the start of a Ctrl+Drag operation. If we already toggle on the press, then it's impossible to drag the existing selection while the Control key is pressed. Ignore Ctrl+Press events and let the corresponding release event toggle the selection. Adjust the relevant test cases accordingly. The QItemDelegate test case used a click+control event incorrectly, such an event doesn't change the clicked state and should not be eaten, and now it does change the selection, so fix the test. Task-number: QTBUG-59888 Change-Id: Ia76126e31c28bc97d3e93e54965bdb1d0b8ac6a4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QAbstractItemView: Don't change selection if editor ate release eventVolker Hilsheimer2021-06-071-1/+2
| | | | | | | | | If a QItemDelegate implementation eats a release event (which they don't do by default), then don't change the selection. Task-number: QTBUG-59888 Change-Id: Ia08637627ce1da34ff9bdac63dfc72e5f53befac Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QAbstractItemView: don't block dragging after double clickVolker Hilsheimer2021-06-033-3/+7
| | | | | | | | | | | | | | | | | | | | | After d6551fe12520 it was no longer possible to start a drag with a double click (where the first click selects an item, and the second press+move starts the drag). Resetting the pressedItem variable to block the emission of the clicked() signal had this unwanted side effect. Instead, use an explicit boolean to store that the next release event will be the result of a double click, so that the clicked() signal is not emitted again (preventing the double-emission was the purpose of change d6551fe12520). Task-number: QTBUG-77771 Fixes: QTBUG-94087 Pick-to: 6.1 5.15 Change-Id: I082c5169d89eb980dcd7985ef3d302b6ff060fb9 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Olivier BARTHELEMY <perso.olivier.barthelemy@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix PageDown behavior and PageUPTang Haixiang2021-05-311-14/+39
| | | | | | | | | | | | | When the PageDown is pressed, the current's rect cannot be used to match the item, because we don't know the size of the rect. Move the rect by the height of the viewport, and then move the rect upwards until it matches the button <= viewport's bottom of the item Fixes: QTBUG-92583 Pick-to: 6.1 Change-Id: I210edc0e8b942984f3fc20e7752c6e1315152ea1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-1/+1
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Add missing prepositionPaul Wicking2021-05-251-2/+2
| | | | | | | Fixes: QTBUG-93969 Pick-to: 6.1 Change-Id: I60e08ab7f17459b6cff969767273228a8406cfc3 Reviewed-by: Johanna Vanhatapio <johanna.vanhatapio@qt.io>
* Check scrollbar visibility when computing QListView marginsChen Bin2021-05-111-1/+1
| | | | | | | | | | | | | | | | | When the listview setWordWrap is true and ScrollBarPolicy is ScrollBarAsNeeded, if the text needs a newline display and the vbar is not shown, the width of the item was subtracted from the width of the scrollbar. In most cases, the listview needs to reserve the size of the scrollbar. But if the flow is TopToBottom and the vertical scrollbar is not visible, the width of the vertical scrollbar cannot be reserved. Fixes: QTBUG-92366 Pick-to: 5.15 6.0 6.1 Change-Id: I73cce691099a253d409019dbb3fe9a16e1830bb1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* ItemViews: don't delete dragged items when a subclass accepted the moveVolker Hilsheimer2021-05-013-12/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends 0f1008a5936c903ca9448193df7df6117e2c617b, which introduced the dropEventMoved private data member through which the drop-site itemview can notify the drag-site that the drop handler has taken care of the move operation. However, if a subclass of an item view overrides dropEvent to move and accept the event before calling the default implementation, then the flag would not be set, as the dropOn helper would return false. So QAbstractItemView still removed the item, resulting in two items being removed when one was move-dropped. Set the dropEventMoved member also when the QTreeWidget::dropEvent handler is called by a subclass override and the event is already accepted. This way, overrides don't have to artifically set the accepted action to "IgnoreAction" to disable the handling in drag site. [ChangeLog][QtWidgets][QAbstractItemView] Classes overriding dropEvent for MoveAction events to move data can call accept() on the event before calling the superclass to prevent QAbstractItemView from deleting the source item. Task-number: QTBUG-87057 Task-number: QTBUG-77427 Pick-to: 6.1 Change-Id: Ibe75fc1b2ca60627c825ad9b9b6d48953577edec Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix typo in a comment, PE_PanelViewItemRow doesn't existSérgio Martins2021-04-271-1/+1
| | | | | | Change-Id: I25897ec093aca38081745eff329ec3d042bc02c5 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix QTreeModel calling beginRemoveRows twiceLuca Beldi2021-04-261-11/+7
| | | | | | | | | | | | | For items that are children of other items, removeRows calls beginRemoveRows directly and then once again inside takeChild() The signal blocker that dates back to the monolitic import from Nokia prevents the model from emitting extra signals but the persistent indexes are corrupted nonetheless. Fixes: QTBUG-90030 Pick-to: 6.1 6.0 5.15 Change-Id: I5bc4b2598bf13247683b113faeec22471f1f04a4 Reviewed-by: David Faure <david.faure@kdab.com>
* Document parameter correctly, fix qdoc warningVolker Hilsheimer2021-04-131-1/+1
| | | | | | | | | Not needed in 6.1, the method is still (incorrectly) marked as \internal there. Change-Id: Idf1d924d8d320eca2388dbd28006eeaf9efedc3a Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
* QTable/ListView: mark functions as reimp instead internalChristian Ehrlicher2021-04-022-6/+6
| | | | | | | | | Some public accessible functions were wrongly marked as \internal instead \reimp. Change-Id: I6196427fc1b6535f6725107a00be82ab4cc821c3 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix the crashes when animated QTreeWidgetItems are hiddenQiang Li2021-03-081-1/+3
| | | | | | | | | | | | | | | | | | QTreeView's drawTree implementation performs lazy layouting when calling itemDecorationAt. If animations are enabled, this can change the list of items, and invalidate the copy made earlier. Don't copy the list of items, use a reference instead so that code iterating over the items later operates on valid data. Add an assert in the private itemHeight method, it must not be called with an index that is out of bounds. Fixes: QTBUG-42469 Pick-to: 6.0 6.1 5.15 Change-Id: Ifdb782881447912e00baffd1c407de10a1d8d0d4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAbstractFileIconProvider: Use platform theme iconsFriedemann Kleint2021-02-211-9/+1
| | | | | | | | Add code paths to use platform theme icons should icon themes fail. Task-number: QTBUG-66177 Change-Id: I9554637f5230b1f57faaeef6b2c04cf082271edb 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>