[vlc-commits] commit: Qt: use QStackedLayout for playlist views (Jakob Leben )

git at videolan.org git at videolan.org
Tue Apr 6 12:51:01 CEST 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Tue Apr  6 11:51:25 2010 +0200| [40969236e471223f172e07982534d310a6842782] | committer: Jakob Leben 

Qt: use QStackedLayout for playlist views

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

 .../gui/qt4/components/playlist/standardpanel.cpp  |   25 ++++++-------------
 .../gui/qt4/components/playlist/standardpanel.hpp  |    2 +
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 84da46c..6dcf065 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -47,6 +47,7 @@
 #include <QToolButton>
 #include <QFontMetrics>
 #include <QPainter>
+#include <QStackedLayout>
 
 #include <assert.h>
 
@@ -69,6 +70,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     iconView = NULL;
     treeView = NULL;
     listView = NULL;
+    viewStack = new QStackedLayout();
+    layout->addLayout( viewStack, 1, 0, 1, -1 );
 
     model = new PLModel( p_playlist, p_intf, p_root, this );
     currentRootId = -1;
@@ -271,7 +274,7 @@ void StandardPLPanel::createIconView()
     CONNECT( iconView, activated( const QModelIndex & ),
              this, activate( const QModelIndex & ) );
     iconView->installEventFilter( this );
-    layout->addWidget( iconView, 1, 0, 1, -1 );
+    viewStack->addWidget( iconView );
 }
 
 void StandardPLPanel::createListView()
@@ -283,7 +286,7 @@ void StandardPLPanel::createListView()
     CONNECT( listView, activated( const QModelIndex & ),
              this, activate( const QModelIndex & ) );
     listView->installEventFilter( this );
-    layout->addWidget( listView, 1, 0, 1, -1 );
+    viewStack->addWidget( listView );
 }
 
 
@@ -346,7 +349,7 @@ void StandardPLPanel::createTreeView()
              this, toggleColumnShown( int ) );
 
     /* Finish the layout */
-    layout->addWidget( treeView, 1, 0, 1, -1 );
+    viewStack->addWidget( treeView );
 }
 
 void StandardPLPanel::showView( int i_view )
@@ -357,40 +360,28 @@ void StandardPLPanel::showView( int i_view )
     {
         if( treeView == NULL )
             createTreeView();
-        if( iconView ) iconView->hide();
-        if( listView ) listView->hide();
-        treeView->show();
         currentView = treeView;
-        viewActions[i_view]->setChecked( true );
         break;
     }
     case ICON_VIEW:
     {
         if( iconView == NULL )
             createIconView();
-
-        if( treeView ) treeView->hide();
-        if( listView ) listView->hide();
-        iconView->show();
         currentView = iconView;
-        viewActions[i_view]->setChecked( true );
         break;
     }
     case LIST_VIEW:
     {
         if( listView == NULL )
             createListView();
-
-        if( treeView ) treeView->hide();
-        if( iconView ) iconView->hide();
-        listView->show();
         currentView = listView;
-        viewActions[i_view]->setChecked( true );
         break;
     }
     default: return;
     }
 
+    viewStack->setCurrentWidget( currentView );
+    viewActions[i_view]->setChecked( true );
     browseInto();
     gotoPlayingItem();
 }
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index ab1cd03..a340330 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -45,6 +45,7 @@ class PLModel;
 class QPushButton;
 class QKeyEvent;
 class QWheelEvent;
+class QStackedLayout;
 class PlIconView;
 class PlListView;
 class LocationBar;
@@ -82,6 +83,7 @@ private:
     PlIconView  *iconView;
     PlListView  *listView;
     QAbstractItemView *currentView;
+    QStackedLayout *viewStack;
 
     QAction *viewActions[ VIEW_COUNT ];
     QAction *iconViewAction, *treeViewAction;



More information about the vlc-commits mailing list