summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qtableview.cpp6
-rw-r--r--src/widgets/itemviews/qtableview_p.h3
2 files changed, 4 insertions, 5 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 384a34d5a1..d1793a3049 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -3410,7 +3410,7 @@ void QTableViewPrivate::selectRow(int row, bool anchor)
selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
if ((anchor && !(command & QItemSelectionModel::Current))
|| (q->selectionMode() == QTableView::SingleSelection))
- rowSectionAnchor = row;
+ currentSelectionStartIndex = model->index(row, column, root);
if (q->selectionMode() != QTableView::SingleSelection
&& command.testFlag(QItemSelectionModel::Toggle)) {
@@ -3423,6 +3423,7 @@ void QTableViewPrivate::selectRow(int row, bool anchor)
command |= QItemSelectionModel::Current;
}
+ const auto rowSectionAnchor = currentSelectionStartIndex.row();
QModelIndex upper = model->index(qMin(rowSectionAnchor, row), column, root);
QModelIndex lower = model->index(qMax(rowSectionAnchor, row), column, root);
if ((verticalHeader->sectionsMoved() && upper.row() != lower.row())) {
@@ -3449,7 +3450,7 @@ void QTableViewPrivate::selectColumn(int column, bool anchor)
selectionModel->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
if ((anchor && !(command & QItemSelectionModel::Current))
|| (q->selectionMode() == QTableView::SingleSelection))
- columnSectionAnchor = column;
+ currentSelectionStartIndex = model->index(row, column, root);
if (q->selectionMode() != QTableView::SingleSelection
&& command.testFlag(QItemSelectionModel::Toggle)) {
@@ -3462,6 +3463,7 @@ void QTableViewPrivate::selectColumn(int column, bool anchor)
command |= QItemSelectionModel::Current;
}
+ const auto columnSectionAnchor = currentSelectionStartIndex.column();
QModelIndex left = model->index(row, qMin(columnSectionAnchor, column), root);
QModelIndex right = model->index(row, qMax(columnSectionAnchor, column), root);
if ((horizontalHeader->sectionsMoved() && left.column() != right.column())) {
diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h
index 2b110f18a0..23095c0087 100644
--- a/src/widgets/itemviews/qtableview_p.h
+++ b/src/widgets/itemviews/qtableview_p.h
@@ -136,7 +136,6 @@ class QTableViewPrivate : public QAbstractItemViewPrivate
public:
QTableViewPrivate()
: showGrid(true), gridStyle(Qt::SolidLine),
- rowSectionAnchor(-1), columnSectionAnchor(-1),
columnResizeTimerID(0), rowResizeTimerID(0),
horizontalHeader(nullptr), verticalHeader(nullptr),
sortingEnabled(false), geometryRecursionBlock(false),
@@ -186,8 +185,6 @@ public:
bool showGrid;
Qt::PenStyle gridStyle;
- int rowSectionAnchor;
- int columnSectionAnchor;
int columnResizeTimerID;
int rowResizeTimerID;
QList<int> columnsToUpdate;