[vlmc-devel] commit: Asking for confirmation before removing a clip contained in the timeline. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Tue Apr 20 01:55:47 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Apr 20 01:55:16 2010 +0200| [636e307adafbf635a200f64705a8c9bc529fa292] | committer: Hugo Beauzée-Luyssen 

Asking for confirmation before removing a clip contained in the timeline.

This also checks for any child clip.
Fixes #79

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

 src/Gui/library/MediaCellView.cpp     |   20 ++++++++++++++++++++
 src/Gui/project/GuiProjectManager.cpp |    2 +-
 src/Gui/timeline/TracksView.cpp       |    9 +++++----
 src/Workflow/MainWorkflow.cpp         |    9 +++++++++
 src/Workflow/MainWorkflow.h           |   14 +++++++++++---
 src/Workflow/TrackHandler.cpp         |    9 +++++++++
 src/Workflow/TrackHandler.h           |    2 ++
 src/Workflow/TrackWorkflow.cpp        |   18 +++++++++++++++++-
 src/Workflow/TrackWorkflow.h          |    2 ++
 9 files changed, 76 insertions(+), 9 deletions(-)

diff --git a/src/Gui/library/MediaCellView.cpp b/src/Gui/library/MediaCellView.cpp
index 7c7807f..3ad0c3b 100644
--- a/src/Gui/library/MediaCellView.cpp
+++ b/src/Gui/library/MediaCellView.cpp
@@ -29,7 +29,9 @@
 #include "Library.h"
 #include "Media.h"
 #include "MetaDataManager.h"
+#include "MainWorkflow.h"
 
+#include <QMessageBox>
 #include <QTime>
 
 MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
@@ -212,6 +214,24 @@ void    MediaCellView::mouseMoveEvent( QMouseEvent* event )
 
 void        MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
 {
+    if ( MainWorkflow::getInstance()->contains( m_clip->uuid() ) == true )
+    {
+        QMessageBox msgBox;
+        msgBox.setText( tr( "This clip or some of its children are contained in the timeline." ) );
+        msgBox.setInformativeText( tr( "Removing it will delete it from the timeline. Do you want to proceed ?" ) );
+        msgBox.setStandardButtons( QMessageBox::Ok | QMessageBox::Cancel );
+        msgBox.setDefaultButton( QMessageBox::Ok );
+        int     ret = msgBox.exec();
+
+        switch ( ret )
+        {
+            case QMessageBox::Ok:
+                break ;
+            case QMessageBox::Cancel:
+            default:
+                return ;
+        }
+    }
     emit cellDeleted( m_clip );
 }
 
diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index a21524b..066ffdc 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -70,7 +70,7 @@ GUIProjectManager::askForSaveIfModified()
         msgBox.setText( tr( "The project has been modified." ) );
         msgBox.setInformativeText( tr( "Do you want to save it?" ) );
         msgBox.setStandardButtons( QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel );
-        msgBox.setDefaultButton(QMessageBox::Save);
+        msgBox.setDefaultButton( QMessageBox::Save );
         int     ret = msgBox.exec();
 
         switch ( ret )
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 853ff76..f0a273e 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -32,12 +32,13 @@
 #include "WorkflowRenderer.h"
 #include "UndoStack.h"
 
-#include <QScrollBar>
-#include <QMouseEvent>
-#include <QWheelEvent>
 #include <QGraphicsLinearLayout>
 #include <QGraphicsWidget>
 #include <QGraphicsRectItem>
+#include <QMouseEvent>
+#include <QScrollBar>
+#include <QWheelEvent>
+
 #include <QtDebug>
 
 TracksView::TracksView( QGraphicsScene *scene, MainWorkflow *mainWorkflow,
@@ -186,7 +187,7 @@ TracksView::clear()
 void
 TracksView::removeClip( const QUuid& uuid  )
 {
-    AbstractGraphicsMediaItem *item;
+    AbstractGraphicsMediaItem*      item;
 
     // Get the list of all items in the timeline
     QList<AbstractGraphicsMediaItem*> items = mediaItems();
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index 325545a..ad1efbb 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -445,3 +445,12 @@ MainWorkflow::unsplit( ClipHelper* origin, ClipHelper* splitted, quint32 trackId
     removeClip( splitted->uuid(), trackId, trackType );
     origin->setEnd( splitted->end() );
 }
+
+bool
+MainWorkflow::contains( const QUuid &uuid ) const
+{
+    for ( qint32 type = 0; type < NbTrackType; ++type )
+        if ( m_tracks[type]->contains( uuid ) == true )
+            return true;
+    return false;
+}
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index 6a09a06..2aff016 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -331,6 +331,14 @@ class   MainWorkflow : public QObject, public Singleton<MainWorkflow>
         void                    unsplit( ClipHelper* origin, ClipHelper* splitted, quint32 trackId,
                                          MainWorkflow::TrackType trackType );
 
+        /**
+         *  \return     true if the current workflow contains the clip which the uuid was
+         *              passed. Falsed otherwise.
+         *
+         *  \param      uuid    The Clip uuid, not the ClipHelper's.
+         */
+        bool                    contains( const QUuid& uuid ) const;
+
     private:
         MainWorkflow( int trackCount = 64 );
         ~MainWorkflow();
@@ -345,11 +353,11 @@ class   MainWorkflow : public QObject, public Singleton<MainWorkflow>
 
         /**
          * \param   uuid : The clip's uuid.
-         *              Please note that the UUID must be the "timeline uuid"
-         *              and note the clip's uuid, or else nothing would match.
+         *              Please note that the UUID must be the real clip's uuid,
+         *              and not the timeline (ClipHelper) uuid, or else nothing would match.
          *  \param  trackId : the track id
          *  \param  trackType : the track type (audio or video)
-         *  \returns    The clip that matches the given UUID.
+         *  \returns    The clip that matches the given UUID, or NULL.
          */
         Clip*                   getClip( const QUuid& uuid, unsigned int trackId,
                                          MainWorkflow::TrackType trackType );
diff --git a/src/Workflow/TrackHandler.cpp b/src/Workflow/TrackHandler.cpp
index ef49ff7..0f2cdec 100644
--- a/src/Workflow/TrackHandler.cpp
+++ b/src/Workflow/TrackHandler.cpp
@@ -316,3 +316,12 @@ TrackHandler::unmuteClip( const QUuid &uuid, quint32 trackId )
 {
     m_tracks[trackId]->unmuteClip( uuid );
 }
+
+bool
+TrackHandler::contains( const QUuid &uuid ) const
+{
+    for ( unsigned int i = 0; i < m_trackCount; ++i )
+        if ( m_tracks[i]->contains( uuid ) == true )
+            return true;
+    return false;
+}
diff --git a/src/Workflow/TrackHandler.h b/src/Workflow/TrackHandler.h
index 50fc458..39b95d3 100644
--- a/src/Workflow/TrackHandler.h
+++ b/src/Workflow/TrackHandler.h
@@ -99,6 +99,8 @@ class   TrackHandler : public QObject
         void                    muteClip( const QUuid& uuid, quint32 trackId );
         void                    unmuteClip( const QUuid& uuid, quint32 trackId );
 
+        bool                    contains( const QUuid& uuid ) const;
+
     private:
         void                    computeLength();
         void                    activateTrack( unsigned int tracKId );
diff --git a/src/Workflow/TrackWorkflow.cpp b/src/Workflow/TrackWorkflow.cpp
index 5d80a03..3f01289 100644
--- a/src/Workflow/TrackWorkflow.cpp
+++ b/src/Workflow/TrackWorkflow.cpp
@@ -128,7 +128,7 @@ Clip*               TrackWorkflow::getClip( const QUuid& uuid )
 
     while ( it != end )
     {
-        if ( it.value()->getClipHelper()->uuid() == uuid )
+        if ( it.value()->getClipHelper()->clip()->uuid() == uuid )
             return it.value()->clip();
         ++it;
     }
@@ -509,3 +509,19 @@ TrackWorkflow::preload()
         ++it;
     }
 }
+
+bool
+TrackWorkflow::contains( const QUuid &uuid ) const
+{
+    QMap<qint64, ClipWorkflow*>::const_iterator       it = m_clips.begin();
+    QMap<qint64, ClipWorkflow*>::const_iterator       end = m_clips.end();
+
+    while ( it != end )
+    {
+        if ( it.value()->getClipHelper()->clip()->uuid() == uuid ||
+             it.value()->getClipHelper()->clip()->isChild( uuid ) )
+            return true;
+        ++it;
+    }
+    return false;
+}
diff --git a/src/Workflow/TrackWorkflow.h b/src/Workflow/TrackWorkflow.h
index 35273e9..b503cb7 100644
--- a/src/Workflow/TrackWorkflow.h
+++ b/src/Workflow/TrackWorkflow.h
@@ -85,6 +85,8 @@ class   TrackWorkflow : public QObject
 
         void                                    preload();
 
+        bool                                    contains( const QUuid& uuid ) const;
+
     private:
         void                                    computeLength();
         void*                                   renderClip( ClipWorkflow* cw, qint64 currentFrame,



More information about the Vlmc-devel mailing list