mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
selection: update selection on key-presses
Commit 2cea115ddb
"fixed" the selection
by hooking into mouseRelease events. An unintended consequence was
that scrolling with the cursor keys didn't update the current dive.
Therefore, also hook into the corresponding key-press events.
This is just horrible, but I'm not aware of any possibility to fix
it properly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
d6114fc37e
commit
2b3dc019db
2 changed files with 14 additions and 0 deletions
|
@ -554,6 +554,19 @@ void DiveListView::mouseReleaseEvent(QMouseEvent *event)
|
|||
selectionChangeDone();
|
||||
}
|
||||
|
||||
void DiveListView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
// Hook into cursor-up and cursor-down events and update selection if necessary.
|
||||
// See comment in mouseReleaseEvent()
|
||||
if (event->key() != Qt::Key_Down && event->key() != Qt::Key_Up)
|
||||
return QTreeView::keyPressEvent(event);
|
||||
QModelIndexList selectionBefore = selectionModel()->selectedRows();
|
||||
QTreeView::keyPressEvent(event);
|
||||
QModelIndexList selectionAfter = selectionModel()->selectedRows();
|
||||
if (selectionBefore != selectionAfter)
|
||||
selectionChangeDone();
|
||||
}
|
||||
|
||||
void DiveListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)
|
||||
{
|
||||
// We hook into QTreeView's setSelection() to update the UI
|
||||
|
|
|
@ -66,6 +66,7 @@ slots:
|
|||
private:
|
||||
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void selectAll() override;
|
||||
void selectionChangeDone();
|
||||
DiveTripModelBase::Layout currentLayout;
|
||||
|
|
Loading…
Add table
Reference in a new issue