From ffdbac71c6379880cab6cf75ecc91948f0caf438 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 23 Aug 2007 10:41:53 +0000 Subject: [PATCH] hopefully fix the keyboard navigation svn path=/trunk/KDE/kdegraphics/okular/; revision=703795 --- ui/sidebar.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/ui/sidebar.cpp b/ui/sidebar.cpp index 81df8b0fb..044d9f62d 100644 --- a/ui/sidebar.cpp +++ b/ui/sidebar.cpp @@ -229,8 +229,54 @@ void SidebarListWidget::mouseReleaseEvent( QMouseEvent *event ) QModelIndex SidebarListWidget::moveCursor( QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) { + Q_UNUSED( modifiers ) QModelIndex oldindex = currentIndex(); - QModelIndex newindex = QListWidget::moveCursor( cursorAction, modifiers ); + QModelIndex newindex = oldindex; + switch ( cursorAction ) + { + case MoveUp: + case MovePrevious: + { + int row = oldindex.row() - 1; + while ( row > -1 && !( model()->index( row, 0 ).flags() & Qt::ItemIsSelectable ) ) --row; + if ( row > -1 ) + newindex = model()->index( row, 0 ); + break; + } + case MoveDown: + case MoveNext: + { + int row = oldindex.row() + 1; + int max = model()->rowCount(); + while ( row < max && !( model()->index( row, 0 ).flags() & Qt::ItemIsSelectable ) ) ++row; + if ( row < max ) + newindex = model()->index( row, 0 ); + break; + } + case MoveHome: + case MovePageUp: + { + int row = 0; + while ( row < oldindex.row() && !( model()->index( row, 0 ).flags() & Qt::ItemIsSelectable ) ) ++row; + if ( row < oldindex.row() ) + newindex = model()->index( row, 0 ); + break; + } + case MoveEnd: + case MovePageDown: + { + int row = model()->rowCount() - 1; + while ( row > oldindex.row() && !( model()->index( row, 0 ).flags() & Qt::ItemIsSelectable ) ) --row; + if ( row > oldindex.row() ) + newindex = model()->index( row, 0 ); + break; + } + // no navigation possible for these + case MoveLeft: + case MoveRight: + break; + } + // dirty hack to change item when the key cursor changes item if ( oldindex != newindex ) {