[vlmc-devel] commit: GraphicsItem: Refactoring to reduce the usage of ClipHelpers in TracksView ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Wed Sep 8 00:40:24 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Sep 8 00:39:59 2010 +0200| [a8e040decf666d7f47f028814dd5f1f9380840d8] | committer: Hugo Beauzée-Luyssen
GraphicsItem: Refactoring to reduce the usage of ClipHelpers in TracksView
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=a8e040decf666d7f47f028814dd5f1f9380840d8
---
src/Gui/timeline/AbstractGraphicsItem.h | 9 +++++++++
src/Gui/timeline/AbstractGraphicsMediaItem.cpp | 17 +++++++++++++++++
src/Gui/timeline/AbstractGraphicsMediaItem.h | 4 ++++
src/Gui/timeline/GraphicsEffectItem.cpp | 14 +++++++++++++-
src/Gui/timeline/GraphicsEffectItem.h | 3 +++
src/Gui/timeline/TracksView.cpp | 17 +++++++----------
6 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/src/Gui/timeline/AbstractGraphicsItem.h b/src/Gui/timeline/AbstractGraphicsItem.h
index fdc1237..c103e00 100644
--- a/src/Gui/timeline/AbstractGraphicsItem.h
+++ b/src/Gui/timeline/AbstractGraphicsItem.h
@@ -32,6 +32,11 @@ class TracksView;
class QUuid;
+namespace Workflow
+{
+ class Helper;
+}
+
#include "Types.h"
class AbstractGraphicsItem : public QObject, public QGraphicsItem
@@ -110,6 +115,10 @@ class AbstractGraphicsItem : public QObject, public QGraphicsItem
virtual qint64 end() const = 0;
qint64 width() const;
+ virtual void triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
+ Workflow::Helper *helper, qint64 pos ) = 0;
+ virtual Workflow::Helper *helper() = 0;
+
protected:
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
virtual void hoverMoveEvent( QGraphicsSceneHoverEvent* event );
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index 41e19ee..832b505 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -272,3 +272,20 @@ AbstractGraphicsMediaItem::end() const
{
return m_clipHelper->end();
}
+
+void
+AbstractGraphicsMediaItem::triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
+ Workflow::Helper *helper, qint64 pos )
+{
+ ClipHelper *clipHelper = qobject_cast<ClipHelper*>( helper );
+ if ( clipHelper == NULL )
+ return ;
+ Commands::trigger( new Commands::MainWorkflow::MoveClip( oldTrack, newTrack,
+ clipHelper, pos ) );
+}
+
+Workflow::Helper*
+AbstractGraphicsMediaItem::helper()
+{
+ return m_clipHelper;
+}
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index a6dc8b2..7de227f 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -56,6 +56,10 @@ public:
virtual qint64 begin() const;
virtual qint64 end() const;
+ virtual Workflow::Helper *helper();
+ virtual void triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
+ Workflow::Helper *helper, qint64 pos );
+
protected:
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* event );
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
diff --git a/src/Gui/timeline/GraphicsEffectItem.cpp b/src/Gui/timeline/GraphicsEffectItem.cpp
index 71560e2..ccfd12e 100644
--- a/src/Gui/timeline/GraphicsEffectItem.cpp
+++ b/src/Gui/timeline/GraphicsEffectItem.cpp
@@ -195,9 +195,21 @@ GraphicsEffectItem::begin() const
return 0;
}
-
qint64
GraphicsEffectItem::end() const
{
return -1;
}
+
+Workflow::Helper*
+GraphicsEffectItem::helper()
+{
+ return m_effectHelper;
+}
+
+void
+GraphicsEffectItem::triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
+ Workflow::Helper *helper, qint64 pos )
+{
+ //FIXME
+}
diff --git a/src/Gui/timeline/GraphicsEffectItem.h b/src/Gui/timeline/GraphicsEffectItem.h
index f347e29..881b621 100644
--- a/src/Gui/timeline/GraphicsEffectItem.h
+++ b/src/Gui/timeline/GraphicsEffectItem.h
@@ -44,6 +44,9 @@ class GraphicsEffectItem : public AbstractGraphicsItem
Effect* effect();
virtual qint64 begin() const;
virtual qint64 end() const;
+ virtual Workflow::Helper *helper();
+ virtual void triggerMove(TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
+ Workflow::Helper *helper, qint64 pos);
protected:
virtual bool hasResizeBoundaries() const;
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 2faca6f..f9244ce 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -988,19 +988,16 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
UndoStack::getInstance()->beginMacro( "Move clip" );
- Commands::trigger( new Commands::MainWorkflow::MoveClip( m_actionItem->m_oldTrack,
- m_actionItem->track()->trackWorkflow(),
- m_actionItem->clipHelper(),
- m_actionItem->startPos() ) );
-
+ m_actionItem->triggerMove( m_actionItem->m_oldTrack, m_actionItem->track()->trackWorkflow(),
+ m_actionItem->helper(), m_actionItem->startPos() );
// Update the linked item too
if ( m_actionItem->groupItem() )
{
- Commands::trigger( new Commands::MainWorkflow::MoveClip( m_actionItem->m_oldTrack,
- m_actionItem->track()->trackWorkflow(),
- m_actionItem->clipHelper(),
- m_actionItem->startPos() ) );
-
+ //CHECK: This used to use m_actionItem and not m_actionItem->groupItem().
+ m_actionItem->groupItem()->triggerMove( m_actionItem->groupItem()->m_oldTrack,
+ m_actionItem->groupItem()->track()->trackWorkflow(),
+ m_actionItem->groupItem()->helper(),
+ m_actionItem->startPos() );
m_actionItem->groupItem()->m_oldTrack = m_actionItem->groupItem()->track()->trackWorkflow();
}
More information about the Vlmc-devel
mailing list