diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2016-03-22 11:59:56 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2016-03-23 15:12:04 +0000 |
commit | fce83bd9f84883f93829e6ca9eacf098b018a02d (patch) | |
tree | 286d52ea7adeb86c64ee1109ada3bdddd9eed7b2 /src/widgets/itemviews | |
parent | 2119b86db25fac3165c562f9d40e5874de824c80 (diff) |
QAbstractItemView: trigger handlers (and redraw) when changing selection model
The most visible problem is that changing selection model didn't update()
the view, resulting in the old selection/current item still being drawn.
In general trigger the handlers for when the selection/current item
changes.
Change-Id: Ib3b2ad70412e6a21a182d4c173e617710bcc630d
Task-number: QTBUG-50535
Reviewed-by: Stephen Kelly <ske@ableton.com>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index a126fef65e..251b09ce7d 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -765,7 +765,13 @@ void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel) return; } + QItemSelection oldSelection; + QModelIndex oldCurrentIndex; + if (d->selectionModel) { + oldSelection = d->selectionModel->selection(); + oldCurrentIndex = d->selectionModel->currentIndex(); + disconnect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection))); disconnect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), @@ -779,6 +785,9 @@ void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel) this, SLOT(selectionChanged(QItemSelection,QItemSelection))); connect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex))); + + selectionChanged(d->selectionModel->selection(), oldSelection); + currentChanged(d->selectionModel->currentIndex(), oldCurrentIndex); } } |