@@ -26,6 +26,7 @@
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "parserbase.h"
|
||||
#include "asxiniparser.h"
|
||||
@@ -38,8 +39,8 @@ constexpr auto qt_endl = Qt::endl;
|
||||
constexpr auto qt_endl = endl;
|
||||
#endif
|
||||
|
||||
AsxIniParser::AsxIniParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: ParserBase(collection, parent) {}
|
||||
AsxIniParser::AsxIniParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: ParserBase(collection_backend, parent) {}
|
||||
|
||||
bool AsxIniParser::TryMagic(const QByteArray &data) const {
|
||||
return data.toLower().contains("[reference]");
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "parserbase.h"
|
||||
@@ -40,7 +41,7 @@ class AsxIniParser : public ParserBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AsxIniParser(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit AsxIniParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "ASX/INI"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "asxini"; }
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "utilities/xmlutils.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "xmlparser.h"
|
||||
@@ -36,8 +37,8 @@
|
||||
|
||||
class CollectionBackendInterface;
|
||||
|
||||
ASXParser::ASXParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: XMLParser(collection, parent) {}
|
||||
ASXParser::ASXParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: XMLParser(collection_backend, parent) {}
|
||||
|
||||
SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_search) const {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "xmlparser.h"
|
||||
@@ -42,7 +43,7 @@ class ASXParser : public XMLParser {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ASXParser(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit ASXParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "ASX"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "asx"; }
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
# include <QStringConverter>
|
||||
#endif
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
@@ -59,8 +60,8 @@ const char *CueParser::kGenre = "genre";
|
||||
const char *CueParser::kDate = "date";
|
||||
const char *CueParser::kDisc = "discnumber";
|
||||
|
||||
CueParser::CueParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: ParserBase(collection, parent) {}
|
||||
CueParser::CueParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: ParserBase(collection_backend, parent) {}
|
||||
|
||||
SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_search) const {
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "parserbase.h"
|
||||
@@ -60,7 +61,7 @@ class CueParser : public ParserBase {
|
||||
static const char *kDate;
|
||||
static const char *kDisc;
|
||||
|
||||
explicit CueParser(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit CueParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "CUE"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "cue"; }
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QStringList>
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
@@ -35,8 +36,8 @@
|
||||
|
||||
class CollectionBackendInterface;
|
||||
|
||||
M3UParser::M3UParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: ParserBase(collection, parent) {}
|
||||
M3UParser::M3UParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: ParserBase(collection_backend, parent) {}
|
||||
|
||||
SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_search) const {
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "parserbase.h"
|
||||
@@ -41,7 +42,7 @@ class M3UParser : public ParserBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit M3UParser(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit M3UParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "M3U"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "m3u" << "m3u8"; }
|
||||
|
||||
@@ -27,14 +27,15 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "parserbase.h"
|
||||
|
||||
ParserBase::ParserBase(CollectionBackendInterface *collection, QObject *parent)
|
||||
: QObject(parent), collection_(collection) {}
|
||||
ParserBase::ParserBase(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: QObject(parent), collection_backend_(collection_backend) {}
|
||||
|
||||
void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning, const QDir &dir, Song *song, const bool collection_search) const {
|
||||
|
||||
@@ -79,8 +80,8 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
||||
const QUrl url = QUrl::fromLocalFile(filename);
|
||||
|
||||
// Search in the collection
|
||||
if (collection_ && collection_search) {
|
||||
Song collection_song = collection_->GetSongByUrl(url, beginning);
|
||||
if (collection_backend_ && collection_search) {
|
||||
Song collection_song = collection_backend_->GetSongByUrl(url, beginning);
|
||||
// If it was found in the collection then use it, otherwise load metadata from disk.
|
||||
if (collection_song.is_valid()) {
|
||||
*song = collection_song;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef PARSERBASE_H
|
||||
#define PARSERBASE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
@@ -30,7 +32,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "config.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
|
||||
@@ -41,7 +43,7 @@ class ParserBase : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParserBase(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit ParserBase(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual QStringList file_extensions() const = 0;
|
||||
@@ -72,7 +74,7 @@ class ParserBase : public QObject {
|
||||
static QString URLOrFilename(const QUrl &url, const QDir &dir, const PlaylistSettingsPage::PathType path_type);
|
||||
|
||||
private:
|
||||
CollectionBackendInterface *collection_;
|
||||
SharedPtr<CollectionBackendInterface> collection_backend_;
|
||||
};
|
||||
|
||||
#endif // PARSERBASE_H
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "playlistparser.h"
|
||||
#include "parserbase.h"
|
||||
@@ -43,16 +44,16 @@
|
||||
|
||||
const int PlaylistParser::kMagicSize = 512;
|
||||
|
||||
PlaylistParser::PlaylistParser(CollectionBackendInterface *collection, QObject *parent) : QObject(parent) {
|
||||
PlaylistParser::PlaylistParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent) : QObject(parent) {
|
||||
|
||||
default_parser_ = new XSPFParser(collection, this);
|
||||
default_parser_ = new XSPFParser(collection_backend, this);
|
||||
parsers_ << default_parser_;
|
||||
parsers_ << new M3UParser(collection, this);
|
||||
parsers_ << new PLSParser(collection, this);
|
||||
parsers_ << new ASXParser(collection, this);
|
||||
parsers_ << new AsxIniParser(collection, this);
|
||||
parsers_ << new CueParser(collection, this);
|
||||
parsers_ << new WplParser(collection, this);
|
||||
parsers_ << new M3UParser(collection_backend, this);
|
||||
parsers_ << new PLSParser(collection_backend, this);
|
||||
parsers_ << new ASXParser(collection_backend, this);
|
||||
parsers_ << new AsxIniParser(collection_backend, this);
|
||||
parsers_ << new CueParser(collection_backend, this);
|
||||
parsers_ << new WplParser(collection_backend, this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
|
||||
@@ -41,7 +42,7 @@ class PlaylistParser : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaylistParser(CollectionBackendInterface *collection = nullptr, QObject *parent = nullptr);
|
||||
explicit PlaylistParser(SharedPtr<CollectionBackendInterface> collection_backend = nullptr, QObject *parent = nullptr);
|
||||
|
||||
enum class Type {
|
||||
Load,
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "parserbase.h"
|
||||
@@ -41,8 +42,8 @@ constexpr auto qt_endl = Qt::endl;
|
||||
constexpr auto qt_endl = endl;
|
||||
#endif
|
||||
|
||||
PLSParser::PLSParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: ParserBase(collection, parent) {}
|
||||
PLSParser::PLSParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: ParserBase(collection_backend, parent) {}
|
||||
|
||||
SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_search) const {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "parserbase.h"
|
||||
@@ -40,7 +41,7 @@ class PLSParser : public ParserBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PLSParser(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit PLSParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "PLS"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "pls"; }
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "utilities/xmlutils.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "xmlparser.h"
|
||||
@@ -36,8 +37,8 @@
|
||||
|
||||
class CollectionBackendInterface;
|
||||
|
||||
WplParser::WplParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: XMLParser(collection, parent) {}
|
||||
WplParser::WplParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: XMLParser(collection_backend, parent) {}
|
||||
|
||||
bool WplParser::TryMagic(const QByteArray &data) const {
|
||||
return data.contains("<?wpl") || data.contains("<smil>");
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "xmlparser.h"
|
||||
@@ -43,7 +44,7 @@ class WplParser : public XMLParser {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WplParser(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit WplParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "WPL"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "wpl"; }
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "parserbase.h"
|
||||
#include "xmlparser.h"
|
||||
|
||||
class CollectionBackendInterface;
|
||||
|
||||
XMLParser::XMLParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: ParserBase(collection, parent) {}
|
||||
XMLParser::XMLParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: ParserBase(collection_backend, parent) {}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <QString>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "parserbase.h"
|
||||
|
||||
class CollectionBackendInterface;
|
||||
@@ -36,7 +37,7 @@ class XMLParser : public ParserBase {
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
explicit XMLParser(CollectionBackendInterface *collection, QObject *parent);
|
||||
explicit XMLParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent);
|
||||
|
||||
class StreamElement {
|
||||
public:
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "utilities/xmlutils.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
@@ -37,8 +38,8 @@
|
||||
|
||||
class CollectionBackendInterface;
|
||||
|
||||
XSPFParser::XSPFParser(CollectionBackendInterface *collection, QObject *parent)
|
||||
: XMLParser(collection, parent) {}
|
||||
XSPFParser::XSPFParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
|
||||
: XMLParser(collection_backend, parent) {}
|
||||
|
||||
SongList XSPFParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_search) const {
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "xmlparser.h"
|
||||
@@ -41,7 +42,7 @@ class XSPFParser : public XMLParser {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit XSPFParser(CollectionBackendInterface *collection, QObject *parent = nullptr);
|
||||
explicit XSPFParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "XSPF"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "xspf"; }
|
||||
|
||||
Reference in New Issue
Block a user