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

MainWorkflow: saving is functionnal again.

parent 234fa727
...@@ -230,7 +230,7 @@ void ProjectManager::__saveProject( const QString &fileName ) ...@@ -230,7 +230,7 @@ void ProjectManager::__saveProject( const QString &fileName )
project.writeStartElement( "vlmc" ); project.writeStartElement( "vlmc" );
Library::getInstance()->saveProject( project ); Library::getInstance()->saveProject( project );
// MainWorkflow::getInstance()->saveProject( doc, rootNode ); MainWorkflow::getInstance()->saveProject( project );
// SettingsManager::getInstance()->save( doc, rootNode ); // SettingsManager::getInstance()->save( doc, rootNode );
project.writeEndElement(); project.writeEndElement();
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "SettingsManager.h" #include "SettingsManager.h"
#include <QDomElement> #include <QDomElement>
#include <QXmlStreamWriter>
LightVideoFrame *MainWorkflow::blackOutput = NULL; LightVideoFrame *MainWorkflow::blackOutput = NULL;
...@@ -379,14 +380,14 @@ MainWorkflow::loadProject( const QDomElement &project ) ...@@ -379,14 +380,14 @@ MainWorkflow::loadProject( const QDomElement &project )
} }
void void
MainWorkflow::saveProject( QDomDocument& doc, QDomElement& rootNode ) MainWorkflow::saveProject( QXmlStreamWriter& project ) const
{ {
QDomElement project = doc.createElement( "timeline" ); project.writeStartElement( "timeline" );
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i ) for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
{ {
m_tracks[i]->save( doc, project ); m_tracks[i]->save( project );
} }
rootNode.appendChild( project ); project.writeEndElement();
} }
void void
......
...@@ -31,6 +31,7 @@ class QDomDocument; ...@@ -31,6 +31,7 @@ class QDomDocument;
class QDomElement; class QDomElement;
class QMutex; class QMutex;
class QReadWriteLock; class QReadWriteLock;
class QXmlStreamWriter;
class Clip; class Clip;
class EffectsEngine; class EffectsEngine;
...@@ -412,12 +413,11 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -412,12 +413,11 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/ */
void loadProject( const QDomElement& project ); void loadProject( const QDomElement& project );
/** /**
* \brief Save the project on a given node, for a given document. * \brief Save the project on a XML stream.
* *
* \param doc A reference to the document. * \param project The XML stream representing the project
* \param rootNode A reference on the node that will contain the timeline.
*/ */
void saveProject( QDomDocument& doc, QDomElement& rootNode ); void saveProject( QXmlStreamWriter& project ) const;
/** /**
* \brief Clear the workflow. * \brief Clear the workflow.
* *
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <QDomDocument> #include <QDomDocument>
#include <QDomElement> #include <QDomElement>
#include <QXmlStreamWriter>
LightVideoFrame* TrackHandler::nullOutput = NULL; LightVideoFrame* TrackHandler::nullOutput = NULL;
...@@ -276,18 +277,17 @@ TrackHandler::getTrackCount() const ...@@ -276,18 +277,17 @@ TrackHandler::getTrackCount() const
} }
void void
TrackHandler::save( QDomDocument& doc, QDomElement& timelineNode ) const TrackHandler::save( QXmlStreamWriter& project ) const
{ {
for ( unsigned int i = 0; i < m_trackCount; ++i) for ( unsigned int i = 0; i < m_trackCount; ++i)
{ {
if ( m_tracks[i]->getLength() > 0 ) if ( m_tracks[i]->getLength() > 0 )
{ {
QDomElement trackNode = doc.createElement( "track" ); project.writeStartElement( "track" );
project.writeAttribute( "type", QString::number( (int)m_trackType ) );
trackNode.setAttribute( "id", i ); project.writeAttribute( "id", QString::number( i ) );
m_tracks[i]->save( project );
m_tracks[i]->save( doc, trackNode ); project.writeEndElement();
timelineNode.appendChild( trackNode );
} }
} }
} }
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
class EffectEngine; class EffectEngine;
class TrackWorkflow; class TrackWorkflow;
class QXmlStreamWriter;
class TrackHandler : public QObject class TrackHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
...@@ -72,7 +74,7 @@ class TrackHandler : public QObject ...@@ -72,7 +74,7 @@ class TrackHandler : public QObject
bool endIsReached() const; bool endIsReached() const;
void save( QDomDocument& doc, QDomElement& timelineNode ) const; void save( QXmlStreamWriter& project ) const;
/** /**
* \brief Will configure the track workflow so they render only one frame * \brief Will configure the track workflow so they render only one frame
......
...@@ -29,9 +29,11 @@ ...@@ -29,9 +29,11 @@
#include "AudioClipWorkflow.h" #include "AudioClipWorkflow.h"
#include "Clip.h" #include "Clip.h"
#include "Media.h" #include "Media.h"
#include <QReadWriteLock> #include <QReadWriteLock>
#include <QDomDocument> #include <QDomDocument>
#include <QDomElement> #include <QDomElement>
#include <QXmlStreamWriter>
TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type ) : TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type ) :
m_trackId( trackId ), m_trackId( trackId ),
...@@ -386,7 +388,7 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id ) ...@@ -386,7 +388,7 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id )
return NULL; return NULL;
} }
void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const void TrackWorkflow::save( QXmlStreamWriter& project ) const
{ {
QReadLocker lock( m_clipsLock ); QReadLocker lock( m_clipsLock );
...@@ -395,44 +397,12 @@ void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const ...@@ -395,44 +397,12 @@ void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const
for ( ; it != end ; ++it ) for ( ; it != end ; ++it )
{ {
QDomElement clipNode = doc.createElement( "clip" ); project.writeStartElement( "clip" );
project.writeAttribute( "uuid", it.value()->getClip()->getParent()->uuid().toString() );
{ project.writeAttribute( "startFrame", QString::number( it.key() ) );
QDomElement parent = doc.createElement( "parent" ); project.writeAttribute( "begin", QString::number( it.value()->getClip()->begin() ) );
project.writeAttribute( "end", QString::number( it.value()->getClip()->end() ) );
QDomCharacterData text = doc.createTextNode( it.value()->getClip()->getMedia()->baseClip()->uuid().toString() ); project.writeEndElement();
parent.appendChild( text );
clipNode.appendChild( parent );
}
{
QDomElement startFrame = doc.createElement( "startFrame" );
QDomCharacterData text = doc.createTextNode( QString::number( it.key() ) );
startFrame.appendChild( text );
clipNode.appendChild( startFrame );
}
{
QDomElement begin = doc.createElement( "begin" );
QDomCharacterData text = doc.createTextNode( QString::number( it.value()->getClip()->begin() ) );
begin.appendChild( text );
clipNode.appendChild( begin );
}
{
QDomElement end = doc.createElement( "end" );
QDomCharacterData text = doc.createTextNode( QString::number( it.value()->getClip()->end() ) );
end.appendChild( text );
clipNode.appendChild( end );
}
{
QDomElement trackType = doc.createElement( "trackType" );
QDomCharacterData text = doc.createTextNode( QString::number( m_trackType ) );
trackType.appendChild( text );
clipNode.appendChild( trackType );
}
trackNode.appendChild( clipNode );
} }
} }
......
...@@ -68,7 +68,7 @@ class TrackWorkflow : public QObject ...@@ -68,7 +68,7 @@ class TrackWorkflow : public QObject
//FIXME: this won't be reliable as soon as we change the fps from the configuration //FIXME: this won't be reliable as soon as we change the fps from the configuration
static const unsigned int nbFrameBeforePreload = 60; static const unsigned int nbFrameBeforePreload = 60;
void save( QDomDocument& doc, QDomElement& trackNode ) const; void save( QXmlStreamWriter& project ) const;
void clear(); void clear();
void renderOneFrame(); void renderOneFrame();
......
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