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

Refactor clips moving

parent f4cf352c
......@@ -43,15 +43,22 @@ EffectHelper::effectInstance() const
return m_effectInstance;
}
const EffectUser*
EffectHelper::target() const
EffectUser*
EffectHelper::target()
{
return m_target;
}
EffectUser*
EffectHelper::oldTarget()
{
return m_oldTarget;
}
void
EffectHelper::setTarget( const EffectUser *target )
EffectHelper::setTarget( EffectUser *target )
{
m_oldTarget = m_target;
m_target = target;
m_begin = 0;
if ( target != NULL )
......
......@@ -42,12 +42,14 @@ class EffectHelper : public Workflow::Helper
EffectInstance *effectInstance();
const EffectInstance *effectInstance() const;
const EffectUser *target() const;
void setTarget( const EffectUser *target );
EffectUser *target();
EffectUser *oldTarget();
void setTarget( EffectUser *target );
private:
EffectInstance *m_effectInstance;
const EffectUser *m_target;
EffectUser *m_target;
EffectUser *m_oldTarget;
};
Q_DECLARE_METATYPE( EffectHelper* );
......
......@@ -29,6 +29,7 @@ class GraphicsTrack;
class TrackWorkflow;
class TracksScene;
class TracksView;
class EffectUser;
class QUuid;
......@@ -117,8 +118,7 @@ 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 void triggerMove( EffectUser *target ) = 0;
virtual void triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
qint64 newBegin, qint64 newEnd, qint64 pos ) = 0;
virtual Workflow::Helper *helper() = 0;
......@@ -165,9 +165,9 @@ class AbstractGraphicsItem : public QObject, public QGraphicsItem
/// This pointer will be set when inserted in the tracksView.
TracksView* m_tracksView;
QColor m_itemColor;
TrackWorkflow *m_oldTrack;
private:
TrackWorkflow *m_oldTrack;
qint64 m_width;
qint64 m_height;
/// Pointer used to save the address of a linked item.
......
......@@ -274,14 +274,12 @@ AbstractGraphicsMediaItem::end() const
}
void
AbstractGraphicsMediaItem::triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
Workflow::Helper *helper, qint64 pos )
AbstractGraphicsMediaItem::triggerMove( EffectUser *target )
{
ClipHelper *clipHelper = qobject_cast<ClipHelper*>( helper );
if ( clipHelper == NULL )
TrackWorkflow *tw = qobject_cast<TrackWorkflow*>( target );
if ( tw == NULL )
return ;
Commands::trigger( new Commands::Clip::Move( oldTrack, newTrack,
clipHelper, pos ) );
Commands::trigger( new Commands::Clip::Move( m_oldTrack, tw, m_clipHelper, startPos() ) );
}
Workflow::Helper*
......
......@@ -57,8 +57,7 @@ public:
virtual qint64 end() const;
virtual Workflow::Helper *helper();
virtual void triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
Workflow::Helper *helper, qint64 pos );
virtual void triggerMove( EffectUser *target );
virtual void triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
qint64 newBegin, qint64 newEnd, qint64 pos );
virtual qint64 itemHeight() const;
......
......@@ -25,6 +25,7 @@
#include "Commands.h"
#include "EffectHelper.h"
#include "EffectInstance.h"
#include "GraphicsTrack.h"
#include "Timeline.h"
#include "TracksView.h"
#include "TrackWorkflow.h"
......@@ -245,13 +246,10 @@ GraphicsEffectItem::helper()
}
void
GraphicsEffectItem::triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
Workflow::Helper *helper, qint64 pos )
GraphicsEffectItem::triggerMove( EffectUser *target )
{
EffectHelper *eh = qobject_cast<EffectHelper*>( helper );
if ( eh == NULL )
return ;
Commands::trigger( new Commands::Effect::Move( eh, oldTrack, newTrack, pos ) );
Commands::trigger( new Commands::Effect::Move( m_effectHelper, m_effectHelper->oldTarget(),
target, startPos() ) );
}
void
......
......@@ -26,6 +26,8 @@
#include "AbstractGraphicsItem.h"
#include "EffectsEngine.h"
class EffectUser;
class QUuid;
class GraphicsEffectItem : public AbstractGraphicsItem
......@@ -48,8 +50,7 @@ class GraphicsEffectItem : public AbstractGraphicsItem
virtual qint64 maxBegin() const;
virtual qint64 maxEnd() const;
virtual Workflow::Helper *helper();
virtual void triggerMove(TrackWorkflow *oldTrack, TrackWorkflow *newTrack,
Workflow::Helper *helper, qint64 pos);
virtual void triggerMove( EffectUser *target );
virtual void triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
qint64 newBegin, qint64 newEnd, qint64 pos );
virtual qint64 itemHeight() const;
......
......@@ -229,7 +229,6 @@ TracksView::removeClip( const QUuid& uuid )
void
TracksView::addItem( TrackWorkflow *tw, Workflow::Helper *helper, qint64 start )
{
qDebug() << "Adding item:" << helper->uuid();
Q_ASSERT( helper );
//If for some reasons the clip was already loaded, don't add it twice.
......@@ -1057,16 +1056,19 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
UndoStack::getInstance()->beginMacro( "Move clip" );
m_actionItem->triggerMove( m_actionItem->m_oldTrack, m_actionItem->track()->trackWorkflow(),
m_actionItem->helper(), m_actionItem->startPos() );
// m_actionItem->triggerMove( m_oldTrack, m_actionItem->track()->trackWorkflow(),
// m_actionItem->helper(), m_actionItem->startPos() );
EffectUser *target = m_actionItem->track()->trackWorkflow();
// GraphicsEffectItem *effectItem = qobject_cast<GraphicsEffectItem*>( m_actionItem );
// if ( effectItem != NULL )
// {
// }
m_actionItem->triggerMove( target );
// Update the linked item too
if ( m_actionItem->groupItem() )
{
//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()->triggerMove( m_actionItem->groupItem()->track()->trackWorkflow() );
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