diff --git a/src/collection/collection.cpp b/src/collection/collection.cpp index 4d6c854ea..28f86e204 100644 --- a/src/collection/collection.cpp +++ b/src/collection/collection.cpp @@ -91,6 +91,7 @@ void SCollection::Init() { connect(watcher_, SIGNAL(SubdirsDiscovered(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); connect(watcher_, SIGNAL(SubdirsMTimeUpdated(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); connect(watcher_, SIGNAL(CompilationsNeedUpdating()), backend_, SLOT(UpdateCompilations())); + connect(backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsStatisticsChanged(SongList))); connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song))); connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped())); @@ -126,3 +127,6 @@ void SCollection::CurrentSongChanged(const Song &song) { // FIXME } } + +void SCollection::SongsStatisticsChanged(const SongList &songs) { +} diff --git a/src/collection/collection.h b/src/collection/collection.h index decf4bd5d..6ef900f4e 100644 --- a/src/collection/collection.h +++ b/src/collection/collection.h @@ -71,6 +71,7 @@ class SCollection : public QObject { void IncrementalScan(); void CurrentSongChanged(const Song &song); + void SongsStatisticsChanged(const SongList& songs); void Stopped(); private: diff --git a/src/collection/collectionbackend.cpp b/src/collection/collectionbackend.cpp index 66b619684..9b2777235 100644 --- a/src/collection/collectionbackend.cpp +++ b/src/collection/collectionbackend.cpp @@ -1068,6 +1068,7 @@ bool CollectionBackend::ExecQuery(CollectionQuery *q) { } void CollectionBackend::IncrementPlayCount(int id) { + if (id == -1) return; QMutexLocker l(db_->Mutex()); @@ -1081,6 +1082,7 @@ void CollectionBackend::IncrementPlayCount(int id) { if (db_->CheckErrors(q)) return; Song new_song = GetSongById(id, db); + emit SongsStatisticsChanged(SongList() << new_song); } @@ -1098,6 +1100,7 @@ void CollectionBackend::IncrementSkipCount(int id, float progress) { if (db_->CheckErrors(q)) return; Song new_song = GetSongById(id, db); + emit SongsStatisticsChanged(SongList() << new_song); } @@ -1115,6 +1118,7 @@ void CollectionBackend::ResetStatistics(int id) { if (db_->CheckErrors(q)) return; Song new_song = GetSongById(id, db); + emit SongsStatisticsChanged(SongList() << new_song); } diff --git a/src/collection/collectionbackend.h b/src/collection/collectionbackend.h index 6df0abf85..f728e9fba 100644 --- a/src/collection/collectionbackend.h +++ b/src/collection/collectionbackend.h @@ -202,6 +202,7 @@ signals: void SongsDiscovered(const SongList &songs); void SongsDeleted(const SongList &songs); + void SongsStatisticsChanged(const SongList& songs); void DatabaseReset(); diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 7ecc700ee..74dd04062 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -121,6 +121,7 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q connect(backend_, SIGNAL(TotalSongCountUpdated(int)), SLOT(TotalSongCountUpdatedSlot(int))); connect(backend_, SIGNAL(TotalArtistCountUpdated(int)), SLOT(TotalArtistCountUpdatedSlot(int))); connect(backend_, SIGNAL(TotalAlbumCountUpdated(int)), SLOT(TotalAlbumCountUpdatedSlot(int))); + connect(backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsSlightlyChanged(SongList))); backend_->UpdateTotalSongCountAsync(); backend_->UpdateTotalArtistCountAsync(); diff --git a/src/core/player.cpp b/src/core/player.cpp index bcda8d4ce..07523799d 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -380,7 +380,7 @@ void Player::TrackEnded() { if (HandleStopAfter()) return; if (current_item_ && current_item_->IsLocalCollectionItem() && current_item_->Metadata().id() != -1) { - app_->playlist_manager()->collection_backend()->IncrementPlayCountAsync( current_item_->Metadata().id()); + app_->playlist_manager()->collection_backend()->IncrementPlayCountAsync(current_item_->Metadata().id()); } NextInternal(Engine::Auto); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 632734129..c8476840e 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -90,6 +90,7 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken playlist_container_ = playlist_container; connect(collection_backend_, SIGNAL(SongsDiscovered(SongList)), SLOT(SongsDiscovered(SongList))); + connect(collection_backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsDiscovered(SongList))); for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) { AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);