+PLSelItem * putSDData( PLSelItem* item, const char* name, const char* longname )
+{
+ item->treeItem()->setData( 0, NAME_ROLE, qfu( name ) );
+ item->treeItem()->setData( 0, LONGNAME_ROLE, qfu( longname ) );
+ return item;
+}
+
+PLSelItem * putPLData( PLSelItem* item, playlist_item_t* plItem )
+{
+ item->treeItem()->setData( 0, PL_ITEM_ROLE, QVariant::fromValue( plItem ) );
+/* item->setData( 0, PL_ITEM_ID_ROLE, plItem->i_id );
+ item->setData( 0, IN_ITEM_ROLE, QVariant::fromValue( (void*) plItem->p_input ) ); );*/
+ return item;
+}
+
+void PLSelector::createItems()
+{
+ /* PL */
+ PLSelItem *pl = putPLData( addItem( PL_ITEM_TYPE, "Playlist", true ),
+ THEPL->p_playing );
+ pl->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PL ) );
+
+ /* ML */
+ PLSelItem *ml = putPLData( addItem( PL_ITEM_TYPE, "Media Library", true ),
+ THEPL->p_media_library );
+ ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) );
+
+ /* SD nodes */
+ QTreeWidgetItem *mycomp = addItem( CATEGORY_TYPE, "My Computer" )->treeItem();
+ QTreeWidgetItem *devices = addItem( CATEGORY_TYPE, "Devices" )->treeItem();
+ QTreeWidgetItem *lan = addItem( CATEGORY_TYPE, "Local Network" )->treeItem();
+ QTreeWidgetItem *internet = addItem( CATEGORY_TYPE, "Internet" )->treeItem();
+
+ /* SD subnodes */
+ char **ppsz_longnames;
+ int *p_categories;
+ char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames, &p_categories );
+ if( !ppsz_names )
+ return;
+
+ char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
+ int *p_category = p_categories;
+ for( ; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++ )
+ {
+ //msg_Dbg( p_intf, "Adding a SD item: %s", *ppsz_longname );
+
+ PLSelItem *selItem;
+ switch( *p_category )
+ {
+ case SD_CAT_INTERNET:
+ {
+ selItem = addItem( SD_TYPE, *ppsz_longname, false, internet );
+ if( !strncmp( *ppsz_name, "podcast", 7 ) )
+ {
+ selItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PODCAST ) );
+ selItem->addAction( ADD_ACTION, qtr( "Subscribe to a podcast" ) );
+ CONNECT( selItem, action( PLSelItem* ), this, podcastAdd( PLSelItem* ) );
+ podcastsParent = selItem->treeItem();
+ }
+ }
+ break;
+ case SD_CAT_DEVICES:
+ selItem = addItem( SD_TYPE, *ppsz_longname, false, devices );
+ break;
+ case SD_CAT_LAN:
+ selItem = addItem( SD_TYPE, *ppsz_longname, false, lan );
+ break;
+ case SD_CAT_MYCOMPUTER:
+ selItem = addItem( SD_TYPE, *ppsz_longname, false, mycomp );
+ break;
+ default:
+ selItem = addItem( SD_TYPE, *ppsz_longname );
+ }
+
+ putSDData( selItem, *ppsz_name, *ppsz_longname );
+ free( *ppsz_name );
+ free( *ppsz_longname );
+ }
+ free( ppsz_names );
+ free( ppsz_longnames );
+ free( p_categories );
+
+ if( mycomp->childCount() == 0 ) delete mycomp;
+ if( devices->childCount() == 0 ) delete devices;
+ if( lan->childCount() == 0 ) delete lan;
+ if( internet->childCount() == 0 ) delete internet;
+}
+