[vlmc-devel] commit: Timeline: Save the timeline configuration to the project file. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Apr 22 21:12:24 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Apr 22 20:37:52 2010 +0200| [27eb7d2ef31f35d8862ba4919e3d3e492f4fef8c] | committer: Hugo Beauzée-Luyssen 

Timeline: Save the timeline configuration to the project file.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=27eb7d2ef31f35d8862ba4919e3d3e492f4fef8c
---

 src/Gui/project/GuiProjectManager.cpp        |    7 ++++++
 src/Gui/project/GuiProjectManager.h          |    1 +
 src/Gui/timeline/AbstractGraphicsMediaItem.h |    4 +-
 src/Gui/timeline/Timeline.cpp                |   28 +++++++++++++++++++++++--
 src/Gui/timeline/Timeline.h                  |    4 +++
 src/Project/ProjectManager.cpp               |    1 +
 src/Project/ProjectManager.h                 |    8 ++++++-
 src/Workflow/MainWorkflow.cpp                |    4 +-
 8 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index dcae06d..f262664 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -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 );
+}
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index 37ba86b..eb234d6 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -55,6 +55,7 @@ public:
 
 protected:
     virtual void    failedToLoad( const QString &reason ) const;
+    virtual void    saveTimeline( QXmlStreamWriter &project );
 
 private:
     bool            createNewProjectFile( bool saveAs );
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index fe7c6e8..a377cf8 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -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 );
 
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index b869631..53d71a8 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -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();
+}
diff --git a/src/Gui/timeline/Timeline.h b/src/Gui/timeline/Timeline.h
index 7b61a80..c2f7702 100644
--- a/src/Gui/timeline/Timeline.h
+++ b/src/Gui/timeline/Timeline.h
@@ -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.
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index e82d136..cb0d429 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -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();
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index 32e3e6d..a2c20fa 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -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();
 
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 41db17f..2d00122 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -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 );



More information about the Vlmc-devel mailing list