Commit 48911bc9 authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Timeline: do not delete a clip manually, trigger a Command instead

When the Command is added to the stack, the backend must tell the GUI to
execute it. That way, we avoids "echo" and probably other weird things.
parent e0ea8bd8
......@@ -20,7 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QMessageBox>
#include "TracksScene.h"
#include "Commands.h"
#include "GraphicsMovieItem.h"
#include "Timeline.h"
TracksScene::TracksScene( QObject* parent ) : QGraphicsScene( parent )
{
......@@ -53,13 +57,23 @@ void TracksScene::keyPressEvent( QKeyEvent* keyEvent )
// Skip the deletion process
if ( b == QMessageBox::No ) return;
QVector<Commands::MainWorkflow::ClipActionInfo> clipsinfos;
QList<QGraphicsItem*> items = selectedItems();
for (int i = 0; i < items.size(); ++i )
{
AbstractGraphicsMediaItem* item = qgraphicsitem_cast<AbstractGraphicsMediaItem*>( items.at(i) );
GraphicsMovieItem* item = qgraphicsitem_cast<GraphicsMovieItem*>( items.at(i) );
if ( !item ) return;
tv->removeMediaItem( item );
Commands::MainWorkflow::ClipActionInfo ai;
ai.clip = item->clip();
ai.trackNumber = item->trackNumber();
ai.pos = item->pos().x();
clipsinfos.append( ai );
}
Commands::trigger( new Commands::MainWorkflow::RemoveClips( tv->m_mainWorkflow,
clipsinfos ) );
}
QGraphicsScene::keyPressEvent( keyEvent );
......
......@@ -24,8 +24,6 @@
#define TRACKSSCENE_H
#include <QGraphicsScene>
#include <QMessageBox>
#include "Timeline.h"
class TracksView;
......
......@@ -326,8 +326,6 @@ void TracksView::removeMediaItem( AbstractGraphicsMediaItem* item, bool notifyBa
void TracksView::removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items, bool notifyBackend )
{
QVector<Commands::MainWorkflow::ClipActionInfo> clipsinfos;
for ( int i = 0; i < items.size(); ++i )
{
GraphicsMovieItem* movieItem = qgraphicsitem_cast<GraphicsMovieItem*>( items.at( i ) );
......@@ -338,18 +336,8 @@ void TracksView::removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items
continue;
}
Commands::MainWorkflow::ClipActionInfo ai;
ai.clip = movieItem->clip();
ai.trackNumber = movieItem->trackNumber();
ai.pos = movieItem->pos().x();
clipsinfos.append( ai );
delete movieItem;
}
if ( notifyBackend )
Commands::trigger( new Commands::MainWorkflow::RemoveClips( m_mainWorkflow,
clipsinfos ) );
}
void TracksView::dragLeaveEvent( QDragLeaveEvent* event )
......
......@@ -38,7 +38,7 @@
#include "AbstractGraphicsMediaItem.h"
class GraphicsMovieItem;
//class AbstractGraphicsMediaItem;
class TracksScene;
class TracksView : public QGraphicsView
{
......@@ -111,6 +111,7 @@ signals:
void durationChanged( int duration );
friend class Timeline;
friend class TracksScene;
};
#endif // TRACKSVIEW_H
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