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