Qmmp
fileloader_p.h
1 /***************************************************************************
2  * Copyright (C) 2006-2020 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 #include <qmmp/trackinfo.h>
30 
31 class PlayListTrack;
32 class PlayListItem;
33 class QmmpUiSettings;
34 
44 class FileLoader : public QThread
45 {
46  Q_OBJECT
47 public:
52  FileLoader(QObject *parent = nullptr);
56  ~FileLoader();
60  void add(const QString &path);
64  void add(const QStringList &paths);
65  void addPlayList(const QString &fmt, const QByteArray &data);
66 
67  void insert(PlayListItem *before, const QString &path);
68  void insert(PlayListItem *before, const QStringList &paths);
69 
70 
71 public slots:
75  void finish();
76 
77 signals:
82  void newTracksToInsert(PlayListItem *before, QList<PlayListTrack *> tracks);
83 
84 private:
85  void run() override;
86  QList<PlayListTrack*> processFile(const QString &path, QStringList *ignoredPaths = nullptr);
87  void insertPlayList(const QString &fmt, const QByteArray &contents, PlayListItem *before);
88  void insertPlayList(const QString &path, PlayListItem *before);
89  void addDirectory(const QString &s, PlayListItem *before = nullptr);
90  bool checkRestrictFilters(const QFileInfo &info);
91  bool checkExcludeFilters(const QFileInfo &info);
92  void removeIgnoredTracks(QList<PlayListTrack *> *tracks, const QStringList &ignoredPaths);
93  struct LoaderTask
94  {
95  QString path;
96  PlayListItem *before;
97  QString playListFormat;
98  QByteArray playListContent;
99  };
100  QQueue <LoaderTask> m_tasks;
101  QStringList m_filters;
102  QmmpUiSettings *m_settings;
103  bool m_finished;
104  bool m_readMetaDataForPlayLists;
105  TrackInfo::Parts m_parts;
106  QMutex m_mutex;
107 
108 };
109 
110 #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:36
The PlayListTrack class provides a track for use with the PlayListModel class.
Definition: playlisttrack.h:36