[vlmc-devel] MediaListView: Watch project events when applicable

Hugo Beauzée-Luyssen git at videolan.org
Tue Apr 1 00:13:29 CEST 2014


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Apr  1 00:58:58 2014 +0300| [9720e9a97684fc89c2e9f6c8f720465b300740d8] | committer: Hugo Beauzée-Luyssen

MediaListView: Watch project events when applicable

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=9720e9a97684fc89c2e9f6c8f720465b300740d8
---

 src/Gui/import/ImportController.cpp |    3 ++-
 src/Gui/library/MediaLibrary.cpp    |    8 ++++++-
 src/Gui/library/MediaLibrary.h      |    3 +++
 src/Gui/library/MediaListView.cpp   |   42 +++++++++++++++++++++++------------
 src/Gui/library/MediaListView.h     |    6 ++++-
 5 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/src/Gui/import/ImportController.cpp b/src/Gui/import/ImportController.cpp
index de93a96..7a4a37f 100644
--- a/src/Gui/import/ImportController.cpp
+++ b/src/Gui/import/ImportController.cpp
@@ -62,7 +62,8 @@ ImportController::ImportController(QWidget *parent) :
     m_ui->previewContainer->setRenderer( m_clipRenderer );
     m_stackNav = new StackViewController( m_ui->stackViewContainer );
     m_temporaryMedias = new MediaContainer;
-    m_mediaListView = new MediaListView( m_stackNav, m_temporaryMedias );
+    m_mediaListView = new MediaListView( m_stackNav );
+    m_mediaListView->setMediaContainer( m_temporaryMedias );
 //    m_tag = new TagWidget( m_ui->tagContainer, 6 );
     m_filesModel = new QFileSystemModel( this );
     m_stackNav->pushViewController( m_mediaListView );
diff --git a/src/Gui/library/MediaLibrary.cpp b/src/Gui/library/MediaLibrary.cpp
index abf9c86..0c6b290 100644
--- a/src/Gui/library/MediaLibrary.cpp
+++ b/src/Gui/library/MediaLibrary.cpp
@@ -42,7 +42,7 @@ MediaLibrary::MediaLibrary(QWidget *parent) : QWidget(parent),
     setAcceptDrops( true );
 
     StackViewController *nav = new StackViewController( m_ui->mediaListContainer );
-    m_mediaListView = new MediaListView( nav, Project::getInstance()->library() );
+    m_mediaListView = new MediaListView( nav );
     nav->pushViewController( m_mediaListView );
 
     connect( m_ui->importButton, SIGNAL( clicked() ),
@@ -58,6 +58,12 @@ MediaLibrary::MediaLibrary(QWidget *parent) : QWidget(parent),
 }
 
 void
+MediaLibrary::setMediaContainer( MediaContainer* container )
+{
+
+}
+
+void
 MediaLibrary::changeEvent( QEvent *e )
 {
     QWidget::changeEvent( e );
diff --git a/src/Gui/library/MediaLibrary.h b/src/Gui/library/MediaLibrary.h
index f611bca..8c7141e 100644
--- a/src/Gui/library/MediaLibrary.h
+++ b/src/Gui/library/MediaLibrary.h
@@ -28,6 +28,7 @@
 #include "ui_MediaLibrary.h"
 class   Clip;
 class   MediaListView;
+class   MediaContainer;
 class   ViewController;
 
 class MediaLibrary : public QWidget
@@ -38,6 +39,8 @@ class MediaLibrary : public QWidget
     public:
         typedef bool    (*Filter)( const Clip*, const QString& filter );
         explicit MediaLibrary( QWidget *parent = 0);
+        void        setMediaContainer( MediaContainer* container );
+
 
     protected:
         void        dragEnterEvent( QDragEnterEvent *event );
diff --git a/src/Gui/library/MediaListView.cpp b/src/Gui/library/MediaListView.cpp
index 4230b68..25d2385 100644
--- a/src/Gui/library/MediaListView.cpp
+++ b/src/Gui/library/MediaListView.cpp
@@ -24,25 +24,19 @@
 
 #include "Media/Clip.h"
 #include "MediaCellView.h"
-#include "Library/MediaContainer.h"
+#include "Library/Library.h"
+#include "Main/Core.h"
+#include "Project/Project.h"
 #include "StackViewController.h"
 
 #include <QApplication>
 
-MediaListView::MediaListView( StackViewController *nav, MediaContainer *mc ) :
+MediaListView::MediaListView(StackViewController *nav) :
         ListViewController( nav ),
-        m_nav( nav ),
-        m_mediaContainer( mc )
+        m_nav( nav )
 {
-    connect( mc, SIGNAL( newClipLoaded( Clip* ) ),
-             this, SLOT( newClipLoaded( Clip* ) ) );
-    connect( this, SIGNAL( clipRemoved( const QUuid& ) ),
-             mc, SLOT( deleteClip( const QUuid& ) ) );
-    connect( mc, SIGNAL( clipRemoved( const QUuid& ) ),
-             this, SLOT( __clipRemoved( const QUuid& ) ) );
-    connect( mc, SIGNAL( destroyed() ), this, SLOT( deleteLater() ) );
-    foreach ( Clip *clip, mc->clips() )
-        newClipLoaded( clip );
+    connect( Core::getInstance(), SIGNAL( projectLoading( Project* ) ),
+             this, SLOT( projectLoading( Project* ) ) );
 }
 
 MediaListView::~MediaListView()
@@ -69,6 +63,12 @@ MediaListView::newClipLoaded( Clip *clip )
 }
 
 void
+MediaListView::projectLoading( Project* project )
+{
+    setMediaContainer( project->library() );
+}
+
+void
 MediaListView::cellSelection( const QUuid &uuid )
 {
     if ( m_currentUuid == uuid )
@@ -117,7 +117,9 @@ void
 MediaListView::showSubClips( const QUuid &uuid )
 {
     Clip    *clip = m_mediaContainer->clip( uuid );
-    m_nav->pushViewController( new MediaListView( m_nav, clip->getChilds() ) );
+    MediaListView* view = new MediaListView( m_nav );
+    view->setMediaContainer( clip->getChilds() );
+    m_nav->pushViewController( view );
 }
 
 const MediaListView::MediaList&
@@ -125,3 +127,15 @@ MediaListView::mediaList() const
 {
     return m_cells;
 }
+
+void
+MediaListView::setMediaContainer( MediaContainer* container )
+{
+    m_mediaContainer = container;
+    connect( m_mediaContainer, SIGNAL( newClipLoaded( Clip* ) ),
+             this, SLOT( newClipLoaded( Clip* ) ) );
+    connect( this, SIGNAL( clipRemoved( const QUuid& ) ),
+             m_mediaContainer, SLOT( deleteClip( const QUuid& ) ) );
+    connect( m_mediaContainer, SIGNAL( clipRemoved( const QUuid& ) ),
+             this, SLOT( __clipRemoved( const QUuid& ) ) );
+}
diff --git a/src/Gui/library/MediaListView.h b/src/Gui/library/MediaListView.h
index e4930e0..1bd3c45 100644
--- a/src/Gui/library/MediaListView.h
+++ b/src/Gui/library/MediaListView.h
@@ -33,6 +33,7 @@ class   Clip;
 class   Media;
 class   MediaContainer;
 class   MediaCellView;
+class   Project;
 class   StackViewController;
 
 class   QWidget;
@@ -44,10 +45,11 @@ class MediaListView : public ListViewController
 public:
     typedef     QHash<QUuid, MediaCellView*>    MediaList;
 
-    MediaListView( StackViewController *nav, MediaContainer *mc );
+    MediaListView( StackViewController *nav );
     virtual ~MediaListView();
 
     const MediaList                 &mediaList() const;
+    void                            setMediaContainer( MediaContainer* container );
 
 private:
     StackViewController             *m_nav;
@@ -71,6 +73,8 @@ private slots:
     void        __clipRemoved( const QUuid& );
     void        newClipLoaded( Clip *clip );
 
+    void        projectLoading( Project* project );
+
 signals:
     void        clipSelected( Clip* );
     /// Used when the user clicks the deletion arrow.



More information about the Vlmc-devel mailing list