diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-01-12 19:42:12 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2015-01-12 19:42:12 +0000 |
| commit | 261ba82130d9c624a3212ff0a6059bb97a4c2b51 (patch) | |
| tree | c0d5d28dcd326e181b430dd394ab44468694a942 /src | |
| parent | c1f385ae6136ebb0f2d75f5cc83e97610de0fc63 (diff) | |
| download | qmmp-261ba82130d9c624a3212ff0a6059bb97a4c2b51.tar.gz qmmp-261ba82130d9c624a3212ff0a6059bb97a4c2b51.tar.bz2 qmmp-261ba82130d9c624a3212ff0a6059bb97a4c2b51.zip | |
refactoring
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@4690 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmmpui/fileloader.cpp | 36 | ||||
| -rw-r--r-- | src/qmmpui/fileloader_p.h | 10 |
2 files changed, 21 insertions, 25 deletions
diff --git a/src/qmmpui/fileloader.cpp b/src/qmmpui/fileloader.cpp index 1b94c35e7..1199cb4cf 100644 --- a/src/qmmpui/fileloader.cpp +++ b/src/qmmpui/fileloader.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2013 by Ilya Kotov * + * Copyright (C) 2006-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -79,18 +79,11 @@ void FileLoader::addDirectory(const QString& s, PlayListItem *before) void FileLoader::run() { m_finished = false; - while((!m_paths.isEmpty() || !m_insertItems.isEmpty()) && !m_finished) + while(!m_tasks.isEmpty() && !m_finished) { - PlayListItem *before = 0; - QString path; - if(!m_insertItems.isEmpty()) - { - InsertItem i = m_insertItems.dequeue(); - before = i.before; - path = i.path; - } - else if(!m_paths.isEmpty()) - path = m_paths.dequeue(); + LoaderTask i = m_tasks.dequeue(); + PlayListItem *before = i.before; + QString path = i.path; QFileInfo info(path); @@ -114,7 +107,13 @@ void FileLoader::add(const QString &path) void FileLoader::add(const QStringList &paths) { - m_paths << paths; + foreach (QString path, paths) + { + LoaderTask task; + task.before = 0; + task.path = path; + m_tasks.append(task); + } MetaDataManager::instance()->prepareForAnotherThread(); m_filters = MetaDataManager::instance()->nameFilters(); start(QThread::IdlePriority); @@ -129,12 +128,11 @@ void FileLoader::insert(PlayListItem *before, const QStringList &paths) { foreach (QString path, paths) { - InsertItem item; - item.before = before; - item.path = path; - m_insertItems.append(item); + LoaderTask task; + task.before = before; + task.path = path; + m_tasks.append(task); } - MetaDataManager::instance()->prepareForAnotherThread(); m_filters = MetaDataManager::instance()->nameFilters(); start(QThread::IdlePriority); @@ -144,7 +142,7 @@ void FileLoader::finish() { m_finished = true; wait(); - m_paths.clear(); + m_tasks.clear(); } bool FileLoader::checkRestrictFilters(const QFileInfo &info) diff --git a/src/qmmpui/fileloader_p.h b/src/qmmpui/fileloader_p.h index 66ce40ef0..11bc1a0bd 100644 --- a/src/qmmpui/fileloader_p.h +++ b/src/qmmpui/fileloader_p.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006-2012 by Ilya Kotov * + * Copyright (C) 2006-2015 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -82,14 +82,12 @@ private: void addDirectory(const QString &s, PlayListItem *before = 0); bool checkRestrictFilters(const QFileInfo &info); bool checkExcludeFilters(const QFileInfo &info); - struct InsertItem + struct LoaderTask { - PlayListItem *before; QString path; - + PlayListItem *before; }; - QQueue <QString> m_paths; - QQueue <InsertItem> m_insertItems; + QQueue <LoaderTask> m_tasks; QStringList m_filters; QmmpUiSettings *m_settings; bool m_finished; |
