]> git.sesse.net Git - vlc/commitdiff
qt4: keep selected popup item visible when sorting
authorIlkka Ollakka <ileoo@videolan.org>
Sun, 28 Mar 2010 14:41:59 +0000 (17:41 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Sun, 28 Mar 2010 15:59:36 +0000 (18:59 +0300)
Still could be better to leave selected item as selected after sorting.

modules/gui/qt4/components/playlist/playlist_model.cpp

index 0c4f57f14c97dcd1fb86ca01cfcef0607de8be51..d1a7ac4187483f631432f655e45510f47f316ae3 100644 (file)
@@ -864,6 +864,15 @@ void PLModel::sort( int i_root_id, int column, Qt::SortOrder order )
         endInsertRows( );
     }
     PL_UNLOCK;
+    /* if we have popup item, try to make sure that you keep that item visible */
+    if( i_popup_item > -1 )
+    {
+        PLItem *popupitem = findById( rootItem, i_popup_item );
+        if( popupitem ) emit currentChanged( index( popupitem, 0 ) );
+        /* reset i_popup_item as we don't show it as selected anymore anyway */
+        i_popup_item = -1;
+    }
+    else if( currentIndex().isValid() ) emit currentChanged( currentIndex() );
 }
 
 void PLModel::search( const QString& search_text, const QModelIndex & idx, bool b_recursive )