Use QStringLiteral
This commit is contained in:
@@ -58,7 +58,7 @@ SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, con
|
||||
QString key = line.left(equals).toLower();
|
||||
QString value = line.mid(equals + 1);
|
||||
|
||||
if (key.startsWith("ref")) {
|
||||
if (key.startsWith(QLatin1String("ref"))) {
|
||||
Song song = LoadSong(value, 0, 0, dir, collection_search);
|
||||
if (song.is_valid()) {
|
||||
ret << song;
|
||||
|
||||
@@ -43,14 +43,14 @@ class AsxIniParser : public ParserBase {
|
||||
public:
|
||||
explicit AsxIniParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "ASX/INI"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "asxini"; }
|
||||
QString name() const override { return QStringLiteral("ASX/INI"); }
|
||||
QStringList file_extensions() const override { return QStringList() << QStringLiteral("asxini"); }
|
||||
bool load_supported() const override { return true; }
|
||||
bool save_supported() const override { return true; }
|
||||
|
||||
bool TryMagic(const QByteArray &data) const override;
|
||||
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = "", const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,14 +48,14 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
QByteArray data = device->readAll();
|
||||
|
||||
// Some playlists have unescaped & characters in URLs :(
|
||||
QRegularExpression ex("(href\\s*=\\s*\")([^\"]+)\"", QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpression ex(QStringLiteral("(href\\s*=\\s*\")([^\"]+)\""), QRegularExpression::CaseInsensitiveOption);
|
||||
qint64 index = 0;
|
||||
for (QRegularExpressionMatch re_match = ex.match(data, index); re_match.hasMatch(); re_match = ex.match(data, index)) {
|
||||
index = re_match.capturedStart();
|
||||
QString url = re_match.captured(2);
|
||||
url.replace(QRegularExpression("&(?!amp;|quot;|apos;|lt;|gt;)"), "&");
|
||||
url.replace(QRegularExpression(QStringLiteral("&(?!amp;|quot;|apos;|lt;|gt;)")), QStringLiteral("&"));
|
||||
|
||||
QByteArray replacement = QString("%1%2\"").arg(re_match.captured(1), url).toLocal8Bit();
|
||||
QByteArray replacement = QStringLiteral("%1%2\"").arg(re_match.captured(1), url).toLocal8Bit();
|
||||
data.replace(re_match.captured(0).toLocal8Bit(), replacement);
|
||||
index += replacement.length();
|
||||
}
|
||||
@@ -64,13 +64,13 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
if (!buffer.open(QIODevice::ReadOnly)) return SongList();
|
||||
|
||||
QXmlStreamReader reader(&buffer);
|
||||
if (!Utilities::ParseUntilElementCI(&reader, "asx")) {
|
||||
if (!Utilities::ParseUntilElementCI(&reader, QStringLiteral("asx"))) {
|
||||
buffer.close();
|
||||
return SongList();
|
||||
}
|
||||
|
||||
SongList ret;
|
||||
while (!reader.atEnd() && Utilities::ParseUntilElementCI(&reader, "entry")) {
|
||||
while (!reader.atEnd() && Utilities::ParseUntilElementCI(&reader, QStringLiteral("entry"))) {
|
||||
Song song = ParseTrack(&reader, dir, collection_search);
|
||||
if (song.is_valid()) {
|
||||
ret << song;
|
||||
@@ -137,13 +137,13 @@ void ASXParser::Save(const SongList &songs, QIODevice *device, const QDir&, cons
|
||||
writer.setAutoFormattingIndent(2);
|
||||
writer.writeStartDocument();
|
||||
{
|
||||
StreamElement asx("asx", &writer);
|
||||
StreamElement asx(QStringLiteral("asx"), &writer);
|
||||
writer.writeAttribute("version", "3.0");
|
||||
for (const Song &song : songs) {
|
||||
StreamElement entry("entry", &writer);
|
||||
StreamElement entry(QStringLiteral("entry"), &writer);
|
||||
writer.writeTextElement("title", song.title());
|
||||
{
|
||||
StreamElement ref("ref", &writer);
|
||||
StreamElement ref(QStringLiteral("ref"), &writer);
|
||||
writer.writeAttribute("href", song.url().toString());
|
||||
}
|
||||
if (!song.artist().isEmpty()) {
|
||||
|
||||
@@ -45,14 +45,14 @@ class ASXParser : public XMLParser {
|
||||
public:
|
||||
explicit ASXParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "ASX"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "asx"; }
|
||||
QString name() const override { return QStringLiteral("ASX"); }
|
||||
QStringList file_extensions() const override { return QStringList() << QStringLiteral("asx"); }
|
||||
bool load_supported() const override { return true; }
|
||||
bool save_supported() const override { return true; }
|
||||
|
||||
bool TryMagic(const QByteArray &data) const override;
|
||||
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = "", const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -152,7 +152,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
}
|
||||
|
||||
// if this is a data file, all of its tracks will be ignored
|
||||
bool valid_file = file_type.compare("BINARY", Qt::CaseInsensitive) != 0 && file_type.compare("MOTOROLA", Qt::CaseInsensitive) != 0;
|
||||
bool valid_file = file_type.compare(QLatin1String("BINARY"), Qt::CaseInsensitive) != 0 && file_type.compare(QLatin1String("MOTOROLA"), Qt::CaseInsensitive) != 0;
|
||||
|
||||
QString track_type;
|
||||
QString index;
|
||||
@@ -173,7 +173,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
|
||||
const QString &line_name = splitted[0];
|
||||
const QString &line_value = splitted[1];
|
||||
QString line_additional = splitted.size() > 2 ? splitted[2].toLower() : "";
|
||||
QString line_additional = splitted.size() > 2 ? splitted[2].toLower() : QLatin1String("");
|
||||
|
||||
if (line_name.compare(kTrack, Qt::CaseInsensitive) == 0) {
|
||||
|
||||
@@ -184,7 +184,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
}
|
||||
|
||||
// clear the state
|
||||
track_type = index = artist = composer = title = date = genre = "";
|
||||
track_type = index = artist = composer = title = date = genre = QLatin1String("");
|
||||
|
||||
if (!line_additional.isEmpty()) {
|
||||
track_type = line_additional;
|
||||
@@ -292,7 +292,7 @@ QStringList CueParser::SplitCueLine(const QString &line) {
|
||||
}
|
||||
|
||||
// Let's remove the empty entries while we're at it
|
||||
return re_match.capturedTexts().filter(QRegularExpression(".+")).mid(1, -1).replaceInStrings(QRegularExpression("^\"\"$"), "");
|
||||
return re_match.capturedTexts().filter(QRegularExpression(QStringLiteral(".+"))).mid(1, -1).replaceInStrings(QRegularExpression(QStringLiteral("^\"\"$")), QLatin1String(""));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -63,15 +63,15 @@ class CueParser : public ParserBase {
|
||||
|
||||
explicit CueParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "CUE"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "cue"; }
|
||||
QString mime_type() const override { return "application/x-cue"; }
|
||||
QString name() const override { return QStringLiteral("CUE"); }
|
||||
QStringList file_extensions() const override { return QStringList() << QStringLiteral("cue"); }
|
||||
QString mime_type() const override { return QStringLiteral("application/x-cue"); }
|
||||
bool load_supported() const override { return true; }
|
||||
bool save_supported() const override { return false; }
|
||||
|
||||
bool TryMagic(const QByteArray &data) const override;
|
||||
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = "", const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
|
||||
|
||||
static QString FindCueFilename(const QString &filename);
|
||||
|
||||
@@ -48,13 +48,13 @@ SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
|
||||
QString data = QString::fromUtf8(device->readAll());
|
||||
data.replace('\r', '\n');
|
||||
data.replace("\n\n", "\n");
|
||||
data.replace(QLatin1String("\n\n"), QLatin1String("\n"));
|
||||
QByteArray bytes = data.toUtf8();
|
||||
QBuffer buffer(&bytes);
|
||||
if (!buffer.open(QIODevice::ReadOnly)) return SongList();
|
||||
|
||||
QString line = QString::fromUtf8(buffer.readLine()).trimmed();
|
||||
if (line.startsWith("#EXTM3U")) {
|
||||
if (line.startsWith(QLatin1String("#EXTM3U"))) {
|
||||
// This is in extended M3U format.
|
||||
type = M3UType::EXTENDED;
|
||||
line = QString::fromUtf8(buffer.readLine()).trimmed();
|
||||
@@ -64,7 +64,7 @@ SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
forever {
|
||||
if (line.startsWith('#')) {
|
||||
// Extended info or comment.
|
||||
if (type == M3UType::EXTENDED && line.startsWith("#EXT")) {
|
||||
if (type == M3UType::EXTENDED && line.startsWith(QLatin1String("#EXT"))) {
|
||||
if (!ParseMetadata(line, ¤t_metadata)) {
|
||||
qLog(Warning) << "Failed to parse metadata: " << line;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ bool M3UParser::ParseMetadata(const QString &line, M3UParser::Metadata *metadata
|
||||
metadata->length = length * kNsecPerSec;
|
||||
|
||||
QString track_info = info.section(',', 1);
|
||||
QStringList list = track_info.split(" - ");
|
||||
QStringList list = track_info.split(QStringLiteral(" - "));
|
||||
if (list.size() <= 1) {
|
||||
metadata->title = track_info;
|
||||
return true;
|
||||
@@ -136,7 +136,7 @@ void M3UParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
|
||||
continue;
|
||||
}
|
||||
if (write_metadata || (song.is_stream() && !song.is_radio())) {
|
||||
QString meta = QString("#EXTINF:%1,%2 - %3\n").arg(song.length_nanosec() / kNsecPerSec).arg(song.artist(), song.title());
|
||||
QString meta = QStringLiteral("#EXTINF:%1,%2 - %3\n").arg(song.length_nanosec() / kNsecPerSec).arg(song.artist(), song.title());
|
||||
device->write(meta.toUtf8());
|
||||
}
|
||||
device->write(URLOrFilename(song.url(), dir, path_type).toUtf8());
|
||||
|
||||
@@ -44,15 +44,15 @@ class M3UParser : public ParserBase {
|
||||
public:
|
||||
explicit M3UParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "M3U"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "m3u" << "m3u8"; }
|
||||
QString mime_type() const override { return "text/uri-list"; }
|
||||
QString name() const override { return QStringLiteral("M3U"); }
|
||||
QStringList file_extensions() const override { return QStringList() << QStringLiteral("m3u") << QStringLiteral("m3u8"); }
|
||||
QString mime_type() const override { return QStringLiteral("text/uri-list"); }
|
||||
bool load_supported() const override { return true; }
|
||||
bool save_supported() const override { return true; }
|
||||
|
||||
bool TryMagic(const QByteArray &data) const override;
|
||||
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = "", const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -45,7 +45,7 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
|
||||
|
||||
QString filename = filename_or_url;
|
||||
|
||||
if (filename_or_url.contains(QRegularExpression("^[a-z]{2,}:", QRegularExpression::CaseInsensitiveOption))) {
|
||||
if (filename_or_url.contains(QRegularExpression(QStringLiteral("^[a-z]{2,}:"), QRegularExpression::CaseInsensitiveOption))) {
|
||||
QUrl url(filename_or_url);
|
||||
song->set_source(Song::SourceFromURL(url));
|
||||
if (song->source() == Song::Source::LocalFile) {
|
||||
@@ -119,7 +119,7 @@ QString ParserBase::URLOrFilename(const QUrl &url, const QDir &dir, const Playli
|
||||
if (path_type != PlaylistSettingsPage::PathType::Absolute && QDir::isAbsolutePath(filename)) {
|
||||
const QString relative = dir.relativeFilePath(filename);
|
||||
|
||||
if (!relative.startsWith("../") || path_type == PlaylistSettingsPage::PathType::Relative) {
|
||||
if (!relative.startsWith(QLatin1String("../")) || path_type == PlaylistSettingsPage::PathType::Relative) {
|
||||
return relative;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class ParserBase : public QObject {
|
||||
// This method might not return all the songs found in the playlist.
|
||||
// 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 = "", const QDir &dir = QDir(), const bool collection_lookup = true) const = 0;
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -100,10 +100,10 @@ QString PlaylistParser::filters(const Type type) const {
|
||||
}
|
||||
|
||||
if (type == Type::Load) {
|
||||
filters.prepend(tr("All playlists (%1)").arg(all_extensions.join(" ")));
|
||||
filters.prepend(tr("All playlists (%1)").arg(all_extensions.join(QStringLiteral(" "))));
|
||||
}
|
||||
|
||||
return filters.join(";;");
|
||||
return filters.join(QStringLiteral(";;"));
|
||||
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ QString PlaylistParser::FilterForParser(const ParserBase *parser, QStringList *a
|
||||
|
||||
if (all_extensions) *all_extensions << extensions;
|
||||
|
||||
return tr("%1 playlists (%2)").arg(parser->name(), extensions.join(" "));
|
||||
return tr("%1 playlists (%2)").arg(parser->name(), extensions.join(QStringLiteral(" ")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
Q_UNUSED(playlist_path);
|
||||
|
||||
QMap<int, Song> songs;
|
||||
QRegularExpression n_re("\\d+$");
|
||||
QRegularExpression n_re(QStringLiteral("\\d+$"));
|
||||
|
||||
while (!device->atEnd()) {
|
||||
QString line = QString::fromUtf8(device->readLine()).trimmed();
|
||||
@@ -61,7 +61,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
QRegularExpressionMatch re_match = n_re.match(key);
|
||||
int n = re_match.captured(0).toInt();
|
||||
|
||||
if (key.startsWith("file")) {
|
||||
if (key.startsWith(QLatin1String("file"))) {
|
||||
Song song = LoadSong(value, 0, 0, dir, collection_search);
|
||||
|
||||
// Use the title and length we've already loaded if any
|
||||
@@ -72,10 +72,10 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
|
||||
songs[n] = song;
|
||||
}
|
||||
else if (key.startsWith("title")) {
|
||||
else if (key.startsWith(QLatin1String("title"))) {
|
||||
songs[n].set_title(value);
|
||||
}
|
||||
else if (key.startsWith("length")) {
|
||||
else if (key.startsWith(QLatin1String("length"))) {
|
||||
qint64 seconds = value.toLongLong();
|
||||
if (seconds > 0) {
|
||||
songs[n].set_length_nanosec(seconds * kNsecPerSec);
|
||||
|
||||
@@ -43,15 +43,15 @@ class PLSParser : public ParserBase {
|
||||
public:
|
||||
explicit PLSParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "PLS"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "pls"; }
|
||||
QString mime_type() const override { return "audio/x-scpls"; }
|
||||
QString name() const override { return QStringLiteral("PLS"); }
|
||||
QStringList file_extensions() const override { return QStringList() << QStringLiteral("pls"); }
|
||||
QString mime_type() const override { return QStringLiteral("audio/x-scpls"); }
|
||||
bool load_supported() const override { return true; }
|
||||
bool save_supported() const override { return true; }
|
||||
|
||||
bool TryMagic(const QByteArray &data) const override;
|
||||
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = "", const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,11 +51,11 @@ SongList WplParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
SongList ret;
|
||||
|
||||
QXmlStreamReader reader(device);
|
||||
if (!Utilities::ParseUntilElement(&reader, "smil") || !Utilities::ParseUntilElement(&reader, "body")) {
|
||||
if (!Utilities::ParseUntilElement(&reader, QStringLiteral("smil")) || !Utilities::ParseUntilElement(&reader, QStringLiteral("body"))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, "seq")) {
|
||||
while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, QStringLiteral("seq"))) {
|
||||
ParseSeq(dir, &reader, &ret, collection_search);
|
||||
}
|
||||
return ret;
|
||||
@@ -103,18 +103,18 @@ void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
|
||||
writer.setAutoFormattingIndent(2);
|
||||
writer.writeProcessingInstruction("wpl", "version=\"1.0\"");
|
||||
|
||||
StreamElement smil("smil", &writer);
|
||||
StreamElement smil(QStringLiteral("smil"), &writer);
|
||||
|
||||
{
|
||||
StreamElement head("head", &writer);
|
||||
WriteMeta("Generator", "Strawberry -- " STRAWBERRY_VERSION_DISPLAY, &writer);
|
||||
WriteMeta("ItemCount", QString::number(songs.count()), &writer);
|
||||
StreamElement head(QStringLiteral("head"), &writer);
|
||||
WriteMeta(QStringLiteral("Generator"), "Strawberry -- " STRAWBERRY_VERSION_DISPLAY, &writer);
|
||||
WriteMeta(QStringLiteral("ItemCount"), QString::number(songs.count()), &writer);
|
||||
}
|
||||
|
||||
{
|
||||
StreamElement body("body", &writer);
|
||||
StreamElement body(QStringLiteral("body"), &writer);
|
||||
{
|
||||
StreamElement seq("seq", &writer);
|
||||
StreamElement seq(QStringLiteral("seq"), &writer);
|
||||
for (const Song &song : songs) {
|
||||
writer.writeStartElement("media");
|
||||
writer.writeAttribute("src", URLOrFilename(song.url(), dir, path_type));
|
||||
|
||||
@@ -46,9 +46,9 @@ class WplParser : public XMLParser {
|
||||
public:
|
||||
explicit WplParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "WPL"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "wpl"; }
|
||||
QString mime_type() const override { return "application/vnd.ms-wpl"; }
|
||||
QString name() const override { return QStringLiteral("WPL"); }
|
||||
QStringList file_extensions() const override { return QStringList() << QStringLiteral("wpl"); }
|
||||
QString mime_type() const override { return QStringLiteral("application/vnd.ms-wpl"); }
|
||||
bool load_supported() const override { return true; }
|
||||
bool save_supported() const override { return true; }
|
||||
|
||||
|
||||
@@ -48,11 +48,11 @@ SongList XSPFParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
SongList ret;
|
||||
|
||||
QXmlStreamReader reader(device);
|
||||
if (!Utilities::ParseUntilElement(&reader, "playlist") || !Utilities::ParseUntilElement(&reader, "trackList")) {
|
||||
if (!Utilities::ParseUntilElement(&reader, QStringLiteral("playlist")) || !Utilities::ParseUntilElement(&reader, QStringLiteral("trackList"))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, "track")) {
|
||||
while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, QStringLiteral("track"))) {
|
||||
Song song = ParseTrack(&reader, dir, collection_search);
|
||||
if (song.is_valid()) {
|
||||
ret << song;
|
||||
@@ -142,7 +142,7 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
|
||||
writer.setAutoFormatting(true);
|
||||
writer.setAutoFormattingIndent(2);
|
||||
writer.writeStartDocument();
|
||||
StreamElement playlist("playlist", &writer);
|
||||
StreamElement playlist(QStringLiteral("playlist"), &writer);
|
||||
writer.writeAttribute("version", "1");
|
||||
writer.writeDefaultNamespace("http://xspf.org/ns/0/");
|
||||
|
||||
@@ -151,11 +151,11 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
|
||||
bool write_metadata = s.value("write_metadata", true).toBool();
|
||||
s.endGroup();
|
||||
|
||||
StreamElement tracklist("trackList", &writer);
|
||||
StreamElement tracklist(QStringLiteral("trackList"), &writer);
|
||||
for (const Song &song : songs) {
|
||||
QString filename_or_url = QUrl::toPercentEncoding(URLOrFilename(song.url(), dir, path_type), "/ ");
|
||||
|
||||
StreamElement track("track", &writer);
|
||||
StreamElement track(QStringLiteral("track"), &writer);
|
||||
writer.writeTextElement("location", filename_or_url);
|
||||
|
||||
if (write_metadata || (song.is_stream() && !song.is_radio())) {
|
||||
|
||||
@@ -44,14 +44,14 @@ class XSPFParser : public XMLParser {
|
||||
public:
|
||||
explicit XSPFParser(SharedPtr<CollectionBackendInterface> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
QString name() const override { return "XSPF"; }
|
||||
QStringList file_extensions() const override { return QStringList() << "xspf"; }
|
||||
QString name() const override { return QStringLiteral("XSPF"); }
|
||||
QStringList file_extensions() const override { return QStringList() << QStringLiteral("xspf"); }
|
||||
bool load_supported() const override { return true; }
|
||||
bool save_supported() const override { return true; }
|
||||
|
||||
bool TryMagic(const QByteArray &data) const override;
|
||||
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = "", const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
SongList Load(QIODevice *device, const QString &playlist_path = QLatin1String(""), const QDir &dir = QDir(), const bool collection_search = true) const override;
|
||||
void Save(const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettingsPage::PathType path_type = PlaylistSettingsPage::PathType::Automatic) const override;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user