[vlc-commits] Qt: export PLModel in the main struct

Jean-Baptiste Kempf git at videolan.org
Sun Oct 9 23:35:35 CEST 2011


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Oct  7 18:25:52 2011 +0200| [a8bf114168e22da27e28b6b4473c11ec8a57bc28] | committer: Jean-Baptiste Kempf

Qt: export PLModel in the main struct

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

 modules/gui/qt4/components/playlist/playlist.cpp   |    2 +-
 .../gui/qt4/components/playlist/playlist_model.hpp |   13 +++++++++++++
 modules/gui/qt4/qt4.cpp                            |    4 ++++
 modules/gui/qt4/qt4.hpp                            |    9 ++++++---
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 7193040..296d117 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -94,7 +94,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     setMinimumWidth( 400 );
 
-    PLModel *model = new PLModel( p_playlist, p_intf, p_root, this );
+    PLModel *model = PLModel::getPLModel( p_intf );
 #ifdef MEDIA_LIBRARY
     MLModel *mlmodel = new MLModel( p_intf, this );
     mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, mlmodel );
diff --git a/modules/gui/qt4/components/playlist/playlist_model.hpp b/modules/gui/qt4/components/playlist/playlist_model.hpp
index d1bf758..4fc4109 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.hpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.hpp
@@ -56,6 +56,19 @@ public:
              playlist_item_t *, QObject *parent = 0 );
     virtual ~PLModel();
 
+    static PLModel* getPLModel( intf_thread_t *p_intf )
+    {
+        if(!p_intf->p_sys->pl_model )
+        {
+            playlist_Lock( THEPL );
+            playlist_item_t *p_root = THEPL->p_playing;
+            playlist_Unlock( THEPL );
+            p_intf->p_sys->pl_model = new PLModel( THEPL, p_intf, p_root, NULL );
+        }
+
+        return p_intf->p_sys->pl_model;
+    }
+
     /*** QModel subclassing ***/
 
     /* Data structure */
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index c8a32b7..b1b3e15 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -356,6 +356,7 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
     intf_sys_t *p_sys = p_intf->p_sys = new intf_sys_t;
     p_intf->p_sys->b_isDialogProvider = isDialogProvider;
     p_sys->p_mi = NULL;
+    p_sys->pl_model = NULL;
 
     /* */
     vlc_sem_init (&ready, 0);
@@ -555,6 +556,9 @@ static void *Thread( void *obj )
     /* Delete the configuration. Application has to be deleted after that. */
     delete p_intf->p_sys->mainSettings;
 
+    /* */
+    delete p_intf->p_sys->pl_model;
+
     /* Destroy the MainInputManager */
     MainInputManager::killInstance();
 
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index 6d0ce5f..3e904e8 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -53,22 +53,25 @@ class QVLCApp;
 class QMenu;
 class MainInterface;
 class QSettings;
+class PLModel;
 
 struct intf_sys_t
 {
     vlc_thread_t thread;
 
     QVLCApp *p_app;          /* Main Qt Application */
+
     MainInterface *p_mi;     /* Main Interface, NULL if DialogProvider Mode */
 
     QSettings *mainSettings; /* Qt State settings not messing main VLC ones */
 
-    bool b_isDialogProvider; /* Qt mode or Skins mode */
-
-    int  i_screenHeight;     /* Detection of Small screens */
+    PLModel *pl_model;
 
     QString filepath;        /* Last path used in dialogs */
 
+    int  i_screenHeight;     /* Detection of Small screens */
+
+    bool b_isDialogProvider; /* Qt mode or Skins mode */
 #ifdef WIN32
     bool disable_volume_keys;
 #endif



More information about the vlc-commits mailing list