Refactoring

This commit is contained in:
Jonas Kvinge
2024-10-22 18:12:33 +02:00
parent dfcf715291
commit 8da2b9cd94
623 changed files with 9071 additions and 5126 deletions

View File

@@ -26,8 +26,8 @@
#include <QString>
#include <QTextStream>
#include "core/shared_ptr.h"
#include "settings/playlistsettingspage.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "parserbase.h"
#include "asxiniparser.h"
@@ -35,8 +35,8 @@ using namespace Qt::Literals::StringLiterals;
class CollectionBackendInterface;
AsxIniParser::AsxIniParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(collection_backend, parent) {}
AsxIniParser::AsxIniParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(tagreader_client, collection_backend, parent) {}
bool AsxIniParser::TryMagic(const QByteArray &data) const {
return data.toLower().contains("[reference]");
@@ -66,7 +66,7 @@ SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, con
}
void AsxIniParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type) const {
void AsxIniParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
QTextStream s(device);
s << "[Reference]" << Qt::endl;

View File

@@ -29,19 +29,20 @@
#include <QStringList>
#include <QDir>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "parserbase.h"
class QIODevice;
class TagReaderClient;
class CollectionBackendInterface;
class AsxIniParser : public ParserBase {
Q_OBJECT
public:
explicit AsxIniParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit AsxIniParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("ASX/INI"); }
QStringList file_extensions() const override { return QStringList() << QStringLiteral("asxini"); }
@@ -51,7 +52,7 @@ class AsxIniParser : public ParserBase {
bool TryMagic(const QByteArray &data) const override;
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_lookup = true) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
};
#endif // ASXINIPARSER_H

View File

@@ -29,9 +29,9 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "utilities/xmlutils.h"
#include "settings/playlistsettingspage.h"
#include "constants/playlistsettings.h"
#include "xmlparser.h"
#include "asxparser.h"
@@ -39,8 +39,8 @@ using namespace Qt::Literals::StringLiterals;
class CollectionBackendInterface;
ASXParser::ASXParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: XMLParser(collection_backend, parent) {}
ASXParser::ASXParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: XMLParser(tagreader_client, collection_backend, parent) {}
SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const {
@@ -133,7 +133,7 @@ return_song:
}
void ASXParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type) const {
void ASXParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
Q_UNUSED(dir)
Q_UNUSED(path_type)

View File

@@ -29,21 +29,22 @@
#include <QStringList>
#include <QDir>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "xmlparser.h"
class QIODevice;
class QXmlStreamReader;
class TagReaderClient;
class CollectionBackendInterface;
class ASXParser : public XMLParser {
Q_OBJECT
public:
explicit ASXParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit ASXParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("ASX"); }
QStringList file_extensions() const override { return QStringList() << QStringLiteral("asx"); }
@@ -53,7 +54,7 @@ class ASXParser : public XMLParser {
bool TryMagic(const QByteArray &data) const override;
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_lookup = true) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
private:
Song ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_lookup) const;

View File

@@ -32,11 +32,11 @@
#include <QTextStream>
#include <QStringConverter>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/timeconstants.h"
#include "core/logging.h"
#include "utilities/timeconstants.h"
#include "utilities/textencodingutils.h"
#include "settings/playlistsettingspage.h"
#include "constants/playlistsettings.h"
#include "parserbase.h"
#include "cueparser.h"
@@ -63,8 +63,8 @@ constexpr char kDate[] = "date";
constexpr char kDisc[] = "discnumber";
} // namespace
CueParser::CueParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(collection_backend, parent) {}
CueParser::CueParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(tagreader_client, collection_backend, parent) {}
SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const {
@@ -378,7 +378,7 @@ qint64 CueParser::IndexToMarker(const QString &index) {
}
void CueParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type) const {
void CueParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
Q_UNUSED(songs);
Q_UNUSED(device);

View File

@@ -31,12 +31,13 @@
#include <QStringList>
#include <QDir>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "parserbase.h"
class QIODevice;
class TagReaderClient;
class CollectionBackendInterface;
// This parser will try to detect the real encoding of a .cue file
@@ -45,7 +46,7 @@ class CueParser : public ParserBase {
Q_OBJECT
public:
explicit CueParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit CueParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("CUE"); }
QStringList file_extensions() const override { return QStringList() << QStringLiteral("cue"); }
@@ -56,7 +57,7 @@ class CueParser : public ParserBase {
bool TryMagic(const QByteArray &data) const override;
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_lookup = true) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
static QString FindCueFilename(const QString &filename);

View File

@@ -27,11 +27,11 @@
#include <QStringList>
#include <QSettings>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/logging.h"
#include "core/settings.h"
#include "utilities/timeconstants.h"
#include "settings/playlistsettingspage.h"
#include "constants/timeconstants.h"
#include "constants/playlistsettings.h"
#include "parserbase.h"
#include "m3uparser.h"
@@ -39,8 +39,8 @@ using namespace Qt::Literals::StringLiterals;
class CollectionBackendInterface;
M3UParser::M3UParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(collection_backend, parent) {}
M3UParser::M3UParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(tagreader_client, collection_backend, parent) {}
SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const {
@@ -125,13 +125,13 @@ bool M3UParser::ParseMetadata(const QString &line, M3UParser::Metadata *metadata
}
void M3UParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type) const {
void M3UParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
device->write("#EXTM3U\n");
Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
bool write_metadata = s.value("write_metadata", true).toBool();
s.beginGroup(PlaylistSettings::kSettingsGroup);
bool write_metadata = s.value(PlaylistSettings::kWriteMetadata, true).toBool();
s.endGroup();
for (const Song &song : songs) {

View File

@@ -30,19 +30,20 @@
#include <QStringList>
#include <QDir>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "parserbase.h"
class QIODevice;
class TagReaderClient;
class CollectionBackendInterface;
class M3UParser : public ParserBase {
Q_OBJECT
public:
explicit M3UParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit M3UParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("M3U"); }
QStringList file_extensions() const override { return QStringList() << QStringLiteral("m3u") << QStringLiteral("m3u8"); }
@@ -53,7 +54,7 @@ class M3UParser : public ParserBase {
bool TryMagic(const QByteArray &data) const override;
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_lookup = true) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
private:
enum class M3UType {

View File

@@ -27,17 +27,17 @@
#include <QRegularExpression>
#include <QUrl>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/logging.h"
#include "tagreader/tagreaderclient.h"
#include "collection/collectionbackend.h"
#include "settings/playlistsettingspage.h"
#include "constants/playlistsettings.h"
#include "parserbase.h"
using namespace Qt::Literals::StringLiterals;
ParserBase::ParserBase(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: QObject(parent), collection_backend_(collection_backend) {}
ParserBase::ParserBase(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: QObject(parent), tagreader_client_(tagreader_client), collection_backend_(collection_backend) {}
void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, Song *song, const bool collection_lookup) const {
@@ -105,9 +105,11 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
}
}
const TagReaderResult result = TagReaderClient::Instance()->ReadFileBlocking(filename, song);
if (!result.success()) {
qLog(Error) << "Could not read file" << filename << result.error_string();
if (tagreader_client_) {
const TagReaderResult result = tagreader_client_->ReadFileBlocking(filename, song);
if (!result.success()) {
qLog(Error) << "Could not read file" << filename << result.error_string();
}
}
}
@@ -121,16 +123,16 @@ Song ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
}
QString ParserBase::URLOrFilename(const QUrl &url, const QDir &dir, const PlaylistSettingsPage::PathType path_type) {
QString ParserBase::URLOrFilename(const QUrl &url, const QDir &dir, const PlaylistSettings::PathType path_type) {
if (!url.isLocalFile()) return url.toString();
const QString filename = url.toLocalFile();
if (path_type != PlaylistSettingsPage::PathType::Absolute && QDir::isAbsolutePath(filename)) {
if (path_type != PlaylistSettings::PathType::Absolute && QDir::isAbsolutePath(filename)) {
const QString relative = dir.relativeFilePath(filename);
if (!relative.startsWith("../"_L1) || path_type == PlaylistSettingsPage::PathType::Relative) {
if (!relative.startsWith("../"_L1) || path_type == PlaylistSettings::PathType::Relative) {
return relative;
}
}

View File

@@ -32,18 +32,19 @@
#include <QStringList>
#include <QUrl>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "constants/playlistsettings.h"
class QIODevice;
class CollectionBackendInterface;
class TagReaderClient;
class ParserBase : public QObject {
Q_OBJECT
public:
explicit ParserBase(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit ParserBase(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
virtual QString name() const = 0;
virtual QStringList file_extensions() const = 0;
@@ -59,7 +60,7 @@ class ParserBase : public QObject {
// Any playlist parser may decide to leave out some entries if it finds them incomplete or invalid.
// This means that the final resulting SongList should be considered valid (at least from the parser's point of view).
virtual SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_lookup = true) const = 0;
virtual void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const = 0;
virtual void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const = 0;
Q_SIGNALS:
void Error(const QString &error) const;
@@ -73,10 +74,11 @@ class ParserBase : public QObject {
// If the URL is a file:// URL then returns its path, absolute or relative to the directory depending on the path_type option.
// Otherwise, returns the URL as is. This function should always be used when saving a playlist.
static QString URLOrFilename(const QUrl &url, const QDir &dir, const PlaylistSettingsPage::PathType path_type);
static QString URLOrFilename(const QUrl &url, const QDir &dir, const PlaylistSettings::PathType path_type);
private:
SharedPtr<CollectionBackendInterface> collection_backend_;
const SharedPtr<TagReaderClient> tagreader_client_;
const SharedPtr<CollectionBackendInterface> collection_backend_;
};
#endif // PARSERBASE_H

View File

@@ -29,9 +29,9 @@
#include <QString>
#include <QStringList>
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/logging.h"
#include "core/shared_ptr.h"
#include "settings/playlistsettingspage.h"
#include "playlistparser.h"
#include "parserbase.h"
#include "asxiniparser.h"
@@ -46,15 +46,15 @@ using namespace Qt::Literals::StringLiterals;
const int PlaylistParser::kMagicSize = 512;
PlaylistParser::PlaylistParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent) : QObject(parent), default_parser_(nullptr) {
PlaylistParser::PlaylistParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent) : QObject(parent), default_parser_(nullptr) {
AddParser(new XSPFParser(collection_backend, this));
AddParser(new M3UParser(collection_backend, this));
AddParser(new PLSParser(collection_backend, this));
AddParser(new ASXParser(collection_backend, this));
AddParser(new AsxIniParser(collection_backend, this));
AddParser(new CueParser(collection_backend, this));
AddParser(new WplParser(collection_backend, this));
AddParser(new XSPFParser(tagreader_client, collection_backend, this));
AddParser(new M3UParser(tagreader_client, collection_backend, this));
AddParser(new PLSParser(tagreader_client, collection_backend, this));
AddParser(new ASXParser(tagreader_client, collection_backend, this));
AddParser(new AsxIniParser(tagreader_client, collection_backend, this));
AddParser(new CueParser(tagreader_client, collection_backend, this));
AddParser(new WplParser(tagreader_client, collection_backend, this));
}
@@ -214,7 +214,7 @@ SongList PlaylistParser::LoadFromDevice(QIODevice *device, const QString &path_h
}
void PlaylistParser::Save(const SongList &songs, const QString &filename, const PlaylistSettingsPage::PathType path_type) const {
void PlaylistParser::Save(const SongList &songs, const QString &filename, const PlaylistSettings::PathType path_type) const {
QFileInfo fileinfo(filename);
QDir dir(fileinfo.path());
@@ -233,10 +233,10 @@ void PlaylistParser::Save(const SongList &songs, const QString &filename, const
return;
}
if (path_type == PlaylistSettingsPage::PathType::Absolute && dir.path() != dir.absolutePath()) {
if (path_type == PlaylistSettings::PathType::Absolute && dir.path() != dir.absolutePath()) {
dir.setPath(dir.absolutePath());
}
else if (path_type != PlaylistSettingsPage::PathType::Absolute && !dir.canonicalPath().isEmpty() && dir.path() != dir.canonicalPath()) {
else if (path_type != PlaylistSettings::PathType::Absolute && !dir.canonicalPath().isEmpty() && dir.path() != dir.canonicalPath()) {
dir.setPath(dir.canonicalPath());
}

View File

@@ -30,11 +30,12 @@
#include <QString>
#include <QStringList>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "constants/playlistsettings.h"
class QIODevice;
class TagReaderClient;
class CollectionBackendInterface;
class ParserBase;
@@ -42,7 +43,7 @@ class PlaylistParser : public QObject {
Q_OBJECT
public:
explicit PlaylistParser(SharedPtr<CollectionBackendInterface> collection_backend = nullptr, QObject *parent = nullptr);
explicit PlaylistParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend = nullptr, QObject *parent = nullptr);
enum class Type {
Load,
@@ -65,7 +66,7 @@ class PlaylistParser : public QObject {
SongList LoadFromFile(const QString &filename) const;
SongList LoadFromDevice(QIODevice *device, const QString &path_hint = QString(), const QDir &dir_hint = QDir()) const;
void Save(const SongList &songs, const QString &filename, const PlaylistSettingsPage::PathType) const;
void Save(const SongList &songs, const QString &filename, const PlaylistSettings::PathType) const;
Q_SIGNALS:
void Error(const QString &error) const;

View File

@@ -28,9 +28,9 @@
#include <QRegularExpression>
#include <QTextStream>
#include "core/shared_ptr.h"
#include "utilities/timeconstants.h"
#include "settings/playlistsettingspage.h"
#include "includes/shared_ptr.h"
#include "constants/timeconstants.h"
#include "constants/playlistsettings.h"
#include "parserbase.h"
#include "plsparser.h"
@@ -38,8 +38,8 @@ using namespace Qt::Literals::StringLiterals;
class CollectionBackendInterface;
PLSParser::PLSParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(collection_backend, parent) {}
PLSParser::PLSParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(tagreader_client, collection_backend, parent) {}
SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const {
@@ -83,7 +83,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
}
void PLSParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type) const {
void PLSParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
QTextStream s(device);
s << "[playlist]" << Qt::endl;

View File

@@ -29,19 +29,20 @@
#include <QString>
#include <QStringList>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "parserbase.h"
class QIODevice;
class TagReaderClient;
class CollectionBackendInterface;
class PLSParser : public ParserBase {
Q_OBJECT
public:
explicit PLSParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit PLSParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("PLS"); }
QStringList file_extensions() const override { return QStringList() << QStringLiteral("pls"); }
@@ -52,7 +53,7 @@ class PLSParser : public ParserBase {
bool TryMagic(const QByteArray &data) const override;
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_lookup = true) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
};
#endif // PLSPARSER_H

View File

@@ -29,9 +29,9 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "utilities/xmlutils.h"
#include "settings/playlistsettingspage.h"
#include "constants/playlistsettings.h"
#include "xmlparser.h"
#include "wplparser.h"
@@ -39,8 +39,8 @@ using namespace Qt::Literals::StringLiterals;
class CollectionBackendInterface;
WplParser::WplParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: XMLParser(collection_backend, parent) {}
WplParser::WplParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: XMLParser(tagreader_client, collection_backend, parent) {}
bool WplParser::TryMagic(const QByteArray &data) const {
return data.contains("<?wpl") || data.contains("<smil>");
@@ -98,7 +98,7 @@ void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *so
}
void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type) const {
void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
QXmlStreamWriter writer(device);
writer.setAutoFormatting(true);

View File

@@ -29,22 +29,23 @@
#include <QString>
#include <QStringList>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "xmlparser.h"
class QIODevice;
class QXmlStreamReader;
class QXmlStreamWriter;
class TagReaderClient;
class CollectionBackendInterface;
class WplParser : public XMLParser {
Q_OBJECT
public:
explicit WplParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit WplParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("WPL"); }
QStringList file_extensions() const override { return QStringList() << QStringLiteral("wpl"); }
@@ -55,7 +56,7 @@ class WplParser : public XMLParser {
bool TryMagic(const QByteArray &data) const override;
SongList Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup = true) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
private:
void ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *songs, const bool collection_lookup) const;

View File

@@ -20,11 +20,11 @@
#include <QObject>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "parserbase.h"
#include "xmlparser.h"
class CollectionBackendInterface;
XMLParser::XMLParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(collection_backend, parent) {}
XMLParser::XMLParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: ParserBase(tagreader_client, collection_backend, parent) {}

View File

@@ -28,16 +28,17 @@
#include <QString>
#include <QXmlStreamWriter>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "parserbase.h"
class TagReaderClient;
class CollectionBackendInterface;
class XMLParser : public ParserBase {
Q_OBJECT
protected:
explicit XMLParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent);
explicit XMLParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent);
class StreamElement {
public:

View File

@@ -29,11 +29,11 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "core/settings.h"
#include "utilities/xmlutils.h"
#include "utilities/timeconstants.h"
#include "settings/playlistsettingspage.h"
#include "constants/timeconstants.h"
#include "constants/playlistsettings.h"
#include "xmlparser.h"
#include "xspfparser.h"
@@ -41,8 +41,8 @@ using namespace Qt::Literals::StringLiterals;
class CollectionBackendInterface;
XSPFParser::XSPFParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: XMLParser(collection_backend, parent) {}
XSPFParser::XSPFParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent)
: XMLParser(tagreader_client, collection_backend, parent) {}
SongList XSPFParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const {
@@ -140,7 +140,7 @@ return_song:
}
void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettingsPage::PathType path_type) const {
void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
QXmlStreamWriter writer(device);
writer.setAutoFormatting(true);
@@ -151,8 +151,8 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
writer.writeDefaultNamespace("http://xspf.org/ns/0/"_L1);
Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
bool write_metadata = s.value("write_metadata", true).toBool();
s.beginGroup(PlaylistSettings::kSettingsGroup);
bool write_metadata = s.value(PlaylistSettings::kWriteMetadata, true).toBool();
s.endGroup();
StreamElement tracklist(u"trackList"_s, &writer);

View File

@@ -29,20 +29,21 @@
#include <QString>
#include <QStringList>
#include "core/shared_ptr.h"
#include "includes/shared_ptr.h"
#include "constants/playlistsettings.h"
#include "core/song.h"
#include "settings/playlistsettingspage.h"
#include "xmlparser.h"
class QIODevice;
class QXmlStreamReader;
class TagReaderClient;
class CollectionBackendInterface;
class XSPFParser : public XMLParser {
Q_OBJECT
public:
explicit XSPFParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
explicit XSPFParser(const SharedPtr<TagReaderClient> tagreader_client, const SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("XSPF"); }
QStringList file_extensions() const override { return QStringList() << QStringLiteral("xspf"); }
@@ -52,7 +53,7 @@ class XSPFParser : public XMLParser {
bool TryMagic(const QByteArray &data) const override;
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_lookup = true) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
private:
Song ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_lookup) const;