Commit 5bcf5091 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Library: When a clip is removed, emit a signal with its uuid, as the clip may have been deleted.

A media that fail to load is automatically removed from the view (as
it's removed from the media container.)
Fixes #4
parent 4bd2acb5
......@@ -251,8 +251,8 @@ MainWindow::setupLibrary()
connect( mediaView, SIGNAL( clipSelected( Clip* ) ),
clipRenderer, SLOT( setClip( Clip* ) ) );
connect( Library::getInstance(), SIGNAL( clipRemoved( const Clip* ) ),
clipRenderer, SLOT( clipUnloaded( const Clip* ) ) );
connect( Library::getInstance(), SIGNAL( clipRemoved( const QUuid& ) ),
clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
}
void MainWindow::on_actionSave_triggered()
......
......@@ -92,8 +92,8 @@ ImportController::ImportController(QWidget *parent) :
m_clipRenderer, SLOT( setClip( Clip* ) ) );
connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
this, SLOT( clipSelection( Clip* ) ) );
connect( m_mediaListView, SIGNAL( clipDeleted( const QUuid& ) ),
m_clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
connect( m_mediaListView, SIGNAL( clipRemoved( const Clip* ) ),
m_clipRenderer, SLOT( clipUnloaded( const Clip* ) ) );
connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ),
this, SLOT( failedToLoad( Media* ) ) );
......
......@@ -45,9 +45,9 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
m_ui->clipCount->setText( QString::number( clip->getChilds()->count() ) );
connect( clip->getChilds(), SIGNAL( newClipLoaded( Clip* ) ),
this, SLOT( nbClipUpdated( Clip* ) ) );
connect( clip->getChilds(), SIGNAL( clipRemoved( const Clip* ) ),
this, SLOT( nbClipUpdated( const Clip* ) ) );
this, SLOT( nbClipUpdated() ) );
connect( clip->getChilds(), SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( nbClipUpdated() ) );
if ( clip->getChilds()->count() == 0 )
{
m_ui->clipCount->hide();
......@@ -103,14 +103,9 @@ void MediaCellView::setTitle( const QString& title )
}
void
MediaCellView::nbClipUpdated( Clip *clip )
MediaCellView::nbClipUpdated()
{
nbClipUpdated( const_cast<const Clip*>( clip ) );
}
void MediaCellView::nbClipUpdated( const Clip *clip )
{
quint32 nbClips = clip->getParent()->getChilds()->count();
quint32 nbClips = m_clip->getParent()->getChilds()->count();
if ( nbClips == 0 )
{
......
......@@ -81,9 +81,7 @@ public slots:
private slots:
void snapshotUpdated( const Media *media );
void metadataUpdated( const Media *media );
void nbClipUpdated( const Clip *clip );
void nbClipUpdated( Clip *clip );
void nbClipUpdated();
};
#endif // MEDIACELLVIEW_H
......@@ -32,8 +32,10 @@ MediaListView::MediaListView( StackViewController* nav, MediaContainer* mc ) :
{
connect( mc, SIGNAL( newClipLoaded(Clip*) ),
this, SLOT( newClipLoaded( Clip* ) ) );
connect( this, SIGNAL( clipDeleted( const QUuid& ) ),
mc, SLOT(removeClip( const QUuid& ) ) );
connect( this, SIGNAL( clipRemoved( const Clip* ) ),
mc, SLOT( removeClip( const Clip* ) ) );
connect( mc, SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( __clipRemoved( const QUuid& ) ) );
foreach ( Clip* clip, mc->clips() )
newClipLoaded( clip );
}
......@@ -52,7 +54,7 @@ void MediaListView::newClipLoaded( Clip *clip )
connect( cell, SIGNAL ( cellSelected( QUuid ) ),
this, SLOT ( cellSelection( QUuid ) ) );
connect( cell, SIGNAL ( cellDeleted( const Clip* ) ),
this, SLOT( clipRemoved( const Clip* ) ) );
this, SLOT( removeClip( const Clip* ) ) );
connect( cell, SIGNAL( arrowClicked( const QUuid& ) ),
this, SLOT( showSubClips( const QUuid& ) ) );
addCell( cell );
......@@ -80,14 +82,18 @@ void MediaListView::cellSelection( const QUuid& uuid )
}
}
void MediaListView::clipRemoved( const Clip* clip )
void MediaListView::removeClip( const Clip* clip )
{
QWidget* cell = m_cells.value( clip->uuid() );
__clipRemoved( clip->uuid() );
emit clipRemoved( clip );
}
void
MediaListView::__clipRemoved( const QUuid &uuid )
{
QWidget* cell = m_cells.take( uuid );
removeCell( cell );
m_cells.remove( clip->uuid() );
m_currentUuid = QUuid();
emit clipDeleted( clip->uuid() );
delete clip;
}
void
......
......@@ -53,11 +53,17 @@ public slots:
void clear();
private slots:
void clipRemoved( const Clip* );
void removeClip( const Clip* );
/**
* \brief Called when the media container unload a clip
*
* This slot will be triggered when a Clip is removed from the media container.
*/
void __clipRemoved( const QUuid& );
void newClipLoaded( Clip* clip );
signals:
void clipSelected( Clip* );
void clipDeleted( const QUuid& );
void clipRemoved( const Clip* );
};
#endif // MEDIALISTVIEW_H
......@@ -72,8 +72,8 @@ TracksView::TracksView( QGraphicsScene *scene, MainWorkflow *mainWorkflow,
connect( m_cursorLine, SIGNAL( cursorPositionChanged(qint64) ),
this, SLOT( ensureCursorVisible() ) );
connect( Library::getInstance(), SIGNAL( clipRemoved( const Clip* ) ),
this, SLOT( deleteMedia( const Clip* ) ) );
connect( Library::getInstance(), SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( deleteMedia( const QUuid& ) ) );
}
void
......@@ -184,7 +184,7 @@ TracksView::clear()
}
void
TracksView::deleteMedia( const Clip* clip )
TracksView::deleteMedia( const QUuid& uuid )
{
AbstractGraphicsMediaItem *item;
......@@ -196,7 +196,7 @@ TracksView::deleteMedia( const Clip* clip )
foreach( item, items )
{
if ( item->clip()->getMedia()->baseClip()->uuid() ==
clip->uuid() )
uuid )
{
// This item needs to be removed.
// Saving its values
......
......@@ -185,7 +185,7 @@ public slots:
* \brief Remove a Media from the timeline (and from the backend).
* \param uuid The unique identifier of the Media.
*/
void deleteMedia( const Clip* clip );
void deleteMedia( const QUuid& uuid );
/**
* \brief Insert an item into the timeline.
* \param clip Clip to insert.
......
......@@ -120,7 +120,7 @@ MediaContainer::clear()
while ( it != end )
{
emit clipRemoved( it.value() );
emit clipRemoved( it.key() );
it.value()->clear();
it.value()->deleteLater();
++it;
......@@ -136,7 +136,7 @@ MediaContainer::removeAll()
while ( it != end )
{
emit clipRemoved( it.value() );
emit clipRemoved( it.key() );
++it;
}
m_clips.clear();
......@@ -150,7 +150,7 @@ MediaContainer::removeClip( const QUuid &uuid )
{
Clip* clip = it.value();
m_clips.remove( uuid );
emit clipRemoved( clip );
emit clipRemoved( uuid );
return clip;
}
return NULL;
......
......@@ -154,9 +154,11 @@ signals:
void newClipLoaded( Clip* );
/**
* \brief This signal should be emiteted when a Clip has been removed
* This signal pass a QUuid as the clip may be deleted when the signal reaches its
* slot.
* \param uuid The removed clip uuid
*/
void clipRemoved( const Clip* );
void clipRemoved( const QUuid& );
};
#endif // MEDIACONTAINER_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