2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-05-22 22:06:19 +02:00
|
|
|
#ifndef PLAYLISTPARSER_H
|
|
|
|
#define PLAYLISTPARSER_H
|
2010-03-09 18:17:32 +01:00
|
|
|
|
2011-01-15 14:59:34 +01:00
|
|
|
#include <QDir>
|
2010-03-09 18:17:32 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
2010-05-22 22:06:19 +02:00
|
|
|
#include "core/song.h"
|
2014-10-07 00:23:28 +02:00
|
|
|
#include "playlist/playlist.h"
|
2010-05-22 22:06:19 +02:00
|
|
|
|
|
|
|
class ParserBase;
|
2010-12-11 11:35:07 +01:00
|
|
|
class LibraryBackendInterface;
|
2010-03-09 18:17:32 +01:00
|
|
|
|
2010-05-22 22:06:19 +02:00
|
|
|
class PlaylistParser : public QObject {
|
2010-03-09 18:17:32 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
PlaylistParser(LibraryBackendInterface* library, QObject* parent = nullptr);
|
2010-05-22 22:06:19 +02:00
|
|
|
|
2010-06-15 15:24:17 +02:00
|
|
|
static const int kMagicSize;
|
|
|
|
|
2010-05-22 22:06:19 +02:00
|
|
|
QStringList file_extensions() const;
|
2010-05-23 00:29:52 +02:00
|
|
|
QString filters() const;
|
2010-05-22 22:28:11 +02:00
|
|
|
|
2017-03-17 03:23:32 +01:00
|
|
|
QStringList mime_types() const;
|
|
|
|
|
2010-07-31 15:10:08 +02:00
|
|
|
QString default_extension() const;
|
|
|
|
QString default_filter() const;
|
|
|
|
|
2011-02-27 13:14:32 +01:00
|
|
|
ParserBase* ParserForMagic(const QByteArray& data,
|
|
|
|
const QString& mime_type = QString()) const;
|
2010-07-24 16:09:27 +02:00
|
|
|
ParserBase* ParserForExtension(const QString& suffix) const;
|
2017-03-17 03:23:32 +01:00
|
|
|
ParserBase* ParserForMimeType(const QString& mime) const;
|
2010-05-22 22:06:19 +02:00
|
|
|
|
2011-02-27 13:14:32 +01:00
|
|
|
SongList LoadFromFile(const QString& filename) const;
|
2014-02-07 16:34:20 +01:00
|
|
|
SongList LoadFromDevice(QIODevice* device,
|
|
|
|
const QString& path_hint = QString(),
|
2011-02-27 13:14:32 +01:00
|
|
|
const QDir& dir_hint = QDir()) const;
|
2014-10-15 21:57:57 +02:00
|
|
|
void Save(const SongList& songs, const QString& filename,
|
|
|
|
Playlist::Path) const;
|
2010-03-09 18:17:32 +01:00
|
|
|
|
2021-06-11 06:17:12 +02:00
|
|
|
signals:
|
|
|
|
void Error(const QString& msg) const;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2021-06-11 06:23:57 +02:00
|
|
|
void AddParser(ParserBase* parser);
|
|
|
|
|
2010-07-31 15:10:08 +02:00
|
|
|
QString FilterForParser(const ParserBase* parser,
|
2014-02-21 17:24:49 +01:00
|
|
|
QStringList* all_extensions = nullptr) const;
|
2010-07-31 15:10:08 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-05-22 22:06:19 +02:00
|
|
|
QList<ParserBase*> parsers_;
|
2010-07-31 15:10:08 +02:00
|
|
|
ParserBase* default_parser_;
|
2010-03-09 18:17:32 +01:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // PLAYLISTPARSER_H
|