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

Adding an undo/redo command for adding clip

parent 23e6bc80
...@@ -192,6 +192,25 @@ void Commands::Clip::Split::undo() ...@@ -192,6 +192,25 @@ void Commands::Clip::Split::undo()
m_toSplit->setEnd( m_oldEnd ); m_toSplit->setEnd( m_oldEnd );
} }
Commands::Effect::Add::Add( EffectHelper *helper, EffectUser *target ) :
m_helper( helper ),
m_target( target )
{
setText( QObject::tr( "Adding effect %1" ).arg( m_helper->effectInstance()->effect()->name() ) );
}
void
Commands::Effect::Add::redo()
{
m_target->addEffect( m_helper );
}
void
Commands::Effect::Add::undo()
{
m_target->removeEffect( m_helper );
}
Commands::Effect::Move::Move( EffectHelper *helper, EffectUser *old, EffectUser *newUser, Commands::Effect::Move::Move( EffectHelper *helper, EffectUser *old, EffectUser *newUser,
qint64 pos) : qint64 pos) :
m_helper( helper ), m_helper( helper ),
...@@ -200,6 +219,7 @@ Commands::Effect::Move::Move( EffectHelper *helper, EffectUser *old, EffectUser ...@@ -200,6 +219,7 @@ Commands::Effect::Move::Move( EffectHelper *helper, EffectUser *old, EffectUser
m_newPos( pos ) m_newPos( pos )
{ {
m_oldPos = helper->begin(); m_oldPos = helper->begin();
setText( QObject::tr( "Moving effect %1" ).arg( m_helper->effectInstance()->effect()->name() ) );
} }
void void
......
...@@ -147,6 +147,17 @@ namespace Commands ...@@ -147,6 +147,17 @@ namespace Commands
} }
namespace Effect namespace Effect
{ {
NEW_COMMAND( Add )
{
public:
Add( EffectHelper *helper, EffectUser *target );
virtual void redo();
virtual void undo();
private:
EffectHelper *m_helper;
EffectUser *m_target;
};
NEW_COMMAND( Move ) NEW_COMMAND( Move )
{ {
public: public:
......
...@@ -741,7 +741,8 @@ TracksView::dropEvent( QDropEvent *event ) ...@@ -741,7 +741,8 @@ TracksView::dropEvent( QDropEvent *event )
if ( clips.size() > 0 ) if ( clips.size() > 0 )
{ {
AbstractGraphicsMediaItem *item = clips.first(); AbstractGraphicsMediaItem *item = clips.first();
item->clipHelper()->clipWorkflow()->addEffect( m_dragEffectItem->effectHelper() ); Commands::trigger( new Commands::Effect::Add( m_dragEffectItem->effectHelper(),
item->clipHelper()->clipWorkflow() ) );
m_dragEffectItem->m_oldTrack = item->track()->trackWorkflow(); m_dragEffectItem->m_oldTrack = item->track()->trackWorkflow();
event->acceptProposedAction(); event->acceptProposedAction();
} }
...@@ -753,7 +754,8 @@ TracksView::dropEvent( QDropEvent *event ) ...@@ -753,7 +754,8 @@ TracksView::dropEvent( QDropEvent *event )
GraphicsTrack *track = qgraphicsitem_cast<GraphicsTrack*>( item ); GraphicsTrack *track = qgraphicsitem_cast<GraphicsTrack*>( item );
if ( track != NULL ) if ( track != NULL )
{ {
track->trackWorkflow()->addEffect( m_dragEffectItem->effectHelper() ); Commands::trigger( new Commands::Effect::Add( m_dragEffectItem->effectHelper(),
track->trackWorkflow() ) );
m_dragEffectItem->m_oldTrack = track->trackWorkflow(); m_dragEffectItem->m_oldTrack = track->trackWorkflow();
event->acceptProposedAction(); event->acceptProposedAction();
break ; break ;
......
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