Skip to content

Commit

Permalink
[ui] Fix unmet expectation: when navigating the browser panel via key…
Browse files Browse the repository at this point in the history
…board, hitting return/enter should load focused dataset
  • Loading branch information
nirvn committed Oct 11, 2021
1 parent 768b69c commit f774de9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/gui/auto_generated/qgsbrowsertreeview.sip.in
Expand Up @@ -48,6 +48,11 @@ Returns the browser model

void setSettingsSection( const QString &section );

protected:

virtual void keyPressEvent( QKeyEvent *event );


protected slots:
virtual void rowsInserted( const QModelIndex &parentIndex, int start, int end );

Expand Down
10 changes: 10 additions & 0 deletions src/gui/qgsbrowsertreeview.cpp
Expand Up @@ -20,6 +20,8 @@
#include "qgsguiutils.h"
#include "qgsdataitem.h"

#include <QKeyEvent>

QgsBrowserTreeView::QgsBrowserTreeView( QWidget *parent )
: QTreeView( parent )
, mSettingsSection( QStringLiteral( "browser" ) )
Expand All @@ -28,6 +30,14 @@ QgsBrowserTreeView::QgsBrowserTreeView( QWidget *parent )
setIndentation( QgsGuiUtils::scaleIconSize( 16 ) );
}

void QgsBrowserTreeView::keyPressEvent( QKeyEvent *event )
{
if ( event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter )
emit doubleClicked( currentIndex() );
else
QTreeView::keyPressEvent( event );
}

void QgsBrowserTreeView::setModel( QAbstractItemModel *model )
{

Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsbrowsertreeview.h
Expand Up @@ -51,6 +51,10 @@ class GUI_EXPORT QgsBrowserTreeView : public QTreeView
// Set section where to store settings (because we have 2 browser dock widgets)
void setSettingsSection( const QString &section ) { mSettingsSection = section; }

protected:

void keyPressEvent( QKeyEvent *event ) override;

protected slots:
void rowsInserted( const QModelIndex &parentIndex, int start, int end ) override;

Expand Down

0 comments on commit f774de9

Please sign in to comment.