Commit 4f8e9c55 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Adding effect deletion using 'delete' key

parent b416bbca
......@@ -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 );
}
......@@ -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;
};
}
}
......
......@@ -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();
......
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