From f91f63b99f25d8a01dc1d211e31cc4f39c0476bf Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 17 Jan 2015 17:52:35 +0000 Subject: added feature to exclude cue data files git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4693 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/fileloader.cpp | 33 +++++++++++++++++++++++++++++---- src/qmmpui/fileloader_p.h | 3 ++- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'src/qmmpui') diff --git a/src/qmmpui/fileloader.cpp b/src/qmmpui/fileloader.cpp index 2bd61483c..3bb505108 100644 --- a/src/qmmpui/fileloader.cpp +++ b/src/qmmpui/fileloader.cpp @@ -37,10 +37,10 @@ FileLoader::FileLoader(QObject *parent) : QThread(parent) FileLoader::~FileLoader() {} -QList FileLoader::processFile(const QString &path) +QList FileLoader::processFile(const QString &path, QStringList *ignoredPaths) { QList tracks; - QList infoList = MetaDataManager::instance()->createPlayList(path, m_use_meta); + QList infoList = MetaDataManager::instance()->createPlayList(path, m_use_meta, ignoredPaths); foreach (FileInfo *info, infoList) { @@ -53,14 +53,20 @@ QList FileLoader::processFile(const QString &path) void FileLoader::addDirectory(const QString& s, PlayListItem *before) { QList tracks; + QStringList ignoredPaths; QDir dir(s); dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setSorting(QDir::Name); QFileInfoList l = dir.entryInfoList(m_filters); + foreach(QFileInfo info, l) { if(checkRestrictFilters(info) && checkExcludeFilters(info)) - tracks.append(processFile(info.absoluteFilePath ())); + { + QStringList paths; + tracks.append(processFile(info.absoluteFilePath (), &ignoredPaths)); + ignoredPaths.append(paths); + } if (m_finished) { @@ -69,16 +75,20 @@ void FileLoader::addDirectory(const QString& s, PlayListItem *before) return; } - if(tracks.count() > 20) //do not send more than 20 tracks at once + if(tracks.count() > 30) //do not send more than 30 tracks at once { + removeIgnoredTracks(&tracks, ignoredPaths); emit newTracksToInsert(before, tracks); tracks.clear(); + ignoredPaths.clear(); } } if(!tracks.isEmpty()) { + removeIgnoredTracks(&tracks, ignoredPaths); emit newTracksToInsert(before, tracks); + ignoredPaths.clear(); } dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); @@ -210,3 +220,18 @@ bool FileLoader::checkExcludeFilters(const QFileInfo &info) } return true; } + +void FileLoader::removeIgnoredTracks(QList *tracks, const QStringList &ignoredPaths) +{ + if(ignoredPaths.isEmpty()) + return; + + foreach(PlayListTrack *track, *tracks) + { + if(ignoredPaths.contains(track->url())) + { + tracks->removeAll(track); + delete track; + } + } +} diff --git a/src/qmmpui/fileloader_p.h b/src/qmmpui/fileloader_p.h index d38163e03..b2cf2c006 100644 --- a/src/qmmpui/fileloader_p.h +++ b/src/qmmpui/fileloader_p.h @@ -78,10 +78,11 @@ signals: private: void run(); - QList processFile(const QString &path); + QList processFile(const QString &path, QStringList *ignoredPaths = 0); void addDirectory(const QString &s, PlayListItem *before = 0); bool checkRestrictFilters(const QFileInfo &info); bool checkExcludeFilters(const QFileInfo &info); + void removeIgnoredTracks(QList *tracks, const QStringList &ignoredPaths); struct LoaderTask { QString path; -- cgit v1.2.3-13-gbd6f