[vlmc-devel] commit: ProjectManager: Handle change of workspace when saving as. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Jun 27 23:06:25 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Jun 23 17:53:29 2010 +0200| [96a69981e0e3ae6df14d40acf688d7759d47aafd] | committer: Hugo Beauzée-Luyssen 

ProjectManager: Handle change of workspace when saving as.

The Workspace part isn't fully fonctionnal yet.

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

 src/Gui/project/GuiProjectManager.cpp |   42 +++++++++++++++++++++++++++++----
 src/Gui/project/GuiProjectManager.h   |    1 +
 src/Library/Library.h                 |    1 +
 src/Project/Workspace.cpp             |   32 ++++++++++++++++++++++--
 src/Project/Workspace.h               |   15 ++++++++---
 5 files changed, 79 insertions(+), 12 deletions(-)

diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index b69b040..62906aa 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -22,15 +22,16 @@
 
 #include "GuiProjectManager.h"
 
-#include <QDateTime>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QTimer>
-
 #include "Library.h"
 #include "MainWorkflow.h"
 #include "SettingsManager.h"
 #include "Timeline.h"
+#include "Workspace.h"
+
+#include <QDateTime>
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QTimer>
 
 GUIProjectManager::GUIProjectManager()
 {
@@ -91,22 +92,53 @@ GUIProjectManager::askForSaveIfModified()
 }
 
 bool
+GUIProjectManager::confirmRelocate() const
+{
+    QMessageBox msgBox;
+    msgBox.setText( tr( "You are about to relocate the project. Every video will be copied to your new workspace." ) );
+    msgBox.setInformativeText( tr( "Do you want to proceed?" ) );
+    msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::No );
+    msgBox.setDefaultButton( QMessageBox::Ok );
+    int     ret = msgBox.exec();
+
+    switch ( ret )
+    {
+    case QMessageBox::Ok:
+        return true;
+    case QMessageBox::No:
+        return false ;
+    default:
+        return false;
+    }
+}
+
+bool
 GUIProjectManager::createNewProjectFile( bool saveAs )
 {
     if ( m_projectFile == NULL || saveAs == true )
     {
+        bool        relocate = false;
+
         QString outputFileName =
             QFileDialog::getSaveFileName( NULL, "Enter the output file name",
                                           VLMC_PROJECT_GET_STRING( "general/Workspace" ),
                                           "VLMC project file(*.vlmc)" );
         if ( outputFileName.length() == 0 )
             return false;
+        if ( Workspace::isInProjectDir( outputFileName ) == false )
+        {
+            if ( confirmRelocate() == false )
+                return false;
+            relocate = true;
+        }
         if ( m_projectFile != NULL )
             delete m_projectFile;
         if ( outputFileName.endsWith( ".vlmc" ) == false )
             outputFileName += ".vlmc";
         m_projectFile = new QFile( outputFileName );
         appendToRecentProject( outputFileName );
+        if ( relocate == true )
+            Workspace::getInstance()->copyAllToWorkspace();
         emit projectUpdated( projectName(), true );
     }
     return true;
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index f38fc6b..70cf46b 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -72,6 +72,7 @@ protected:
 
 private:
     bool            createNewProjectFile( bool saveAs );
+    bool            confirmRelocate() const;
 
 private:
     QTimer*         m_timer;
diff --git a/src/Library/Library.h b/src/Library/Library.h
index 837db92..1f0a307 100644
--- a/src/Library/Library.h
+++ b/src/Library/Library.h
@@ -78,6 +78,7 @@ signals:
     void    projectLoaded();
 
     friend class    Singleton<Library>;
+    friend class    Workspace;
 };
 
 #endif // LIBRARY_H
diff --git a/src/Project/Workspace.cpp b/src/Project/Workspace.cpp
index b310dfb..45e2ff8 100644
--- a/src/Project/Workspace.cpp
+++ b/src/Project/Workspace.cpp
@@ -71,11 +71,25 @@ Workspace::copyTerminated( Media *media, QString dest )
 }
 
 bool
-Workspace::isInProjectDir( const Media *media )
+Workspace::isInProjectDir( const QFileInfo &fInfo )
 {
-    const QString      projectDir = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
+    const QString       projectDir = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
+
+    return ( fInfo.absolutePath().startsWith( projectDir ) );
+}
+
+bool
+Workspace::isInProjectDir( const QString &path )
+{
+    QFileInfo           fInfo( path );
+
+    return isInProjectDir( fInfo );
+}
 
-    return ( media->fileInfo()->absoluteFilePath().startsWith( projectDir ) );
+bool
+Workspace::isInProjectDir(const Media *media)
+{
+    return isInProjectDir( *(media->fileInfo() ) );
 }
 
 QString
@@ -86,3 +100,15 @@ Workspace::pathInProjectDir( const Media *media )
     return ( media->fileInfo()->absoluteFilePath().mid( projectDir.length() ) );
 }
 
+void
+Workspace::copyAllToWorkspace()
+{
+    QHash<QString, Media*>::iterator    it = Library::getInstance()->m_medias.begin();
+    QHash<QString, Media*>::iterator    ite = Library::getInstance()->m_medias.end();
+
+    while ( it != ite )
+    {
+        //FIXME
+        ++it;
+    }
+}
diff --git a/src/Project/Workspace.h b/src/Project/Workspace.h
index a480fa4..5ae9966 100644
--- a/src/Project/Workspace.h
+++ b/src/Project/Workspace.h
@@ -25,10 +25,14 @@
 
 #include <QObject>
 
+#include <QQueue>
+
 #include "Singleton.hpp"
 class   Clip;
 class   Media;
 
+class   QFileInfo;
+
 class Workspace : public QObject, public Singleton<Workspace>
 {
     Q_OBJECT
@@ -36,18 +40,21 @@ class Workspace : public QObject, public Singleton<Workspace>
     public:
         static const QString        workspacePrefix;
 
-        static bool                 isInProjectDir( const Media* media );
+        static bool                 isInProjectDir( const QString &path );
+        static bool                 isInProjectDir( const QFileInfo &fInfo );
+        static bool                 isInProjectDir( const Media *media );
         static QString              pathInProjectDir( const Media* media );
 
-        void    copyToWorkspace( Media* media );
+        void                        copyToWorkspace( Media* media );
+        void                        copyAllToWorkspace();
     private:
         Workspace();
         ~Workspace(){}
 
     public slots:
-        void    clipLoaded( Clip* clip );
+        void                        clipLoaded( Clip* clip );
     private slots:
-        void    copyTerminated( Media* media, QString dest );
+        void                        copyTerminated( Media* media, QString dest );
 
     friend class    Singleton<Workspace>;
 };



More information about the Vlmc-devel mailing list