Fix updating play and skip count

This commit is contained in:
Jonas Kvinge
2019-04-19 14:02:28 +02:00
parent dffc46551e
commit 40db9f7020
7 changed files with 13 additions and 1 deletions

View File

@@ -91,6 +91,7 @@ void SCollection::Init() {
connect(watcher_, SIGNAL(SubdirsDiscovered(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); connect(watcher_, SIGNAL(SubdirsDiscovered(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList)));
connect(watcher_, SIGNAL(SubdirsMTimeUpdated(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList))); connect(watcher_, SIGNAL(SubdirsMTimeUpdated(SubdirectoryList)), backend_, SLOT(AddOrUpdateSubdirs(SubdirectoryList)));
connect(watcher_, SIGNAL(CompilationsNeedUpdating()), backend_, SLOT(UpdateCompilations())); 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_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(CurrentSongChanged(Song)));
connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped())); connect(app_->player(), SIGNAL(Stopped()), SLOT(Stopped()));
@@ -126,3 +127,6 @@ void SCollection::CurrentSongChanged(const Song &song) { // FIXME
} }
} }
void SCollection::SongsStatisticsChanged(const SongList &songs) {
}

View File

@@ -71,6 +71,7 @@ class SCollection : public QObject {
void IncrementalScan(); void IncrementalScan();
void CurrentSongChanged(const Song &song); void CurrentSongChanged(const Song &song);
void SongsStatisticsChanged(const SongList& songs);
void Stopped(); void Stopped();
private: private:

View File

@@ -1068,6 +1068,7 @@ bool CollectionBackend::ExecQuery(CollectionQuery *q) {
} }
void CollectionBackend::IncrementPlayCount(int id) { void CollectionBackend::IncrementPlayCount(int id) {
if (id == -1) return; if (id == -1) return;
QMutexLocker l(db_->Mutex()); QMutexLocker l(db_->Mutex());
@@ -1081,6 +1082,7 @@ void CollectionBackend::IncrementPlayCount(int id) {
if (db_->CheckErrors(q)) return; if (db_->CheckErrors(q)) return;
Song new_song = GetSongById(id, db); 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; if (db_->CheckErrors(q)) return;
Song new_song = GetSongById(id, db); 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; if (db_->CheckErrors(q)) return;
Song new_song = GetSongById(id, db); Song new_song = GetSongById(id, db);
emit SongsStatisticsChanged(SongList() << new_song);
} }

View File

@@ -202,6 +202,7 @@ signals:
void SongsDiscovered(const SongList &songs); void SongsDiscovered(const SongList &songs);
void SongsDeleted(const SongList &songs); void SongsDeleted(const SongList &songs);
void SongsStatisticsChanged(const SongList& songs);
void DatabaseReset(); void DatabaseReset();

View File

@@ -121,6 +121,7 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q
connect(backend_, SIGNAL(TotalSongCountUpdated(int)), SLOT(TotalSongCountUpdatedSlot(int))); connect(backend_, SIGNAL(TotalSongCountUpdated(int)), SLOT(TotalSongCountUpdatedSlot(int)));
connect(backend_, SIGNAL(TotalArtistCountUpdated(int)), SLOT(TotalArtistCountUpdatedSlot(int))); connect(backend_, SIGNAL(TotalArtistCountUpdated(int)), SLOT(TotalArtistCountUpdatedSlot(int)));
connect(backend_, SIGNAL(TotalAlbumCountUpdated(int)), SLOT(TotalAlbumCountUpdatedSlot(int))); connect(backend_, SIGNAL(TotalAlbumCountUpdated(int)), SLOT(TotalAlbumCountUpdatedSlot(int)));
connect(backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsSlightlyChanged(SongList)));
backend_->UpdateTotalSongCountAsync(); backend_->UpdateTotalSongCountAsync();
backend_->UpdateTotalArtistCountAsync(); backend_->UpdateTotalArtistCountAsync();

View File

@@ -380,7 +380,7 @@ void Player::TrackEnded() {
if (HandleStopAfter()) return; if (HandleStopAfter()) return;
if (current_item_ && current_item_->IsLocalCollectionItem() && current_item_->Metadata().id() != -1) { 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); NextInternal(Engine::Auto);

View File

@@ -90,6 +90,7 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken
playlist_container_ = playlist_container; playlist_container_ = playlist_container;
connect(collection_backend_, SIGNAL(SongsDiscovered(SongList)), SLOT(SongsDiscovered(SongList))); 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()) { for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) {
AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite); AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);