Qmmp
metadatamanager.h
1 /***************************************************************************
2  * Copyright (C) 2009-2022 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 
21 #ifndef METADATAMANAGER_H
22 #define METADATAMANAGER_H
23 
24 #include <QList>
25 #include <QStringList>
26 #include <QPixmap>
27 #include <QDir>
28 #include <QMutex>
29 #include <QRegularExpression>
30 #include "trackinfo.h"
31 #include "metadatamodel.h"
32 
33 class DecoderFactory;
34 class EngineFactory;
35 class InputSourceFactory;
36 class QmmpSettings;
37 
38 
42 class QMMP_EXPORT MetaDataManager
43 {
44 public:
53  QList<TrackInfo *> createPlayList(const QString &path, TrackInfo::Parts parts = TrackInfo::AllParts, QStringList *ignoredPaths = nullptr) const;
60  MetaDataModel* createMetaDataModel(const QString &url, bool readOnly) const;
64  QStringList filters() const;
68  QStringList nameFilters() const;
72  QStringList protocols() const;
76  QList<QRegularExpression> regExps() const;
80  bool supports(const QString &file) const;
86  QPixmap getCover(const QString &url) const;
93  QString getCoverPath(const QString &url) const;
101  QString findCoverFile(const QString &fileName) const;
113  static bool hasMatch(const QList<QRegularExpression> &regExps, const QString &path);
118 
119 private:
120  MetaDataManager();
121  ~MetaDataManager();
122  static void destroy();
123 
124  struct CoverCacheItem
125  {
126  QString url;
127  QString coverPath;
128  QPixmap coverPixmap;
129  };
130 
131  QFileInfoList findCoverFiles(QDir dir, int depth) const;
132  CoverCacheItem *createCoverCacheItem(const QString &url) const;
133  mutable QList <CoverCacheItem *> m_cover_cache;
134  QmmpSettings *m_settings;
135  mutable QMutex m_mutex;
136 
137  static MetaDataManager* m_instance;
138 };
139 
140 #endif // METADATAMANAGER_H
Input plugin interface (decoder factory).
Definition: decoderfactory.h:54
Engine plugin interface.
Definition: enginefactory.h:55
Transport plugin interface.
Definition: inputsourcefactory.h:50
The MetaDataManager class is the base class for metadata access.
Definition: metadatamanager.h:43
static MetaDataManager * instance()
QString getCoverPath(const QString &url) const
void prepareForAnotherThread()
void clearCoverCache()
QList< TrackInfo * > createPlayList(const QString &path, TrackInfo::Parts parts=TrackInfo::AllParts, QStringList *ignoredPaths=nullptr) const
bool supports(const QString &file) const
QStringList filters() const
static bool hasMatch(const QList< QRegularExpression > &regExps, const QString &path)
QStringList protocols() const
QString findCoverFile(const QString &fileName) const
QStringList nameFilters() const
MetaDataModel * createMetaDataModel(const QString &url, bool readOnly) const
QList< QRegularExpression > regExps() const
QPixmap getCover(const QString &url) const
The MetaDataModel is the base interface class of metadata access.
Definition: metadatamodel.h:81
The QmmpSettings class provides access to global settings.
Definition: qmmpsettings.h:36
@ AllParts
Definition: trackinfo.h:58