Organize: Update collection directory ID and song path immediately
Fixes #781
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
@@ -429,7 +431,7 @@ SongList CollectionBackend::SongsWithMissingFingerprint(const int id) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_file) {
|
||||
void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_file, const std::optional<int> new_collection_directory_id) {
|
||||
|
||||
// Take a song and update its path
|
||||
Song updated_song = song;
|
||||
@@ -437,6 +439,9 @@ void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_f
|
||||
updated_song.set_url(QUrl::fromLocalFile(new_file.absoluteFilePath()));
|
||||
updated_song.set_basefilename(new_file.fileName());
|
||||
updated_song.InitArtManual();
|
||||
if (updated_song.is_collection_song() && new_collection_directory_id) {
|
||||
updated_song.set_directory_id(new_collection_directory_id.value());
|
||||
}
|
||||
|
||||
AddOrUpdateSongs(SongList() << updated_song);
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QFileInfo>
|
||||
@@ -228,7 +230,7 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
void IncrementPlayCount(const int id);
|
||||
void IncrementSkipCount(const int id, const float progress);
|
||||
void ResetStatistics(const int id);
|
||||
void SongPathChanged(const Song &song, const QFileInfo &new_file);
|
||||
void SongPathChanged(const Song &song, const QFileInfo &new_file, const std::optional<int> new_collection_directory_id);
|
||||
|
||||
SongList GetSongsBy(const QString &artist, const QString &album, const QString &title);
|
||||
void UpdateLastPlayed(const QString &artist, const QString &album, const QString &title, const qint64 lastplayed);
|
||||
|
||||
@@ -51,7 +51,7 @@ void CollectionDirectoryModel::DirectoryDiscovered(const Directory &dir) {
|
||||
QStandardItem *item = new QStandardItem(dir.path);
|
||||
item->setData(dir.id, kIdRole);
|
||||
item->setIcon(dir_icon_);
|
||||
storage_ << std::make_shared<FilesystemMusicStorage>(dir.path);
|
||||
storage_ << std::make_shared<FilesystemMusicStorage>(dir.path, dir.id);
|
||||
appendRow(item);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user