[vlc-commits] FIXME: try to fix cycleViews PL/ML switching

Jean-Baptiste Kempf git at videolan.org
Mon May 9 11:06:00 CEST 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue May  3 02:51:45 2011 +0200| [555c8fb0a100ede3a199000fd43b5b65ac8e5ac1] | committer: Jean-Baptiste Kempf

FIXME: try to fix cycleViews PL/ML switching

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 .../gui/qt4/components/playlist/standardpanel.cpp  |   18 ++++++++++++++++--
 .../gui/qt4/components/playlist/standardpanel.hpp  |    2 ++
 modules/gui/qt4/components/playlist/views.cpp      |    4 ----
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 1753003..aab6879 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -28,8 +28,9 @@
 
 #include "components/playlist/standardpanel.hpp"
 
+#include "components/playlist/vlc_model.hpp"      /* VLCModel */
 #include "components/playlist/playlist_model.hpp" /* PLModel */
-#include "components/playlist/ml_model.hpp" /* MLModel */
+#include "components/playlist/ml_model.hpp"       /* MLModel */
 #include "components/playlist/views.hpp"          /* 3 views */
 #include "components/playlist/selector.hpp"       /* PLSelector */
 #include "menus.hpp"                              /* Popup */
@@ -314,7 +315,6 @@ void StandardPLPanel::createTreeView()
     treeView->setContextMenuPolicy( Qt::CustomContextMenu );
 
     /* setModel after setSortingEnabled(true), or the model will sort immediately! */
-    treeView->setModel( model );
 
     getSettings()->beginGroup("Playlist");
 
@@ -352,8 +352,20 @@ void StandardPLPanel::createTreeView()
     viewStack->addWidget( treeView );
 }
 
+void StandardPLPanel::changeModel( bool b_ml )
+{
+    VLCModel *mod;
+    if( b_ml )
+        mod = mlmodel;
+    else
+        mod = model;
+    if( currentView->model() != mod )
+        currentView->setModel( mod );
+}
+
 void StandardPLPanel::showView( int i_view )
 {
+
     switch( i_view )
     {
     case TREE_VIEW:
@@ -387,6 +399,8 @@ void StandardPLPanel::showView( int i_view )
     default: return;
     }
 
+    changeModel( false );
+
     viewStack->setCurrentWidget( currentView );
     browseInto();
     gotoPlayingItem();
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index bb88172..bfbc8f6 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -70,6 +70,7 @@ public:
 
     const int currentViewIndex();
 
+
 protected:
 
     PLModel *model;
@@ -98,6 +99,7 @@ private:
     void createIconView();
     void createListView();
     void createCoverView();
+    void changeModel ( bool b_ml );
     bool eventFilter ( QObject * watched, QEvent * event );
 
 public slots:
diff --git a/modules/gui/qt4/components/playlist/views.cpp b/modules/gui/qt4/components/playlist/views.cpp
index bb7d5ad..70aa3dd 100644
--- a/modules/gui/qt4/components/playlist/views.cpp
+++ b/modules/gui/qt4/components/playlist/views.cpp
@@ -287,7 +287,6 @@ PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent )
 {
     PlIconViewItemDelegate *delegate = new PlIconViewItemDelegate( this );
 
-    setModel( model );
     setViewMode( QListView::IconMode );
     setMovement( QListView::Static );
     setResizeMode( QListView::Adjust );
@@ -316,7 +315,6 @@ void PlIconView::dragMoveEvent ( QDragMoveEvent * event )
 
 PlListView::PlListView( PLModel *model, QWidget *parent ) : QListView( parent )
 {
-    setModel( model );
     setViewMode( QListView::ListMode );
     setUniformItemSizes( true );
     setSelectionMode( QAbstractItemView::ExtendedSelection );
@@ -383,8 +381,6 @@ PicFlowView::PicFlowView( PLModel *p_model, QWidget *parent ) : QAbstractItemVie
     picFlow->setSlideSize(QSize(128,128));
     layout->addWidget( picFlow );
     setSelectionMode( QAbstractItemView::SingleSelection );
-    setModel( p_model );
-
 }
 
 int PicFlowView::horizontalOffset() const



More information about the vlc-commits mailing list