Qmmp
metadatamanager.h
1 /***************************************************************************
2  * Copyright (C) 2009-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 
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;
105  void clearCoverCache();
109  void prepareForAnotherThread();
113  static bool hasMatch(const QList<QRegularExpression> &regExps, const QString &path);
117  static bool hasMatch(const QList<QRegExp> &regExps, const QString &path);
121  static MetaDataManager* instance();
122 
123 private:
124  MetaDataManager();
125  ~MetaDataManager();
126  static void destroy();
127 
128  struct CoverCacheItem
129  {
130  QString url;
131  QString coverPath;
132  QPixmap coverPixmap;
133  };
134 
135  QFileInfoList findCoverFiles(QDir dir, int depth) const;
136  CoverCacheItem *createCoverCacheItem(const QString &url) const;
137  mutable QList <CoverCacheItem *> m_cover_cache;
138  QmmpSettings *m_settings;
139  mutable QMutex m_mutex;
140 
141  static MetaDataManager* m_instance;
142 };
143 
144 #endif // METADATAMANAGER_H
Transport plugin interface.
Definition: inputsourcefactory.h:49
The QmmpSettings class provides access to global settings.
Definition: qmmpsettings.h:35
The MetaDataModel is the base interface class of metadata access.
Definition: metadatamodel.h:80
The MetaDataManager class is the base class for metadata access.
Definition: metadatamanager.h:42
Input plugin interface (decoder factory).
Definition: decoderfactory.h:53
Definition: trackinfo.h:58
Engine plugin interface.
Definition: enginefactory.h:54