Qmmp
fileloader_p.h
1 /***************************************************************************
2  * Copyright (C) 2006-2017 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef FILELOADER_H
21 #define FILELOADER_H
22 
23 #include <QObject>
24 #include <QQueue>
25 #include <QStringList>
26 #include <QFileInfo>
27 #include <QMutex>
28 #include <QThread>
29 
30 class PlayListTrack;
31 class PlayListItem;
32 class QmmpUiSettings;
33 
43 class FileLoader : public QThread
44 {
45  Q_OBJECT
46 public:
51  FileLoader(QObject *parent = 0);
55  ~FileLoader();
59  void add(const QString &path);
63  void add(const QStringList &paths);
64  void addPlayList(const QString &fmt, const QByteArray &data);
65 
66  void insert(PlayListItem *before, const QString &path);
67  void insert(PlayListItem *before, const QStringList &paths);
68 
69 
70 public slots:
74  void finish();
75 
76 signals:
81  void newTracksToInsert(PlayListItem *before, QList<PlayListTrack *> tracks);
82 
83 private:
84  void run();
85  QList<PlayListTrack*> processFile(const QString &path, QStringList *ignoredPaths = 0);
86  void insertPlayList(const QString &fmt, const QByteArray &contents, PlayListItem *before);
87  void insertPlayList(const QString &path, PlayListItem *before);
88  void addDirectory(const QString &s, PlayListItem *before = 0);
89  bool checkRestrictFilters(const QFileInfo &info);
90  bool checkExcludeFilters(const QFileInfo &info);
91  void removeIgnoredTracks(QList<PlayListTrack *> *tracks, const QStringList &ignoredPaths);
92  struct LoaderTask
93  {
94  QString path;
95  PlayListItem *before;
96  QString playListFormat;
97  QByteArray playListContent;
98  };
99  QQueue <LoaderTask> m_tasks;
100  QStringList m_filters;
101  QmmpUiSettings *m_settings;
102  bool m_finished;
103  bool m_use_meta;
104  QMutex m_mutex;
105 
106 };
107 
108 #endif
The PlayListItem class provides an item for use with the PlayListModel class.
Definition: playlistitem.h:31
The QmmpUiSettings class provides access to global libqmmpui library settings.
Definition: qmmpuisettings.h:35
The PlayListTrack class provides a track for use with the PlayListModel class.
Definition: playlisttrack.h:36