[vlmc-devel] commit: TracksView: Fixing effect clip undo/redo ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Wed Sep 15 00:53:49 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Sep 15 00:47:55 2010 +0200| [735f7e72493dc72fd5d85dcecc343dc0907b2656] | committer: Hugo Beauzée-Luyssen
TracksView: Fixing effect clip undo/redo
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=735f7e72493dc72fd5d85dcecc343dc0907b2656
---
src/Gui/timeline/AbstractGraphicsMediaItem.cpp | 11 +++++
src/Gui/timeline/AbstractGraphicsMediaItem.h | 5 ++
src/Gui/timeline/TracksView.cpp | 51 ++++++++++++++++++++++++
src/Gui/timeline/TracksView.h | 14 ++++---
4 files changed, 75 insertions(+), 6 deletions(-)
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index d83cc0a..cf789db 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -21,6 +21,7 @@
*****************************************************************************/
#include "AbstractGraphicsMediaItem.h"
+#include "ClipWorkflow.h"
#include "TracksView.h"
#include "TracksScene.h"
#include "TrackWorkflow.h"
@@ -48,6 +49,8 @@ AbstractGraphicsMediaItem::AbstractGraphicsMediaItem( Clip* clip ) :
connect( m_clipHelper, SIGNAL( lengthUpdated() ), this, SLOT( adjustLength() ) );
connect( clip, SIGNAL( unloaded( Clip* ) ),
this, SLOT( clipDestroyed( Clip* ) ), Qt::DirectConnection );
+ connect( m_clipHelper->clipWorkflow(), SIGNAL( effectAdded( EffectHelper*, qint64 ) ),
+ this, SLOT( effectAdded( EffectHelper*, qint64 ) ) );
}
AbstractGraphicsMediaItem::AbstractGraphicsMediaItem( ClipHelper* ch ) :
@@ -60,6 +63,8 @@ AbstractGraphicsMediaItem::AbstractGraphicsMediaItem( ClipHelper* ch ) :
connect( ch, SIGNAL( lengthUpdated() ), this, SLOT( adjustLength() ) );
connect( ch->clip(), SIGNAL( unloaded( Clip* ) ),
this, SLOT( clipDestroyed( Clip* ) ), Qt::DirectConnection );
+ connect( m_clipHelper->clipWorkflow(), SIGNAL( effectAdded( EffectHelper*, qint64 ) ),
+ this, SLOT( effectAdded( EffectHelper*, qint64 ) ) );
}
AbstractGraphicsMediaItem::~AbstractGraphicsMediaItem()
@@ -316,3 +321,9 @@ AbstractGraphicsMediaItem::zNotSelected() const
{
return 50;
}
+
+void
+AbstractGraphicsMediaItem::effectAdded( EffectHelper *helper, qint64 pos )
+{
+ emit effectAdded( this, helper, pos );
+}
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index beebe82..45aa373 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -33,6 +33,7 @@ class ClipHelper;
class Clip;
class TracksView;
class TrackWorkflow;
+class EffectHelper;
/**
* \brief Base class for Audio/Video items.
@@ -84,6 +85,8 @@ private slots:
void clipDestroyed( Clip* clip );
+ void effectAdded( EffectHelper *helper, qint64 pos );
+
private:
bool m_muted;
@@ -94,6 +97,8 @@ signals:
* \param frame Frame's number where the cut takes place.
*/
void split( AbstractGraphicsMediaItem* self, qint64 frame );
+
+ void effectAdded( AbstractGraphicsMediaItem*, EffectHelper*, qint64 );
};
#endif // ABSTRACTGRAPHICSMEDIAITEM_H
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 54af7bd..8dd2979 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -207,6 +207,27 @@ TracksView::clear()
}
void
+TracksView::effectRemoved( const QUuid& uuid )
+{
+ // Get the list of all items in the timeline
+ QList<AbstractGraphicsItem*> items = timelineItems();
+
+ // Iterate over each item to check if their parent's uuid
+ // is the one we would like to remove.
+ foreach( AbstractGraphicsItem *item, items )
+ {
+ GraphicsEffectItem *effectItem = qgraphicsitem_cast<GraphicsEffectItem*>( item );
+ if ( effectItem == NULL )
+ continue ;
+ if ( effectItem->uuid() == uuid )
+ {
+ // Remove the item from the timeline
+ removeItem( effectItem );
+ }
+ }
+}
+
+void
TracksView::removeClip( const QUuid& uuid )
{
// Get the list of all items in the timeline
@@ -271,12 +292,20 @@ TracksView::addItem( TrackWorkflow *tw, Workflow::Helper *helper, qint64 start )
mediaItem = new GraphicsMovieItem( clipHelper );
connect( mediaItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
+ connect( mediaItem, SIGNAL( effectAdded( AbstractGraphicsMediaItem*, EffectHelper*, qint64) ),
+ this, SLOT( effectAddedToClip( AbstractGraphicsMediaItem*, EffectHelper*,qint64) ) );
+ connect( mediaItem->clipHelper()->clipWorkflow(), SIGNAL( effectRemoved( QUuid ) ),
+ this, SLOT( effectRemoved( QUuid ) ) );
}
else if ( trackType == Workflow::AudioTrack )
{
mediaItem = new GraphicsAudioItem( clipHelper );
connect( mediaItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
+ connect( mediaItem, SIGNAL( effectAdded( AbstractGraphicsMediaItem*, EffectHelper*, qint64) ),
+ this, SLOT( effectAddedToClip( AbstractGraphicsMediaItem*, EffectHelper*,qint64) ) );
+ connect( mediaItem->clipHelper()->clipWorkflow(), SIGNAL( effectRemoved( QUuid ) ),
+ this, SLOT( effectRemoved( QUuid ) ) );
}
item = mediaItem;
}
@@ -348,6 +377,10 @@ TracksView::clipDragEnterEvent( QDragEnterEvent *event )
m_dragAudioItem->setTrack( getTrack( m_dragAudioItem->trackType(), 0 ) );
connect( m_dragAudioItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
+ connect( m_dragAudioItem, SIGNAL( effectAdded( AbstractGraphicsMediaItem*, EffectHelper*, qint64) ),
+ this, SLOT( effectAddedToClip( AbstractGraphicsMediaItem*, EffectHelper*,qint64) ) );
+ connect( m_dragAudioItem->clipHelper()->clipWorkflow(), SIGNAL( effectRemoved( QUuid ) ),
+ this, SLOT( effectRemoved( QUuid ) ) );
}
if ( clip->getMedia()->hasVideoTrack() == true )
{
@@ -358,6 +391,10 @@ TracksView::clipDragEnterEvent( QDragEnterEvent *event )
m_dragVideoItem->setTrack( getTrack( m_dragVideoItem->trackType(), 0 ) );
connect( m_dragVideoItem, SIGNAL( split(AbstractGraphicsMediaItem*,qint64) ),
this, SLOT( split(AbstractGraphicsMediaItem*,qint64) ) );
+ connect( m_dragVideoItem, SIGNAL( effectAdded( AbstractGraphicsMediaItem*, EffectHelper*, qint64) ),
+ this, SLOT( effectAddedToClip( AbstractGraphicsMediaItem*, EffectHelper*,qint64) ) );
+ connect( m_dragVideoItem->clipHelper()->clipWorkflow(), SIGNAL( effectRemoved( QUuid ) ),
+ this, SLOT( effectRemoved( QUuid ) ) );
}
// Group the items together
if ( clip->getMedia()->hasAudioTrack() == true &&
@@ -1315,3 +1352,17 @@ TracksView::item( const QUuid &uuid )
}
return NULL;
}
+
+void
+TracksView::effectAddedToClip( AbstractGraphicsMediaItem *mediaItem, EffectHelper *helper, qint64 pos )
+{
+ if ( m_itemsLoaded.contains( helper->uuid() ) )
+ return ;
+ GraphicsEffectItem *item = new GraphicsEffectItem( helper );
+ item->setHeight( item->itemHeight() );
+ item->m_tracksView = this;
+ item->setWidth( helper->length() );
+ item->setStartPos( mediaItem->startPos() + pos );
+ item->setTrack( mediaItem->track() );
+ item->m_oldTrack = mediaItem->track()->trackWorkflow();
+}
diff --git a/src/Gui/timeline/TracksView.h b/src/Gui/timeline/TracksView.h
index 24a30b4..b142f33 100644
--- a/src/Gui/timeline/TracksView.h
+++ b/src/Gui/timeline/TracksView.h
@@ -193,17 +193,12 @@ public:
*/
WorkflowRenderer *getRenderer() { return m_renderer; }
/**
- * \brief Remove a Clip from the timeline (and from the backend).
- * \param uuid The unique identifier of the Media.
- */
- void removeClip( const QUuid& uuid );
-
- /**
* \returns The AbstractGraphicsMediaItem identified by the given uuid.
* or NULL if there's no such item.
* \param uuid The ClipHelper's uuid
*/
AbstractGraphicsMediaItem* item( const QUuid& uuid );
+ void removeClip( const QUuid &uuid );
public slots:
/**
@@ -237,6 +232,11 @@ public slots:
* \sa removeMediaItem( const QList<AbstractGraphicsMediaItem*>& )
*/
void removeItem( AbstractGraphicsItem *item );
+ /**
+ * \brief Remove a Clip from the timeline (and from the backend).
+ * \param uuid The unique identifier of the Media.
+ */
+ void effectRemoved( const QUuid& uuid );
protected:
virtual void resizeEvent( QResizeEvent *event );
@@ -283,6 +283,8 @@ private slots:
*/
void split( AbstractGraphicsMediaItem *item, qint64 frame );
+ void effectAddedToClip( AbstractGraphicsMediaItem* mediaItem, EffectHelper* helper, qint64 pos );
+
private:
/**
* \brief Create the initial layout of the tracks
More information about the Vlmc-devel
mailing list