Commit 96a69981 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

ProjectManager: Handle change of workspace when saving as.

The Workspace part isn't fully fonctionnal yet.
parent 0cd238f3
......@@ -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()
{
......@@ -90,23 +91,54 @@ GUIProjectManager::askForSaveIfModified()
return true;
}
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;
......
......@@ -72,6 +72,7 @@ protected:
private:
bool createNewProjectFile( bool saveAs );
bool confirmRelocate() const;
private:
QTimer* m_timer;
......
......@@ -78,6 +78,7 @@ signals:
void projectLoaded();
friend class Singleton<Library>;
friend class Workspace;
};
#endif // LIBRARY_H
......@@ -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;
}
}
......@@ -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>;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment