Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2006-2015 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 #ifndef FILELOADER_H 00021 #define FILELOADER_H 00022 00023 #include <QObject> 00024 #include <QQueue> 00025 #include <QStringList> 00026 #include <QFileInfo> 00027 #include <QMutex> 00028 #include <QThread> 00029 00030 class PlayListTrack; 00031 class PlayListItem; 00032 class QmmpUiSettings; 00033 00043 class FileLoader : public QThread 00044 { 00045 Q_OBJECT 00046 public: 00051 FileLoader(QObject *parent = 0); 00055 ~FileLoader(); 00059 void add(const QString &path); 00063 void add(const QStringList &paths); 00064 00065 void insert(PlayListItem *before, const QString &path); 00066 void insert(PlayListItem *before, const QStringList &paths); 00067 00068 public slots: 00072 void finish(); 00073 00074 signals: 00079 void newTracksToInsert(PlayListItem *before, QList<PlayListTrack *> tracks); 00080 00081 private: 00082 void run(); 00083 QList<PlayListTrack*> processFile(const QString &path, QStringList *ignoredPaths = 0); 00084 void addDirectory(const QString &s, PlayListItem *before = 0); 00085 bool checkRestrictFilters(const QFileInfo &info); 00086 bool checkExcludeFilters(const QFileInfo &info); 00087 void removeIgnoredTracks(QList<PlayListTrack *> *tracks, const QStringList &ignoredPaths); 00088 struct LoaderTask 00089 { 00090 QString path; 00091 PlayListItem *before; 00092 }; 00093 QQueue <LoaderTask> m_tasks; 00094 QStringList m_filters; 00095 QmmpUiSettings *m_settings; 00096 bool m_finished; 00097 bool m_use_meta; 00098 QMutex m_mutex; 00099 00100 }; 00101 00102 #endif