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

GraphicsItem: Refactoring to reduce the usage of ClipHelpers in TracksView

parent daef521b
......@@ -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 );
......
......@@ -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;
}
......@@ -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 );
......
......@@ -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
}
......@@ -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;
......
......@@ -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();
}
......
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