Commit 8b09f593 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

ProjectManager: Clips and Media are now saved.

Nothing else is saved, as we now use a QXmlStreamWriter. The file format
has changed.
Using forward declaration for class Media as soon as possible.
parent 111cbd6a
......@@ -20,13 +20,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtDebug>
#include <QTime>
#include <QPushButton>
#include <QInputDialog>
#include "ClipProperty.h"
#include "ui_ClipProperty.h"
#include "Media.h"
#include <QTime>
#include <QPushButton>
#include <QInputDialog>
ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) :
QDialog( parent ),
......
......@@ -23,9 +23,10 @@
#include "TagWidget.h"
#include "ui_TagWidget.h"
#include "Media.h"
#include <QPushButton>
#include <QDebug>
#include <math.h>
TagWidget::TagWidget( QWidget *parent, int nbButton, QStringList tagList ) :
QWidget( parent ),
......
......@@ -23,13 +23,13 @@
#include "MediaCellView.h"
#include "ui_MediaCellView.h"
#include "Media.h"
#include "Library.h"
#include "ClipProperty.h"
#include <QTime>
#include <QtDebug>
MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
QWidget( parent ),
m_ui( new Ui::MediaCellView ),
......
......@@ -29,6 +29,7 @@
#include "Clip.h"
#include "Commands.h"
#include "Media.h"
AbstractGraphicsMediaItem::AbstractGraphicsMediaItem() :
oldTrackNumber( -1 ), oldPosition( -1 ), m_tracksView( NULL ),
......
......@@ -21,14 +21,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QPainter>
#include <QLinearGradient>
#include <QDebug>
#include <QTime>
#include "GraphicsAudioItem.h"
#include "Media.h"
#include "TracksView.h"
#include "Timeline.h"
#include <QPainter>
#include <QLinearGradient>
#include <QTime>
GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : m_clip( clip )
{
setFlags( QGraphicsItem::ItemIsSelectable );
......
......@@ -25,7 +25,9 @@
#include <QDebug>
#include <QTime>
#include <QFontMetrics>
#include "GraphicsMovieItem.h"
#include "Media.h"
#include "TracksView.h"
#include "Timeline.h"
......
......@@ -22,12 +22,13 @@
#include "TracksView.h"
#include "Commands.h"
#include "Library.h"
#include "GraphicsMovieItem.h"
#include "GraphicsAudioItem.h"
#include "GraphicsCursorItem.h"
#include "Commands.h"
#include "GraphicsTrack.h"
#include "Media.h"
#include "WorkflowRenderer.h"
#include <QScrollBar>
......
......@@ -36,6 +36,7 @@
#include <QDomElement>
#include <QHash>
#include <QUuid>
#include <QXmlStreamWriter>
void
Library::loadProject( const QDomElement& medias )
......@@ -126,9 +127,9 @@ Library::loadProject( const QDomElement& medias )
emit projectLoaded();
}
void
Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
{
//void
//Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
//{
// QHash<QUuid, Media*>::iterator it = m_clips.begin();
// QHash<QUuid, Media*>::iterator end = m_clips.end();
//
......@@ -169,5 +170,23 @@ Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
// }
// }
// rootNode.appendChild( medias );
#warning "FIXME: Project saving";
// #warning "FIXME: Project saving";
//}
void
Library::saveProject( QXmlStreamWriter& project )
{
QHash<QUuid, Clip*>::const_iterator it = m_clips.begin();
QHash<QUuid, Clip*>::const_iterator end = m_clips.end();
project.writeStartElement( "medias" );
while ( it != end )
{
it.value()->getMedia()->save( project );
++it;
}
project.writeEndElement();
project.writeStartElement( "clips" );
save( project );
project.writeEndElement();
}
......@@ -39,11 +39,10 @@
#include <QFileInfo>
#include <QMutex>
#include <QMutexLocker>
#include <QDomElement>
#include <QProgressDialog>
class QDomDocument;
class QDomElement;
class QXmlStreamWriter;
class QDomElement;
class Clip;
class Media;
......@@ -69,7 +68,7 @@ public slots:
/**
* \brief
*/
void saveProject( QDomDocument& doc, QDomElement& rootNode );
void saveProject( QXmlStreamWriter& project );
signals:
/**
......
......@@ -162,3 +162,10 @@ MediaContainer::count() const
{
return m_clips.size();
}
void
MediaContainer::save( QXmlStreamWriter &project )
{
foreach ( Clip* c, m_clips.values() )
c->save( project );
}
......@@ -30,6 +30,7 @@
class Media;
class Clip;
class QFileInfo;
class QXmlStreamWriter;
class MediaContainer : public QObject
{
......@@ -82,6 +83,16 @@ public:
*/
bool addClip( Clip* clip );
/**
* \brief Save the contained media to the given XML stream
*
* This will save all contained clip. If a clip contained subclips, they will be saved
* too, and so on.
*
* \param project The QXmlStreamWriter to write into.
*/
void save( QXmlStreamWriter& project );
/**
* \return All the loaded Clip
*/
......
......@@ -25,9 +25,12 @@
*/
#include <QtDebug>
#include "Library.h"
#include "Clip.h"
#include "Library.h"
#include "Media.h"
#include <QXmlStreamWriter>
const int Clip::DefaultFPS = 30;
......@@ -291,3 +294,30 @@ Clip::clear()
{
m_childs->clear();
}
void
Clip::save( QXmlStreamWriter &project )
{
project.writeStartElement( "clip" );
if ( isRootClip() == true )
project.writeAttribute( "media", m_media->fileInfo()->absoluteFilePath() );
else
{
project.writeAttribute( "parent", m_parent->uuid() );
project.writeAttribute( "rootClip", m_rootClip->uuid() );
}
project.writeAttribute( "uuid", m_uuid.toString() );
project.writeAttribute( "begin", QString::number( m_begin ) );
project.writeAttribute( "end", QString::number( m_end ) );
project.writeAttribute( "metatags", m_metaTags.join( "," ) );
project.writeAttribute( "notes", m_notes );
project.writeAttribute( "maxBegin", QString::number( m_maxBegin ) );
project.writeAttribute( "maxEnd", QString::number( m_maxEnd ) );
if ( m_childs->count() > 0 )
{
project.writeStartElement( "subClips" );
m_childs->save( project );
project.writeEndElement();
}
project.writeEndElement();
}
......@@ -29,13 +29,13 @@
# define CLIP_H__
#include <QObject>
#include <QStringList>
#include <QUuid>
#include "Media.h"
class MediaContainer;
class Media;
class Media;
class QXmlStreamWriter;
class Clip : public QObject
{
......@@ -124,6 +124,8 @@ class Clip : public QObject
bool addSubclip( Clip* clip );
void save( QXmlStreamWriter& project );
private:
Media *m_media;
/**
......
......@@ -22,17 +22,19 @@
/** \file
* This file contains the Media class implementation.
* It contains a VLCMedia and the meta-datas.
* It contains the Media meta-datas, and information to be used with a VLC Media.
* It's used by the Library
*/
#include <QtDebug>
#include <QUrl>
#include "Media.h"
#include "MetaDataManager.h"
#include "VLCMedia.h"
#include "Clip.h"
#include <QXmlStreamWriter>
#include <QtDebug>
#include <QUrl>
QPixmap* Media::defaultSnapshot = NULL;
const QString Media::VideoExtensions = "*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *.mp4 *.ogg *.ogv";
const QString Media::ImageExtensions = "*.gif *.png *.jpg *.jpeg";
......@@ -275,3 +277,11 @@ Media::isMetadataComputed() const
{
return m_metadataComputed;
}
void
Media::save( QXmlStreamWriter& project )
{
project.writeStartElement( "media" );
project.writeAttribute( "mrl", m_fileInfo->absoluteFilePath() );
project.writeEndElement();
}
......@@ -43,6 +43,8 @@ namespace LibVLCpp
}
class Clip;
class QXmlStreamWriter;
/**
* Represents a basic container for media informations.
*/
......@@ -140,6 +142,8 @@ public:
bool isMetadataComputed() const;
void save( QXmlStreamWriter& project );
private:
void setFileType();
......
......@@ -36,6 +36,7 @@
#include <QSettings>
#include <QtDebug>
#include <QTimer>
#include <QXmlStreamWriter>
#include <errno.h>
#include <signal.h>
......@@ -219,24 +220,21 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ )
void ProjectManager::__saveProject( const QString &fileName )
{
QDomImplementation implem = QDomDocument().implementation();
QString name = projectName();
QString publicId = "-//XADECK//DTD Stone 1.0 //EN";
QString systemId = "http://www-imagis.imag.fr/DTD/stone1.dtd";
QDomDocument doc(implem.createDocumentType( name, publicId, systemId ) );
QFile file( fileName );
file.open( QFile::WriteOnly );
QDomElement rootNode = doc.createElement( "vlmc" );
QXmlStreamWriter project( &file );
Library::getInstance()->saveProject( doc, rootNode );
MainWorkflow::getInstance()->saveProject( doc, rootNode );
SettingsManager::getInstance()->save( doc, rootNode );
project.setAutoFormatting( true );
project.writeStartDocument();
project.writeStartElement( "vlmc" );
doc.appendChild( rootNode );
Library::getInstance()->saveProject( project );
// MainWorkflow::getInstance()->saveProject( doc, rootNode );
// SettingsManager::getInstance()->save( doc, rootNode );
QFile file( fileName );
file.open( QFile::WriteOnly );
file.write( doc.toString().toAscii() );
file.close();
project.writeEndElement();
project.writeEndDocument();
}
void ProjectManager::newProject( const QString &projectName )
......
......@@ -21,13 +21,14 @@
*****************************************************************************/
#include "vlmc.h"
#include "Clip.h"
#include "ClipWorkflow.h"
#include "MemoryPool.hpp"
#include "LightVideoFrame.h"
#include "Clip.h"
#include "VLCMediaPlayer.h"
#include "Media.h"
#include "MemoryPool.hpp"
#include "WaitCondition.hpp"
#include "VLCMedia.h"
#include "VLCMediaPlayer.h"
#include <QReadWriteLock>
#include <QWaitCondition>
......
......@@ -26,6 +26,7 @@
#include "MainWorkflow.h"
#include "VLCMediaPlayer.h"
#include "VLCMedia.h"
#include "Media.h"
ImageClipWorkflow::ImageClipWorkflow( Clip *clip ) :
ClipWorkflow( clip ),
......
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