[vlc-devel] commit: Qt: unify item activation among PL views, change title when browsing in iconView (Jakob Leben )

git version control git at videolan.org
Wed Jan 27 14:27:42 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Wed Jan 27 13:52:08 2010 +0100| [83717d05d9b7ba14dca6c4761fe185faac1a87bb] | committer: Jakob Leben 

Qt: unify item activation among PL views, change title when browsing in iconView

Also delay view creation in constructor after the title label has been created

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=83717d05d9b7ba14dca6c4761fe185faac1a87bb
---

 modules/gui/qt4/components/playlist/icon_view.cpp  |   14 -----
 modules/gui/qt4/components/playlist/icon_view.hpp  |    2 -
 .../gui/qt4/components/playlist/standardpanel.cpp  |   51 +++++++++++++-------
 .../gui/qt4/components/playlist/standardpanel.hpp  |    1 +
 4 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/icon_view.cpp b/modules/gui/qt4/components/playlist/icon_view.cpp
index f07b25f..0c35264 100644
--- a/modules/gui/qt4/components/playlist/icon_view.cpp
+++ b/modules/gui/qt4/components/playlist/icon_view.cpp
@@ -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 );
-    }
 }
diff --git a/modules/gui/qt4/components/playlist/icon_view.hpp b/modules/gui/qt4/components/playlist/icon_view.hpp
index 9819eb0..1d73384 100644
--- a/modules/gui/qt4/components/playlist/icon_view.hpp
+++ b/modules/gui/qt4/components/playlist/icon_view.hpp
@@ -47,8 +47,6 @@ class PlIconView : public QListView
 
 public:
     PlIconView( PLModel *model, QWidget *parent = 0 );
-public slots:
-    void activate( const QModelIndex & index );
 };
 
 #endif
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 9b96215..d1f7993 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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 );
+    }
+}
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index 0da499e..02efce4 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -98,6 +98,7 @@ private slots:
     void popupPlView( const QPoint & );
     void toggleColumnShown( int );
     void toggleView();
+    void activate( const QModelIndex & );
 };
 
 #endif




More information about the vlc-devel mailing list