QTableView: fix dropping between items when precisely on the cell border
There's a one-pixel horizontal line between two cells where indexAt(pos) returns a valid index and visualRect(index) doesn't contain pos, because of the 1 pixel cell border. So this code (whose origin predates public git history) would turn the valid index into the root index, leading to an unexpected append instead of insert. The only other case I could find where this condition happened was when dropping onto the branches of a QTreeView, but even there it seems much more expected to drop on the item (or between items) than on the viewport (which often means append at the very bottom, far from the drop area). Change-Id: Ia7c884d3fc925a7536ea3ab75851366c531d8438 Fixes: QTBUG-130045 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> (cherry picked from commit f9336a05bccaf8d287f949e3263e07f2e437835c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e87795850e
commit
dcea42ea5d
@ -2222,7 +2222,7 @@ bool QAbstractItemViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *drop
|
||||
// rootIndex() (i.e. the viewport) might be a valid index
|
||||
if (viewport->rect().contains(event->position().toPoint())) {
|
||||
index = q->indexAt(event->position().toPoint());
|
||||
if (!index.isValid() || !q->visualRect(index).contains(event->position().toPoint()))
|
||||
if (!index.isValid())
|
||||
index = root;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user