Notify collection backend about renamed files when organising files

This commit is contained in:
Jonas Kvinge
2019-03-25 00:53:12 +01:00
parent fc1a2dac90
commit 15c8f2a3ee
9 changed files with 34 additions and 7 deletions

View File

@@ -323,6 +323,17 @@ SongList CollectionBackend::FindSongsInDirectory(int id) {
}
void CollectionBackend::SongPathChanged(const Song &song, const QFileInfo &new_file) {
// Take a song and update its path
Song updated_song = song;
updated_song.InitFromFilePartial(new_file.absoluteFilePath());
SongList updated_songs;
updated_songs << updated_song;
AddOrUpdateSongs(updated_songs);
}
void CollectionBackend::AddOrUpdateSubdirs(const SubdirectoryList &subdirs) {
QMutexLocker l(db_->Mutex());
@@ -575,10 +586,8 @@ QStringList CollectionBackend::GetAllArtistsWithAlbums(const QueryOptions &opt)
}
}
// QStringList ret;
QSet<QString> artists;
while (query.Next()) {
//ret << query.Value(0).toString();
artists << query.Value(0).toString();
}
@@ -586,8 +595,8 @@ QStringList CollectionBackend::GetAllArtistsWithAlbums(const QueryOptions &opt)
artists << query2.Value(0).toString();
}
// return ret;
return QStringList(artists.toList());
}
CollectionBackend::AlbumList CollectionBackend::GetAllAlbums(const QueryOptions &opt) {

View File

@@ -27,6 +27,7 @@
#include <QtGlobal>
#include <QObject>
#include <QFileInfo>
#include <QList>
#include <QVector>
#include <QSet>
@@ -194,6 +195,7 @@ class CollectionBackend : public CollectionBackendInterface {
void IncrementPlayCount(int id);
void IncrementSkipCount(int id, float progress);
void ResetStatistics(int id);
void SongPathChanged(const Song &song, const QFileInfo &new_file);
signals:
void DirectoryDiscovered(const Directory &dir, const SubdirectoryList &subdirs);

View File

@@ -655,7 +655,7 @@ SongList CollectionView::GetSelectedSongs() const {
void CollectionView::Organise() {
if (!organise_dialog_)
organise_dialog_.reset(new OrganiseDialog(app_->task_manager()));
organise_dialog_.reset(new OrganiseDialog(app_->task_manager(), app_->collection_backend()));
organise_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
organise_dialog_->SetCopy(false);