[vlmc-devel] commit: Adding effect deletion using 'delete' key ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Sep 9 01:18:10 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Sep  9 00:32:18 2010 +0200| [4f8e9c554e547ccb125b78d6abe276e689b86442] | committer: Hugo Beauzée-Luyssen 

Adding effect deletion using 'delete' key

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

 src/Commands/Commands.cpp        |   20 ++++++++++++++++++++
 src/Commands/Commands.h          |   11 +++++++++++
 src/Gui/timeline/TracksScene.cpp |   21 +++++++++++++++++----
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 9404e83..4a4dbff 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -253,6 +253,7 @@ Commands::Effect::Resize::Resize( EffectHelper *helper, qint64 newBegin, qint64
 {
     m_oldBegin = helper->begin();
     m_oldEnd = helper->end();
+    setText( QObject::tr( "Resizing effect %1" ).arg( m_helper->effectInstance()->effect()->name() ) );
 }
 
 void
@@ -266,3 +267,22 @@ Commands::Effect::Resize::undo()
 {
     m_helper->setBoundaries( m_oldBegin, m_oldEnd );
 }
+
+Commands::Effect::Remove::Remove( EffectHelper *helper, EffectUser *user ) :
+        m_helper( helper ),
+        m_user( user )
+{
+    setText( QObject::tr( "Deleting effect %1" ).arg( m_helper->effectInstance()->effect()->name() ) );
+}
+
+void
+Commands::Effect::Remove::redo()
+{
+    m_user->removeEffect( m_helper );
+}
+
+void
+Commands::Effect::Remove::undo()
+{
+    m_user->addEffect( m_helper );
+}
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index dd1024a..aaa5ea3 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -187,6 +187,17 @@ namespace Commands
                 qint64              m_oldBegin;
                 qint64              m_oldEnd;
         };
+
+        NEW_COMMAND( Remove )
+        {
+            public:
+                Remove( EffectHelper *helper, EffectUser *user );
+                virtual void    redo();
+                virtual void    undo();
+            private:
+                EffectHelper    *m_helper;
+                EffectUser      *m_user;
+        };
     }
 }
 
diff --git a/src/Gui/timeline/TracksScene.cpp b/src/Gui/timeline/TracksScene.cpp
index 45fb5d7..13bc542 100644
--- a/src/Gui/timeline/TracksScene.cpp
+++ b/src/Gui/timeline/TracksScene.cpp
@@ -23,11 +23,14 @@
 #include "TracksScene.h"
 
 #include "Commands.h"
+#include "ClipHelper.h"
+#include "EffectHelper.h"
 #include "GraphicsAudioItem.h"
 #include "GraphicsMovieItem.h"
 #include "GraphicsTrack.h"
 #include "SettingsManager.h"
 #include "Timeline.h"
+#include "TrackWorkflow.h"
 #include "UndoStack.h"
 
 #include <QMessageBox>
@@ -103,10 +106,20 @@ TracksScene::askRemoveSelectedItems()
     QList<QGraphicsItem*> items = selectedItems();
     for (int i = 0; i < items.size(); ++i )
     {
-        AbstractGraphicsMediaItem* item = qgraphicsitem_cast<AbstractGraphicsMediaItem*>( items.at(i) );
-        if ( !item ) return;
-
-        Commands::trigger( new Commands::Clip::Remove( item->clipHelper(), item->track()->trackWorkflow() ) );
+        AbstractGraphicsItem* item = dynamic_cast<AbstractGraphicsItem*>( items.at(i) );
+        if ( !item )
+            return;
+        ClipHelper  *ch = qobject_cast<ClipHelper*>( item->helper() );
+        if ( ch != NULL )
+        {
+            Commands::trigger( new Commands::Clip::Remove( ch, item->track()->trackWorkflow() ) );
+        }
+        else
+        {
+            EffectHelper    *eh = qobject_cast<EffectHelper*>( item->helper() );
+            Q_ASSERT( eh != NULL );
+            Commands::trigger( new Commands::Effect::Remove( eh, item->track()->trackWorkflow() ) );
+        }
     }
 
     UndoStack::getInstance()->endMacro();



More information about the Vlmc-devel mailing list