Commit 2384ff91 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Starting a Library/Import cleanup

Removed temporary medias from the library
parent 2263ff5a
......@@ -148,11 +148,11 @@ ImportController::mediaSelection( const QUuid& uuid )
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_mediaListController->cell( uuid )->setPalette( p );
setUIMetaData( Library::getInstance()->temporaryMedia( uuid ) );
setUIMetaData( m_temporaryMedias[uuid] );
if ( uuid != NULL && uuid != m_currentUuid )
m_preview->stop();
m_currentUuid = uuid;
emit mediaSelected( Library::getInstance()->temporaryMedia( uuid ) );
emit mediaSelected( m_temporaryMedias[uuid] );
}
}
......@@ -167,9 +167,8 @@ ImportController::clipSelection( const QUuid& uuid )
p.setColor( QPalette::Window, QColor( Qt::darkBlue ) );
m_clipListController->cell( uuid )->setPalette( p );
Clip* clip;
foreach(QUuid id, Library::getInstance()->temporaryMedias()->keys() )
foreach( Media* media, m_temporaryMedias.values() )
{
Media* media = Library::getInstance()->temporaryMedias()->value( id );
if ( ( clip = media->clip( uuid ) ) != 0 )
break;
}
......@@ -185,18 +184,18 @@ ImportController::clipSelection( const QUuid& uuid )
void
ImportController::newMediaLoaded( const QUuid& uuid )
{
Media* media = Library::getInstance()->temporaryMedia( uuid );
if ( media == NULL )
return;
if ( m_temporaryMedias.contains( uuid ) == false )
return ;
Media* media = m_temporaryMedias[uuid];
m_mediaListController->addMedia( media );
}
void
ImportController::updateMediaRequested( const QUuid& uuid )
{
Media* media = Library::getInstance()->temporaryMedia( uuid );
if ( media == NULL )
return;
if ( m_temporaryMedias.contains( uuid ) == false )
return ;
Media* media = m_temporaryMedias[uuid];
ImportMediaCellView* cell = m_mediaListController->cell( media->getUuid() );
if ( cell == NULL )
return;
......@@ -281,7 +280,7 @@ ImportController::reject()
{
m_preview->stop();
m_mediaListController->cleanAll();
Library::getInstance()->deleteTemporaryMedias();
deleteTemporaryMedias();
collapseAllButCurrentPath();
done( Rejected );
}
......@@ -290,12 +289,19 @@ void
ImportController::accept()
{
m_mediaListController->cleanAll();
Library::getInstance()->importDone();
m_preview->stop();
collapseAllButCurrentPath();
done( Accepted );
}
void
ImportController::deleteTemporaryMedias()
{
foreach ( Media* media, m_temporaryMedias.values() )
delete media;
m_temporaryMedias.clear();
}
void
ImportController::collapseAllButCurrentPath()
{
......@@ -329,10 +335,8 @@ void
ImportController::clipDeletion( const QUuid& uuid )
{
m_clipListController->removeClip( uuid );
QUuid id;
foreach( id, Library::getInstance()->temporaryMedias()->keys() )
foreach( Media* media, m_temporaryMedias.values() )
{
Media* media = Library::getInstance()->temporaryMedias()->value( id );
if ( media != NULL && media->clip( uuid ) )
media->removeClip( uuid );
}
......@@ -341,8 +345,10 @@ ImportController::clipDeletion( const QUuid& uuid )
void
ImportController::showClipList( const QUuid& uuid )
{
Media* media = Library::getInstance()->temporaryMedia( uuid );
if ( media == NULL || media->clips()->size() == 0 )
if ( m_temporaryMedias.contains( uuid ) == false )
return ;
Media* media = m_temporaryMedias[uuid];
if ( media->clips()->size() == 0 )
return ;
m_clipListController = new ImportMediaListController( m_stackNav );
......
......@@ -68,6 +68,7 @@ class ImportController : public QDialog
void saveCurrentPath();
void restoreCurrentPath();
void collapseAllButCurrentPath();
void deleteTemporaryMedias();
Ui::ImportController* m_ui;
PreviewWidget* m_preview;
StackViewController* m_stackNav;
......@@ -81,6 +82,7 @@ class ImportController : public QDialog
QUuid m_savedUuid;
bool m_controllerSwitched;
QProgressDialog* m_progressDialog;
QHash< QUuid, Media*> m_temporaryMedias;
public slots:
void newMediaLoaded( const QUuid& uuid );
......
......@@ -51,12 +51,6 @@ Library::media( const QUuid& uuid )
return getElementByUuid( m_medias, uuid );
}
Media*
Library::temporaryMedia( const QUuid& uuid )
{
return getElementByUuid( m_temporaryMedias, uuid );
}
Clip*
Library::clip( const QUuid& uuid )
{
......@@ -110,14 +104,6 @@ Library::deleteMedia( const QUuid& uuid )
SLOT( deleteMedia( const QUuid& ) ) );
delete m_medias.take( uuid );
}
else if ( m_temporaryMedias.contains( uuid ) )
{
disconnect( m_temporaryMedias.value( uuid ),
SIGNAL( audioSpectrumComputed( const QUuid& ) ),
this,
SLOT( deleteMedia( const QUuid& ) ) );
delete m_temporaryMedias.take( uuid );
}
else if ( m_mediaToDelete.contains( uuid ) )
{
delete m_mediaToDelete.value( uuid );
......@@ -131,31 +117,23 @@ Library::deleteMedia( const QUuid& uuid )
this,
SLOT( deleteMedia( const QUuid& ) ) );
}
else if ( m_temporaryMedias.contains( uuid ) )
{
Media* media = m_temporaryMedias.take( uuid );
m_mediaToDelete.insert( uuid, media );
connect( media,
SIGNAL( audioSpectrumComputed( const QUuid& ) ),
this,
SLOT( deleteMedia( const QUuid& ) ) );
}
}
void
Library::addMedia( const QFileInfo& fileInfo, const QString& uuidStr, bool emitSignal )
Library::addMedia( const QFileInfo& fileInfo, const QString& uuid )
{
Media* media = new Media( fileInfo.filePath(), uuidStr );
Media* media = new Media( fileInfo.filePath(), uuid );
m_nbLoadedMedias++;
QUuid id;
foreach( id, m_medias.keys() )
if ( m_medias.value( id )->getFileInfo()->filePath() ==
foreach( Media* it, m_medias.values() )
{
if ( it->getFileInfo()->filePath() ==
media->getFileInfo()->filePath() )
{
delete media;
return;
}
}
connect( media,
SIGNAL( metaDataComputed( Media* ) ),
......@@ -168,13 +146,7 @@ Library::addMedia( const QFileInfo& fileInfo, const QString& uuidStr, bool emitS
MetaDataManager::getInstance()->computeMediaMetadata( media );
m_temporaryMedias[media->getUuid()] = media;
if ( emitSignal )
{
emit progressDialogValue( m_nbLoadedMedias );
emit newMediaLoaded( media->getUuid() );
}
m_medias[media->getUuid()] = media;
}
void
......@@ -233,38 +205,11 @@ Library::snapshotComputed( Media *media )
emit updateMediaRequested( media->getUuid() );
}
bool
Library::mediaAlreadyLoaded( const QString& filePath )
{
QUuid id;
foreach( id, m_temporaryMedias.keys() )
{
Media* media = m_temporaryMedias.value( id );
if ( media->getFileInfo()->filePath() == filePath )
return true;
}
foreach( id, m_medias.keys() )
{
Media* media = m_medias.value( id );
if ( media->getFileInfo()->filePath() == filePath )
return true;
}
return false;
}
bool
Library::mediaAlreadyLoaded( const QFileInfo& fileInfo )
{
QUuid id;
foreach( id, m_temporaryMedias.keys() )
foreach( Media* media, m_medias.values() )
{
Media* media = m_temporaryMedias.value( id );
if ( media->getFileInfo()->filePath() == fileInfo.filePath() )
return true;
}
foreach( id, m_medias.keys() )
{
Media* media = m_medias.value( id );
if ( media->getFileInfo()->filePath() == fileInfo.filePath() )
return true;
}
......@@ -365,9 +310,7 @@ Library::loadProject( const QDomElement& medias )
}
else
{
addMedia( path, uuid, false );
//FIXME : this is ugly
importDone();
addMedia( path, uuid );
}
if ( clipList.size() != 0 )
{
......@@ -457,27 +400,6 @@ Library::clear()
m_medias.clear();
}
void
Library::deleteTemporaryMedias()
{
QUuid uuid;
foreach( uuid, m_temporaryMedias.keys() )
deleteMedia( uuid );
}
void
Library::importDone()
{
QUuid id;
foreach( id, m_temporaryMedias.keys() )
{
Media* media = m_temporaryMedias.value( id );
m_medias.insert( media->getUuid(), media );
emit newMediaImported( media->getUuid() );
}
m_temporaryMedias.clear();
}
void
Library::removeClip( const QUuid& mediaId, const QUuid& clipId )
{
......
......@@ -63,13 +63,6 @@ public:
* \sa clip( const QUuid& uuid )
*/
Media* media( const QUuid& uuid );
/**
* \brief returns the temporary media that match the unique identifier
* \param uuid the unique identifier of the temporary media
* \return a pointer to the required temporary media, or NULL if no medias matches
* \sa temporaryMedia( const QUuid& uuid )
*/
Media* temporaryMedia( const QUuid& uuid );
/**
* \brief returns the clip that match the unique identifier
* \param uuid the unique identifier of the media
......@@ -91,12 +84,6 @@ public:
* \sa temporaryMedias( const QUuid& uuid )
*/
QHash<QUuid, Media*>* medias() { return &m_medias; }
/**
* \brief returns the temporary medias qHash
* \return a pointer to the temporary medias qHash, or NULL if no there is no medias
* \sa medias( const QUuid& uuid )
*/
QHash<QUuid, Media*>* temporaryMedias() { return &m_temporaryMedias; }
/**
* \brief Add the media with already computed metadatas to the library
* \param fileInfo the file info of the media
......@@ -104,7 +91,7 @@ public:
* \sa media( const QUuid& uuid)
* \sa clip( const QUuid& uuid )
*/
void addMedia( const QFileInfo& fileInfo, const QString& uuidStr = QString(), bool emitSignal = true );
void addMedia( const QFileInfo& fileInfo, const QString& uuid = QString() );
/**
* \brief Add the clip to the library
......@@ -119,16 +106,6 @@ public:
* \param fileInfo the path of the media(s)
*/
void loadFile( const QFileInfo& fileInfo, int loadingMedias = 1 );
/**
* \brief
* \param
*/
void deleteTemporaryMedias();
/**
* \brief
* \param
*/
void importDone();
/**
* \brief
* \param
......@@ -140,12 +117,6 @@ private:
* \brief Library Object Constructor
*/
Library();
/**
* \brief Tells the media has already been loaded into library or not
* \param filePath The path of the media file
* \return true if the media is already loaded, false otherwhise
*/
bool mediaAlreadyLoaded( const QString& filePath );
/**
* \brief Tells the media has already been loaded into library or not
* \param fileInfo The files info of the media file
......@@ -165,10 +136,6 @@ private:
* \brief The List of medias loaded into the library
*/
QHash<QUuid, Media*> m_medias;
/**
* \brief The List of temporary medias loaded into the library
*/
QHash<QUuid, Media*> m_temporaryMedias;
/**
* \brief The list of media being queued for deletion
*/
......
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