Commit b88b0306 authored by Ludovic Fauvet's avatar Ludovic Fauvet

UndoRedo: support multi-deletion on audio too.

This commit also remove the ugly list that was used to delete more than
one item at a time. Now it uses the macro commands of QUndoCommand.
parent 35495fd0
......@@ -88,24 +88,20 @@ void Commands::MainWorkflow::MoveClip::undo()
m_undoRedoAction = true;
}
Commands::MainWorkflow::RemoveClips::RemoveClips( WorkflowRenderer* renderer, const QVector<ClipActionInfo>& clipsInfos ) :
m_renderer( renderer ), m_clips( clipsInfos )
Commands::MainWorkflow::RemoveClip::RemoveClip( WorkflowRenderer* renderer, Clip* clip, unsigned int trackNumber, qint64 pos, ::MainWorkflow::TrackType trackType ) :
m_renderer( renderer ), m_clip( clip ), m_trackNumber( trackNumber ),
m_pos( pos ), m_trackType( trackType )
{
setText( QObject::tr( "Remove clip" ) );
}
void Commands::MainWorkflow::RemoveClips::redo()
void Commands::MainWorkflow::RemoveClip::redo()
{
for (int i = 0; i < m_clips.size(); ++i )
{
const ClipActionInfo& clipInfo = m_clips.at( i );
m_renderer->removeClip( clipInfo.clip->getUuid(), clipInfo.trackNumber, clipInfo.trackType );
}
m_renderer->removeClip( m_clip->getUuid(), m_trackNumber, m_trackType );
}
void Commands::MainWorkflow::RemoveClips::undo()
void Commands::MainWorkflow::RemoveClip::undo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_renderer->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos, m_clips.at( i ).trackType );
m_renderer->addClip( m_clip, m_trackNumber, m_pos, m_trackType );
}
Commands::MainWorkflow::ResizeClip::ResizeClip( WorkflowRenderer* renderer, const QUuid& uuid,
......
......@@ -40,14 +40,6 @@ namespace Commands
namespace MainWorkflow
{
struct ClipActionInfo
{
Clip* clip;
quint32 trackNumber;
qint64 pos;
::MainWorkflow::TrackType trackType;
};
NEW_COMMAND( AddClip )
{
public:
......@@ -83,16 +75,19 @@ namespace Commands
::MainWorkflow::TrackType m_trackType;
};
NEW_COMMAND( RemoveClips )
NEW_COMMAND( RemoveClip )
{
public:
RemoveClips( WorkflowRenderer* renderer, const QVector<ClipActionInfo>& clipsInfos );
RemoveClip( WorkflowRenderer* renderer, Clip* clip, unsigned int trackNumber, qint64 pos, ::MainWorkflow::TrackType trackType );
virtual void redo();
virtual void undo();
private:
WorkflowRenderer* m_renderer;
QVector<ClipActionInfo> m_clips;
WorkflowRenderer* m_renderer;
Clip* m_clip;
unsigned int m_trackNumber;
qint64 m_pos;
::MainWorkflow::TrackType m_trackType;
};
/**
......
......@@ -58,7 +58,7 @@ void TracksScene::keyPressEvent( QKeyEvent* keyEvent )
// Skip the deletion process
if ( b == QMessageBox::No ) return;
QVector<Commands::MainWorkflow::ClipActionInfo> clipsinfos;
UndoStack::getInstance()->beginMacro( "Remove clip(s)" );
QList<QGraphicsItem*> items = selectedItems();
for (int i = 0; i < items.size(); ++i )
......@@ -66,16 +66,14 @@ void TracksScene::keyPressEvent( QKeyEvent* keyEvent )
GraphicsMovieItem* item = qgraphicsitem_cast<GraphicsMovieItem*>( items.at(i) );
if ( !item ) return;
Commands::MainWorkflow::ClipActionInfo ai;
ai.clip = item->clip();
ai.trackNumber = item->trackNumber();
ai.pos = item->startPos();
ai.trackType = MainWorkflow::VideoTrack;
clipsinfos.append( ai );
Commands::trigger( new Commands::MainWorkflow::RemoveClip( tv->m_renderer,
item->clip(),
item->trackNumber(),
item->startPos(),
item->mediaType() ) );
}
Commands::trigger( new Commands::MainWorkflow::RemoveClips( tv->m_renderer,
clipsinfos ) );
UndoStack::getInstance()->endMacro();
}
QGraphicsScene::keyPressEvent( keyEvent );
......
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