[vlmc-devel] commit: MediaCellView: Disabling delete button while meta data are processed. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Apr 18 17:12:01 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Apr 18 16:56:23 2010 +0200| [78cbc941c1bcf1d6fd122cf3be08d70883fc1699] | committer: Hugo Beauzée-Luyssen 

MediaCellView: Disabling delete button while meta data are processed.

Fixes #60

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=78cbc941c1bcf1d6fd122cf3be08d70883fc1699
---

 src/Gui/library/MediaCellView.cpp |   22 +++++++++++++++++++++-
 src/Gui/library/MediaCellView.h   |    1 +
 src/Metadata/MetaDataManager.cpp  |    1 +
 src/Metadata/MetaDataManager.h    |    1 +
 4 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/Gui/library/MediaCellView.cpp b/src/Gui/library/MediaCellView.cpp
index 1f8d6b5..7c7807f 100644
--- a/src/Gui/library/MediaCellView.cpp
+++ b/src/Gui/library/MediaCellView.cpp
@@ -26,8 +26,9 @@
 
 #include "Clip.h"
 #include "ClipProperty.h"
-#include "Media.h"
 #include "Library.h"
+#include "Media.h"
+#include "MetaDataManager.h"
 
 #include <QTime>
 
@@ -58,6 +59,8 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
     if ( clip->getMedia()->isMetadataComputed() == false )
     {
         m_ui->thumbnail->setEnabled( false );
+        connect( MetaDataManager::getInstance(), SIGNAL( startingComputing( const Media* )),
+                 this, SLOT( metadataComputingStarted( const Media* ) ), Qt::DirectConnection );
     }
     connect( clip->getMedia(), SIGNAL( metaDataComputed(const Media*) ),
              this, SLOT( metadataUpdated( const Media*) ) );
@@ -75,16 +78,33 @@ MediaCellView::~MediaCellView()
 }
 
 void
+MediaCellView::metadataComputingStarted( const Media *media )
+{
+    if ( media != m_clip->getMedia() )
+        return ;
+    //Disable the delete button to avoid deleting the media while metadata are computed.
+    m_ui->delLabel->setEnabled( false );
+    //We don't need this event anymore now.
+    disconnect( MetaDataManager::getInstance(), SIGNAL( startingComputing( const Media* )),
+             this, SLOT( metadataComputingStarted( const Media* ) ) );
+}
+
+void
 MediaCellView::metadataUpdated( const Media *media )
 {
     setLength( media->lengthMS() );
     m_ui->thumbnail->setEnabled( true );
+    //If the media is a Video or an Image, we must wait for the snapshot to be computer
+    //before allowing deletion.
+    if ( media->fileType() == Media::Audio )
+        m_ui->delLabel->setEnabled( true );
 }
 
 void
 MediaCellView::snapshotUpdated( const Media *media )
 {
     setThumbnail( media->snapshot() );
+    m_ui->delLabel->setEnabled( true );
 }
 
 void MediaCellView::changeEvent( QEvent *e )
diff --git a/src/Gui/library/MediaCellView.h b/src/Gui/library/MediaCellView.h
index 4899426..9e645f7 100644
--- a/src/Gui/library/MediaCellView.h
+++ b/src/Gui/library/MediaCellView.h
@@ -73,6 +73,7 @@ public slots:
 
 private slots:
     void                snapshotUpdated( const Media *media );
+    void                metadataComputingStarted( const Media *media );
     void                metadataUpdated( const Media *media );
     void                nbClipUpdated();
 
diff --git a/src/Metadata/MetaDataManager.cpp b/src/Metadata/MetaDataManager.cpp
index ca88040..e6247c0 100644
--- a/src/Metadata/MetaDataManager.cpp
+++ b/src/Metadata/MetaDataManager.cpp
@@ -44,6 +44,7 @@ MetaDataManager::~MetaDataManager()
 void
 MetaDataManager::launchComputing( Media *media )
 {
+    emit startingComputing( media );
     m_computeInProgress = true;
     m_mediaPlayer = new LibVLCpp::MediaPlayer;
     MetaDataWorker* worker = new MetaDataWorker( m_mediaPlayer, media );
diff --git a/src/Metadata/MetaDataManager.h b/src/Metadata/MetaDataManager.h
index 5d52c8b..1b17eae 100644
--- a/src/Metadata/MetaDataManager.h
+++ b/src/Metadata/MetaDataManager.h
@@ -61,6 +61,7 @@ class MetaDataManager : public QObject, public Singleton<MetaDataManager>
 
     signals:
         void                    failedToCompute( Media* );
+        void                    startingComputing( const Media* );
 };
 
 #endif //METADATAMANAGER_H



More information about the Vlmc-devel mailing list