Commit 0c33156c authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Merge ProjectManager in the Project class.

Expect kitten blood all over the wall.
parent d60edce3
......@@ -28,13 +28,12 @@ SET(VLMC_SRCS
Library/Library.cpp
Library/MediaContainer.cpp
Main/Core.cpp
Main/Project.cpp
Main/main.cpp
Media/Clip.cpp
Media/Media.cpp
Metadata/MetaDataManager.cpp
Project/AutomaticBackup.cpp
Project/ProjectManager.cpp
Project/Project.cpp
Project/Workspace.cpp
Project/WorkspaceWorker.cpp
Project/RecentProjects.cpp
......
......@@ -24,7 +24,7 @@
#include "config.h"
#include "Commands.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Media/Clip.h"
#include "Workflow/ClipHelper.h"
#include "EffectsEngine/EffectHelper.h"
......
......@@ -22,7 +22,7 @@
#include "EffectsEngine/EffectHelper.h"
#include "EffectsEngine/EffectUser.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Workflow/MainWorkflow.h"
EffectHelper::EffectHelper( EffectInstance *effectInstance, qint64 begin, qint64 end,
......
......@@ -34,7 +34,7 @@
#include <QUrl>
#include <QNetworkProxy>
#include "Main/Core.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Library/Library.h"
#include "Tools/VlmcDebug.h"
#include "Tools/VlmcLogger.h"
......@@ -85,8 +85,6 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
//All preferences have been created: restore them:
Core::getInstance()->settings()->load();
Project::getInstance()->projectManager()->setProjectManagerUi( new GUIProjectManager );
// GUI
DockWidgetManager::getInstance( this )->setMainWindow( this );
createGlobalPreferences();
......@@ -110,7 +108,7 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
connect( this, SIGNAL( toolChanged( ToolButtons ) ),
m_timeline, SLOT( setTool( ToolButtons ) ) );
connect( Project::getInstance()->projectManager(), SIGNAL( projectUpdated( const QString&, bool ) ),
connect( Project::getInstance(), SIGNAL( projectUpdated( const QString&, bool ) ),
this, SLOT( projectUpdated( const QString&, bool ) ) );
// Undo/Redo
......@@ -153,7 +151,7 @@ MainWindow::showWizard()
{
if ( m_wizard == NULL )
{
m_wizard = new ProjectWizard( Project::getInstance()->projectManager(), this );
m_wizard = new ProjectWizard( this );
m_wizard->setModal( true );
}
m_wizard->show();
......@@ -330,13 +328,13 @@ MainWindow::initVlmcPreferences()
void
MainWindow::on_actionSave_triggered()
{
Project::getInstance()->projectManager()->save();
Project::getInstance()->save();
}
void
MainWindow::on_actionSave_As_triggered()
{
Project::getInstance()->projectManager()->saveAs();
Project::getInstance()->saveAs();
}
void
......@@ -347,7 +345,7 @@ MainWindow::on_actionLoad_Project_triggered()
"", tr( "VLMC project file(*.vlmc)" ) );
if ( fileName.isEmpty() == true )
return ;
Project::getInstance()->projectManager()->loadProject( fileName );
Project::load( fileName );
}
void
......@@ -753,7 +751,7 @@ MainWindow::saveSettings()
settings->setValue( "private/MainWindowState", saveState() );
settings->setValue( "private/CleanQuit", true );
settings->save();
Project::getInstance()->projectManager()->save();
Project::getInstance()->save();
return true;
}
......@@ -820,7 +818,7 @@ MainWindow::restoreSession()
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if ( res == QMessageBox::Yes )
{
if ( Project::getInstance()->projectManager()->loadEmergencyBackup() == true )
if ( Project::getInstance()->loadEmergencyBackup() == true )
ret = true;
else
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) );
......
......@@ -23,7 +23,7 @@
#include "WorkflowFileRendererDialog.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "vlmc.h"
#include "Workflow/MainWorkflow.h"
#include "Renderer/WorkflowFileRenderer.h"
......
......@@ -26,7 +26,7 @@
#include "ui_ImportController.h"
#include "Main/Core.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Media/Clip.h"
#include "Renderer/ClipRenderer.h"
#include "Backend/ISource.h"
......
......@@ -24,7 +24,7 @@
#include "MediaCellView.h"
#include "ui_MediaCellView.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Media/Clip.h"
#include "ClipProperty.h"
#include "Backend/ISource.h"
......
......@@ -22,7 +22,7 @@
#include "MediaLibrary.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Media/Clip.h"
#include "Library/Library.h"
#include "Media/Media.h"
......
......@@ -53,7 +53,7 @@ GUIProjectManager::getProjectFileDestination( const QString &defaultPath )
IProjectManagerUiCb::SaveMode
IProjectUiCb::SaveMode
GUIProjectManager::shouldSaveBeforeClose()
{
QMessageBox msgBox;
......
......@@ -23,9 +23,9 @@
#ifndef GUIPROJECTMANAGER_H
#define GUIPROJECTMANAGER_H
#include "Project/ProjectManager.h"
#include "Project/Project.h"
class GUIProjectManager : public IProjectManagerUiCb
class GUIProjectManager : public IProjectUiCb
{
public:
virtual bool shouldLoadBackupFile();
......
......@@ -22,7 +22,7 @@
#include <QList>
#include "Main/Project.h"
#include "Project/Project.h"
#include "TracksView.h"
#include "GraphicsTrack.h"
#include "Workflow/MainWorkflow.h"
......
......@@ -22,7 +22,7 @@
#include "Timeline.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Media/Clip.h"
#include "Workflow/ClipHelper.h"
#include "TracksView.h"
......
......@@ -28,7 +28,7 @@
#include "GraphicsAudioItem.h"
#include "GraphicsMovieItem.h"
#include "GraphicsTrack.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Settings/Settings.h"
#include "Timeline.h"
#include "Workflow/TrackWorkflow.h"
......
......@@ -23,7 +23,7 @@
#include "TracksView.h"
#include "Main/Core.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Workflow/ClipHelper.h"
#include "Workflow/ClipWorkflow.h"
#include "Commands/Commands.h"
......
......@@ -27,7 +27,7 @@
#include "GeneralPage.h"
#include "ProjectWizard.h"
#include "Settings/Settings.h"
#include "Project/ProjectManager.h"
#include "Project/Project.h"
GeneralPage::GeneralPage( QWidget *parent ) :
QWizardPage( parent )
......@@ -77,7 +77,7 @@ void
GeneralPage::initializePage()
{
//Since this is a new project, it will be unnamed
QString projectName = ProjectManager::unNamedProject;
QString projectName = Project::unNamedProject;
ui.lineEditName->setText( projectName );
//fetching the global workspace path
......@@ -99,7 +99,7 @@ GeneralPage::validatePage()
{
if ( m_valid == false )
return false;
const QString &defaultProjectName = ProjectManager::unNamedProject;
const QString &defaultProjectName = Project::unNamedProject;
if ( ui.lineEditName->text().isEmpty() ||
ui.lineEditName->text() == defaultProjectName )
{
......
......@@ -24,7 +24,7 @@
#include "project/GuiProjectManager.h"
#include "ProjectWizard.h"
#include "WelcomePage.h"
#include "Main/Project.h"
#include "Project/Project.h"
OpenPage::OpenPage( QWidget *parent ) :
QWizardPage(parent)
......@@ -53,12 +53,9 @@ OpenPage::changeEvent( QEvent *e )
bool
OpenPage::validatePage()
{
ProjectManager* pm = Project::getInstance()->projectManager();
if ( !WelcomePage::projectPath().isEmpty() )
pm->loadProject( WelcomePage::projectPath() );
return true;
if ( WelcomePage::projectPath().isEmpty() == false )
return Project::load( WelcomePage::projectPath() );
return false;
}
int
......
......@@ -25,7 +25,7 @@
#include <QMessageBox>
#include <QWizardPage>
#include "Project/ProjectManager.h"
#include "Project/Project.h"
#include "ProjectWizard.h"
#include "Settings/Settings.h"
#include "WelcomePage.h"
......@@ -34,9 +34,8 @@
#include "VideoPage.h"
#include "Tools/VlmcDebug.h"
ProjectWizard::ProjectWizard( ProjectManager* projectManager, QWidget* parent /*= NULL*/ )
ProjectWizard::ProjectWizard( QWidget* parent /*= NULL*/ )
: QWizard( parent )
, m_projectManager( projectManager )
{
// Create Wizard
......@@ -101,8 +100,9 @@ ProjectWizard::accept()
if ( currentId() == Page_Video )
{
Settings* preferences = Core::getInstance()->settings();
Project::create( field( "projectName" ).toString(), field( "projectPath" ).toString() );
Settings* projectPreferences = Project::getInstance()->settings();
m_projectManager->newProject( field( "projectName" ).toString(), field( "projectPath" ).toString() );
preferences->setValue( "vlmc/DefaultProjectLocation", field( "workspace" ) );
......@@ -120,7 +120,7 @@ ProjectWizard::accept()
void
ProjectWizard::reject()
{
if ( m_projectManager->hasProjectLoaded() )
if ( Project::isProjectLoaded() )
return QWizard::reject();
qApp->quit();
}
......@@ -24,7 +24,6 @@
#ifndef PROJECTWIZARD_H
#define PROJECTWIZARD_H
class ProjectManager;
class WelcomePage;
#include <QWizard>
......@@ -38,7 +37,7 @@ class ProjectWizard : public QWizard
Page_Open,
Page_General, Page_Video };
ProjectWizard( ProjectManager *projectManager, QWidget* parent = NULL );
ProjectWizard( QWidget* parent = NULL );
~ProjectWizard();
protected slots:
......@@ -47,9 +46,6 @@ class ProjectWizard : public QWizard
private slots:
void showHelp();
private:
ProjectManager* m_projectManager;
};
#endif
......@@ -122,7 +122,7 @@ WelcomePage::loadRecentsProjects()
for ( int i = 0; i < recents.count(); ++i )
{
RecentProjects::Project project = recents.at( i );
RecentProjects::RecentProject project = recents.at( i );
QListWidgetItem* item = new QListWidgetItem( project.name );
item->setData( FilePath, project.filePath );
m_ui.projectsListWidget->addItem( item );
......
......@@ -31,7 +31,7 @@
#include "Media/Clip.h"
#include "Media/Media.h"
#include "Metadata/MetaDataManager.h"
#include "Project/ProjectManager.h"
#include "Project/Project.h"
#include "Settings/Settings.h"
#include "Tools/VlmcDebug.h"
#include "Project/Workspace.h"
......@@ -40,12 +40,10 @@
#include <QHash>
#include <QUuid>
Library::Library( Workspace *workspace , ProjectManager *projectManager )
Library::Library( Workspace *workspace )
: m_cleanState( true )
, m_workspace( workspace )
{
connect( this, SIGNAL( cleanStateChanged( bool ) ),
projectManager, SLOT( libraryCleanChanged( bool ) ) );
}
void
......
......@@ -52,7 +52,7 @@ class Library : public MediaContainer
Q_DISABLE_COPY( Library );
public:
Library( Workspace* workspace, ProjectManager* projectManager );
Library(Workspace* workspace);
virtual ~Library(){}
virtual void addMedia( Media* media );
virtual Media *addMedia( const QFileInfo &fileInfo );
......
/*****************************************************************************
* Project.cpp: Handles all core project components
*****************************************************************************
* Copyright (C) 2008-2014 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "Project.h"
#include <QUndoStack>
#include "Library/Library.h"
#include "Workflow/MainWorkflow.h"
#include "Project/ProjectManager.h"
#include "Project/Workspace.h"
#include "Settings/Settings.h"
Project::Project()
{
m_settings = new Settings( QString() );
m_projectManager = new ProjectManager( m_settings );
m_undoStack = new QUndoStack;
m_workflow = new MainWorkflow();
m_workspace = new Workspace( m_settings );
m_library = new Library( m_workspace, m_projectManager );
QObject::connect( m_undoStack, SIGNAL( cleanChanged( bool ) ), m_projectManager, SLOT( cleanChanged( bool ) ) );
QObject::connect( m_projectManager, SIGNAL( projectSaved() ), m_undoStack, SLOT( setClean() ) );
}
Project::~Project()
{
delete m_library;
delete m_workspace;
delete m_workflow;
delete m_undoStack;
delete m_projectManager;
delete m_settings;
}
Library*
Project::library()
{
return m_library;
}
MainWorkflow*
Project::workflow()
{
return m_workflow;
}
QUndoStack*
Project::undoStack()
{
return m_undoStack;
}
Settings*
Project::settings()
{
return m_settings;
}
Workspace*
Project::workspace()
{
return m_workspace;
}
ProjectManager*
Project::projectManager()
{
return m_projectManager;
}
/*****************************************************************************
* Project.h: Handles all core project components
*****************************************************************************
* Copyright (C) 2008-2014 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef PROJECT_H
#define PROJECT_H
#include "Tools/Singleton.hpp"
class QUndoStack;
class Library;
class MainWorkflow;
class ProjectManager;
class Settings;
class Workspace;
class Project : public Singleton<Project>
{
private:
Project();
~Project();
public:
Library* library();
MainWorkflow* workflow();
QUndoStack* undoStack();
Settings* settings();
Workspace* workspace();
ProjectManager* projectManager();
private:
Library* m_library;
MainWorkflow* m_workflow;
QUndoStack* m_undoStack;
Settings* m_settings;
Workspace* m_workspace;
ProjectManager* m_projectManager;
friend class Singleton<Project>;
};
#endif // PROJECT_H
......@@ -31,8 +31,8 @@
#include "Tools/VlmcDebug.h"
#include "Workflow/Types.h"
#include "Renderer/ConsoleRenderer.h"
#include "Project/ProjectManager.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include "Project/Project.h"
#include "Backend/IBackend.h"
#include "Main/Core.h"
......@@ -96,7 +96,7 @@ VLMCGuimain( int argc, char **argv )
if ( argc > ( i + 1 ) && ( arg == "--project" || arg == "-p" ) )
{
Project::getInstance()->projectManager()->loadProject( argv[i+1] );
Project::load( argv[i+1] );
project = true;
break;
}
......@@ -183,7 +183,7 @@ VLMCCoremain( int argc, char **argv )
#ifndef WITH_GUI
ConsoleRenderer renderer;
ProjectManager *pm = Project::getInstance()->projectManager();
ProjectManager *pm = Project::getInstance();
QCoreApplication::connect( pm, SIGNAL( projectLoaded() ), &renderer, SLOT( startRender() ) );
pm->loadProject( app.arguments()[1] );
......
......@@ -24,7 +24,7 @@
#include "Workflow/Types.h"
#include "Tools/VlmcDebug.h"
#include "Main/Project.h"
#include "Project/Project.h"
#include <QMetaType>
#include <QTextStream>
......@@ -52,7 +52,7 @@ signalHandler( int sig )
{
signal( sig, SIG_DFL );
Project::getInstance()->projectManager()->emergencyBackup();
Project::getInstance()->emergencyBackup();
#ifdef WITH_CRASHHANDLER_GUI
CrashHandler* ch = new CrashHandler( sig );
......
......@@ -23,7 +23,7 @@
#include <QTimer>
#include "AutomaticBackup.h"
#include "ProjectManager.h"
#include "Project.h"
#include "Settings/Settings.h"
AutomaticBackup::AutomaticBackup( Settings* vlmcSettings, QObject *parent )
......@@ -51,7 +51,7 @@ AutomaticBackup::~AutomaticBackup()
}
void
AutomaticBackup::setProject(ProjectManager* projectManager)
AutomaticBackup::setProject( Project* projectManager )
{
m_timer->disconnect();
connect( m_timer, SIGNAL( timeout() ), projectManager, SLOT(autoSaveRequired() ) );
......
......@@ -25,7 +25,7 @@
class QTimer;
class ProjectManager;
class Project;
class Settings;
#include <QObject>
......@@ -35,9 +35,9 @@ class AutomaticBackup : public QObject
Q_OBJECT
public:
explicit AutomaticBackup(Settings* vlmcSettings, QObject *parent = 0);
explicit AutomaticBackup( Settings* vlmcSettings, QObject *parent = 0 );
virtual ~AutomaticBackup();
void setProject( ProjectManager* projectManager );
void setProject( Project* projectManager );
private:
Settings* m_vlmcSettings;
......
/*****************************************************************************
* ProjectManager.cpp: Manager the project loading and saving.
* Project.cpp: Handles all core project components
*****************************************************************************
* Copyright (C) 2008-2014 VideoLAN
*
......@@ -20,155 +20,226 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "config.h"
#include "Project.h"
#include <QDir>
#include <QDomDocument>
#include <QFile>
#include <QFileInfo>
#include <QUndoStack>
#include <errno.h>
#include <signal.h>
#include "ProjectManager.h"
#include "Main/Core.h"
#include "Main/Project.h"
#include "Library/Library.h"
#include "Workflow/MainWorkflow.h"
#include "Project/Project.h"
#include "Project/Workspace.h"
#include "Settings/Settings.h"
#include "Gui/timeline/Timeline.h"
#include "Tools/VlmcDebug.h"
//FIXME: List of suspicious include from an architecture point of view:
#include "Renderer/WorkflowRenderer.h"
#include "Project/Workspace.h"
const QString ProjectManager::unNamedProject = ProjectManager::tr( "Untitled Project" );
const QString ProjectManager::backupSuffix = "~";
//FIXME: This shouldn't be here
#include "timeline/Timeline.h"
ProjectManager::ProjectManager( Settings* projectSettings )
const QString Project::unNamedProject = Project::tr( "Untitled Project" );
const QString Project::backupSuffix = "~";
Project::Project()
: m_projectFile( NULL )
, m_isClean( true )
, m_libraryCleanState( true )
, m_projectSettings( projectSettings )
{
initSettings();
//We have to wait for the library to be loaded before loading the workflow
//FIXME
//connect( Project::getInstance()->library(), SIGNAL( projectLoaded() ), this, SLOT( loadWorkflow() ) );
m_settings = new Settings( QString() );
m_undoStack = new QUndoStack;
m_workflow = new MainWorkflow();
m_workspace = new Workspace( m_settings );
m_library = new Library( m_workspace );
connectComponents();
}
ProjectManager::~ProjectManager()
Project::~Project()
{
delete m_projectFile;
delete m_library;
delete m_workspace;
delete m_workflow;
delete m_undoStack;
delete m_settings;
}
void
ProjectManager::setProjectManagerUi( IProjectManagerUiCb *projectManagerUi )
Library*
Project::library()
{
m_projectManagerUi = projectManagerUi;
return m_library;
}
void
ProjectManager::loadWorkflow()
MainWorkflow*
Project::workflow()
{
QDomElement root = m_domDocument->documentElement();
Project::getInstance()->workflow()->loadProject( root );
loadTimeline( root );
emit projectLoaded( projectName(), m_projectFile->fileName() );
return m_workflow;
}
delete m_domDocument;
QUndoStack*
Project::undoStack()
{
return m_undoStack;
}
void
ProjectManager::saveProject( const QString& fileName )
Settings*
Project::settings()
{
QByteArray projectString;
return m_settings;
}
QXmlStreamWriter project( &projectString );
Workspace*
Project::workspace()
{
return m_workspace;
}
project.setAutoFormatting( true );
project.writeStartDocument();
project.writeStartElement( "vlmc" );
//////////////////////////////////////////////////////////////////////////////////////////
Project::getInstance()->library()->saveProject( project );
Project::getInstance()->workflow()->saveProject( project );
Timeline::getInstance()->renderer()->saveProject( project );
Core::getInstance()->settings()->save( project );
Timeline::getInstance()->save( project );
bool