Commit c070b972 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Debug and refactored code in ProjectManager

parent f38af6a3
......@@ -100,8 +100,11 @@ void ProjectWizard::accept()
{
SettingsManager::getInstance()->commit();
}
ProjectManager::getInstance()->newProject(
SettingsManager::getInstance()->getValue( "project", "ProjectName" )->get().toString() );
if ( WelcomePage::projectPath().length() == 0 )
{
ProjectManager::getInstance()->newProject(
SettingsManager::getInstance()->getValue( "project", "ProjectName" )->get().toString() );
}
emit flush();
QDialog::accept();
return ;
......
......@@ -124,15 +124,7 @@ void ProjectManager::loadProject( const QString& fileName )
if ( ProjectManager::isBackupFile( fileName ) == false )
{
// Append the item to the recents list
m_recentsProjects.removeAll( fileName );
m_recentsProjects.prepend( fileName );
while ( m_recentsProjects.count() > 15 )
m_recentsProjects.removeLast();
QSettings s;
s.setValue( "RecentsProjects", m_recentsProjects );
s.sync();
appendToRecentProject( fileName );
}
else
{
......@@ -158,7 +150,7 @@ QString ProjectManager::loadProjectFile()
return fileName;
}
bool ProjectManager::checkProjectOpen( bool saveAs )
bool ProjectManager::createNewProjectFile( bool saveAs )
{
if ( m_projectFile == NULL || saveAs == true )
{
......@@ -172,13 +164,16 @@ bool ProjectManager::checkProjectOpen( bool saveAs )
if ( outputFileName.endsWith( ".vlmc" ) == false )
outputFileName += ".vlmc";
m_projectFile = new QFile( outputFileName );
appendToRecentProject( outputFileName );
}
return true;
}
void ProjectManager::saveProject( bool saveAs /*= true*/ )
{
if ( checkProjectOpen( saveAs ) == false )
//If the project is still unsaved, or if we want to
//save the project with a new name
if ( createNewProjectFile( saveAs ) == false )
return ;
__saveProject( m_projectFile->fileName() );
if ( saveAs == true )
......@@ -286,6 +281,7 @@ bool ProjectManager::loadEmergencyBackup( const QString& projectName )
if ( QFile::exists( lastProject ) == true )
{
loadProject( lastProject );
m_needSave = true;
return true;
}
return false;
......@@ -295,3 +291,16 @@ bool ProjectManager::isBackupFile( const QString& projectFile )
{
return projectFile.endsWith( "backup" );
}
void ProjectManager::appendToRecentProject( const QString& projectFile )
{
// Append the item to the recents list
m_recentsProjects.removeAll( projectFile );
m_recentsProjects.prepend( projectFile );
while ( m_recentsProjects.count() > 15 )
m_recentsProjects.removeLast();
QSettings s;
s.setValue( "RecentsProjects", m_recentsProjects );
s.sync();
}
......@@ -58,11 +58,12 @@ private:
void parseProjectNode( const QDomElement& node );
void emergencyBackup();
static bool isBackupFile( const QString& projectFile );
void appendToRecentProject( const QString& projectName );
ProjectManager();
~ProjectManager();
bool checkProjectOpen( bool saveAs );
bool createNewProjectFile( bool saveAs );
private:
QFile* m_projectFile;
......
......@@ -266,6 +266,9 @@ Clip* MainWorkflow::getClip( const QUuid& uuid, unsigned int trackId, Main
return m_tracks[trackType]->getClip( uuid, trackId );
}
/**
* \warning The mainworkflow is expected to be cleared already by the ProjectManager
*/
void MainWorkflow::loadProject( const QDomElement& project )
{
if ( project.isNull() == true || project.tagName() != "timeline" )
......@@ -274,8 +277,6 @@ void MainWorkflow::loadProject( const QDomElement& project )
return ;
}
clear();
QDomElement elem = project.firstChild().toElement();
while ( elem.isNull() == false )
......@@ -370,6 +371,7 @@ void MainWorkflow::saveProject( QDomDocument& doc, QDomElement& rootNode
void MainWorkflow::clear()
{
qDebug() << "main workflow cleared";
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->clear();
emit cleared();
......
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