From ad9f3ce0788879e78abe914e0657765807305a2a Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Mon, 1 Jul 2024 01:51:48 +0200 Subject: [PATCH] playlistparsers: Rename collection_search to collection_lookup --- src/playlistparsers/asxiniparser.cpp | 4 ++-- src/playlistparsers/asxiniparser.h | 2 +- src/playlistparsers/asxparser.cpp | 8 ++++---- src/playlistparsers/asxparser.h | 4 ++-- src/playlistparsers/cueparser.cpp | 4 ++-- src/playlistparsers/cueparser.h | 2 +- src/playlistparsers/m3uparser.cpp | 4 ++-- src/playlistparsers/m3uparser.h | 2 +- src/playlistparsers/parserbase.cpp | 8 ++++---- src/playlistparsers/parserbase.h | 4 ++-- src/playlistparsers/plsparser.cpp | 4 ++-- src/playlistparsers/plsparser.h | 2 +- src/playlistparsers/wplparser.cpp | 8 ++++---- src/playlistparsers/wplparser.h | 4 ++-- src/playlistparsers/xspfparser.cpp | 17 +++++++++-------- src/playlistparsers/xspfparser.h | 4 ++-- 16 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/playlistparsers/asxiniparser.cpp b/src/playlistparsers/asxiniparser.cpp index 6a94adf33..27e634925 100644 --- a/src/playlistparsers/asxiniparser.cpp +++ b/src/playlistparsers/asxiniparser.cpp @@ -46,7 +46,7 @@ bool AsxIniParser::TryMagic(const QByteArray &data) const { return data.toLower().contains("[reference]"); } -SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_search) const { +SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const { Q_UNUSED(playlist_path); @@ -59,7 +59,7 @@ SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, con QString value = line.mid(equals + 1); if (key.startsWith(QLatin1String("ref"))) { - Song song = LoadSong(value, 0, 0, dir, collection_search); + Song song = LoadSong(value, 0, 0, dir, collection_lookup); if (song.is_valid()) { ret << song; } diff --git a/src/playlistparsers/asxiniparser.h b/src/playlistparsers/asxiniparser.h index def750d5f..25886e49b 100644 --- a/src/playlistparsers/asxiniparser.h +++ b/src/playlistparsers/asxiniparser.h @@ -50,7 +50,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_search = true) 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; }; diff --git a/src/playlistparsers/asxparser.cpp b/src/playlistparsers/asxparser.cpp index 4247dd707..a69ab7672 100644 --- a/src/playlistparsers/asxparser.cpp +++ b/src/playlistparsers/asxparser.cpp @@ -40,7 +40,7 @@ class CollectionBackendInterface; ASXParser::ASXParser(SharedPtr 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 { +SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const { Q_UNUSED(playlist_path); @@ -71,7 +71,7 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const SongList ret; while (!reader.atEnd() && Utilities::ParseUntilElementCI(&reader, QStringLiteral("entry"))) { - Song song = ParseTrack(&reader, dir, collection_search); + Song song = ParseTrack(&reader, dir, collection_lookup); if (song.is_valid()) { ret << song; } @@ -83,7 +83,7 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const } -Song ASXParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_search) const { +Song ASXParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_lookup) const { QString title, artist, album, ref; @@ -117,7 +117,7 @@ Song ASXParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool } return_song: - Song song = LoadSong(ref, 0, 0, dir, collection_search); + Song song = LoadSong(ref, 0, 0, dir, collection_lookup); // Override metadata with what was in the playlist if (song.source() != Song::Source::Collection) { diff --git a/src/playlistparsers/asxparser.h b/src/playlistparsers/asxparser.h index da4f66897..095ab8357 100644 --- a/src/playlistparsers/asxparser.h +++ b/src/playlistparsers/asxparser.h @@ -52,11 +52,11 @@ 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_search = true) 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; private: - Song ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_search) const; + Song ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_lookup) const; }; #endif diff --git a/src/playlistparsers/cueparser.cpp b/src/playlistparsers/cueparser.cpp index e9b8cd9f8..e5065ff76 100644 --- a/src/playlistparsers/cueparser.cpp +++ b/src/playlistparsers/cueparser.cpp @@ -68,7 +68,7 @@ constexpr char kDisc[] = "discnumber"; CueParser::CueParser(SharedPtr 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 { +SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const { SongList ret; @@ -266,7 +266,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const for (int i = 0; i < entries.length(); i++) { CueEntry entry = entries.at(i); - Song song = LoadSong(entry.file, IndexToMarker(entry.index), 0, dir, collection_search); + Song song = LoadSong(entry.file, IndexToMarker(entry.index), 0, dir, collection_lookup); // Cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime) if (cue_mtime.isValid()) { diff --git a/src/playlistparsers/cueparser.h b/src/playlistparsers/cueparser.h index acfde8f0a..35c30ed71 100644 --- a/src/playlistparsers/cueparser.h +++ b/src/playlistparsers/cueparser.h @@ -55,7 +55,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_search = true) 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; static QString FindCueFilename(const QString &filename); diff --git a/src/playlistparsers/m3uparser.cpp b/src/playlistparsers/m3uparser.cpp index 7240b9fa2..4a3c2231e 100644 --- a/src/playlistparsers/m3uparser.cpp +++ b/src/playlistparsers/m3uparser.cpp @@ -40,7 +40,7 @@ class CollectionBackendInterface; M3UParser::M3UParser(SharedPtr 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 { +SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const { Q_UNUSED(playlist_path); @@ -72,7 +72,7 @@ SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const } } else if (!line.isEmpty()) { - Song song = LoadSong(line, 0, 0, dir, collection_search); + Song song = LoadSong(line, 0, 0, dir, collection_lookup); if (!current_metadata.title.isEmpty()) { song.set_title(current_metadata.title); } diff --git a/src/playlistparsers/m3uparser.h b/src/playlistparsers/m3uparser.h index 51f461ae7..c270d7136 100644 --- a/src/playlistparsers/m3uparser.h +++ b/src/playlistparsers/m3uparser.h @@ -52,7 +52,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_search = true) 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; private: diff --git a/src/playlistparsers/parserbase.cpp b/src/playlistparsers/parserbase.cpp index 70636116d..f9501aee3 100644 --- a/src/playlistparsers/parserbase.cpp +++ b/src/playlistparsers/parserbase.cpp @@ -37,7 +37,7 @@ ParserBase::ParserBase(SharedPtr collection_backend, QObject *parent) : QObject(parent), 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_search) const { +void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, Song *song, const bool collection_lookup) const { if (filename_or_url.isEmpty()) { return; @@ -74,7 +74,7 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning const QUrl url = QUrl::fromLocalFile(filename); // Search the collection - if (collection_backend_ && collection_search) { + if (collection_backend_ && collection_lookup) { Song collection_song; if (track > 0) { collection_song = collection_backend_->GetSongByUrlAndTrack(url, track); @@ -106,10 +106,10 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning } -Song ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, const bool collection_search) const { +Song ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, const bool collection_lookup) const { Song song(Song::Source::LocalFile); - LoadSong(filename_or_url, beginning, track, dir, &song, collection_search); + LoadSong(filename_or_url, beginning, track, dir, &song, collection_lookup); return song; diff --git a/src/playlistparsers/parserbase.h b/src/playlistparsers/parserbase.h index 3ab8dd5e6..5ac122c2d 100644 --- a/src/playlistparsers/parserbase.h +++ b/src/playlistparsers/parserbase.h @@ -68,8 +68,8 @@ class ParserBase : public QObject { // Loads a song. If filename_or_url is a URL (with a scheme other than "file") then it is set on the song and the song marked as a stream. // Also sets the song's metadata by searching in the Collection, or loading from the file as a fallback. // This function should always be used when loading a playlist. - Song LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, const bool collection_search) const; - void LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, Song *song, const bool collection_search) const; + Song LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, const bool collection_lookup) const; + void LoadSong(const QString &filename_or_url, const qint64 beginning, const int track, const QDir &dir, Song *song, const bool collection_lookup) const; // 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. diff --git a/src/playlistparsers/plsparser.cpp b/src/playlistparsers/plsparser.cpp index 591b2f546..49372a45c 100644 --- a/src/playlistparsers/plsparser.cpp +++ b/src/playlistparsers/plsparser.cpp @@ -45,7 +45,7 @@ constexpr auto qt_endl = endl; PLSParser::PLSParser(SharedPtr 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 { +SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const { Q_UNUSED(playlist_path); @@ -62,7 +62,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const int n = re_match.captured(0).toInt(); if (key.startsWith(QLatin1String("file"))) { - Song song = LoadSong(value, 0, 0, dir, collection_search); + Song song = LoadSong(value, 0, 0, dir, collection_lookup); // Use the title and length we've already loaded if any if (!songs[n].title().isEmpty()) song.set_title(songs[n].title()); diff --git a/src/playlistparsers/plsparser.h b/src/playlistparsers/plsparser.h index 732746832..efca35033 100644 --- a/src/playlistparsers/plsparser.h +++ b/src/playlistparsers/plsparser.h @@ -51,7 +51,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_search = true) 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; }; diff --git a/src/playlistparsers/wplparser.cpp b/src/playlistparsers/wplparser.cpp index 3078840dd..8baac5121 100644 --- a/src/playlistparsers/wplparser.cpp +++ b/src/playlistparsers/wplparser.cpp @@ -44,7 +44,7 @@ bool WplParser::TryMagic(const QByteArray &data) const { return data.contains(""); } -SongList WplParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_search) const { +SongList WplParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const { Q_UNUSED(playlist_path); @@ -56,13 +56,13 @@ SongList WplParser::Load(QIODevice *device, const QString &playlist_path, const } while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, QStringLiteral("seq"))) { - ParseSeq(dir, &reader, &ret, collection_search); + ParseSeq(dir, &reader, &ret, collection_lookup); } return ret; } -void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *songs, const bool collection_search) const { +void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *songs, const bool collection_lookup) const { while (!reader->atEnd()) { QXmlStreamReader::TokenType type = reader->readNext(); @@ -72,7 +72,7 @@ void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *so if (name == QLatin1String("media")) { QString src = reader->attributes().value(QLatin1String("src")).toString(); if (!src.isEmpty()) { - Song song = LoadSong(src, 0, 0, dir, collection_search); + Song song = LoadSong(src, 0, 0, dir, collection_lookup); if (song.is_valid()) { songs->append(song); } diff --git a/src/playlistparsers/wplparser.h b/src/playlistparsers/wplparser.h index 0f5df20f9..6561e4c17 100644 --- a/src/playlistparsers/wplparser.h +++ b/src/playlistparsers/wplparser.h @@ -54,11 +54,11 @@ 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_search = true) 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; private: - void ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *songs, const bool collection_search = true) const; + void ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *songs, const bool collection_lookup) const; static void WriteMeta(const QString &name, const QString &content, QXmlStreamWriter *writer); }; diff --git a/src/playlistparsers/xspfparser.cpp b/src/playlistparsers/xspfparser.cpp index 4afa864cb..f3903cdb0 100644 --- a/src/playlistparsers/xspfparser.cpp +++ b/src/playlistparsers/xspfparser.cpp @@ -42,28 +42,29 @@ class CollectionBackendInterface; XSPFParser::XSPFParser(SharedPtr 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 { +SongList XSPFParser::Load(QIODevice *device, const QString &playlist_path, const QDir &dir, const bool collection_lookup) const { Q_UNUSED(playlist_path); - SongList ret; + SongList songs; QXmlStreamReader reader(device); if (!Utilities::ParseUntilElement(&reader, QStringLiteral("playlist")) || !Utilities::ParseUntilElement(&reader, QStringLiteral("trackList"))) { - return ret; + return songs; } while (!reader.atEnd() && Utilities::ParseUntilElement(&reader, QStringLiteral("track"))) { - Song song = ParseTrack(&reader, dir, collection_search); + const Song song = ParseTrack(&reader, dir, collection_lookup); if (song.is_valid()) { - ret << song; + songs << song; } } - return ret; + + return songs; } -Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_search) const { +Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_lookup) const { QString title, artist, album, location, art; qint64 nanosec = -1; @@ -121,7 +122,7 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo } return_song: - Song song = LoadSong(location, 0, track_num, dir, collection_search); + Song song = LoadSong(location, 0, track_num, dir, collection_lookup); // Override metadata with what was in the playlist if (song.source() != Song::Source::Collection) { diff --git a/src/playlistparsers/xspfparser.h b/src/playlistparsers/xspfparser.h index 665ad0a87..84a3014d1 100644 --- a/src/playlistparsers/xspfparser.h +++ b/src/playlistparsers/xspfparser.h @@ -51,11 +51,11 @@ 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_search = true) 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; private: - Song ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_search) const; + Song ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool collection_lookup) const; }; #endif