qt4: use longname to search activated input-item
authorIlkka Ollakka <ileoo@iki.fi>
Sun, 25 Oct 2009 12:36:06 +0000 (14:36 +0200)
committerIlkka Ollakka <ileoo@iki.fi>
Sun, 25 Oct 2009 12:36:42 +0000 (14:36 +0200)
Should fix #3112 and maybe make it littlebit cleaner (hopefully)

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

index 42076f9..7bb9cd3 100644 (file)
@@ -82,23 +82,21 @@ void PLSelector::setSource( QTreeWidgetItem *item )
         if( !playlist_IsServicesDiscoveryLoaded( THEPL, qtu( qs ) ) )
         {
             playlist_ServicesDiscoveryAdd( THEPL, qtu( qs ) );
-#warning FIXME
-            playlist_item_t *pl_item =
-                    THEPL->p_root_category->pp_children[THEPL->p_root_category->i_children-1];
-            item->setData( 0, PPL_ITEM_ROLE, QVariant::fromValue( pl_item ) );
 
-            emit activated( pl_item );
-            return;
         }
     }
 
     if( i_type == SD_TYPE )
         msg_Dbg( p_intf, "SD already loaded, reloading" );
 
+    playlist_Lock( THEPL );
     playlist_item_t *pl_item =
-            item->data( 0, PPL_ITEM_ROLE ).value<playlist_item_t *>();
+            playlist_ChildSearchName( THEPL->p_root_onelevel, qtu( item->data(0, LONGNAME_ROLE ).toString() ) );
+    playlist_Unlock( THEPL );
     if( pl_item )
             emit activated( pl_item );
+    else
+            msg_Info( p_intf, "no node found for %s", qtu( item->data(0, LONGNAME_ROLE ).toString() ) );
 }
 
 void PLSelector::createItems()
@@ -135,6 +133,7 @@ void PLSelector::createItems()
         sd_item = new QTreeWidgetItem( QStringList( qfu(*ppsz_longname) ) );
         sd_item->setData( 0, TYPE_ROLE, SD_TYPE );
         sd_item->setData( 0, NAME_ROLE, qfu( *ppsz_name ) );
+        sd_item->setData( 0, LONGNAME_ROLE, qfu( *ppsz_longname ) );
         sd_item->setFlags( sd_item->flags() & ~Qt::ItemIsDropEnabled );
         sds->addChild( sd_item );
         free( *ppsz_name );
index f0471a3..758b35e 100644 (file)
@@ -48,6 +48,7 @@ enum {
     TYPE_ROLE = Qt::UserRole,
     PPL_ITEM_ROLE,
     NAME_ROLE,
+    LONGNAME_ROLE,
 };
 
 Q_DECLARE_METATYPE( playlist_item_t *);