Commit 27eb7d2e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Timeline: Save the timeline configuration to the project file.

parent aba15bd7
......@@ -29,6 +29,7 @@
#include "Library.h"
#include "MainWorkflow.h"
#include "SettingsManager.h"
#include "Timeline.h"
GUIProjectManager::GUIProjectManager()
{
......@@ -206,3 +207,9 @@ GUIProjectManager::failedToLoad( const QString &reason ) const
{
QMessageBox::warning( NULL, tr( "Failed to load project file" ), reason );
}
void
GUIProjectManager::saveTimeline( QXmlStreamWriter &project )
{
Timeline::getInstance()->save( project );
}
......@@ -55,6 +55,7 @@ public:
protected:
virtual void failedToLoad( const QString &reason ) const;
virtual void saveTimeline( QXmlStreamWriter &project );
private:
bool createNewProjectFile( bool saveAs );
......
......@@ -107,6 +107,8 @@ public:
ClipHelper *clipHelper();
QColor itemColor();
protected:
/**
* \details Returns a pointer to the tracksView which contains the item,
......@@ -157,8 +159,6 @@ protected slots:
*/
bool resizeZone( const QPointF& position );
QColor itemColor();
private slots:
void clipDestroyed( Clip* clip );
......
......@@ -20,9 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QHBoxLayout>
#include <QScrollBar>
#include <QtDebug>
#include "Timeline.h"
#include "TracksView.h"
#include "TracksScene.h"
......@@ -31,6 +28,12 @@
#include "WorkflowRenderer.h"
#include "Clip.h"
#include <QHBoxLayout>
#include <QScrollBar>
#include <QXmlStreamWriter>
#include <QtDebug>
Timeline* Timeline::m_instance = NULL;
Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) :
......@@ -175,3 +178,22 @@ void Timeline::actionRemoveClip( const QUuid &uuid, unsigned int track, MainWork
{
tracksView()->removeMediaItem( uuid, track, trackType );
}
void
Timeline::save( QXmlStreamWriter &project ) const
{
project.writeStartElement( "timeline" );
for ( int i = 0; i < tracksView()->m_scene->items().size(); ++i )
{
AbstractGraphicsMediaItem* item =
dynamic_cast<AbstractGraphicsMediaItem*>( tracksView()->m_scene->items().at( i ) );
if ( item == NULL )
continue ;
project.writeStartElement( "item" );
project.writeAttribute( "uuid", item->clipHelper()->uuid().toString() );
project.writeAttribute( "color", item->itemColor().name() );
project.writeEndElement();
}
project.writeEndDocument();
}
......@@ -45,6 +45,8 @@ public:
virtual ~Timeline();
/// Return a pointer to the TracksView instance.
TracksView* tracksView() { return m_tracksView; }
/// Returns a const pointer to the TracksView instance
const TracksView* tracksView() const { return m_tracksView; }
/// Return a pointer to the TracksScene instance.
TracksScene* tracksScene() { return m_tracksScene; }
/// Return a pointer to the TracksRuler instance.
......@@ -52,6 +54,8 @@ public:
/// Return a pointer to the Timeline instance (singleton).
static Timeline* getInstance() { return m_instance; }
void save( QXmlStreamWriter& project ) const;
public slots:
/**
* \brief Asks the workflow to clear itself.
......
......@@ -145,6 +145,7 @@ void ProjectManager::__saveProject( const QString &fileName )
Library::getInstance()->saveProject( project );
MainWorkflow::getInstance()->saveProject( project );
SettingsManager::getInstance()->save( project );
saveTimeline( project );
project.writeEndElement();
project.writeEndDocument();
......
......@@ -32,6 +32,7 @@
class QFile;
class QDomDocument;
class QXmlStreamWriter;
#ifdef WITH_GUI
class ProjectManager : public QObject
......@@ -58,6 +59,12 @@ protected:
* It's only purpose it to write the project for very specific cases.
*/
void __saveProject( const QString& fileName );
/**
* \brief Save the timline.
*
* In non GUI mode, this does nothing.
*/
virtual void saveTimeline( QXmlStreamWriter& ){};
static bool isBackupFile( const QString& projectFile );
void appendToRecentProject( const QString& projectName );
/**
......@@ -72,7 +79,6 @@ protected:
virtual void failedToLoad( const QString& reason ) const;
protected:
ProjectManager();
~ProjectManager();
......
......@@ -277,7 +277,7 @@ MainWorkflow::getClip( const QUuid &uuid, unsigned int trackId,
void
MainWorkflow::loadProject( const QDomElement &root )
{
QDomElement project = root.firstChildElement( "timeline" );
QDomElement project = root.firstChildElement( "workflow" );
if ( project.isNull() == true )
return ;
......@@ -340,7 +340,7 @@ MainWorkflow::loadProject( const QDomElement &root )
void
MainWorkflow::saveProject( QXmlStreamWriter& project ) const
{
project.writeStartElement( "timeline" );
project.writeStartElement( "workflow" );
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
{
m_tracks[i]->save( project );
......
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