Qmmp
Loading...
Searching...
No Matches
fileloader_p.h
1/***************************************************************************
2 * Copyright (C) 2006-2025 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 <QSet>
27#include <QFileInfo>
28#include <QMutex>
29#include <QThread>
30#include <qmmp/trackinfo.h>
31#include "playlisttrack.h"
32
33class PlayListItem;
34class QmmpUiSettings;
35
45class FileLoader : public QThread
46{
47 Q_OBJECT
48public:
53 FileLoader(QObject *parent = nullptr);
57 void add(const QString &path);
61 void add(const QStringList &paths);
62 void addPlayList(const QString &fmt, const QByteArray &data);
63
64 void insert(PlayListTrack *before, const QString &path);
65 void insert(PlayListTrack *before, const QStringList &paths);
66
67
68public slots:
72 void finish();
73
74signals:
79 void newTracksToInsert(PlayListTrack *before, QList<PlayListTrack *> tracks);
80
81private:
82 void run() override;
83 QList<PlayListTrack*> processFile(const QString &path, QStringList *ignoredPaths = nullptr);
84 void insertPlayList(const QString &fmt, const QByteArray &contents, PlayListTrack *before);
85 void insertPlayList(const QString &path, PlayListTrack *before);
86 void addDirectory(const QString &s, PlayListTrack *before = nullptr);
87 bool checkRestrictFilters(const QFileInfo &info);
88 bool checkExcludeFilters(const QFileInfo &info);
89 void removeIgnoredTracks(QList<PlayListTrack *> *tracks, QSet<QString> *ignoredPaths);
90 struct LoaderTask
91 {
92 QString path;
93 PlayListTrack *before;
94 QString playListFormat;
95 QByteArray playListContent;
96 };
97 QQueue <LoaderTask> m_tasks;
98 QStringList m_filters;
99 QmmpUiSettings *m_settings;
100 bool m_finished = false;
101 bool m_readMetaDataForPlayLists = false;
102 TrackInfo::Parts m_parts = TrackInfo::Parts();
103 QMutex m_mutex;
104
105};
106
107#endif
The PlayListItem class provides an item for use with the PlayListModel class.
Definition playlistitem.h:33
The QmmpUiSettings class provides access to global libqmmpui library settings.
Definition qmmpuisettings.h:36