Commit b3a50081 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Fix minor bugs

parent 5bd86267
...@@ -105,11 +105,6 @@ ImportController::ImportController(QWidget *parent) : ...@@ -105,11 +105,6 @@ ImportController::ImportController(QWidget *parent) :
m_mediaListController, SLOT( clipAdded( Clip* ) ) ); //StackViewController m_mediaListController, SLOT( clipAdded( Clip* ) ) ); //StackViewController
connect( m_stackNav, SIGNAL( previousButtonPushed() ), connect( m_stackNav, SIGNAL( previousButtonPushed() ),
this, SLOT( restoreContext() ) ); this, SLOT( restoreContext() ) );
connect( Library::getInstance(), SIGNAL( progressDialogMax( int ) ),
this, SLOT( progressDialogMax( int ) ) );
connect( Library::getInstance(), SIGNAL( progressDialogValue( int ) ),
this, SLOT( progressDialogValue( int ) ) );
} }
ImportController::~ImportController() ImportController::~ImportController()
...@@ -239,6 +234,13 @@ ImportController::forwardButtonClicked() ...@@ -239,6 +234,13 @@ ImportController::forwardButtonClicked()
{ {
QModelIndex index = m_ui->treeView->selectionModel()->currentIndex(); QModelIndex index = m_ui->treeView->selectionModel()->currentIndex();
QString filePath = m_filesModel->fileInfo( index ).filePath(); QString filePath = m_filesModel->fileInfo( index ).filePath();
foreach ( Media* media, m_temporaryMedias.values() )
if ( media->getFileInfo()->filePath() == filePath )
return ;
if ( Library::getInstance()->mediaAlreadyLoaded( filePath ) == true )
return ;
Media* media = new Media( filePath ); Media* media = new Media( filePath );
connect( media, SIGNAL( metaDataComputed( Media* ) ), connect( media, SIGNAL( metaDataComputed( Media* ) ),
this, SLOT( updateMediaRequested( Media* ) ) ); this, SLOT( updateMediaRequested( Media* ) ) );
...@@ -287,6 +289,7 @@ ImportController::accept() ...@@ -287,6 +289,7 @@ ImportController::accept()
collapseAllButCurrentPath(); collapseAllButCurrentPath();
foreach ( Media* media, m_temporaryMedias.values() ) foreach ( Media* media, m_temporaryMedias.values() )
Library::getInstance()->addMedia( media ); Library::getInstance()->addMedia( media );
m_temporaryMedias.clear();
done( Accepted ); done( Accepted );
} }
...@@ -316,8 +319,9 @@ ImportController::collapseAllButCurrentPath() ...@@ -316,8 +319,9 @@ ImportController::collapseAllButCurrentPath()
void void
ImportController::mediaDeletion( const QUuid& uuid ) ImportController::mediaDeletion( const QUuid& uuid )
{ {
Library::getInstance()->deleteMedia( uuid );
m_mediaListController->removeMedia( uuid ); m_mediaListController->removeMedia( uuid );
if ( m_temporaryMedias.contains( uuid ) == true )
delete m_temporaryMedias.take( uuid );
if ( uuid == m_currentUuid ) if ( uuid == m_currentUuid )
{ {
......
...@@ -108,8 +108,7 @@ Library::addMedia( const QFileInfo& fileInfo, const QString& uuid ) ...@@ -108,8 +108,7 @@ Library::addMedia( const QFileInfo& fileInfo, const QString& uuid )
foreach( Media* it, m_medias.values() ) foreach( Media* it, m_medias.values() )
{ {
if ( it->getFileInfo()->filePath() == if ( it->getFileInfo()->filePath() == media->getFileInfo()->filePath() )
media->getFileInfo()->filePath() )
{ {
delete media; delete media;
return; return;
......
...@@ -113,17 +113,18 @@ public: ...@@ -113,17 +113,18 @@ public:
*/ */
void addMedia( Media *media ); void addMedia( Media *media );
/**
* \brief Check if a file has already been loaded into library.
* \param fileInfo The file infos
* \return true if the file is already loaded, false otherwhise
*/
bool mediaAlreadyLoaded( const QFileInfo& fileInfo );
private: private:
/** /**
* \brief Library Object Constructor * \brief Library Object Constructor
*/ */
Library(); Library();
/**
* \brief Tells the media has already been loaded into library or not
* \param fileInfo The files info of the media file
* \return true if the media is already loaded, false otherwhise
*/
bool mediaAlreadyLoaded( const QFileInfo& fileInfo );
/** /**
* \brief This method is used to load a media directly from it's * \brief This method is used to load a media directly from it's
* path, with a specified UUID. * path, with a specified UUID.
......
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