diff --git a/foldertreeview.cpp b/foldertreeview.cpp index 77780fdb1..47a5377bc 100644 --- a/foldertreeview.cpp +++ b/foldertreeview.cpp @@ -17,6 +17,7 @@ */ #include "foldertreeview.h" +#include #include FolderTreeView::FolderTreeView(QWidget *parent ) @@ -41,4 +42,33 @@ void FolderTreeView::init() { } +void FolderTreeView::selectModelIndex( const QModelIndex & index ) +{ + if ( index.isValid() ) { + clearSelection(); + scrollTo( index ); + setCurrentIndex(index); + } +} + + +void FolderTreeView::slotFocusNextFolder() +{ + QModelIndex current = currentIndex(); + if ( current.isValid() ) { + model()->fetchMore( current ); + if ( model()->hasChildren( current ) ) { + expand( current ); + QModelIndex below = indexBelow( current ); + selectModelIndex( below ); + } else if ( current.row() < model()->rowCount( model()->parent( current ) ) -1 ) { + QModelIndex item = model()->index( current.row()+1, current.column(), model()->parent( current ) ); + selectModelIndex( item ); + } else { + QModelIndex below = indexBelow( current ); + selectModelIndex( below ); + } + } +} + #include "foldertreeview.moc" diff --git a/foldertreeview.h b/foldertreeview.h index 25b9c9f7f..77a5fa62a 100644 --- a/foldertreeview.h +++ b/foldertreeview.h @@ -32,6 +32,10 @@ public: virtual ~FolderTreeView(); protected: void init(); + void selectModelIndex( const QModelIndex & ); +public slots: + void slotFocusNextFolder(); + }; diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index 30f0ec37b..79823390e 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -906,10 +906,8 @@ void KMMainWidget::createWidgets() { KAction *action = new KAction(i18n("Focus on Next Folder"), this); actionCollection()->addAction("inc_current_folder", action ); -#ifdef OLD_FOLDERVIEW connect( action, SIGNAL( triggered( bool ) ), - mMainFolderView, SLOT( slotFocusNextFolder() ) ); -#endif + mCollectionFolderView->folderTreeView(), SLOT( slotFocusNextFolder() ) ); action->setShortcut( QKeySequence( Qt::CTRL+Qt::Key_Right ) ); } {