]> git.sesse.net Git - vlc/commitdiff
Qt: return playlist model and views to "now playing" root if current root is deleted
authorJakob Leben <jleben@videolan.org>
Wed, 10 Feb 2010 07:27:42 +0000 (08:27 +0100)
committerJakob Leben <jleben@videolan.org>
Wed, 10 Feb 2010 10:07:39 +0000 (11:07 +0100)
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/playlist_model.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index d2fba6f06cd3205be52bec5fb974675c8322b2d1..6c6272f454edb573d1d15ecac918ec89601b54b8 100644 (file)
@@ -700,9 +700,6 @@ void PLModel::removeItem( PLItem *item )
     if( item->i_id == i_cached_id ) i_cached_id = -1;
     i_cached_input_id = -1;
 
-    if(item == rootItem)
-        rootItem = NULL;
-
     if( item->parentItem ) {
         int i = item->parentItem->children.indexOf( item );
         beginRemoveRows( index( item->parentItem, 0), i, i );
@@ -712,6 +709,12 @@ void PLModel::removeItem( PLItem *item )
     }
     else delete item;
 
+    if(item == rootItem)
+    {
+        rootItem = NULL;
+        rebuild( p_playlist->p_playing );
+        emit rootChanged();
+    }
 }
 
 /* This function must be entered WITH the playlist lock */
index 9e368478bb84b631c80396d6afe8df4ef666db1f..cb5e68c3e04766c9ee682acc8f9eeaa6b6c192c5 100644 (file)
@@ -150,6 +150,7 @@ private:
 
 signals:
     void currentChanged( const QModelIndex& );
+    void rootChanged();
 
 public slots:
     void activateItem( const QModelIndex &index );
index d26cc6482b5ebc7fb2c79281ad7dcd4e0471cc71..4d073a439e866bf1c2a3104df37552528ea281bd 100644 (file)
@@ -79,6 +79,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
 
     locationBar = new LocationBar( model );
     layout->addWidget( locationBar, 0, 0 );
+    CONNECT( model, rootChanged(), locationBar, setRootIndex() );
 
     /* A Spacer and the search possibilities */
     layout->setColumnStretch( 1, 10 );
@@ -499,6 +500,11 @@ void LocationBar::setIndex( const QModelIndex &index )
     }
 }
 
+void LocationBar::setRootIndex()
+{
+    setIndex( QModelIndex() );
+}
+
 void LocationBar::invoke( int i_id )
 {
     QModelIndex index = model->index( i_id, 0 );
index dd868b2621059e18187a6945656fb617d4f6592d..dd5aebfe8fb4c6c5ce1b51a25c16fd304065a886 100644 (file)
@@ -118,6 +118,8 @@ public:
     void setIndex( const QModelIndex & );
 signals:
     void invoked( const QModelIndex & );
+public slots:
+    void setRootIndex();
 private slots:
     void invoke( int i_item_id );
 private:
@@ -129,13 +131,13 @@ private:
 
 class LocationButton : public QPushButton
 {
-  public:
-      LocationButton( const QString &, bool bold, bool arrow );
-  private:
-      void paintEvent ( QPaintEvent * event );
-      QSize sizeHint() const;
-      QFontMetrics *metrics;
-      bool b_arrow;
+public:
+    LocationButton( const QString &, bool bold, bool arrow );
+private:
+    void paintEvent ( QPaintEvent * event );
+    QSize sizeHint() const;
+    QFontMetrics *metrics;
+    bool b_arrow;
 };
 
 #endif