[vlmc-devel] commit: Timeline: Project loading is functionnal again. ( Hugo Beauzee-Luyssen )

git at videolan.org git at videolan.org
Sat Mar 13 14:39:49 CET 2010


vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Sat Mar 13 14:26:23 2010 +0100| [9461620f43dff4c5084dfc8834c118eaec974402] | committer: Hugo Beauzee-Luyssen 

Timeline: Project loading is functionnal again.

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

 src/Project/ProjectManager.cpp |   19 ++++----
 src/Project/ProjectManager.h   |    4 +-
 src/Workflow/MainWorkflow.cpp  |   94 ++++++++++++---------------------------
 3 files changed, 42 insertions(+), 75 deletions(-)

diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index 5a8062a..ebaee83 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -133,10 +133,12 @@ void    ProjectManager::cleanChanged( bool val )
 
 void    ProjectManager::loadTimeline()
 {
-//    QDomElement     root = m_domDocument->documentElement();
-//
-//    MainWorkflow::getInstance()->loadProject( root.firstChildElement( "timeline" ) );
-//    emit projectUpdated( projectName(), true );
+    QDomElement     root = m_domDocument->documentElement();
+
+    MainWorkflow::getInstance()->loadProject( root );
+    emit projectUpdated( projectName(), true );
+//    SettingsManager::getInstance()->load( root.firstChildElement( "project" ) );
+    delete m_domDocument;
 }
 
 void    ProjectManager::loadProject( const QString& fileName )
@@ -151,8 +153,8 @@ void    ProjectManager::loadProject( const QString& fileName )
     m_projectFile->open( QFile::ReadOnly );
     m_projectFile->close();
 
-    QDomDocument    doc;
-    doc.setContent( m_projectFile );
+    m_domDocument = new QDomDocument;
+    m_domDocument->setContent( m_projectFile );
     m_needSave = false;
 
     if ( ProjectManager::isBackupFile( fileName ) == false )
@@ -165,11 +167,10 @@ void    ProjectManager::loadProject( const QString& fileName )
         m_projectFile = NULL;
     }
 
-    QDomElement     root = doc.documentElement();
+    QDomElement     root = m_domDocument->documentElement();
 
-//    connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadTimeline() ) );
+    connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadTimeline() ) );
     Library::getInstance()->loadProject( root );
-//    SettingsManager::getInstance()->load( root.firstChildElement( "project" ) );
 }
 
 QString  ProjectManager::acquireProjectFileName()
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index d0dfc4b..15e70b0 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -30,7 +30,8 @@
 
 #include "Singleton.hpp"
 
-class QFile;
+class   QFile;
+class   QDomDocument;
 
 class   ProjectManager : public QObject, public Singleton<ProjectManager>
 {
@@ -95,6 +96,7 @@ private:
     QString         m_projectName;
     QString         m_projectDescription;
     QTimer*         m_timer;
+    QDomDocument    *m_domDocument;
 
     friend class    Singleton<ProjectManager>;
 
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 648b03e..b81b8d3 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -284,13 +284,11 @@ MainWorkflow::getClip( const QUuid &uuid, unsigned int trackId,
  *  \warning    The mainworkflow is expected to be already cleared by the ProjectManager
  */
 void
-MainWorkflow::loadProject( const QDomElement &project )
+MainWorkflow::loadProject( const QDomElement &root )
 {
-    if ( project.isNull() == true || project.tagName() != "timeline" )
-    {
-        qWarning() << "Invalid timeline node (" << project.tagName() << ')';
+    QDomElement     project = root.firstChildElement( "timeline" );
+    if ( project.isNull() == true )
         return ;
-    }
 
     QDomElement elem = project.firstChild().toElement();
 
@@ -298,81 +296,47 @@ MainWorkflow::loadProject( const QDomElement &project )
     {
         bool    ok;
 
-        Q_ASSERT( elem.tagName() == "track" );
         unsigned int trackId = elem.attribute( "id" ).toUInt( &ok );
         if ( ok == false )
         {
             qWarning() << "Invalid track number in project file";
             return ;
         }
+        MainWorkflow::TrackType     type;
+        int utype = elem.attribute( "type" ).toInt( &ok );
+        if ( ok == false || (utype < 0 && utype >= MainWorkflow::NbTrackType ) )
+        {
+            qWarning() << "Invalid track type";
+            return ;
+        }
+        type = static_cast<MainWorkflow::TrackType>( utype );
+
         QDomElement clip = elem.firstChild().toElement();
         while ( clip.isNull() == false )
         {
             //Iterate over clip fields:
-            QDomElement clipProperty = clip.firstChild().toElement();
-            QUuid                       parentUuid;
-            qint64                      begin;
-            qint64                      end;
-            qint64                      startPos;
-            MainWorkflow::TrackType     trackType = MainWorkflow::VideoTrack;
-
-            while ( clipProperty.isNull() == false )
+            QString                     uuid;
+            QString                     begin;
+            QString                     end;
+            QString                     startFrame;
+
+            uuid = clip.attribute( "uuid" );
+            begin = clip.attribute( "begin" );
+            end = clip.attribute( "end" );
+            startFrame = clip.attribute( "startFrame" );
+
+            if ( uuid.isEmpty() == true || startFrame.isEmpty() == true )
             {
-                QString tagName = clipProperty.tagName();
-                bool    ok;
-
-                if ( tagName == "parent" )
-                    parentUuid = QUuid( clipProperty.text() );
-                else if ( tagName == "begin" )
-                {
-                    begin = clipProperty.text().toLongLong( &ok );
-                    if ( ok == false )
-                    {
-                        qWarning() << "Invalid clip begin";
-                        return ;
-                    }
-                }
-                else if ( tagName == "end" )
-                {
-                    end = clipProperty.text().toLongLong( &ok );
-                    if ( ok == false )
-                    {
-                        qWarning() << "Invalid clip end";
-                        return ;
-                    }
-                }
-                else if ( tagName == "startFrame" )
-                {
-                    startPos = clipProperty.text().toLongLong( &ok );
-                    if ( ok == false )
-                    {
-                        qWarning() << "Invalid clip starting frame";
-                        return ;
-                    }
-                }
-                else if ( tagName == "trackType" )
-                {
-                    trackType = static_cast<MainWorkflow::TrackType>(
-                                                    clipProperty.text().toUInt( &ok ) );
-                    if ( ok == false )
-                    {
-                        qWarning() << "Invalid track type starting frame";
-                        return ;
-                    }
-                }
-                else
-                    qDebug() << "Unknown field" << clipProperty.tagName();
-
-                clipProperty = clipProperty.nextSibling().toElement();
+                qWarning() << "Invalid clip node";
+                return ;
             }
 
-            if ( Library::getInstance()->clip( parentUuid ) != NULL )
+            Clip* c = Library::getInstance()->clip( uuid );
+            if ( c != NULL )
             {
-                Clip    *c = new Clip( Library::getInstance()->clip( parentUuid ),
-                                       begin, end, parentUuid.toString() );
-                addClip( c, trackId, startPos, trackType );
+                addClip( new Clip( c, begin.toLongLong(), end.toLongLong() ),
+                         trackId, startFrame.toLongLong(), type );
             }
-
             clip = clip.nextSibling().toElement();
         }
         elem = elem.nextSibling().toElement();



More information about the Vlmc-devel mailing list