]> git.sesse.net Git - vlc/commitdiff
Qt: unify item activation among PL views, change title when browsing in iconView
authorJakob Leben <jleben@videolan.org>
Wed, 27 Jan 2010 12:52:08 +0000 (13:52 +0100)
committerJakob Leben <jleben@videolan.org>
Wed, 27 Jan 2010 12:52:08 +0000 (13:52 +0100)
Also delay view creation in constructor after the title label has been created

modules/gui/qt4/components/playlist/icon_view.cpp
modules/gui/qt4/components/playlist/icon_view.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index f07b25f60aea94de97d6c7c581964a9972455a9c..0c35264a7c2f041e513ffe667b45c5641d153bcf 100644 (file)
@@ -121,18 +121,4 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
 
     PlListViewItemDelegate *pl = new PlListViewItemDelegate();
     setItemDelegate( pl );
-
-    CONNECT( this, activated( const QModelIndex & ), this, activate( const QModelIndex & ) );
-}
-
-void PlIconView::activate( const QModelIndex & index )
-{
-    if( model()->hasChildren( index ) )
-        setRootIndex( index );
-    else
-    {
-        PLModel *plModel = qobject_cast<PLModel*>( model() );
-        if( !plModel ) return;
-        plModel->activateItem( index );
-    }
 }
index 9819eb08fa34507862557a9464beb9b2dac60040..1d733848c187afd0ffb7e391541087775eb55752 100644 (file)
@@ -47,8 +47,6 @@ class PlIconView : public QListView
 
 public:
     PlIconView( PLModel *model, QWidget *parent = 0 );
-public slots:
-    void activate( const QModelIndex & index );
 };
 
 #endif
index 9b96215b5f56fd6d672cb77c15f5788d54c4b530..d1f79935b36e5b1336426223755d81d9e13d8eb2 100644 (file)
@@ -65,23 +65,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     iconView = NULL;
     treeView = NULL;
 
-    /* Saved Settings */
-    getSettings()->beginGroup("Playlist");
-
-    int i_viewMode = getSettings()->value( "view-mode", TREE_VIEW ).toInt();
-    if( i_viewMode == ICON_VIEW )
-    {
-        createIconView();
-        currentView = iconView;
-    }
-    else
-    {
-        createTreeView();
-        currentView = treeView;
-    }
-
-    getSettings()->endGroup();
-
     currentRootId = -1;
 
     /* Title label */
@@ -113,6 +96,23 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     viewButton->setIcon( QIcon( ":/buttons/playlist/playlist_add" ) );
     layout->addWidget( viewButton, 0, 2 );
     BUTTONACT( viewButton, toggleView() );
+
+    /* Saved Settings */
+    getSettings()->beginGroup("Playlist");
+
+    int i_viewMode = getSettings()->value( "view-mode", TREE_VIEW ).toInt();
+    if( i_viewMode == ICON_VIEW )
+    {
+        createIconView();
+        currentView = iconView;
+    }
+    else
+    {
+        createTreeView();
+        currentView = treeView;
+    }
+
+    getSettings()->endGroup();
 }
 
 StandardPLPanel::~StandardPLPanel()
@@ -272,6 +272,8 @@ void StandardPLPanel::createIconView()
     iconView->setContextMenuPolicy( Qt::CustomContextMenu );
     CONNECT( iconView, customContextMenuRequested( const QPoint & ),
              this, popupPlView( const QPoint & ) );
+    CONNECT( iconView, activated( const QModelIndex & ),
+             this, activate( const QModelIndex & ) );
 
     layout->addWidget( iconView, 1, 0, 1, -1 );
 }
@@ -316,7 +318,7 @@ void StandardPLPanel::createTreeView()
 
     /* Connections for the TreeView */
     CONNECT( treeView, activated( const QModelIndex& ),
-             model,activateItem( const QModelIndex& ) );
+             this, activate( const QModelIndex& ) );
     CONNECT( treeView->header(), customContextMenuRequested( const QPoint & ),
              this, popupSelectColumn( QPoint ) );
     CONNECT( treeView, customContextMenuRequested( const QPoint & ),
@@ -358,3 +360,16 @@ void StandardPLPanel::wheelEvent( QWheelEvent *e )
     // Accept this event in order to prevent unwanted volume up/down changes
     e->accept();
 }
+
+void StandardPLPanel::activate( const QModelIndex &index )
+{
+    if( model->hasChildren( index ) && currentView == iconView )
+    {
+        iconView->setRootIndex( index );
+        title->setText( index.data().toString() );
+    }
+    else
+    {
+        model->activateItem( index );
+    }
+}
index 0da499eb57365d6ad9544be03b29c969e44ef8e5..02efce4a36cd8f4554a37dfec340908075949763 100644 (file)
@@ -98,6 +98,7 @@ private slots:
     void popupPlView( const QPoint & );
     void toggleColumnShown( int );
     void toggleView();
+    void activate( const QModelIndex & );
 };
 
 #endif