[vlmc-devel] commit: When a clip is deleted from the library, remove it from the timeline. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Wed Apr 14 00:36:27 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Apr 14 00:19:05 2010 +0200| [7f1d51733e2950fcdb8aad64ec5508acfb7a207b] | committer: Hugo Beauzée-Luyssen
When a clip is deleted from the library, remove it from the timeline.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=7f1d51733e2950fcdb8aad64ec5508acfb7a207b
---
src/Gui/timeline/AbstractGraphicsMediaItem.cpp | 14 +++++++++++---
src/Gui/timeline/AbstractGraphicsMediaItem.h | 10 +++++++++-
src/Gui/timeline/GraphicsAudioItem.cpp | 2 +-
src/Gui/timeline/GraphicsAudioItem.h | 3 ---
src/Gui/timeline/GraphicsMovieItem.cpp | 2 +-
src/Gui/timeline/GraphicsMovieItem.h | 3 ---
src/Gui/timeline/TracksView.cpp | 7 ++-----
src/Gui/timeline/TracksView.h | 10 +++++-----
src/Library/Library.cpp | 1 +
src/Media/Clip.cpp | 1 +
src/Media/Clip.h | 4 ++++
11 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index cec34c1..40dcb54 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -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() );
+}
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index 4e39434..34f4aaa 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -53,7 +53,7 @@ public:
END
};
- AbstractGraphicsMediaItem();
+ AbstractGraphicsMediaItem( Clip* clip );
virtual ~AbstractGraphicsMediaItem();
/// Defines the outer bounds of the item as a rectangle
@@ -124,6 +124,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;
diff --git a/src/Gui/timeline/GraphicsAudioItem.cpp b/src/Gui/timeline/GraphicsAudioItem.cpp
index e40ed8a..d8abccd 100644
--- a/src/Gui/timeline/GraphicsAudioItem.cpp
+++ b/src/Gui/timeline/GraphicsAudioItem.cpp
@@ -32,7 +32,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneHoverEvent>
-GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : m_clip( clip )
+GraphicsAudioItem::GraphicsAudioItem( Clip* clip ) : AbstractGraphicsMediaItem( clip )
{
setFlags( QGraphicsItem::ItemIsSelectable );
diff --git a/src/Gui/timeline/GraphicsAudioItem.h b/src/Gui/timeline/GraphicsAudioItem.h
index 6e52ca4..ae03038 100644
--- a/src/Gui/timeline/GraphicsAudioItem.h
+++ b/src/Gui/timeline/GraphicsAudioItem.h
@@ -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.
diff --git a/src/Gui/timeline/GraphicsMovieItem.cpp b/src/Gui/timeline/GraphicsMovieItem.cpp
index 943560f..ce36b35 100644
--- a/src/Gui/timeline/GraphicsMovieItem.cpp
+++ b/src/Gui/timeline/GraphicsMovieItem.cpp
@@ -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 );
diff --git a/src/Gui/timeline/GraphicsMovieItem.h b/src/Gui/timeline/GraphicsMovieItem.h
index 4095f6d..e091939 100644
--- a/src/Gui/timeline/GraphicsMovieItem.h
+++ b/src/Gui/timeline/GraphicsMovieItem.h
@@ -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.
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 0a3a4c7..200d2bc 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -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
diff --git a/src/Gui/timeline/TracksView.h b/src/Gui/timeline/TracksView.h
index 36466cd..394578b 100644
--- a/src/Gui/timeline/TracksView.h
+++ b/src/Gui/timeline/TracksView.h
@@ -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:
/**
@@ -182,11 +187,6 @@ public slots:
*/
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.
* \param track The track's number.
diff --git a/src/Library/Library.cpp b/src/Library/Library.cpp
index 32180a1..367bb96 100644
--- a/src/Library/Library.cpp
+++ b/src/Library/Library.cpp
@@ -100,3 +100,4 @@ Library::mediaLoaded( const Media* media )
if ( m_nbMediaToLoad == 0 )
emit projectLoaded();
}
+
diff --git a/src/Media/Clip.cpp b/src/Media/Clip.cpp
index bf06f2b..91bd476 100644
--- a/src/Media/Clip.cpp
+++ b/src/Media/Clip.cpp
@@ -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;
diff --git a/src/Media/Clip.h b/src/Media/Clip.h
index d9d89c1..339d324 100644
--- a/src/Media/Clip.h
+++ b/src/Media/Clip.h
@@ -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__
More information about the Vlmc-devel
mailing list