Commit 9345f57d authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Fixing many bugs due to previous refactoring.

parent acf53111
...@@ -105,21 +105,22 @@ void Commands::MainWorkflow::MoveClip::undo() ...@@ -105,21 +105,22 @@ void Commands::MainWorkflow::MoveClip::undo()
m_undoRedoAction = true; m_undoRedoAction = true;
} }
Commands::MainWorkflow::RemoveClip::RemoveClip( Clip* clip, quint32 trackNumber, Commands::MainWorkflow::RemoveClip::RemoveClip( Clip* clip, const QUuid& uuid, quint32 trackNumber,
qint64 pos, ::MainWorkflow::TrackType trackType ) : qint64 pos, ::MainWorkflow::TrackType trackType ) :
m_clip( clip ), m_trackNumber( trackNumber ), m_clip( clip ), m_trackNumber( trackNumber ),
m_pos( pos ), m_trackType( trackType ) m_pos( pos ), m_trackType( trackType ),
m_uuid( uuid )
{ {
setText( QObject::tr( "Remove clip" ) ); setText( QObject::tr( "Remove clip" ) );
} }
void Commands::MainWorkflow::RemoveClip::redo() void Commands::MainWorkflow::RemoveClip::redo()
{ {
::MainWorkflow::getInstance()->removeClip( m_clip->uuid(), m_trackNumber, m_trackType ); ::MainWorkflow::getInstance()->removeClip( m_uuid, m_trackNumber, m_trackType );
} }
void Commands::MainWorkflow::RemoveClip::undo() void Commands::MainWorkflow::RemoveClip::undo()
{ {
::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType, true ); m_uuid = ::MainWorkflow::getInstance()->addClip( m_clip, m_trackNumber, m_pos, m_trackType, true );
} }
Commands::MainWorkflow::ResizeClip::ResizeClip( const QUuid& uuid, Commands::MainWorkflow::ResizeClip::ResizeClip( const QUuid& uuid,
......
...@@ -99,7 +99,7 @@ namespace Commands ...@@ -99,7 +99,7 @@ namespace Commands
NEW_COMMAND( RemoveClip ) NEW_COMMAND( RemoveClip )
{ {
public: public:
RemoveClip( Clip* clip, unsigned int trackNumber, RemoveClip( Clip* clip, const QUuid& uuid, unsigned int trackNumber,
qint64 pos, ::MainWorkflow::TrackType trackType ); qint64 pos, ::MainWorkflow::TrackType trackType );
virtual void redo(); virtual void redo();
virtual void undo(); virtual void undo();
...@@ -109,6 +109,7 @@ namespace Commands ...@@ -109,6 +109,7 @@ namespace Commands
unsigned int m_trackNumber; unsigned int m_trackNumber;
qint64 m_pos; qint64 m_pos;
::MainWorkflow::TrackType m_trackType; ::MainWorkflow::TrackType m_trackType;
QUuid m_uuid;
}; };
/** /**
......
...@@ -158,13 +158,13 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent ...@@ -158,13 +158,13 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent
if ( ( m_muted = muteAction->isChecked() ) ) if ( ( m_muted = muteAction->isChecked() ) )
{ {
tracksView()->m_mainWorkflow->muteClip( clip()->uuid(), tracksView()->m_mainWorkflow->muteClip( uuid(),
trackNumber(), trackNumber(),
mediaType() ); mediaType() );
} }
else else
{ {
tracksView()->m_mainWorkflow->unmuteClip( clip()->uuid(), tracksView()->m_mainWorkflow->unmuteClip( uuid(),
trackNumber(), trackNumber(),
mediaType() ); mediaType() );
} }
...@@ -190,7 +190,7 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent ...@@ -190,7 +190,7 @@ void AbstractGraphicsMediaItem::contextMenuEvent( QGraphicsSceneContextMenuEvent
{ {
item1->group( this ); item1->group( this );
tracksView()->moveMediaItem( item1, item1->trackNumber(), startPos() ); tracksView()->moveMediaItem( item1, item1->trackNumber(), startPos() );
MainWorkflow::getInstance()->moveClip( item1->clip()->uuid(), item1->trackNumber(), MainWorkflow::getInstance()->moveClip( item1->uuid(), item1->trackNumber(),
trackNumber(), startPos(), trackNumber(), startPos(),
item1->mediaType() ); item1->mediaType() );
} }
......
...@@ -84,8 +84,8 @@ Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) : ...@@ -84,8 +84,8 @@ Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) :
this, SLOT( actionAddClip(Clip*,uint,qint64,MainWorkflow::TrackType ) ) ); this, SLOT( actionAddClip(Clip*,uint,qint64,MainWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64,MainWorkflow::TrackType ) ), connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64,MainWorkflow::TrackType ) ),
this, SLOT( actionMoveClip(QUuid,uint,qint64,MainWorkflow::TrackType ) ) ); this, SLOT( actionMoveClip(QUuid,uint,qint64,MainWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved(Clip*,uint,MainWorkflow::TrackType ) ), connect( m_mainWorkflow, SIGNAL( clipRemoved(const QUuid&,uint,MainWorkflow::TrackType ) ),
this, SLOT( actionRemoveClip(Clip*,uint,MainWorkflow::TrackType )) ); this, SLOT( actionRemoveClip(const QUuid&,uint,MainWorkflow::TrackType )) );
// Clear / reset // Clear / reset
connect( m_mainWorkflow, SIGNAL( cleared() ), m_tracksControls, SLOT( clear() ) ); connect( m_mainWorkflow, SIGNAL( cleared() ), m_tracksControls, SLOT( clear() ) );
...@@ -171,7 +171,7 @@ void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 tim ...@@ -171,7 +171,7 @@ void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 tim
tracksRuler()->update(); tracksRuler()->update();
} }
void Timeline::actionRemoveClip( Clip* clip, unsigned int track, MainWorkflow::TrackType trackType ) void Timeline::actionRemoveClip( const QUuid &uuid, unsigned int track, MainWorkflow::TrackType trackType )
{ {
tracksView()->removeMediaItem( clip->uuid(), track, trackType ); tracksView()->removeMediaItem( uuid, track, trackType );
} }
...@@ -91,7 +91,7 @@ public slots: ...@@ -91,7 +91,7 @@ public slots:
* \param uuid The Universally Unique Identifier of the item. * \param uuid The Universally Unique Identifier of the item.
* \param track The current track of the item. * \param track The current track of the item.
*/ */
void actionRemoveClip( Clip* clip, unsigned int track, MainWorkflow::TrackType trackType ); void actionRemoveClip( const QUuid& uuid, unsigned int track, MainWorkflow::TrackType trackType );
protected: protected:
virtual void changeEvent( QEvent *e ); virtual void changeEvent( QEvent *e );
......
...@@ -60,7 +60,8 @@ void TracksScene::contextMenuEvent( QGraphicsSceneContextMenuEvent* event ) ...@@ -60,7 +60,8 @@ void TracksScene::contextMenuEvent( QGraphicsSceneContextMenuEvent* event )
//TODO Event not handled, create and show a menu here. //TODO Event not handled, create and show a menu here.
} }
void TracksScene::askRemoveSelectedItems() void
TracksScene::askRemoveSelectedItems()
{ {
TracksView* tv = Timeline::getInstance()->tracksView(); TracksView* tv = Timeline::getInstance()->tracksView();
...@@ -86,10 +87,11 @@ void TracksScene::askRemoveSelectedItems() ...@@ -86,10 +87,11 @@ void TracksScene::askRemoveSelectedItems()
QList<QGraphicsItem*> items = selectedItems(); QList<QGraphicsItem*> items = selectedItems();
for (int i = 0; i < items.size(); ++i ) for (int i = 0; i < items.size(); ++i )
{ {
GraphicsMovieItem* item = qgraphicsitem_cast<GraphicsMovieItem*>( items.at(i) ); AbstractGraphicsMediaItem* item = qgraphicsitem_cast<AbstractGraphicsMediaItem*>( items.at(i) );
if ( !item ) return; if ( !item ) return;
Commands::trigger( new Commands::MainWorkflow::RemoveClip( item->clip(), Commands::trigger( new Commands::MainWorkflow::RemoveClip( item->clip(),
item->uuid(),
item->trackNumber(), item->trackNumber(),
item->startPos(), item->startPos(),
item->mediaType() ) ); item->mediaType() ) );
......
...@@ -217,7 +217,7 @@ MainWorkflow::removeClip( const QUuid &uuid, unsigned int trackId, ...@@ -217,7 +217,7 @@ MainWorkflow::removeClip( const QUuid &uuid, unsigned int trackId,
if ( clip != NULL ) if ( clip != NULL )
{ {
computeLength(); computeLength();
emit clipRemoved( clip, trackId, trackType ); emit clipRemoved( uuid, trackId, trackType );
} }
return clip; return clip;
} }
......
...@@ -454,12 +454,12 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow> ...@@ -454,12 +454,12 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
MainWorkflow::TrackType trackType ); MainWorkflow::TrackType trackType );
/** /**
* \brief Emitted when a clip is removed * \brief Emitted when a clip is removed
* \param clip The clip that has been removed. * \param uuid The clip that has been removed's uuid.
* \param trackId The track that was containing the clip * \param trackId The track that was containing the clip
* \param trackType The type of 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, MainWorkflow::TrackType ) * \sa removeClip( const QUuid&, unsigned int, MainWorkflow::TrackType )
*/ */
void clipRemoved( Clip* clip, unsigned int trackId, void clipRemoved( const QUuid& uuid, unsigned int trackId,
MainWorkflow::TrackType trackType ); MainWorkflow::TrackType trackType );
/** /**
* \brief Emitted when a clip has been moved * \brief Emitted when a clip has been moved
......
...@@ -112,7 +112,7 @@ qint64 TrackWorkflow::getClipPosition( const QUuid& uuid ) const ...@@ -112,7 +112,7 @@ qint64 TrackWorkflow::getClipPosition( const QUuid& uuid ) const
while ( it != end ) while ( it != end )
{ {
if ( it.value()->getClip()->uuid() == uuid ) if ( it.value()->uuid() == uuid )
return it.key(); return it.key();
++it; ++it;
} }
...@@ -126,7 +126,7 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid ) ...@@ -126,7 +126,7 @@ Clip* TrackWorkflow::getClip( const QUuid& uuid )
while ( it != end ) while ( it != end )
{ {
if ( it.value()->getClip()->uuid() == uuid ) if ( it.value()->uuid() == uuid )
return it.value()->getClip(); return it.value()->getClip();
++it; ++it;
} }
...@@ -326,7 +326,7 @@ void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame ) ...@@ -326,7 +326,7 @@ void TrackWorkflow::moveClip( const QUuid& id, qint64 startingFrame )
while ( it != end ) while ( it != end )
{ {
if ( it.value()->getClip()->uuid() == id ) if ( it.value()->uuid() == id )
{ {
ClipWorkflow* cw = it.value(); ClipWorkflow* cw = it.value();
m_clips.erase( it ); m_clips.erase( it );
...@@ -350,7 +350,7 @@ Clip* TrackWorkflow::removeClip( const QUuid& id ) ...@@ -350,7 +350,7 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
while ( it != end ) while ( it != end )
{ {
if ( it.value()->getClip()->uuid() == id ) if ( it.value()->uuid() == id )
{ {
ClipWorkflow* cw = it.value(); ClipWorkflow* cw = it.value();
Clip* clip = cw->getClip(); Clip* clip = cw->getClip();
...@@ -359,6 +359,7 @@ Clip* TrackWorkflow::removeClip( const QUuid& id ) ...@@ -359,6 +359,7 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
computeLength(); computeLength();
cw->disconnect(); cw->disconnect();
delete cw; delete cw;
qDebug() << "Deleted clipworkflow";
if ( m_length == 0 ) if ( m_length == 0 )
emit trackEndReached( m_trackId ); emit trackEndReached( m_trackId );
return clip; return clip;
...@@ -377,7 +378,7 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id ) ...@@ -377,7 +378,7 @@ ClipWorkflow* TrackWorkflow::removeClipWorkflow( const QUuid& id )
while ( it != end ) while ( it != end )
{ {
if ( it.value()->getClip()->uuid() == id ) if ( it.value()->uuid() == id )
{ {
ClipWorkflow* cw = it.value(); ClipWorkflow* cw = it.value();
cw->disconnect(); cw->disconnect();
...@@ -459,7 +460,7 @@ TrackWorkflow::muteClip( const QUuid &uuid ) ...@@ -459,7 +460,7 @@ TrackWorkflow::muteClip( const QUuid &uuid )
while ( it != end ) while ( it != end )
{ {
if ( it.value()->getClip()->uuid() == uuid ) if ( it.value()->uuid() == uuid )
{ {
it.value()->mute(); it.value()->mute();
return ; return ;
...@@ -480,7 +481,7 @@ TrackWorkflow::unmuteClip( const QUuid &uuid ) ...@@ -480,7 +481,7 @@ TrackWorkflow::unmuteClip( const QUuid &uuid )
while ( it != end ) while ( it != end )
{ {
if ( it.value()->getClip()->uuid() == uuid ) if ( it.value()->uuid() == uuid )
{ {
it.value()->unmute(); it.value()->unmute();
return ; return ;
......
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