Commit 78f34164 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Project saving backend is functionnal

parent 5c63b168
......@@ -148,8 +148,3 @@ void GraphicsMovieItem::updateTitle()
//FIXME there is a small visual refresh bug here
m_movieTitle->setPlainText( fm.elidedText( text, Qt::ElideRight, width ) );
}
void GraphicsMovieItem::setClip( Clip* clip )
{
m_clip = clip;
}
......@@ -366,10 +366,9 @@ void TracksView::dropEvent( QDropEvent* event )
qreal mappedXPos = ( mapToScene( event->pos() ).x() + 0.5 );
m_dragItem->oldTrackNumber = m_dragItem->trackNumber();
Clip* clip = new Clip( m_dragItem->clip() );
m_dragItem->setClip( clip );
Commands::trigger( new Commands::MainWorkflow::AddClip( m_mainWorkflow,
clip,
m_dragItem->clip(),
m_dragItem->trackNumber(),
(qint64)mappedXPos ) );
m_dragItem = NULL;
......
......@@ -392,3 +392,26 @@ Clip* MainWorkflow::getClip( const QUuid& uuid, unsigned int trackId )
return m_tracks[trackId]->getClip( uuid );
}
void MainWorkflow::loadProject( const QDomElement& project )
{
Q_ASSERT( 0 );
}
void MainWorkflow::saveProject( QDomDocument& doc )
{
QDomElement project = doc.createElement( "timeline" );
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 );
project.appendChild( trackNode );
}
}
doc.appendChild( project );
}
......@@ -27,6 +27,7 @@
#include <QObject>
#include <QReadWriteLock>
#include <QMutex>
#include <QDomElement>
#include "Toggleable.hpp"
#include "TrackWorkflow.h"
......@@ -143,6 +144,10 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void trackUnpaused();
void tracksRenderCompleted( unsigned int trackId );
public slots:
void loadProject( const QDomElement& project );
void saveProject( QDomDocument& doc );
signals:
/**
* \brief Used to notify a change to the timeline cursor
......
......@@ -502,3 +502,47 @@ void TrackWorkflow::clipWorkflowUnpaused()
emit trackUnpaused();
}
}
void TrackWorkflow::save( QDomDocument& doc, QDomElement& trackNode ) const
{
QReadLocker lock( m_clipsLock );
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::const_iterator end = m_clips.end();
for ( ; it != end ; ++it )
{
QDomElement clipNode = doc.createElement( "clip" );
{
QDomElement parent = doc.createElement( "parent" );
QDomCharacterData text = doc.createTextNode( it.value()->getClip()->getParent()->getUuid().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()->getBegin() ) );
begin.appendChild( text );
clipNode.appendChild( begin );
}
{
QDomElement end = doc.createElement( "end" );
QDomCharacterData text = doc.createTextNode( QString::number( it.value()->getClip()->getEnd() ) );
end.appendChild( text );
clipNode.appendChild( end );
}
trackNode.appendChild( clipNode );
}
}
......@@ -29,6 +29,7 @@
#include <QMap>
#include <QList>
#include <QReadWriteLock>
#include <QDomElement>
#include "ClipWorkflow.h"
......@@ -69,6 +70,8 @@ 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;
private:
void computeLength();
void renderClip( ClipWorkflow* cw, qint64 currentFrame,
......
......@@ -10,7 +10,8 @@ INCLUDEPATH = build/moc \
build/ui
QT += gui \
network \
svg
svg \
xml
SOURCES += src/main.cpp \
src/GUI/MainWindow.cpp \
src/GUI/LibraryWidget.cpp \
......
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