]> git.sesse.net Git - vlc/commitdiff
Qt: reuse the SD data
authorJean-Baptiste Kempf <jb@videolan.org>
Sun, 6 Sep 2009 22:22:34 +0000 (00:22 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 6 Sep 2009 22:22:34 +0000 (00:22 +0200)
When reloading, correctly update the view.

modules/gui/qt4/components/playlist/selector.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp

index d989931eb3caf7b7fd2e32a20692d5ae76057182..9ba8c35c16646307f17971172a10729a7cf91d60 100644 (file)
@@ -77,25 +77,30 @@ void PLSelector::setSource( QTreeWidgetItem *item )
 
     int i_type = item->data( 0, Qt::UserRole ).toInt();
 
+    assert( ( i_type == PL_TYPE || i_type == ML_TYPE || i_type == SD_TYPE ) );
     if( i_type == SD_TYPE )
     {
-        QString qs = item->data( 0, Qt::UserRole + 1 ).toString();
+        QString qs = item->data( 0, Qt::UserRole + 2 ).toString();
         if( !playlist_IsServicesDiscoveryLoaded( THEPL, qtu( qs ) ) )
         {
             playlist_ServicesDiscoveryAdd( THEPL, qtu( qs ) );
 #warning FIXME
-            emit activated( THEPL->p_root_category->pp_children[THEPL->p_root_category->i_children-1] );
+            playlist_item_t *pl_item =
+                    THEPL->p_root_category->pp_children[THEPL->p_root_category->i_children-1];
+            item->setData( 0, Qt::UserRole + 1, QVariant::fromValue( pl_item ) );
+
+            emit activated( pl_item );
+            return;
         }
     }
-    else if( i_type == PL_TYPE || i_type == ML_TYPE )
-    {
-        playlist_item_t *pl_item =
-                item->data( 0, Qt::UserRole + 1 ).value<playlist_item_t *>();
-        if( pl_item )
+
+    if( i_type == SD_TYPE )
+        msg_Dbg( p_intf, "SD already loaded, reloading" );
+
+    playlist_item_t *pl_item =
+            item->data( 0, Qt::UserRole + 1 ).value<playlist_item_t *>();
+    if( pl_item )
             emit activated( pl_item );
-    }
-    else
-        assert( 0 );
 }
 
 void PLSelector::createItems()
@@ -132,7 +137,7 @@ void PLSelector::createItems()
     {
         sd_item = new QTreeWidgetItem( QStringList( *ppsz_longname ) );
         sd_item->setData( 0, Qt::UserRole, SD_TYPE );
-        sd_item->setData( 0, Qt::UserRole + 1, qfu( *ppsz_name ) );
+        sd_item->setData( 0, Qt::UserRole + 2, qfu( *ppsz_name ) );
         sds->addChild( sd_item );
     }
 }
index b1c2292a89e2032a756b7201153d8a4986198c73..5445ebde2e45f29e5541f575dc8fbc6b883653c1 100644 (file)
@@ -344,4 +344,3 @@ StandardPLPanel::~StandardPLPanel()
     getSettings()->endGroup();
 }
 
-