@@ -221,17 +221,17 @@ void PlaylistManager::Load(const QString &filename) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistManager::Save(const int id, const QString &filename, const PlaylistSettings::PathType path_type) {
|
||||
void PlaylistManager::Save(const int id, const QString &playlist_name, const QString &filename, const PlaylistSettings::PathType path_type) {
|
||||
|
||||
if (playlists_.contains(id)) {
|
||||
parser_->Save(playlist(id)->GetAllSongs(), filename, path_type);
|
||||
parser_->Save(playlist_name, playlist(id)->GetAllSongs(), filename, path_type);
|
||||
}
|
||||
else {
|
||||
// Playlist is not in the playlist manager: probably save action was triggered from the left sidebar and the playlist isn't loaded.
|
||||
QFuture<SongList> future = QtConcurrent::run(&PlaylistBackend::GetPlaylistSongs, playlist_backend_, id);
|
||||
QFutureWatcher<SongList> *watcher = new QFutureWatcher<SongList>();
|
||||
QObject::connect(watcher, &QFutureWatcher<SongList>::finished, this, [this, watcher, filename, path_type]() {
|
||||
ItemsLoadedForSavePlaylist(watcher->result(), filename, path_type);
|
||||
QObject::connect(watcher, &QFutureWatcher<SongList>::finished, this, [this, watcher, playlist_name, filename, path_type]() {
|
||||
ItemsLoadedForSavePlaylist(playlist_name, watcher->result(), filename, path_type);
|
||||
watcher->deleteLater();
|
||||
});
|
||||
watcher->setFuture(future);
|
||||
@@ -239,9 +239,9 @@ void PlaylistManager::Save(const int id, const QString &filename, const Playlist
|
||||
|
||||
}
|
||||
|
||||
void PlaylistManager::ItemsLoadedForSavePlaylist(const SongList &songs, const QString &filename, const PlaylistSettings::PathType path_type) {
|
||||
void PlaylistManager::ItemsLoadedForSavePlaylist(const QString &playlist_name, const SongList &songs, const QString &filename, const PlaylistSettings::PathType path_type) {
|
||||
|
||||
parser_->Save(songs, filename, path_type);
|
||||
parser_->Save(playlist_name, songs, filename, path_type);
|
||||
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ void PlaylistManager::SaveWithUI(const int id, const QString &playlist_name) {
|
||||
s.setValue(PlaylistSettings::kLastSaveExtension, fileinfo.suffix());
|
||||
s.endGroup();
|
||||
|
||||
Save(id == -1 ? current_id() : id, filename, path_type);
|
||||
Save(id == -1 ? current_id() : id, playlist_name, filename, path_type);
|
||||
|
||||
}
|
||||
|
||||
@@ -609,7 +609,7 @@ void PlaylistManager::SaveAllPlaylists() {
|
||||
for (QMap<int, Data>::const_iterator it = playlists_.constBegin(); it != playlists_.constEnd(); ++it) {
|
||||
const Data &data = *it;
|
||||
const QString filepath = path + QLatin1Char('/') + data.name + QLatin1Char('.') + extension;
|
||||
Save(it.key(), filepath, path_type);
|
||||
Save(it.key(), data.name, filepath, path_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
public Q_SLOTS:
|
||||
void New(const QString &name, const SongList &songs = SongList(), const QString &special_type = QString()) override;
|
||||
void Load(const QString &filename) override;
|
||||
void Save(const int id, const QString &filename, const PlaylistSettings::PathType path_type) override;
|
||||
void Save(const int id, const QString &playlist_name, const QString &filename, const PlaylistSettings::PathType path_type) override;
|
||||
// Display a file dialog to let user choose a file before saving the file
|
||||
void SaveWithUI(const int id, const QString &playlist_name);
|
||||
void Rename(const int id, const QString &new_name) override;
|
||||
@@ -148,7 +148,7 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
void OneOfPlaylistsChanged();
|
||||
void UpdateSummaryText();
|
||||
void UpdateCollectionSongs(const SongList &songs);
|
||||
void ItemsLoadedForSavePlaylist(const SongList &songs, const QString &filename, const PlaylistSettings::PathType path_type);
|
||||
void ItemsLoadedForSavePlaylist(const QString &playlist_name, const SongList &songs, const QString &filename, const PlaylistSettings::PathType path_type);
|
||||
void PlaylistLoaded();
|
||||
|
||||
private:
|
||||
|
||||
@@ -79,7 +79,7 @@ class PlaylistManagerInterface : public QObject {
|
||||
public Q_SLOTS:
|
||||
virtual void New(const QString &name, const SongList &songs = SongList(), const QString &special_type = QString()) = 0;
|
||||
virtual void Load(const QString &filename) = 0;
|
||||
virtual void Save(const int id, const QString &filename, const PlaylistSettings::PathType path_type) = 0;
|
||||
virtual void Save(const int id, const QString &playlist_name, const QString &filename, const PlaylistSettings::PathType path_type) = 0;
|
||||
virtual void Rename(const int id, const QString &new_name) = 0;
|
||||
virtual void Delete(const int id) = 0;
|
||||
virtual bool Close(const int id) = 0;
|
||||
|
||||
@@ -66,7 +66,9 @@ SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, con
|
||||
|
||||
}
|
||||
|
||||
void AsxIniParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
void AsxIniParser::Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
Q_UNUSED(playlist_name)
|
||||
|
||||
QTextStream s(device);
|
||||
s << "[Reference]" << Qt::endl;
|
||||
|
||||
@@ -52,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
void Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
};
|
||||
|
||||
#endif // ASXINIPARSER_H
|
||||
|
||||
@@ -133,8 +133,9 @@ return_song:
|
||||
|
||||
}
|
||||
|
||||
void ASXParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
void ASXParser::Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
Q_UNUSED(playlist_name)
|
||||
Q_UNUSED(dir)
|
||||
Q_UNUSED(path_type)
|
||||
|
||||
|
||||
@@ -54,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
void Save(const QString &playlist_name, 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;
|
||||
|
||||
@@ -378,8 +378,9 @@ qint64 CueParser::IndexToMarker(const QString &index) {
|
||||
|
||||
}
|
||||
|
||||
void CueParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
void CueParser::Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
Q_UNUSED(playlist_name);
|
||||
Q_UNUSED(songs);
|
||||
Q_UNUSED(device);
|
||||
Q_UNUSED(dir);
|
||||
|
||||
@@ -57,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
void Save(const QString &playlist_name, 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);
|
||||
|
||||
|
||||
@@ -125,7 +125,9 @@ bool M3UParser::ParseMetadata(const QString &line, M3UParser::Metadata *metadata
|
||||
|
||||
}
|
||||
|
||||
void M3UParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
void M3UParser::Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
Q_UNUSED(playlist_name)
|
||||
|
||||
device->write("#EXTM3U\n");
|
||||
|
||||
|
||||
@@ -54,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
void Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
|
||||
private:
|
||||
enum class M3UType {
|
||||
|
||||
@@ -60,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const = 0;
|
||||
virtual void Save(const QString &playlist_name, 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;
|
||||
|
||||
@@ -214,7 +214,7 @@ SongList PlaylistParser::LoadFromDevice(QIODevice *device, const QString &path_h
|
||||
|
||||
}
|
||||
|
||||
void PlaylistParser::Save(const SongList &songs, const QString &filename, const PlaylistSettings::PathType path_type) const {
|
||||
void PlaylistParser::Save(const QString &playlist_name, const SongList &songs, const QString &filename, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
QFileInfo fileinfo(filename);
|
||||
QDir dir(fileinfo.path());
|
||||
@@ -248,7 +248,7 @@ void PlaylistParser::Save(const SongList &songs, const QString &filename, const
|
||||
return;
|
||||
}
|
||||
|
||||
parser->Save(songs, &file, dir, path_type);
|
||||
parser->Save(playlist_name, songs, &file, dir, path_type);
|
||||
|
||||
file.close();
|
||||
|
||||
|
||||
@@ -66,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 PlaylistSettings::PathType) const;
|
||||
void Save(const QString &playlist_name, const SongList &songs, const QString &filename, const PlaylistSettings::PathType) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void Error(const QString &error) const;
|
||||
|
||||
@@ -83,7 +83,9 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
|
||||
|
||||
}
|
||||
|
||||
void PLSParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
void PLSParser::Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
Q_UNUSED(playlist_name)
|
||||
|
||||
QTextStream s(device);
|
||||
s << "[playlist]" << Qt::endl;
|
||||
|
||||
@@ -53,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
void Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir = QDir(), const PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
};
|
||||
|
||||
#endif // PLSPARSER_H
|
||||
|
||||
@@ -98,7 +98,9 @@ void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *so
|
||||
|
||||
}
|
||||
|
||||
void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
void WplParser::Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
Q_UNUSED(playlist_name)
|
||||
|
||||
QXmlStreamWriter writer(device);
|
||||
writer.setAutoFormatting(true);
|
||||
|
||||
@@ -56,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
void Save(const QString &playlist_name, 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;
|
||||
|
||||
@@ -140,7 +140,7 @@ return_song:
|
||||
|
||||
}
|
||||
|
||||
void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
void XSPFParser::Save(const QString &playlist_name, const SongList &songs, QIODevice *device, const QDir &dir, const PlaylistSettings::PathType path_type) const {
|
||||
|
||||
QXmlStreamWriter writer(device);
|
||||
writer.setAutoFormatting(true);
|
||||
@@ -150,6 +150,8 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
|
||||
writer.writeAttribute("version"_L1, "1"_L1);
|
||||
writer.writeDefaultNamespace("http://xspf.org/ns/0/"_L1);
|
||||
|
||||
writer.writeTextElement("title"_L1, playlist_name);
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(PlaylistSettings::kSettingsGroup);
|
||||
bool write_metadata = s.value(PlaylistSettings::kWriteMetadata, true).toBool();
|
||||
|
||||
@@ -53,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 PlaylistSettings::PathType path_type = PlaylistSettings::PathType::Automatic) const override;
|
||||
void Save(const QString &playlist_name, 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;
|
||||
|
||||
Reference in New Issue
Block a user