Commit 55f67f80 authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

Move the progress dialog from the library to the import controller

parent fd32f0c2
......@@ -73,6 +73,11 @@ ImportController::ImportController(QWidget *parent) :
m_fsWatcher = new QFileSystemWatcher();
m_fsWatcher->addPath( m_currentlyWatchedDir );
m_progressDialog = new QProgressDialog( tr("Importing files..."),
tr("Cancel"), 0, 0, NULL);
m_progressDialog->setWindowModality( Qt::WindowModal );
m_progressDialog->setMinimumDuration( 1000 );
connect( m_fsWatcher, SIGNAL( directoryChanged( QString ) ),
m_filesModel, SLOT( refresh() ) );
connect( m_ui->treeView, SIGNAL( clicked( QModelIndex ) ),
......@@ -103,6 +108,11 @@ ImportController::ImportController(QWidget *parent) :
m_mediaListController, SLOT( clipAdded( Clip* ) ) ); //StackViewController
connect( m_stackNav, SIGNAL( previousButtonPushed() ),
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()
......@@ -378,3 +388,15 @@ ImportController::restoreCurrentPath()
QFileInfo info = path.toString();
m_currentlyWatchedDir = info.absoluteFilePath();
}
void
ImportController::progressDialogMax( int max )
{
m_progressDialog->setMaximum( max );
}
void
ImportController::progressDialogValue( int value )
{
m_progressDialog->setValue( value );
}
......@@ -40,6 +40,7 @@
#include <QDialog>
#include <QDirModel>
#include <QFileSystemWatcher>
#include <QProgressDialog>
namespace Ui
{
......@@ -79,6 +80,7 @@ class ImportController : public QDialog
QUuid m_currentUuid;
QUuid m_savedUuid;
bool m_controllerSwitched;
QProgressDialog* m_progressDialog;
public slots:
void newMediaLoaded( const QUuid& uuid );
......@@ -91,6 +93,8 @@ class ImportController : public QDialog
void clipDeletion( const QUuid& uuid );
void showClipList( const QUuid& uuid );
void restoreContext();
void progressDialogMax( int max );
void progressDialogValue( int value );
private slots:
void forwardButtonClicked();
......
......@@ -42,10 +42,6 @@
Library::Library()
{
m_progressDialog = new QProgressDialog( tr("Importing files..."),
tr("Cancel"), 0, m_loadingMedias, NULL);
m_progressDialog->setWindowModality( Qt::WindowModal );
m_progressDialog->setMinimumDuration( 1000 );
m_nbLoadedMedias = 0;
}
......@@ -174,7 +170,7 @@ Library::addMedia( const QFileInfo& fileInfo )
m_temporaryMedias[media->getUuid()] = media;
m_progressDialog->setValue(m_nbLoadedMedias);
emit progressDialogValue( m_nbLoadedMedias );
emit newMediaLoaded( media->getUuid() );
}
......@@ -278,8 +274,8 @@ Library::loadFile( const QFileInfo& fileInfo, int loadingMedias )
{
if ( loadingMedias == 1 )
{
m_progressDialog->setMaximum( 1 );
m_progressDialog->setValue( 0 );
emit progressDialogMax( 1 );
emit progressDialogValue( 0 );
m_loadingMedias = 1;
m_nbLoadedMedias = 0;
}
......@@ -288,8 +284,8 @@ Library::loadFile( const QFileInfo& fileInfo, int loadingMedias )
addMedia( fileInfo );
else
{
m_progressDialog->setMaximum( m_loadingMedias-- );
m_progressDialog->setValue( ++m_nbLoadedMedias );
emit progressDialogMax( m_loadingMedias-- );
emit progressDialogValue( ++m_nbLoadedMedias );
}
}
else
......@@ -300,8 +296,8 @@ Library::loadFile( const QFileInfo& fileInfo, int loadingMedias )
m_loadingMedias = list.count();
m_nbLoadedMedias = 0;
m_progressDialog->setMaximum( m_loadingMedias );
m_progressDialog->setValue( 0 );
emit progressDialogMax( m_loadingMedias );
emit progressDialogValue( 0 );
foreach( file, list )
loadFile( file, m_loadingMedias );
}
......
......@@ -187,10 +187,6 @@ private:
* \brief
*/
QStringList m_filters;
/**
* \brief The progress bar dialog
*/
QProgressDialog* m_progressDialog;
/**
* \brief
*/
......@@ -269,6 +265,14 @@ signals:
* \brief
*/
void updateMediaRequested( const QUuid& uuid );
/**
* \brief
*/
void progressDialogMax( int max );
/**
* \brief
*/
void progressDialogValue( int value );
/**
* \brief
*/
......
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