hopefully fix the keyboard navigation

svn path=/trunk/KDE/kdegraphics/okular/; revision=703795
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 01ec727681
commit ffdbac71c6
  1. 48
      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 )
{

Loading…
Cancel
Save