[vlc-commits] Qt: MLModel creation and assignation

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 00:23:37 2011 +0200| [677d037919253b1c8c63f545c9aa8c9895625008] | committer: Jean-Baptiste Kempf

Qt: MLModel creation and assignation

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

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

 modules/gui/qt4/components/playlist/playlist.cpp   |    4 +-
 .../gui/qt4/components/playlist/standardpanel.cpp  |   52 ++++++++++++-------
 .../gui/qt4/components/playlist/standardpanel.hpp  |    4 +-
 3 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 24fff93..e8ec882 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -30,6 +30,7 @@
 #include "components/playlist/standardpanel.hpp"  /* MainView */
 #include "components/playlist/selector.hpp"       /* PLSelector */
 #include "components/playlist/playlist_model.hpp" /* PLModel */
+#include "components/playlist/ml_model.hpp"       /* MLModel */
 #include "components/interface_widgets.hpp"       /* CoverArtLabel */
 
 #include "util/searchlineedit.hpp"
@@ -93,7 +94,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     setMinimumWidth( 400 );
 
     PLModel *model = new PLModel( p_playlist, p_intf, p_root, this );
-    mainView = new StandardPLPanel( this, p_intf, p_root, selector, model );
+    MLModel *mlmodel = new MLModel( p_intf, this );
+    mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, mlmodel );
 
     /* Location Bar */
     locationBar = new LocationBar( model );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 54189c3..1753003 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -29,6 +29,7 @@
 #include "components/playlist/standardpanel.hpp"
 
 #include "components/playlist/playlist_model.hpp" /* PLModel */
+#include "components/playlist/ml_model.hpp" /* MLModel */
 #include "components/playlist/views.hpp"          /* 3 views */
 #include "components/playlist/selector.hpp"       /* PLSelector */
 #include "menus.hpp"                              /* Popup */
@@ -53,9 +54,11 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
                                   intf_thread_t *_p_intf,
                                   playlist_item_t *p_root,
                                   PLSelector *_p_selector,
-                                  PLModel *_p_model )
+                                  PLModel *_p_model,
+                                  MLModel *_p_plmodel)
                 : QWidget( _parent ), p_intf( _p_intf ),
-                  p_selector( _p_selector ), model( _p_model )
+                  p_selector( _p_selector ), model( _p_model ),
+                  mlmodel( _p_plmodel)
 {
     viewStack = new QStackedLayout( this );
     viewStack->setSpacing( 0 ); viewStack->setMargin( 0 );
@@ -191,10 +194,18 @@ void StandardPLPanel::searchDelayed( const QString& searchText )
 /* This activated by the selector selection */
 void StandardPLPanel::setRoot( playlist_item_t *p_item, bool b )
 {
-    if( b ) //SQLML
-        return;
-
-    model->rebuild( p_item );
+    if( b )
+    {
+        msg_Dbg( p_intf, "Setting the SQL ML" );
+        currentView->setModel( mlmodel );
+    }
+    else
+    {
+        msg_Dbg( p_intf, "Normal PL/ML or SD" );
+        if( currentView->model() != model )
+            currentView->setModel( model );
+        model->rebuild( p_item );
+    }
 }
 
 void StandardPLPanel::browseInto( const QModelIndex &index )
@@ -409,20 +420,23 @@ void StandardPLPanel::cycleViews()
 
 void StandardPLPanel::activate( const QModelIndex &index )
 {
-    /* If we are not a leaf node */
-    if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
+    if( currentView->model() == model )
     {
-        if( currentView != treeView )
-            browseInto( index );
-    }
-    else
-    {
-        playlist_Lock( THEPL );
-        playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
-        p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
-        lastActivatedId = p_item->p_input->i_id;
-        playlist_Unlock( THEPL );
-        model->activateItem( index );
+        /* If we are not a leaf node */
+        if( !index.data( PLModel::IsLeafNodeRole ).toBool() )
+        {
+            if( currentView != treeView )
+                browseInto( index );
+        }
+        else
+        {
+            playlist_Lock( THEPL );
+            playlist_item_t *p_item = playlist_ItemGetById( THEPL, model->itemId( index ) );
+            p_item->i_flags |= PLAYLIST_SUBITEM_STOP_FLAG;
+            lastActivatedId = p_item->p_input->i_id;
+            playlist_Unlock( THEPL );
+            model->activateItem( index );
+        }
     }
 }
 
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index 4520ff8..bb88172 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -37,6 +37,7 @@
 
 class QSignalMapper;
 class PLModel;
+class MLModel;
 class QKeyEvent;
 class QWheelEvent;
 class QStackedLayout;
@@ -58,7 +59,7 @@ class StandardPLPanel: public QWidget
 
 public:
     StandardPLPanel( PlaylistWidget *, intf_thread_t *,
-                     playlist_item_t *, PLSelector *, PLModel * );
+                     playlist_item_t *, PLSelector *, PLModel *, MLModel * );
     virtual ~StandardPLPanel();
 
     enum { ICON_VIEW = 0,
@@ -72,6 +73,7 @@ public:
 protected:
 
     PLModel *model;
+    MLModel *mlmodel;
     virtual void wheelEvent( QWheelEvent *e );
 private:
     intf_thread_t *p_intf;



More information about the vlc-commits mailing list