Commit bb251cac authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Remove a clip from the timeline when asked to by the backend

parent c03e2a52
......@@ -60,6 +60,7 @@ Timeline::Timeline( QWidget *parent ) :
connect( m_tracksView->horizontalScrollBar(), SIGNAL( valueChanged( int ) ), m_tracksRuler, SLOT( moveRuler( int ) ) );
connect( m_tracksView, SIGNAL( durationChanged(int) ), this, SLOT( setDuration(int) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64 ) ), this, SLOT( actionMoveClip(QUuid,uint,qint64) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved(QUuid,uint) ), this, SLOT( actionRemoveClip(QUuid,uint)) );
}
Timeline::~Timeline()
......@@ -98,3 +99,10 @@ void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 tim
tracksView()->updateDuration();
tracksRuler()->update();
}
void Timeline::actionRemoveClip( const QUuid& uuid, unsigned int track )
{
// The signal was triggered by the backend, so we do not have to
// notify it again. I guess it would be a very bad idea.
tracksView()->removeMediaItem( uuid, track, false );
}
......@@ -47,6 +47,7 @@ public slots:
void changeZoom( int factor );
void setDuration( int duration );
void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time );
void actionRemoveClip( const QUuid& uuid, unsigned int track );
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -268,14 +268,32 @@ void TracksView::moveMediaItem( AbstractGraphicsMediaItem* item, int track, qint
}
}
void TracksView::removeMediaItem( AbstractGraphicsMediaItem* item )
void TracksView::removeMediaItem( const QUuid& uuid, unsigned int track, bool notifyBackend )
{
Q_UNUSED( track );
//TODO When a clever API will be done to manage the tracks, we could
// use the "track" argument to limit the search into the track instead
// of the full scene.
QList<QGraphicsItem*> sceneItems = m_scene->items();
for ( int i = 0; i < sceneItems.size(); ++i )
{
AbstractGraphicsMediaItem* item =
dynamic_cast<AbstractGraphicsMediaItem*>( sceneItems.at( i ) );
if ( !item || item->uuid() != uuid ) continue;
removeMediaItem( item, notifyBackend );
}
}
void TracksView::removeMediaItem( AbstractGraphicsMediaItem* item, bool notifyBackend )
{
QList<AbstractGraphicsMediaItem*> items;
items.append( item );
removeMediaItem( items );
removeMediaItem( items, notifyBackend );
}
void TracksView::removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items )
void TracksView::removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items, bool notifyBackend )
{
QVector<Commands::MainWorkflow::ClipActionInfo> clipsinfos;
......@@ -298,8 +316,9 @@ void TracksView::removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items
delete movieItem;
}
Commands::trigger( new Commands::MainWorkflow::RemoveClips( m_mainWorkflow,
clipsinfos ) );
if ( notifyBackend )
Commands::trigger( new Commands::MainWorkflow::RemoveClips( m_mainWorkflow,
clipsinfos ) );
}
void TracksView::dragLeaveEvent( QDragLeaveEvent* event )
......
......@@ -55,11 +55,12 @@ public:
GraphicsCursorItem* tracksCursor() const { return m_cursorLine; }
void setScale( double scaleFactor );
QList<AbstractGraphicsMediaItem*> mediaItems( const QPoint& pos );
void removeMediaItem( AbstractGraphicsMediaItem* item );
void removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items );
void removeMediaItem( AbstractGraphicsMediaItem* item, bool notifyBackend = true );
void removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items, bool notifyBackend = true );
public slots:
void moveMediaItem( const QUuid& uuid, unsigned int track, qint64 time );
void removeMediaItem( const QUuid& uuid, unsigned int track, bool notifyBackend = true );
protected:
virtual void resizeEvent( QResizeEvent* event );
......
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