@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user