Commit a80651d1 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Remplacing QDirModel by QFileSystemModel

QDirModel will soon be outdated, QFileSystemModel is faster, uses its
own thread, and check for filesystem changes by itself.
Also: Removing useless attributes from Library
parent 949521fb
......@@ -45,21 +45,18 @@ ImportController::ImportController(QWidget *parent) :
m_stackNav = new StackViewController( m_ui->stackViewContainer, false );
m_mediaListController = new ImportMediaListController( m_stackNav );
m_tag = new TagWidget( m_ui->tagContainer, 6 );
m_filesModel = new QDirModel();
m_filesModel = new QFileSystemModel( this );
m_stackNav->pushViewController( m_mediaListController );
QStringList filters;
filters << "*.mov" << "*.avi" << "*.mkv" << "*.mpg" << "*.mpeg" << "*.wmv" << "*.mp4"
<< "*.ogg" << "*.ogv";
filters << "*.mp3" << "*.oga" << "*.flac" << "*.aac" << "*.wav";
filters << "*.gif" << "*.png" << "*.jpg";
m_filesModel->setFilter( QDir::AllDirs | QDir::Files | QDir::Readable | QDir::Drives |
QDir::NoDotAndDotDot );
filters << Media::AudioExtensions.split(' ', QString::SkipEmptyParts)
<< Media::VideoExtensions.split(' ', QString::SkipEmptyParts)
<< Media::ImageExtensions.split(' ', QString::SkipEmptyParts);
m_filesModel->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot );
m_filesModel->sort( 2, Qt::AscendingOrder );
m_filesModel->sort( 0, Qt::AscendingOrder );
m_filesModel->setNameFilters( filters );
Library::getInstance()->setFilter( filters );
m_filesModel->setRootPath( "/" );
restoreCurrentPath();
......@@ -74,16 +71,11 @@ ImportController::ImportController(QWidget *parent) :
m_ui->treeView->setColumnHidden( 3, true );
m_ui->forwardButton->setEnabled( true );
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 ) ),
this, SLOT( treeViewClicked( QModelIndex ) ) );
connect( m_ui->treeView, SIGNAL( doubleClicked( QModelIndex ) ),
......@@ -292,9 +284,7 @@ ImportController::treeViewClicked( const QModelIndex& index )
{
if ( m_filesModel->isDir( index ) )
{
m_fsWatcher->removePath( m_currentlyWatchedDir );
m_currentlyWatchedDir = m_filesModel->filePath( index );
m_fsWatcher->addPath( m_filesModel->filePath( index ) );
saveCurrentPath();
}
m_ui->forwardButton->setEnabled( true );
......@@ -303,7 +293,8 @@ ImportController::treeViewClicked( const QModelIndex& index )
void
ImportController::treeViewDoubleClicked( const QModelIndex& index )
{
forwardButtonClicked();
if ( m_filesModel->isDir( index ) == false )
forwardButtonClicked();
}
void
......
......@@ -38,7 +38,7 @@
#include "TagWidget.h"
#include <QDialog>
#include <QDirModel>
#include <QFileSystemModel>
#include <QFileSystemWatcher>
#include <QProgressDialog>
......@@ -77,8 +77,7 @@ class ImportController : public QDialog
TagWidget* m_tag;
ImportMediaListController* m_mediaListController;
ImportMediaListController* m_clipListController;
QDirModel* m_filesModel;
QFileSystemWatcher* m_fsWatcher;
QFileSystemModel *m_filesModel;
QString m_currentlyWatchedDir;
QUuid m_currentUuid;
QUuid m_savedUuid;
......
......@@ -42,7 +42,6 @@
Library::Library()
{
m_nbLoadedMedias = 0;
}
Media*
......@@ -104,7 +103,6 @@ void
Library::addMedia( const QFileInfo& fileInfo, const QString& uuid )
{
Media* media = new Media( fileInfo.filePath(), uuid );
m_nbLoadedMedias++;
foreach( Media* it, m_medias.values() )
{
......
......@@ -101,11 +101,6 @@ public:
* \sa clip( const QUuid& uuid )
*/
void addClip( Clip* clip );
/**
* \brief
* \param
*/
void setFilter( const QStringList& filter ) { m_filters = filter; }
/**
* \brief Add an already preparsed media.
*
......@@ -142,18 +137,6 @@ private:
* \param container The type of container used for storage, where T is Clip or Media
* \param uuid The uuid of the element you are looking for
*/
int m_loadingMedias;
/**
* \brief
*/
int m_nbLoadedMedias;
/**
* \brief
*/
QStringList m_filters;
/**
* \brief
*/
template <typename T>
T getElementByUuid( const QHash<QUuid, T>& container ,
const QUuid& 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