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

Adding a closeProject method

parent d4c7b116
......@@ -42,9 +42,15 @@ UndoStack::UndoStack( QWidget* parent ) : QUndoView( parent )
connect( m_undoShortcut, SIGNAL( activated() ), m_undoStack, SLOT( undo() ) );
connect( m_redoShortcut, SIGNAL( activated() ), m_undoStack, SLOT( redo() ) );
connect( ProjectManager::getInstance(), SIGNAL( projectClosed() ), this, SLOT( clear() ) );
}
void UndoStack::push( QUndoCommand* command )
{
m_undoStack->push( command );
}
void UndoStack::clear()
{
m_undoStack->setIndex( 0 );
}
......@@ -45,6 +45,9 @@ class UndoStack : public QUndoView, public QSingleton<UndoStack>
KeyboardShortcutHelper* m_undoShortcut;
KeyboardShortcutHelper* m_redoShortcut;
public slots:
void clear();
signals:
void cleanChanged( bool val );
......
......@@ -63,7 +63,6 @@ void Library::metaDataComputed( Media* media )
emit newMediaLoaded( media );
Clip* clip = new Clip( media );
m_clips[media->getUuid()] = clip;
emit newClipLoaded( clip );
}
void Library::newMediaLoadingAsked( const QString& filePath, const QString& uuid )
......@@ -202,3 +201,25 @@ void Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
}
rootNode.appendChild( medias );
}
void Library::clear()
{
QHash<QUuid, Media*>::iterator it = m_medias.begin();
QHash<QUuid, Media*>::iterator end = m_medias.end();
while ( it != end )
{
emit mediaRemoved( it.key() );
delete it.value();
++it;
}
m_medias.clear();
QHash<QUuid, Clip*>::iterator it2 = m_clips.begin();
QHash<QUuid, Clip*>::iterator end2 = m_clips.end();
while ( it2 != end2 )
{
delete it2.value();
++it2;
}
m_clips.clear();
}
......@@ -82,12 +82,15 @@ public slots:
void loadProject( const QDomElement& project );
void saveProject( QDomDocument& doc, QDomElement& rootNode );
/**
* \brief Clear the library (remove all the loaded media and delete them)
*/
void clear();
private slots:
void metaDataComputed( Media* );
signals:
void newClipLoaded( Clip* );
void metadataRequired( Media* );
void newMediaLoaded( Media* );
void mediaRemoved( const QUuid& );
......
......@@ -33,6 +33,8 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
{
QSettings s;
m_recentsProjects = s.value( "RecentsProjects" ).toStringList();
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
}
ProjectManager::~ProjectManager()
......@@ -90,9 +92,8 @@ void ProjectManager::loadProject( const QString& fileName )
QSettings s;
s.setValue( "RecentsProjects", m_recentsProjects );
closeProject();
if ( !m_projectFile )
delete m_projectFile;
m_projectFile = new QFile( fileName );
m_domDocument = new QDomDocument;
......@@ -163,3 +164,13 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ )
}
emit projectSaved();
}
void ProjectManager::closeProject()
{
if ( m_projectFile != NULL )
{
delete m_projectFile;
m_projectFile = NULL;
}
emit projectClosed();
}
......@@ -40,6 +40,7 @@ public:
void saveProject( bool saveAs = true );
bool needSave() const;
QStringList recentsProjects() const;
void closeProject();
private:
ProjectManager();
......@@ -62,6 +63,7 @@ private slots:
signals:
void projectChanged( const QString& projectName, bool savedState );
void projectSaved();
void projectClosed();
};
#endif // PROJECTMANAGER_H
......@@ -123,8 +123,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/
Clip* getClip( const QUuid& uuid, unsigned int trackId, MainWorkflow::TrackType trackType );
void clear();
void setFullSpeedRender( bool value );
int getTrackCount( MainWorkflow::TrackType trackType ) const;
......@@ -168,6 +166,7 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
public slots:
void loadProject( const QDomElement& project );
void saveProject( QDomDocument& doc, QDomElement& rootNode );
void clear();
signals:
/**
......
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