[vlmc-devel] Workspace: Kill old media media copying code

Hugo Beauzée-Luyssen git at videolan.org
Thu Aug 18 22:57:04 CEST 2016


vlmc | branch: medialibrary | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Aug 18 22:21:59 2016 +0200| [c4f577c898eae1b3a67fa4cf96dd2a544c201ce1] | committer: Hugo Beauzée-Luyssen

Workspace: Kill old media media copying code

It hasn't been tested for ages, and isn't aligned with our current goal
of using the medialibrary.

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

 src/Project/Workspace.cpp | 104 ----------------------------------------------
 src/Project/Workspace.h   |  11 -----
 2 files changed, 115 deletions(-)

diff --git a/src/Project/Workspace.cpp b/src/Project/Workspace.cpp
index ca5f095..0203638 100644
--- a/src/Project/Workspace.cpp
+++ b/src/Project/Workspace.cpp
@@ -33,118 +33,14 @@
 #include "Settings/Settings.h"
 #include "Tools/VlmcDebug.h"
 
-#include "Project/WorkspaceWorker.h"
-
-#include <QMutex>
-
-#ifdef HAVE_GUI
-# include <QMessageBox>
-#endif
-
 const QString   Workspace::workspacePrefix = "workspace://";
 
 Workspace::Workspace(Settings *settings)
-    : m_copyInProgress( false )
 {
     SettingValue* workspaceDir = settings->createVar( SettingValue::String, "vlmc/Workspace", "",
                                                       "", "", SettingValue::Private );
     connect(workspaceDir, SIGNAL( changed( QVariant ) ),
             this, SLOT( workspaceChanged( QVariant ) ) );
-    // Wait for the SettingValue to be loaded.
-    m_mediasToCopyMutex = new QMutex;
-}
-
-Workspace::~Workspace()
-{
-    delete m_mediasToCopyMutex;
-}
-
-bool
-Workspace::copyToWorkspace( Media *media )
-{
-    if ( m_workspaceDir.isEmpty() )
-    {
-        setError( "There is no current workspace. Please create a project first.");
-        return false;
-    }
-    QMutexLocker    lock( m_mediasToCopyMutex );
-
-    if ( m_copyInProgress == true )
-    {
-        m_mediasToCopy.enqueue( media );
-    }
-    else
-    {
-        vlmcDebug() << "Copying media:" << media->fileInfo()->absoluteFilePath() << "to workspace.";
-        m_copyInProgress = true;
-        Q_ASSERT( this->isInWorkspace( media ) == false );
-        startCopyWorker( media );
-    }
-    return true;
-}
-
-void
-Workspace::startCopyWorker( Media *media )
-{
-    const QString   dest = m_workspaceDir + '/' + media->fileInfo()->fileName();
-
-    if ( QFile::exists( dest ) == true )
-    {
-#ifdef HAVE_GUI
-        QMessageBox::StandardButton b =
-                QMessageBox::question( nullptr, tr( "File already exists!" ),
-                                       tr( "A file with the same name already exists, do you want to "
-                                           "overwrite it?" ),
-                                       QMessageBox::Yes | QMessageBox::No,
-                                       QMessageBox::No );
-        if ( b == QMessageBox::No )
-            copyTerminated( media, dest );
-#else
-        copyTerminated( media, dest );
-#endif
-    }
-    WorkspaceWorker *worker = new WorkspaceWorker( media, dest );
-    //This one is direct connected since the thread is terminated just after emitting the signal.
-    connect( worker, SIGNAL( copied( Media*, QString ) ),
-             this, SLOT( copyTerminated( Media*, QString ) ), Qt::DirectConnection );
-    worker->start();
-}
-
-void
-Workspace::clipLoaded( Clip *clip )
-{
-    //Don't bother if the clip is a subclip.
-    if ( clip->isRootClip() == false )
-        return ;
-    //If already in workspace : well...
-    if ( isInWorkspace( clip->media() ) == true )
-        return ;
-    copyToWorkspace( clip->media() );
-}
-
-void
-Workspace::copyTerminated( Media *media, QString dest )
-{
-    emit notify( tr( "Workspace: " ) + media->fileInfo()->fileName() + tr( " copied to " ) + dest );
-
-    media->setFilePath( dest );
-    media->disconnect( this );
-
-    QMutexLocker    lock( m_mediasToCopyMutex );
-    if ( m_mediasToCopy.size() > 0 )
-    {
-        while ( m_mediasToCopy.size() > 0 )
-        {
-            Media   *toCopy = m_mediasToCopy.dequeue();
-            if ( isInWorkspace( media ) == true )
-            {
-                startCopyWorker( toCopy );
-                break ;
-            }
-        }
-    }
-    else
-        m_copyInProgress = false;
 }
 
 void
diff --git a/src/Project/Workspace.h b/src/Project/Workspace.h
index e149fe4..0bf0573 100644
--- a/src/Project/Workspace.h
+++ b/src/Project/Workspace.h
@@ -24,11 +24,9 @@
 #define WORKSPACE_H
 
 #include <QObject>
-#include <QQueue>
 
 #include "Tools/ErrorHandler.h"
 
-class   QMutex;
 class   QFileInfo;
 
 class   Clip;
@@ -43,24 +41,15 @@ class Workspace : public QObject, public ErrorHandler
         static const QString        workspacePrefix;
 
         Workspace( Settings* settings );
-        ~Workspace();
         bool                        isInWorkspace( const QString &path );
         bool                        isInWorkspace( const Media *media );
 
-        bool                        copyToWorkspace( Media* media );
     private:
-        void                        startCopyWorker( Media *media );
         bool                        isInWorkspace( const QFileInfo &fInfo );
     private:
-        QQueue<Media*>              m_mediasToCopy;
-        QMutex                      *m_mediasToCopyMutex;
-        bool                        m_copyInProgress;
         QString                     m_workspaceDir;
 
-    public slots:
-        void                        clipLoaded( Clip* clip );
     private slots:
-        void                        copyTerminated( Media* media, QString dest );
         void                        workspaceChanged( const QVariant& newWorkspace );
 
     signals:



More information about the Vlmc-devel mailing list