]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/selector.cpp
vlc_sd_GetNames: add object parameter
[vlc] / modules / gui / qt4 / components / playlist / selector.cpp
index edd05914051de0e57c71c71c8601215fb92a6021..61f6ab74b973874b0e3cafcf7798223d3659e94d 100644 (file)
@@ -33,6 +33,7 @@
 #include "qt4.hpp"
 #include "../../dialogs_provider.hpp"
 #include "playlist.hpp"
+#include "util/customwidgets.hpp"
 
 #include <QVBoxLayout>
 #include <QHeaderView>
 #include <vlc_services_discovery.h>
 
 PLSelItem::PLSelItem ( QTreeWidgetItem *i, const QString& text )
-    : qitem(i), btnAction( NULL )
+    : qitem(i), lblAction( NULL)
 {
     layout = new QHBoxLayout();
     layout->setContentsMargins(0,0,0,0);
+    layout->addSpacing( 3 );
 
     lbl = new QLabel( text );
-    lbl->setMargin(3);
-    layout->addWidget(lbl);
+
+    layout->addWidget(lbl, 1);
 
     setLayout( layout );
+
+    setMinimumHeight( 22 ); //Action icon height plus 6
 }
 
 void PLSelItem::addAction( ItemAction act, const QString& tooltip )
 {
-    if( btnAction ) return;
+    if( lblAction ) return; //might change later
+
+    QIcon icon;
 
     switch( act )
     {
     case ADD_ACTION:
-        btnAction = new QPushButton("+"); break;
+        icon = QIcon( ":/buttons/playlist/playlist_add" ); break;
     case RM_ACTION:
-        btnAction = new QPushButton("-"); break;
+        icon = QIcon( ":/buttons/playlist/playlist_remove" ); break;
     }
-    if( !tooltip.isEmpty() ) btnAction->setToolTip( tooltip );
-    btnAction->setMaximumWidth(23);
 
-    layout->addWidget( btnAction );
-    btnAction->hide();
+    lblAction = new QVLCIconLabel( icon );
+
+    if( !tooltip.isEmpty() ) lblAction->setToolTip( tooltip );
+
+    layout->addWidget( lblAction, 0 );
+    lblAction->hide();
+    layout->addSpacing( 3 );
 
-    CONNECT( btnAction, clicked(), this, triggerAction() );
+    CONNECT( lblAction, clicked(), this, triggerAction() );
 }
 
-void PLSelItem::showAction() { if( btnAction ) btnAction->show(); }
+void PLSelItem::showAction() { if( lblAction ) lblAction->show(); }
 
-void PLSelItem::hideAction() { if( btnAction ) btnAction->hide(); }
+void PLSelItem::hideAction() { if( lblAction ) lblAction->hide(); }
 
 void PLSelItem::setText( const QString& text ) { lbl->setText( text ); }
 
@@ -89,18 +98,13 @@ void PLSelItem::leaveEvent( QEvent *ev ){ hideAction(); }
 PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
            : QTreeWidget( p ), p_intf(_p_intf)
 {
-    /* custom QItemDelegate just to assure the minimum row height,
-       which otherwise fails when new child item is inserted */
     setFrameStyle( QFrame::NoFrame );
     viewport()->setAutoFillBackground( false );
     setIconSize( QSize( 24,24 ) );
     setIndentation( 10 );
     header()->hide();
-    //setHeaderLabel( qtr( "Medias" ) );
-    //header()->setMovable( false );
     setRootIsDecorated( false );
     setAlternatingRowColors( false );
-    setItemDelegate( new PLSelectorDelegate() );
     podcastsParent = NULL;
     podcastsParentId = -1;
 
@@ -108,11 +112,9 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
     setDropIndicatorShown(true);
     invisibleRootItem()->setFlags( invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled );
 
-    plEM = new PlaylistEventManager( THEPL );
-
-    CONNECT( plEM, itemAdded( int, int ),
+    CONNECT( THEMIM, playlistItemAppended( int, int ),
              this, plItemAdded( int, int ) );
-    CONNECT( plEM, itemRemoved( int ),
+    CONNECT( THEMIM, playlistItemRemoved( int ),
              this, plItemRemoved( int ) );
     CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
             this, inputItemUpdate( input_item_t * ) );
@@ -131,8 +133,6 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
 
 PLSelector::~PLSelector()
 {
-    delete plEM;
-
     if( podcastsParent )
     {
         int c = podcastsParent->childCount();
@@ -255,7 +255,7 @@ void PLSelector::createItems()
     msrc->setExpanded( true );
 
     char **ppsz_longnames;
-    char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
+    char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames );
     if( !ppsz_names )
         return;
 
@@ -463,4 +463,5 @@ void PLSelector::podcastRemove( PLSelItem* item )
 PLSelItem * PLSelector::itemWidget( QTreeWidgetItem *item )
 {
     return ( static_cast<PLSelItem*>( QTreeWidget::itemWidget( item, 0 ) ) );
-}
\ No newline at end of file
+}
+