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

When a clip is deleted from the library, remove it from the timeline.

parent 648a2889
......@@ -32,12 +32,13 @@
#include "Commands.h"
#include "Media.h"
AbstractGraphicsMediaItem::AbstractGraphicsMediaItem() :
oldTrackNumber( -1 ), oldPosition( -1 ), m_tracksView( NULL ),
AbstractGraphicsMediaItem::AbstractGraphicsMediaItem( Clip* clip ) :
oldTrackNumber( -1 ), oldPosition( -1 ), m_clip( clip ), m_tracksView( NULL ),
m_group( NULL ), m_width( 0 ), m_height( 0 ), m_resizeExpected( false ),
m_muted( false )
{
connect( clip, SIGNAL( unloaded( Clip* ) ),
this, SLOT( clipDestroyed( Clip* ) ), Qt::DirectConnection );
}
AbstractGraphicsMediaItem::~AbstractGraphicsMediaItem()
......@@ -308,3 +309,10 @@ QColor AbstractGraphicsMediaItem::itemColor()
{
return m_itemColor;
}
void
AbstractGraphicsMediaItem::clipDestroyed( Clip* clip )
{
if ( m_tracksView != NULL )
m_tracksView->removeClip( clip->uuid() );
}
......@@ -53,7 +53,7 @@ public:
END
};
AbstractGraphicsMediaItem();
AbstractGraphicsMediaItem( Clip* clip );
virtual ~AbstractGraphicsMediaItem();
/// Defines the outer bounds of the item as a rectangle
......@@ -123,6 +123,11 @@ protected:
*/
qint64 oldPosition;
/**
* \brief The Clip this AbstractGraphicsMediaItem is based upon.
*/
Clip* m_clip;
/**
* \brief Return a pointer to the linked item.
* \details This method will return NULL if there is no linked item.
......@@ -157,6 +162,9 @@ protected slots:
QColor itemColor();
private slots:
void clipDestroyed( Clip* clip );
private:
/// This pointer will be set when inserted in the tracksView.
TracksView* m_tracksView;
......
......@@ -32,7 +32,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneHoverEvent>
GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : m_clip( clip )
GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : AbstractGraphicsMediaItem( clip )
{
setFlags( QGraphicsItem::ItemIsSelectable );
......
......@@ -74,9 +74,6 @@ protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent* event );
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
private:
Clip* m_clip;
signals:
/**
* \brief Emitted when the item detect a cut request.
......
......@@ -33,7 +33,7 @@
#include "TracksView.h"
#include "Timeline.h"
GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) : m_clip( clip )
GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) : AbstractGraphicsMediaItem( clip )
{
setFlags( QGraphicsItem::ItemIsSelectable );
......
......@@ -74,9 +74,6 @@ protected:
virtual void mousePressEvent( QGraphicsSceneMouseEvent* event );
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
private:
Clip* m_clip;
signals:
/**
* \brief Emitted when the item detect a cut request.
......
......@@ -74,8 +74,6 @@ TracksView::TracksView( QGraphicsScene *scene, MainWorkflow *mainWorkflow,
connect( m_cursorLine, SIGNAL( cursorMoved(qint64) ),
this, SLOT( ensureCursorVisible() ) );
connect( Library::getInstance(), SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( deleteMedia( const QUuid& ) ) );
}
void
......@@ -186,7 +184,7 @@ TracksView::clear()
}
void
TracksView::deleteMedia( const QUuid& uuid )
TracksView::removeClip( const QUuid& uuid )
{
AbstractGraphicsMediaItem *item;
......@@ -197,8 +195,7 @@ TracksView::deleteMedia( const QUuid& uuid )
// is the one we would like to remove.
foreach( item, items )
{
if ( item->clip()->getMedia()->baseClip()->uuid() ==
uuid )
if ( item->clip()->uuid() == uuid || item->clip()->isChild( uuid ) == true )
{
// This item needs to be removed.
// Saving its values
......
......@@ -174,6 +174,11 @@ public:
* \deprecated Do not use, will be removed soon.
*/
bool setItemOldTrack( const QUuid &uuid, quint32 oldTrackNumber );
/**
* \brief Remove a Clip from the timeline (and from the backend).
* \param uuid The unique identifier of the Media.
*/
void removeClip( const QUuid& uuid );
public slots:
/**
......@@ -181,11 +186,6 @@ public slots:
* \sa Timeline::clear
*/
void clear();
/**
* \brief Remove a Media from the timeline (and from the backend).
* \param uuid The unique identifier of the Media.
*/
void deleteMedia( const QUuid& uuid );
/**
* \brief Insert an item into the timeline.
* \param clip Clip to insert.
......
......@@ -100,3 +100,4 @@ Library::mediaLoaded( const Media* media )
if ( m_nbMediaToLoad == 0 )
emit projectLoaded();
}
......@@ -86,6 +86,7 @@ Clip::Clip( Clip *parent, qint64 begin /*= -1*/, qint64 end /*= -1*/,
Clip::~Clip()
{
emit unloaded( this );
delete m_childs;
if ( isRootClip() == true )
delete m_media;
......
......@@ -195,6 +195,10 @@ class Clip : public QObject
signals:
void lengthUpdated();
/**
* \brief Act just like QObject::destroyed(), but before the clip deletion.
*/
void unloaded( Clip* );
};
#endif //CLIP_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