[vlmc-devel] commit: Timeline: Load 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 21:11:53 2010 +0200| [d2df935925bfb11c0545fa8fd7c422050e07589b] | committer: Hugo Beauzée-Luyssen
Timeline: Load the project file
Right now, this just loads the elements' color
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=d2df935925bfb11c0545fa8fd7c422050e07589b
---
src/Gui/project/GuiProjectManager.cpp | 6 +++++
src/Gui/project/GuiProjectManager.h | 1 +
src/Gui/timeline/AbstractGraphicsMediaItem.cpp | 9 ++++++-
src/Gui/timeline/AbstractGraphicsMediaItem.h | 3 +-
src/Gui/timeline/Timeline.cpp | 28 ++++++++++++++++++++++++
src/Gui/timeline/Timeline.h | 1 +
src/Gui/timeline/TracksView.cpp | 15 ++++++++++++
src/Gui/timeline/TracksView.h | 7 ++++++
src/Project/ProjectManager.cpp | 6 +++-
src/Project/ProjectManager.h | 3 +-
10 files changed, 74 insertions(+), 5 deletions(-)
diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index f262664..ce8be7f 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -213,3 +213,9 @@ GUIProjectManager::saveTimeline( QXmlStreamWriter &project )
{
Timeline::getInstance()->save( project );
}
+
+void
+GUIProjectManager::loadTimeline( const QDomElement &root )
+{
+ Timeline::getInstance()->load( root );
+}
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index eb234d6..eefa185 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -56,6 +56,7 @@ public:
protected:
virtual void failedToLoad( const QString &reason ) const;
virtual void saveTimeline( QXmlStreamWriter &project );
+ virtual void loadTimeline( const QDomElement& root );
private:
bool createNewProjectFile( bool saveAs );
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index 8c39909..22ab475 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -324,12 +324,19 @@ bool AbstractGraphicsMediaItem::resizeZone( const QPointF& position )
return false;
}
-QColor AbstractGraphicsMediaItem::itemColor()
+QColor
+AbstractGraphicsMediaItem::itemColor()
{
return m_itemColor;
}
void
+AbstractGraphicsMediaItem::setColor( const QColor &color )
+{
+ m_itemColor = color;
+}
+
+void
AbstractGraphicsMediaItem::clipDestroyed( Clip* clip )
{
if ( m_tracksView != NULL )
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index a377cf8..303af41 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -107,7 +107,8 @@ public:
ClipHelper *clipHelper();
- QColor itemColor();
+ QColor itemColor();
+ void setColor( const QColor& color );
protected:
/**
diff --git a/src/Gui/timeline/Timeline.cpp b/src/Gui/timeline/Timeline.cpp
index 53d71a8..8b579e4 100644
--- a/src/Gui/timeline/Timeline.cpp
+++ b/src/Gui/timeline/Timeline.cpp
@@ -29,6 +29,7 @@
#include "Clip.h"
#include <QHBoxLayout>
+#include <QDomElement>
#include <QScrollBar>
#include <QXmlStreamWriter>
@@ -197,3 +198,30 @@ Timeline::save( QXmlStreamWriter &project ) const
}
project.writeEndDocument();
}
+
+void
+Timeline::load( const QDomElement &root )
+{
+ QDomElement project = root.firstChildElement( "timeline" );
+ if ( project.isNull() == true )
+ {
+ qCritical() << "No timeline node in the project file";
+ return ;
+ }
+
+ QDomElement elem = project.firstChild().toElement();
+ while ( elem.isNull() == false )
+ {
+ QString uuid = elem.attribute( "uuid" );
+
+ AbstractGraphicsMediaItem *item = tracksView()->item( uuid );
+ if ( item != NULL )
+ {
+ QString color = elem.attribute( "color" );
+ item->setColor( color );
+ }
+ else
+ qWarning() << "No such timeline item:" << uuid;
+ elem = elem.nextSibling().toElement();
+ }
+}
diff --git a/src/Gui/timeline/Timeline.h b/src/Gui/timeline/Timeline.h
index c2f7702..ffafe3a 100644
--- a/src/Gui/timeline/Timeline.h
+++ b/src/Gui/timeline/Timeline.h
@@ -55,6 +55,7 @@ public:
static Timeline* getInstance() { return m_instance; }
void save( QXmlStreamWriter& project ) const;
+ void load( const QDomElement &root );
public slots:
/**
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index f0a273e..d4db135 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -1189,3 +1189,18 @@ TracksView::split( AbstractGraphicsMediaItem *item, qint64 frame )
item->startPos() + frame, frame + item->clipHelper()->begin(),
item->mediaType() ) );
}
+
+AbstractGraphicsMediaItem*
+TracksView::item( const QUuid &uuid )
+{
+ for ( int i = 0; i < m_scene->items().size(); ++i )
+ {
+ AbstractGraphicsMediaItem* item =
+ dynamic_cast<AbstractGraphicsMediaItem*>( m_scene->items().at( i ) );
+ if ( item == NULL )
+ continue ;
+ if ( item->uuid() == uuid )
+ return item;
+ }
+ return NULL;
+}
diff --git a/src/Gui/timeline/TracksView.h b/src/Gui/timeline/TracksView.h
index 7ffbc78..9c44b0e 100644
--- a/src/Gui/timeline/TracksView.h
+++ b/src/Gui/timeline/TracksView.h
@@ -180,6 +180,13 @@ public:
*/
void removeClip( const QUuid& uuid );
+ /**
+ * \returns The AbstractGraphicsMediaItem identified by the given uuid.
+ * or NULL if there's no such item.
+ * \param uuid The ClipHelper's uuid
+ */
+ AbstractGraphicsMediaItem* item( const QUuid& uuid );
+
public slots:
/**
* \brief Remove all items from the timeline.
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index a4b963b..329baec 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -64,7 +64,8 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
QT_TRANSLATE_NOOP( "PreferenceWidget", "Project name" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "The project name" ) );
- connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadTimeline() ) );
+ //We have to wait for the library to be loaded before loading the workflow
+ connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadWorkflow() ) );
}
ProjectManager::~ProjectManager()
@@ -83,11 +84,12 @@ QStringList ProjectManager::recentsProjects() const
return m_recentsProjects;
}
-void ProjectManager::loadTimeline()
+void ProjectManager::loadWorkflow()
{
QDomElement root = m_domDocument->documentElement();
MainWorkflow::getInstance()->loadProject( root );
+ loadTimeline( root );
SettingsManager::getInstance()->load( root );
emit projectUpdated( projectName(), true );
emit projectLoaded();
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index a2c20fa..f4d44da 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -78,6 +78,7 @@ protected:
QString projectName() const;
virtual void failedToLoad( const QString& reason ) const;
+ virtual void loadTimeline( const QDomElement& ){};
ProjectManager();
~ProjectManager();
@@ -93,7 +94,7 @@ protected:
friend class Singleton<ProjectManager>;
protected slots:
- void loadTimeline();
+ void loadWorkflow();
signals:
/**
More information about the Vlmc-devel
mailing list