[vlmc-devel] commit: MainWorkflow: saving is functionnal again. (Hugo Beauzee-Luyssen )
git at videolan.org
git at videolan.org
Fri Mar 12 20:06:40 CET 2010
vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Fri Mar 12 15:48:16 2010 +0100| [917242017e3fc908fa0b8677c2d27e33ca7108df] | committer: Hugo Beauzee-Luyssen
MainWorkflow: saving is functionnal again.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=917242017e3fc908fa0b8677c2d27e33ca7108df
---
src/Project/ProjectManager.cpp | 2 +-
src/Workflow/MainWorkflow.cpp | 9 ++++---
src/Workflow/MainWorkflow.h | 8 +++---
src/Workflow/TrackHandler.cpp | 14 +++++-----
src/Workflow/TrackHandler.h | 4 ++-
src/Workflow/TrackWorkflow.cpp | 48 +++++++--------------------------------
src/Workflow/TrackWorkflow.h | 2 +-
7 files changed, 30 insertions(+), 57 deletions(-)
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index c3ab4a7..7bf4314 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -230,7 +230,7 @@ void ProjectManager::__saveProject( const QString &fileName )
project.writeStartElement( "vlmc" );
Library::getInstance()->saveProject( project );
-// MainWorkflow::getInstance()->saveProject( doc, rootNode );
+ MainWorkflow::getInstance()->saveProject( project );
// SettingsManager::getInstance()->save( doc, rootNode );
project.writeEndElement();
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 380ba98..648b03e 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -34,6 +34,7 @@
#include "SettingsManager.h"
#include <QDomElement>
+#include <QXmlStreamWriter>
LightVideoFrame *MainWorkflow::blackOutput = NULL;
@@ -379,14 +380,14 @@ MainWorkflow::loadProject( const QDomElement &project )
}
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 )
{
- m_tracks[i]->save( doc, project );
+ m_tracks[i]->save( project );
}
- rootNode.appendChild( project );
+ project.writeEndElement();
}
void
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 8adce92..6d48dc1 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -31,6 +31,7 @@ class QDomDocument;
class QDomElement;
class QMutex;
class QReadWriteLock;
+class QXmlStreamWriter;
class Clip;
class EffectsEngine;
@@ -412,12 +413,11 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/
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 rootNode A reference on the node that will contain the timeline.
+ * \param project The XML stream representing the project
*/
- void saveProject( QDomDocument& doc, QDomElement& rootNode );
+ void saveProject( QXmlStreamWriter& project ) const;
/**
* \brief Clear the workflow.
*
diff --git a/src/Workflow/TrackHandler.cpp b/src/Workflow/TrackHandler.cpp
index 796e152..4cbc789 100644
--- a/src/Workflow/TrackHandler.cpp
+++ b/src/Workflow/TrackHandler.cpp
@@ -27,6 +27,7 @@
#include <QDomDocument>
#include <QDomElement>
+#include <QXmlStreamWriter>
LightVideoFrame* TrackHandler::nullOutput = NULL;
@@ -276,18 +277,17 @@ TrackHandler::getTrackCount() const
}
void
-TrackHandler::save( QDomDocument& doc, QDomElement& timelineNode ) const
+TrackHandler::save( QXmlStreamWriter& project ) const
{
for ( unsigned int i = 0; i < m_trackCount; ++i)
{
if ( m_tracks[i]->getLength() > 0 )
{
- QDomElement trackNode = doc.createElement( "track" );
-
- trackNode.setAttribute( "id", i );
-
- m_tracks[i]->save( doc, trackNode );
- timelineNode.appendChild( trackNode );
+ project.writeStartElement( "track" );
+ project.writeAttribute( "type", QString::number( (int)m_trackType ) );
+ project.writeAttribute( "id", QString::number( i ) );
+ m_tracks[i]->save( project );
+ project.writeEndElement();
}
}
}
diff --git a/src/Workflow/TrackHandler.h b/src/Workflow/TrackHandler.h
index 1784d0b..3d8de27 100644
--- a/src/Workflow/TrackHandler.h
+++ b/src/Workflow/TrackHandler.h
@@ -33,6 +33,8 @@
class EffectEngine;
class TrackWorkflow;
+class QXmlStreamWriter;
+
class TrackHandler : public QObject
{
Q_OBJECT
@@ -72,7 +74,7 @@ class TrackHandler : public QObject
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
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 2acd9a6..9775bd5 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -29,9 +29,11 @@
#include "AudioClipWorkflow.h"
#include "Clip.h"
#include "Media.h"
+
#include <QReadWriteLock>
#include <QDomDocument>
#include <QDomElement>
+#include <QXmlStreamWriter>
TrackWorkflow::TrackWorkflow( unsigned int trackId, MainWorkflow::TrackType type ) :
m_trackId( trackId ),
@@ -386,7 +388,7 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id )
return NULL;
}
-void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const
+void TrackWorkflow::save( QXmlStreamWriter& project ) const
{
QReadLocker lock( m_clipsLock );
@@ -395,44 +397,12 @@ void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const
for ( ; it != end ; ++it )
{
- QDomElement clipNode = doc.createElement( "clip" );
-
- {
- QDomElement parent = doc.createElement( "parent" );
-
- QDomCharacterData text = doc.createTextNode( it.value()->getClip()->getMedia()->baseClip()->uuid().toString() );
- 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 );
+ project.writeStartElement( "clip" );
+ project.writeAttribute( "uuid", it.value()->getClip()->getParent()->uuid().toString() );
+ project.writeAttribute( "startFrame", QString::number( it.key() ) );
+ project.writeAttribute( "begin", QString::number( it.value()->getClip()->begin() ) );
+ project.writeAttribute( "end", QString::number( it.value()->getClip()->end() ) );
+ project.writeEndElement();
}
}
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index a2d2e16..3068fd4 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -68,7 +68,7 @@ class TrackWorkflow : public QObject
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static const unsigned int nbFrameBeforePreload = 60;
- void save( QDomDocument& doc, QDomElement& trackNode ) const;
+ void save( QXmlStreamWriter& project ) const;
void clear();
void renderOneFrame();
More information about the Vlmc-devel
mailing list