[vlmc-devel] Move Library to Core

Hugo Beauzée-Luyssen git at videolan.org
Fri Mar 4 17:14:18 CET 2016


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Mar  4 11:43:25 2016 +0100| [b2f6f3679987146ad8ba4c45dfc6a88f186e910c] | committer: Hugo Beauzée-Luyssen

Move Library to Core

> https://code.videolan.org/videolan/vlmc/commit/b2f6f3679987146ad8ba4c45dfc6a88f186e910c
---

 src/Gui/MainWindow.cpp              |  2 +-
 src/Gui/import/ImportController.cpp |  4 ++--
 src/Gui/library/MediaLibrary.cpp    |  6 ++----
 src/Gui/library/MediaListView.cpp   |  2 +-
 src/Gui/timeline/TracksView.cpp     |  2 +-
 src/Main/Core.cpp                   | 14 ++++++++++++--
 src/Main/Core.h                     |  4 +++-
 src/Project/Project.cpp             | 13 -------------
 src/Project/Project.h               |  4 +---
 src/Workflow/MainWorkflow.cpp       |  2 +-
 10 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index eb61e7d..3e482db 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -865,7 +865,7 @@ MainWindow::onProjectLoading(Project* project)
     m_undoView->setStack( Core::getInstance()->undoStack() );
 
     const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
-    connect( project->library(), SIGNAL( clipRemoved( const QUuid& ) ), clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
+    connect( Core::getInstance()->library(), SIGNAL( clipRemoved( const QUuid& ) ), clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
 
     m_projectPreview->setRenderer( Core::getInstance()->workflowRenderer() );
 }
diff --git a/src/Gui/import/ImportController.cpp b/src/Gui/import/ImportController.cpp
index 633c3d4..6c7857e 100644
--- a/src/Gui/import/ImportController.cpp
+++ b/src/Gui/import/ImportController.cpp
@@ -157,7 +157,7 @@ void
 ImportController::importMedia( const QString &filePath )
 {
     vlmcDebug() << "Importing" << filePath;
-    if ( Core::getInstance()->currentProject()->library()->mediaAlreadyLoaded( filePath ) == true ||
+    if ( Core::getInstance()->library()->mediaAlreadyLoaded( filePath ) == true ||
          m_temporaryMedias->mediaAlreadyLoaded( filePath ) == true )
         return ;
 
@@ -242,7 +242,7 @@ ImportController::accept()
     {
         if ( clip->getMedia()->source()->length() == 0 )
             invalidMedias = true;
-        Core::getInstance()->currentProject()->library()->addClip( clip );
+        Core::getInstance()->library()->addClip( clip );
     }
     if ( invalidMedias == true )
         handleInvalidMedias();
diff --git a/src/Gui/library/MediaLibrary.cpp b/src/Gui/library/MediaLibrary.cpp
index 29c3fcd..1e2a18f 100644
--- a/src/Gui/library/MediaLibrary.cpp
+++ b/src/Gui/library/MediaLibrary.cpp
@@ -167,8 +167,6 @@ MediaLibrary::dropEvent( QDropEvent *event )
         return;
     }
 
-    Q_ASSERT( Core::getInstance()->currentProject()->library() != NULL );
-
     foreach ( const QUrl &url, fileList )
     {
         const QString       &fileName = url.toLocalFile();
@@ -176,13 +174,13 @@ MediaLibrary::dropEvent( QDropEvent *event )
         if ( fileName.isEmpty() )
             continue;
 
-        Media       *media = Core::getInstance()->currentProject()->library()->addMedia( fileName );
+        Media       *media = Core::getInstance()->library()->addMedia( fileName );
 
         if ( media != NULL )
         {
             Clip*       clip = new Clip( media );
             media->setBaseClip( clip );
-            Core::getInstance()->currentProject()->library()->addClip( clip );
+            Core::getInstance()->library()->addClip( clip );
             event->accept();
         }
         else
diff --git a/src/Gui/library/MediaListView.cpp b/src/Gui/library/MediaListView.cpp
index 25d2385..38ba9f9 100644
--- a/src/Gui/library/MediaListView.cpp
+++ b/src/Gui/library/MediaListView.cpp
@@ -65,7 +65,7 @@ MediaListView::newClipLoaded( Clip *clip )
 void
 MediaListView::projectLoading( Project* project )
 {
-    setMediaContainer( project->library() );
+    setMediaContainer( Core::getInstance()->library() );
 }
 
 void
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 5f805b5..9559808 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -375,7 +375,7 @@ void
 TracksView::clipDragEnterEvent( QDragEnterEvent *event )
 {
     const QString fullId = QString( event->mimeData()->data( "vlmc/uuid" ) );
-    Clip *clip = Core::getInstance()->currentProject()->library()->clip( fullId );
+    Clip *clip = Core::getInstance()->library()->clip( fullId );
     if ( clip == NULL )
         return;
     bool hasVideo = clip->getMedia()->source()->hasVideo();
diff --git a/src/Main/Core.cpp b/src/Main/Core.cpp
index ae3757b..908e78e 100644
--- a/src/Main/Core.cpp
+++ b/src/Main/Core.cpp
@@ -35,12 +35,13 @@
 
 #include <Backend/IBackend.h>
 #include <EffectsEngine/EffectsEngine.h>
-#include <Settings/Settings.h>
-#include <Tools/VlmcLogger.h>
+#include "Library/Library.h"
 #include "Project/AutomaticBackup.h"
 #include "Project/RecentProjects.h"
 #include "Project/Workspace.h"
 #include "Renderer/WorkflowRenderer.h"
+#include <Settings/Settings.h>
+#include <Tools/VlmcLogger.h>
 #include "Workflow/MainWorkflow.h"
 
 Core::Core()
@@ -57,15 +58,18 @@ Core::Core()
     m_workflow = new MainWorkflow;
     m_workflowRenderer = new WorkflowRenderer( Backend::getBackend(), m_workflow );
     m_undoStack = new QUndoStack;
+    m_library = new Library( m_workspace );
 
     //FIXME: This requires that we always have a project instance, which is the plan, but is broken for now
     connect( m_undoStack, SIGNAL( cleanChanged( bool ) ), m_currentProject, SLOT( cleanChanged( bool ) ) );
     connect( m_currentProject, SIGNAL( projectSaved() ), m_undoStack, SLOT( setClean() ) );
+    connect( m_library, SIGNAL( cleanStateChanged( bool ) ), m_currentProject, SLOT( libraryCleanChanged( bool ) ) );
 }
 
 Core::~Core()
 {
     m_settings->save();
+    delete m_library;
     delete m_undoStack;
     delete m_workflowRenderer;
     delete m_workflow;
@@ -207,6 +211,12 @@ Core::undoStack()
     return m_undoStack;
 }
 
+Library*
+Core::library()
+{
+    return m_library;
+}
+
 Core*
 Core::getInstance()
 {
diff --git a/src/Main/Core.h b/src/Main/Core.h
index 130b27b..2d6d78e 100644
--- a/src/Main/Core.h
+++ b/src/Main/Core.h
@@ -25,6 +25,7 @@
 
 class AutomaticBackup;
 class EffectsEngine;
+class Library;
 class MainWorkflow;
 class NotificationZone;
 class Project;
@@ -59,7 +60,7 @@ class Core : public QObject
         WorkflowRenderer*       workflowRenderer();
         MainWorkflow*           workflow();
         QUndoStack*             undoStack();
-
+        Library*                library();
 
         bool                    loadProject( const QString& fileName );
         bool                    newProject( const QString& projectName, const QString& projectPath );
@@ -97,6 +98,7 @@ class Core : public QObject
         MainWorkflow*           m_workflow;
         WorkflowRenderer*       m_workflowRenderer;
         QUndoStack*             m_undoStack;
+        Library*                m_library;
 };
 
 #endif // CORE_H
diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index f7e2762..3ce5409 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -27,7 +27,6 @@
 
 #include "AutomaticBackup.h"
 #include "Backend/IBackend.h"
-#include "Library/Library.h"
 #include "Project.h"
 #include "ProjectCallbacks.h"
 #include "RecentProjects.h"
@@ -51,7 +50,6 @@ Project::Project( QFile* projectFile )
     m_isClean = projectFile->fileName().endsWith( Project::backupSuffix ) == false;
 
     m_settings = new Settings( QString() );
-    m_library = new Library( Core::getInstance()->workspace() );
     initSettings();
     connectComponents();
     load();
@@ -65,7 +63,6 @@ Project::Project( const QString& projectName, const QString& projectPath )
     , m_projectManagerUi( NULL )
 {
     m_settings = new Settings( QString() );
-    m_library = new Library( Core::getInstance()->workspace() );
     initSettings();
     connectComponents();
     m_projectFile = new QFile( projectPath + "/project.vlmc" );
@@ -78,16 +75,9 @@ Project::~Project()
     Q_ASSERT( m_projectFile != NULL );
 
     delete m_projectFile;
-    delete m_library;
     delete m_settings;
 }
 
-Library*
-Project::library()
-{
-    return m_library;
-}
-
 Settings*
 Project::settings()
 {
@@ -135,13 +125,10 @@ Project::load()
 void
 Project::connectComponents()
 {
-    connect( m_library, SIGNAL( cleanStateChanged( bool ) ),
-             this, SLOT( libraryCleanChanged( bool ) ) );
     //We have to wait for the library to be loaded before loading the workflow
     //FIXME
     //connect( Core::getInstance()->currentProject()->library(), SIGNAL( projectLoaded() ), this, SLOT( loadWorkflow() ) );
     registerLoadSave( m_settings );
-    registerLoadSave( m_library );
 }
 
 void
diff --git a/src/Project/Project.h b/src/Project/Project.h
index 564d5ff..74007f9 100644
--- a/src/Project/Project.h
+++ b/src/Project/Project.h
@@ -90,7 +90,7 @@ class Project : public QObject
         void                newProject( const QString& projectName, const QString& projectPath );
 
 
-    private slots:
+    public slots:
         void                cleanChanged( bool val );
         void                libraryCleanChanged( bool val );
         void                projectNameChanged( const QVariant& projectName );
@@ -138,11 +138,9 @@ class Project : public QObject
     ///////////////////////////////////
     // Dependent components part below:
     public:
-        Library*            library();
         Settings*           settings();
 
     private:
-        Library*            m_library;
         Settings*           m_settings;
 };
 
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 41d6613..da9e47a 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -290,7 +290,7 @@ MainWorkflow::load(const QDomDocument& root )
                     return false;
                 }
 
-                Clip* c = Core::getInstance()->currentProject()->library()->clip( uuid );
+                Clip* c = Core::getInstance()->library()->clip( uuid );
                 if ( c != NULL )
                 {
                     ClipHelper  *ch = new ClipHelper( c, begin.toLongLong(),



More information about the Vlmc-devel mailing list