[vlmc-devel] commit: Libary: Handle clean state. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Mon Jun 28 00:57:06 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Jun 28 00:56:33 2010 +0200| [22c353422d90352d3271eadaf534602c62f1a453] | committer: Hugo Beauzée-Luyssen
Libary: Handle clean state.
Now, adding a media set the project in an unclean state, which avoid
beeing able to close without saving when a media has been loaded without
saving the project afterward.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=22c353422d90352d3271eadaf534602c62f1a453
---
src/Gui/project/GuiProjectManager.cpp | 2 +
src/Library/Library.cpp | 46 +++++++++++++++++++++++++++++++++
src/Library/Library.h | 12 ++++++++-
src/Library/MediaContainer.h | 7 +++--
4 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index a9bac37..5096127 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -39,6 +39,8 @@ GUIProjectManager::GUIProjectManager()
{
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
+ connect( Library::getInstance(), SIGNAL( cleanStateChanged( bool ) ),
+ this, SLOT( cleanChanged( bool ) ) );
//Automatic save part :
m_timer = new QTimer( this );
diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index ea9aed9..a88a3f7 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -39,6 +39,10 @@
#include <QHash>
#include <QUuid>
+Library::Library() : m_cleanState( true )
+{
+}
+
void
Library::loadProject( const QDomElement& doc )
{
@@ -95,6 +99,7 @@ Library::saveProject( QXmlStreamWriter& project )
project.writeStartElement( "clips" );
save( project );
project.writeEndElement();
+ setCleanState( true );
}
void
@@ -109,3 +114,44 @@ Library::mediaLoaded( const Media* media )
if ( m_nbMediaToLoad == 0 )
emit projectLoaded();
}
+
+void
+Library::addMedia( Media* media )
+{
+ setCleanState( false );
+ MediaContainer::addMedia( media );
+}
+
+Media*
+Library::addMedia( const QFileInfo &fileInfo )
+{
+ Media* media = MediaContainer::addMedia( fileInfo );
+ if ( media != NULL )
+ setCleanState( false );
+ return media;
+}
+
+bool
+Library::addClip( Clip *clip )
+{
+ bool ret = MediaContainer::addClip( clip );
+ if ( ret != false )
+ setCleanState( false );
+ return ret;
+}
+
+bool
+Library::isInCleanState() const
+{
+ return m_cleanState;
+}
+
+void
+Library::setCleanState( bool newState )
+{
+ if ( newState != m_cleanState )
+ {
+ m_cleanState = newState;
+ emit cleanStateChanged( newState );
+ }
+}
diff --git a/src/Library/Library.h b/src/Library/Library.h
index 1f0a307..504f58c 100644
--- a/src/Library/Library.h
+++ b/src/Library/Library.h
@@ -51,12 +51,21 @@ class Library : public MediaContainer, public Singleton<Library>
Q_OBJECT
Q_DISABLE_COPY( Library );
+public:
+ virtual void addMedia( Media* media );
+ virtual Media *addMedia( const QFileInfo &fileInfo );
+ virtual bool addClip( Clip *clip );
+ bool isInCleanState() const;
+
private:
- Library() {}
+ Library();
virtual ~Library(){}
+ void setCleanState( bool newState );
+
private:
QAtomicInt m_nbMediaToLoad;
+ bool m_cleanState;
public slots:
/**
@@ -76,6 +85,7 @@ signals:
* \brief
*/
void projectLoaded();
+ void cleanStateChanged( bool newState );
friend class Singleton<Library>;
friend class Workspace;
diff --git a/src/Library/MediaContainer.h b/src/Library/MediaContainer.h
index e610d81..5ca37e4 100644
--- a/src/Library/MediaContainer.h
+++ b/src/Library/MediaContainer.h
@@ -63,19 +63,20 @@ public:
*
* \param media The media to add to the library
*/
- void addMedia( Media *media );
+ virtual void addMedia( Media *media );
/**
* \brief Add a file to the media library
*
* This method will also handle metadata parsing.
* \param fileInfo the file info of the media
- * \return true if the media was successfully loaded. false otherwise.
+ * \return The newly create media if the media was successfully loaded.
+ * NULL otherwise.
* \sa addClip( Clip* clip )
* \sa media( const QUuid& uuid)
* \sa clip( const QUuid& uuid )
*/
- Media* addMedia( const QFileInfo& fileInfo );
+ virtual Media *addMedia( const QFileInfo& fileInfo );
/**
* \brief Check if a file has already been loaded into library.
* \param fileInfo The file infos
More information about the Vlmc-devel
mailing list