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 @@ ...@@ -20,13 +20,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <QtDebug>
#include <QTime>
#include <QPushButton>
#include <QInputDialog>
#include "ClipProperty.h" #include "ClipProperty.h"
#include "ui_ClipProperty.h" #include "ui_ClipProperty.h"
#include "Media.h"
#include <QTime>
#include <QPushButton>
#include <QInputDialog>
ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) : ClipProperty::ClipProperty( Clip* clip, QWidget *parent ) :
QDialog( parent ), QDialog( parent ),
......
...@@ -23,9 +23,10 @@ ...@@ -23,9 +23,10 @@
#include "TagWidget.h" #include "TagWidget.h"
#include "ui_TagWidget.h" #include "ui_TagWidget.h"
#include "Media.h"
#include <QPushButton> #include <QPushButton>
#include <QDebug>
#include <math.h>
TagWidget::TagWidget( QWidget *parent, int nbButton, QStringList tagList ) : TagWidget::TagWidget( QWidget *parent, int nbButton, QStringList tagList ) :
QWidget( parent ), QWidget( parent ),
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#include "MediaCellView.h" #include "MediaCellView.h"
#include "ui_MediaCellView.h" #include "ui_MediaCellView.h"
#include "Media.h"
#include "Library.h" #include "Library.h"
#include "ClipProperty.h" #include "ClipProperty.h"
#include <QTime> #include <QTime>
#include <QtDebug>
MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) : MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
QWidget( parent ), QWidget( parent ),
m_ui( new Ui::MediaCellView ), m_ui( new Ui::MediaCellView ),
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "Clip.h" #include "Clip.h"
#include "Commands.h" #include "Commands.h"
#include "Media.h"
AbstractGraphicsMediaItem::AbstractGraphicsMediaItem() : AbstractGraphicsMediaItem::AbstractGraphicsMediaItem() :
oldTrackNumber( -1 ), oldPosition( -1 ), m_tracksView( NULL ), oldTrackNumber( -1 ), oldPosition( -1 ), m_tracksView( NULL ),
......
...@@ -21,14 +21,15 @@ ...@@ -21,14 +21,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <QPainter>
#include <QLinearGradient>
#include <QDebug>
#include <QTime>
#include "GraphicsAudioItem.h" #include "GraphicsAudioItem.h"
#include "Media.h"
#include "TracksView.h" #include "TracksView.h"
#include "Timeline.h" #include "Timeline.h"
#include <QPainter>
#include <QLinearGradient>
#include <QTime>
GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : m_clip( clip ) GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : m_clip( clip )
{ {
setFlags( QGraphicsItem::ItemIsSelectable ); setFlags( QGraphicsItem::ItemIsSelectable );
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
#include <QDebug> #include <QDebug>
#include <QTime> #include <QTime>
#include <QFontMetrics> #include <QFontMetrics>
#include "GraphicsMovieItem.h" #include "GraphicsMovieItem.h"
#include "Media.h"
#include "TracksView.h" #include "TracksView.h"
#include "Timeline.h" #include "Timeline.h"
......
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
#include "TracksView.h" #include "TracksView.h"
#include "Commands.h"
#include "Library.h" #include "Library.h"
#include "GraphicsMovieItem.h" #include "GraphicsMovieItem.h"
#include "GraphicsAudioItem.h" #include "GraphicsAudioItem.h"
#include "GraphicsCursorItem.h" #include "GraphicsCursorItem.h"
#include "Commands.h"
#include "GraphicsTrack.h" #include "GraphicsTrack.h"
#include "Media.h"
#include "WorkflowRenderer.h" #include "WorkflowRenderer.h"
#include <QScrollBar> #include <QScrollBar>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <QDomElement> #include <QDomElement>
#include <QHash> #include <QHash>
#include <QUuid> #include <QUuid>
#include <QXmlStreamWriter>
void void
Library::loadProject( const QDomElement& medias ) Library::loadProject( const QDomElement& medias )
...@@ -126,9 +127,9 @@ Library::loadProject( const QDomElement& medias ) ...@@ -126,9 +127,9 @@ Library::loadProject( const QDomElement& medias )
emit projectLoaded(); emit projectLoaded();
} }
void //void
Library::saveProject( QDomDocument& doc, QDomElement& rootNode ) //Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
{ //{
// QHash<QUuid, Media*>::iterator it = m_clips.begin(); // QHash<QUuid, Media*>::iterator it = m_clips.begin();
// QHash<QUuid, Media*>::iterator end = m_clips.end(); // QHash<QUuid, Media*>::iterator end = m_clips.end();
// //
...@@ -169,5 +170,23 @@ Library::saveProject( QDomDocument& doc, QDomElement& rootNode ) ...@@ -169,5 +170,23 @@ Library::saveProject( QDomDocument& doc, QDomElement& rootNode )
// } // }
// } // }
// rootNode.appendChild( medias ); // 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 @@ ...@@ -39,11 +39,10 @@
#include <QFileInfo> #include <QFileInfo>
#include <QMutex> #include <QMutex>
#include <QMutexLocker> #include <QMutexLocker>
#include <QDomElement>
#include <QProgressDialog> #include <QProgressDialog>
class QDomDocument; class QXmlStreamWriter;
class QDomElement; class QDomElement;
class Clip; class Clip;
class Media; class Media;
...@@ -69,7 +68,7 @@ public slots: ...@@ -69,7 +68,7 @@ public slots:
/** /**
* \brief * \brief
*/ */
void saveProject( QDomDocument& doc, QDomElement& rootNode ); void saveProject( QXmlStreamWriter& project );
signals: signals:
/** /**
......
...@@ -162,3 +162,10 @@ MediaContainer::count() const ...@@ -162,3 +162,10 @@ MediaContainer::count() const
{ {
return m_clips.size(); return m_clips.size();
} }
void
MediaContainer::save( QXmlStreamWriter &project )
{
foreach ( Clip* c, m_clips.values() )
c->save( project );
}
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
class Media; class Media;
class Clip; class Clip;
class QFileInfo; class QFileInfo;
class QXmlStreamWriter;
class MediaContainer : public QObject class MediaContainer : public QObject
{ {
...@@ -82,6 +83,16 @@ public: ...@@ -82,6 +83,16 @@ public:
*/ */
bool addClip( Clip* clip ); 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 * \return All the loaded Clip
*/ */
......
...@@ -25,9 +25,12 @@ ...@@ -25,9 +25,12 @@
*/ */
#include <QtDebug> #include <QtDebug>
#include "Library.h"
#include "Clip.h" #include "Clip.h"
#include "Library.h"
#include "Media.h"
#include <QXmlStreamWriter>
const int Clip::DefaultFPS = 30; const int Clip::DefaultFPS = 30;
...@@ -291,3 +294,30 @@ Clip::clear() ...@@ -291,3 +294,30 @@ Clip::clear()
{ {
m_childs->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 @@ ...@@ -29,13 +29,13 @@
# define CLIP_H__ # define CLIP_H__
#include <QObject> #include <QObject>
#include <QStringList>
#include <QUuid> #include <QUuid>
#include "Media.h"
class MediaContainer; class MediaContainer;
class Media;
class Media; class QXmlStreamWriter;
class Clip : public QObject class Clip : public QObject
{ {
...@@ -124,6 +124,8 @@ class Clip : public QObject ...@@ -124,6 +124,8 @@ class Clip : public QObject
bool addSubclip( Clip* clip ); bool addSubclip( Clip* clip );
void save( QXmlStreamWriter& project );
private: private:
Media *m_media; Media *m_media;
/** /**
......
...@@ -22,17 +22,19 @@ ...@@ -22,17 +22,19 @@
/** \file /** \file
* This file contains the Media class implementation. * 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 * It's used by the Library
*/ */
#include <QtDebug>
#include <QUrl>
#include "Media.h" #include "Media.h"
#include "MetaDataManager.h" #include "MetaDataManager.h"
#include "VLCMedia.h" #include "VLCMedia.h"
#include "Clip.h" #include "Clip.h"
#include <QXmlStreamWriter>
#include <QtDebug>
#include <QUrl>
QPixmap* Media::defaultSnapshot = NULL; QPixmap* Media::defaultSnapshot = NULL;
const QString Media::VideoExtensions = "*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *.mp4 *.ogg *.ogv"; const QString Media::VideoExtensions = "*.mov *.avi *.mkv *.mpg *.mpeg *.wmv *.mp4 *.ogg *.ogv";
const QString Media::ImageExtensions = "*.gif *.png *.jpg *.jpeg"; const QString Media::ImageExtensions = "*.gif *.png *.jpg *.jpeg";
...@@ -275,3 +277,11 @@ Media::isMetadataComputed() const ...@@ -275,3 +277,11 @@ Media::isMetadataComputed() const
{ {
return m_metadataComputed; 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 ...@@ -43,6 +43,8 @@ namespace LibVLCpp
} }
class Clip; class Clip;
class QXmlStreamWriter;
/** /**
* Represents a basic container for media informations. * Represents a basic container for media informations.
*/ */
...@@ -140,6 +142,8 @@ public: ...@@ -140,6 +142,8 @@ public:
bool isMetadataComputed() const; bool isMetadataComputed() const;
void save( QXmlStreamWriter& project );
private: private:
void setFileType(); void setFileType();
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <QSettings> #include <QSettings>
#include <QtDebug> #include <QtDebug>
#include <QTimer> #include <QTimer>
#include <QXmlStreamWriter>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
...@@ -219,24 +220,21 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ ) ...@@ -219,24 +220,21 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ )
void ProjectManager::__saveProject( const QString &fileName ) void ProjectManager::__saveProject( const QString &fileName )
{ {
QDomImplementation implem = QDomDocument().implementation(); QFile file( fileName );
QString name = projectName(); file.open( QFile::WriteOnly );
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 ) );
QDomElement rootNode = doc.createElement( "vlmc" ); QXmlStreamWriter project( &file );
Library::getInstance()->saveProject( doc, rootNode ); project.setAutoFormatting( true );
MainWorkflow::getInstance()->saveProject( doc, rootNode ); project.writeStartDocument();
SettingsManager::getInstance()->save( doc, rootNode ); project.writeStartElement( "vlmc" );
doc.appendChild( rootNode ); Library::getInstance()->saveProject( project );
// MainWorkflow::getInstance()->saveProject( doc, rootNode );
// SettingsManager::getInstance()->save( doc, rootNode );
QFile file( fileName ); project.writeEndElement();
file.open( QFile::WriteOnly ); project.writeEndDocument();
file.write( doc.toString().toAscii() );
file.close();
} }
void ProjectManager::newProject( const QString &projectName ) void ProjectManager::newProject( const QString &projectName )
......
...@@ -21,13 +21,14 @@ ...@@ -21,13 +21,14 @@
*****************************************************************************/ *****************************************************************************/
#include "vlmc.h" #include "vlmc.h"
#include "Clip.h"
#include "ClipWorkflow.h" #include "ClipWorkflow.h"
#include "MemoryPool.hpp"
#include "LightVideoFrame.h" #include "LightVideoFrame.h"
#include "Clip.h" #include "Media.h"
#include "VLCMediaPlayer.h" #include "MemoryPool.hpp"
#include "WaitCondition.hpp" #include "WaitCondition.hpp"
#include "VLCMedia.h" #include "VLCMedia.h"
#include "VLCMediaPlayer.h"
#include <QReadWriteLock> #include <QReadWriteLock>
#include <QWaitCondition> #include <QWaitCondition>
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "MainWorkflow.h" #include "MainWorkflow.h"
#include "VLCMediaPlayer.h" #include "VLCMediaPlayer.h"
#include "VLCMedia.h" #include "VLCMedia.h"
#include "Media.h"
ImageClipWorkflow::ImageClipWorkflow( Clip *clip ) : ImageClipWorkflow::ImageClipWorkflow( Clip *clip ) :
ClipWorkflow( 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