Skip to content
Permalink
Browse files

Slightly improved keyboard navigation in variable editor

  • Loading branch information
nyalldawson committed Sep 14, 2015
1 parent 0a60bab commit d0813410c13c1ca0427bcdc1986d0e0bdf2788b5
Showing with 34 additions and 0 deletions.
  1. +32 −0 src/gui/qgsvariableeditorwidget.cpp
  2. +2 −0 src/gui/qgsvariableeditorwidget.h
@@ -585,6 +585,38 @@ void QgsVariableEditorTree::editNext( const QModelIndex& index )
}
}

QModelIndex QgsVariableEditorTree::moveCursor( QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers )
{
if ( cursorAction == QAbstractItemView::MoveNext )
{
QModelIndex index = currentIndex();
if ( index.isValid() )
{
if ( index.column() + 1 < model()->columnCount() )
return index.sibling( index.row(), index.column() + 1 );
else if ( index.row() + 1 < model()->rowCount( index.parent() ) )
return index.sibling( index.row() + 1, 0 );
else
return QModelIndex();
}
}
else if ( cursorAction == QAbstractItemView::MovePrevious )
{
QModelIndex index = currentIndex();
if ( index.isValid() )
{
if ( index.column() >= 1 )
return index.sibling( index.row(), index.column() - 1 );
else if ( index.row() >= 1 )
return index.sibling( index.row() - 1, model()->columnCount() - 1 );
else
return QModelIndex();
}
}

return QTreeWidget::moveCursor( cursorAction, modifiers );
}

void QgsVariableEditorTree::keyPressEvent( QKeyEvent *event )
{
switch ( event->key() )
@@ -186,6 +186,8 @@ class QgsVariableEditorTree : public QTreeWidget
void toggleContextExpanded( QTreeWidgetItem *item );
void editNext( const QModelIndex &index );

QModelIndex moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) override;

static QIcon mExpandIcon;

private:

0 comments on commit d081341

Please sign in to comment.
You can’t perform that action at this time.