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

Fixing clip removal.

parent c8e7927c
...@@ -87,8 +87,6 @@ Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) : ...@@ -87,8 +87,6 @@ Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) :
// Clip actions // Clip actions
connect( m_mainWorkflow, SIGNAL( clipMoved( QUuid, uint, qint64, Workflow::TrackType ) ), connect( m_mainWorkflow, SIGNAL( clipMoved( QUuid, uint, qint64, Workflow::TrackType ) ),
this, SLOT( actionMoveClip(QUuid, uint, qint64, Workflow::TrackType ) ) ); this, SLOT( actionMoveClip(QUuid, uint, qint64, Workflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved( const QUuid&, uint, Workflow::TrackType ) ),
this, SLOT( actionRemoveClip( const QUuid&, uint, Workflow::TrackType )) );
// Clear / reset // Clear / reset
connect( m_mainWorkflow, SIGNAL( cleared() ), m_tracksControls, SLOT( clear() ) ); connect( m_mainWorkflow, SIGNAL( cleared() ), m_tracksControls, SLOT( clear() ) );
...@@ -169,11 +167,6 @@ void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 tim ...@@ -169,11 +167,6 @@ void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 tim
tracksRuler()->update(); tracksRuler()->update();
} }
void Timeline::actionRemoveClip( const QUuid &uuid, unsigned int track, Workflow::TrackType trackType )
{
tracksView()->removeMediaItem( uuid, track, trackType );
}
void void
Timeline::save( QXmlStreamWriter &project ) const Timeline::save( QXmlStreamWriter &project ) const
{ {
......
...@@ -89,12 +89,6 @@ public slots: ...@@ -89,12 +89,6 @@ public slots:
* \param time The new position (in frames) of the item. * \param time The new position (in frames) of the item.
*/ */
void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, Workflow::TrackType ); void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, Workflow::TrackType );
/**
* \brief Remove an item from the timeline.
* \param uuid The Universally Unique Identifier of the item.
* \param track The current track of the item.
*/
void actionRemoveClip( const QUuid& uuid, unsigned int track, Workflow::TrackType trackType );
void dragEnterEvent( QDragEnterEvent *event ); void dragEnterEvent( QDragEnterEvent *event );
void dropEvent( QDropEvent *event ); void dropEvent( QDropEvent *event );
......
...@@ -123,6 +123,8 @@ TracksView::addVideoTrack() ...@@ -123,6 +123,8 @@ TracksView::addVideoTrack()
m_numVideoTrack++; m_numVideoTrack++;
connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, ClipHelper*, qint64 ) ), connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, ClipHelper*, qint64 ) ),
this, SLOT( addMediaItem( TrackWorkflow*, ClipHelper*, qint64 ) ) ); this, SLOT( addMediaItem( TrackWorkflow*, ClipHelper*, qint64 ) ) );
connect( track->trackWorkflow(), SIGNAL( clipRemoved( TrackWorkflow*, ClipHelper* ) ),
this, SLOT( removeMediaItem( TrackWorkflow*, ClipHelper* ) ) );
emit videoTrackAdded( track ); emit videoTrackAdded( track );
} }
...@@ -138,6 +140,8 @@ TracksView::addAudioTrack() ...@@ -138,6 +140,8 @@ TracksView::addAudioTrack()
m_numAudioTrack++; m_numAudioTrack++;
connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, ClipHelper*, qint64 ) ), connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, ClipHelper*, qint64 ) ),
this, SLOT( addMediaItem( TrackWorkflow*, ClipHelper*, qint64 ) ) ); this, SLOT( addMediaItem( TrackWorkflow*, ClipHelper*, qint64 ) ) );
connect( track->trackWorkflow(), SIGNAL( clipRemoved( TrackWorkflow*, ClipHelper* ) ),
this, SLOT( removeMediaItem( TrackWorkflow*, ClipHelper* ) ) );
emit audioTrackAdded( track ); emit audioTrackAdded( track );
} }
...@@ -208,16 +212,12 @@ TracksView::removeClip( const QUuid& uuid ) ...@@ -208,16 +212,12 @@ TracksView::removeClip( const QUuid& uuid )
// This item needs to be removed. // This item needs to be removed.
// Saving its values // Saving its values
QUuid itemUuid = item->uuid(); QUuid itemUuid = item->uuid();
quint32 itemTn = item->trackNumber();
Workflow::TrackType itemTt = item->mediaType();
// Remove the item from the timeline // Remove the item from the timeline
removeMediaItem( itemUuid, itemTn, itemTt ); removeMediaItem( item->track()->trackWorkflow(), item->clipHelper() );
// Removing the item from the backend. // Removing the item from the backend.
MainWorkflow::getInstance()->removeClip( itemUuid, item->track()->trackWorkflow()->removeClip( itemUuid );
itemTn,
itemTt );
} }
} }
} }
...@@ -608,9 +608,9 @@ TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64 ...@@ -608,9 +608,9 @@ TracksView::findPosition( AbstractGraphicsMediaItem *item, quint32 track, qint64
} }
void void
TracksView::removeMediaItem( const QUuid &uuid, unsigned int trackId, Workflow::TrackType trackType ) TracksView::removeMediaItem( TrackWorkflow *tw, ClipHelper *ch )
{ {
GraphicsTrack *track = getTrack( trackType, trackId ); GraphicsTrack *track = getTrack( tw->type(), tw->trackId() );
if ( track == NULL ) if ( track == NULL )
return ; return ;
...@@ -620,7 +620,7 @@ TracksView::removeMediaItem( const QUuid &uuid, unsigned int trackId, Workflow:: ...@@ -620,7 +620,7 @@ TracksView::removeMediaItem( const QUuid &uuid, unsigned int trackId, Workflow::
{ {
AbstractGraphicsMediaItem *item = AbstractGraphicsMediaItem *item =
dynamic_cast<AbstractGraphicsMediaItem*>( trackItems.at( i ) ); dynamic_cast<AbstractGraphicsMediaItem*>( trackItems.at( i ) );
if ( !item || item->uuid() != uuid ) continue; if ( !item || item->uuid() != ch->uuid() ) continue;
removeMediaItem( item ); removeMediaItem( item );
} }
} }
......
...@@ -218,7 +218,7 @@ public slots: ...@@ -218,7 +218,7 @@ public slots:
* \param track The current track of the item. * \param track The current track of the item.
* \param trackType The type of the track (Audio or Video) * \param trackType The type of the track (Audio or Video)
*/ */
void removeMediaItem( const QUuid &uuid, unsigned int track, Workflow::TrackType trackType ); void removeMediaItem( TrackWorkflow* tw, ClipHelper* ch );
/** /**
* \brief This is an overloaded method provided for convenience. * \brief This is an overloaded method provided for convenience.
* \param item A pointer to AbstractGraphicsMediaItem. * \param item A pointer to AbstractGraphicsMediaItem.
......
...@@ -72,18 +72,6 @@ MainWorkflow::~MainWorkflow() ...@@ -72,18 +72,6 @@ MainWorkflow::~MainWorkflow()
delete m_blackOutput; delete m_blackOutput;
} }
//void
//MainWorkflow::addClip( ClipHelper *clipHelper, unsigned int trackId,
// qint64 start, Workflow::TrackType trackType,
// bool informGui )
//{
// m_tracks[trackType]->addClip( clipHelper, trackId, start );
// computeLength();
// //Inform the GUI
// if ( informGui == true )
// emit clipAdded( clipHelper, trackId, start, trackType );
//}
EffectsEngine::EffectHelper* EffectsEngine::EffectHelper*
MainWorkflow::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid, Workflow::TrackType type ) MainWorkflow::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid, Workflow::TrackType type )
{ {
...@@ -217,19 +205,6 @@ MainWorkflow::moveClip( const QUuid &clipUuid, unsigned int oldTrack, ...@@ -217,19 +205,6 @@ MainWorkflow::moveClip( const QUuid &clipUuid, unsigned int oldTrack,
} }
} }
Clip*
MainWorkflow::removeClip( const QUuid &uuid, unsigned int trackId,
Workflow::TrackType trackType )
{
Clip *clip = m_tracks[trackType]->removeClip( uuid, trackId );
if ( clip != NULL )
{
computeLength();
emit clipRemoved( uuid, trackId, trackType );
}
return clip;
}
void void
MainWorkflow::muteTrack( unsigned int trackId, Workflow::TrackType trackType ) MainWorkflow::muteTrack( unsigned int trackId, Workflow::TrackType trackType )
{ {
...@@ -472,7 +447,7 @@ MainWorkflow::unsplit( ClipHelper* origin, ClipHelper* splitted, quint32 trackId ...@@ -472,7 +447,7 @@ MainWorkflow::unsplit( ClipHelper* origin, ClipHelper* splitted, quint32 trackId
{ {
QMutexLocker lock( m_renderStartedMutex ); QMutexLocker lock( m_renderStartedMutex );
removeClip( splitted->uuid(), trackId, trackType ); // removeClip( splitted->uuid(), trackId, trackType );
origin->setEnd( splitted->end() ); origin->setEnd( splitted->end() );
} }
......
...@@ -57,24 +57,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -57,24 +57,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
Q_OBJECT Q_OBJECT
public: public:
/**
* \brief Add a clip to the workflow
*
* When called, this method will emit
* clipAdded( Clip*, unsigned int, qint64, MainWorkflow::TrackType ) SIGNAL.
* \param clip The clip to add
* \param trackId The number of the track (starting at 0)
* \param start The clip's starting position
* \param type The track type (audio or video)
* \param informGui Will be false if the action is queried by the GUI.
* true otherwise.
* \sa removeClip( const QUuid&, unsigned int, Workflow::TrackType )
* \sa clipAdded( Clip*, unsigned int, qint64, Workflow::TrackType )
*/
// void addClip( ClipHelper* clipHelper, quint32 trackId, qint64 start,
// Workflow::TrackType type, bool informGui );
EffectsEngine::EffectHelper *addEffect( Effect* effect, quint32 trackId, EffectsEngine::EffectHelper *addEffect( Effect* effect, quint32 trackId,
const QUuid &uuid, Workflow::TrackType type ); const QUuid &uuid, Workflow::TrackType type );
...@@ -155,21 +137,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -155,21 +137,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/ */
void previousFrame( Workflow::TrackType trackType ); void previousFrame( Workflow::TrackType trackType );
/**
* \brief Remove a clip from the workflow
*
* The created ClipWorkflow is deleted, and the added clip is returned.
* Calling this method will cause
* clipRemoved( Clip*, unsigned int, Workflow::TrackType ) to be emitted.
* \param uuid The uuid of the clip to remove.
* \param trackId The id of the track containing the clip to remove
* \param trackType The type of the track containing the clip to remove
* \sa addClip( Clip*, unsigned int, qint64, TrackType )
* \sa clipRemoved(Clip*, unsigned int, Workflow::TrackType)
*/
Clip* removeClip( const QUuid& uuid, unsigned int trackId,
Workflow::TrackType trackType );
/** /**
* \brief Move a clip in the workflow * \brief Move a clip in the workflow
* *
...@@ -437,15 +404,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -437,15 +404,6 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/ */
void mainWorkflowEndReached(); void mainWorkflowEndReached();
/**
* \brief Emitted when a clip is removed
* \param uuid The clip that has been removed's uuid.
* \param trackId The track that was containing the clip
* \param trackType The type of the track that was containing the clip
* \sa removeClip( const QUuid&, unsigned int, Workflow::TrackType )
*/
void clipRemoved( const QUuid& uuid, unsigned int trackId,
Workflow::TrackType trackType );
/** /**
* \brief Emitted when a clip has been moved * \brief Emitted when a clip has been moved
* *
......
...@@ -401,6 +401,7 @@ Clip* TrackWorkflow::removeClip( const QUuid& id ) ...@@ -401,6 +401,7 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
stopClipWorkflow( cw ); stopClipWorkflow( cw );
computeLength(); computeLength();
cw->disconnect(); cw->disconnect();
emit clipRemoved( this, cw->getClipHelper() );
delete cw; delete cw;
return clip; return clip;
} }
......
...@@ -128,6 +128,7 @@ class TrackWorkflow : public QObject ...@@ -128,6 +128,7 @@ class TrackWorkflow : public QObject
signals: signals:
void lengthChanged( qint64 newLength ); void lengthChanged( qint64 newLength );
void clipAdded( TrackWorkflow*, ClipHelper*, qint64 ); void clipAdded( TrackWorkflow*, ClipHelper*, qint64 );
void clipRemoved( TrackWorkflow*, ClipHelper* );
}; };
#endif // TRACKWORKFLOW_H #endif // TRACKWORKFLOW_H
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