From e3587d369e7ca9acc652e5c29328eefd9ff79622 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 10 Sep 2020 22:05:12 +0200 Subject: [PATCH] Add const --- src/collection/collectionbackend.cpp | 30 ++++++++++++++-------------- src/collection/collectionbackend.h | 10 +++++----- src/collection/collectionview.cpp | 12 +++++------ src/collection/collectionview.h | 10 +++++----- src/playlist/playlistmanager.cpp | 2 +- src/playlist/playlistmanager.h | 18 ++++++++--------- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/collection/collectionbackend.cpp b/src/collection/collectionbackend.cpp index 6d1500fd5..df9e0b3fc 100644 --- a/src/collection/collectionbackend.cpp +++ b/src/collection/collectionbackend.cpp @@ -109,15 +109,15 @@ void CollectionBackend::UpdateTotalAlbumCountAsync() { metaObject()->invokeMethod(this, "UpdateTotalAlbumCount", Qt::QueuedConnection); } -void CollectionBackend::IncrementPlayCountAsync(int id) { +void CollectionBackend::IncrementPlayCountAsync(const int id) { metaObject()->invokeMethod(this, "IncrementPlayCount", Qt::QueuedConnection, Q_ARG(int, id)); } -void CollectionBackend::IncrementSkipCountAsync(int id, float progress) { +void CollectionBackend::IncrementSkipCountAsync(const int id, const float progress) { metaObject()->invokeMethod(this, "IncrementSkipCount", Qt::QueuedConnection, Q_ARG(int, id), Q_ARG(float, progress)); } -void CollectionBackend::ResetStatisticsAsync(int id) { +void CollectionBackend::ResetStatisticsAsync(const int id) { metaObject()->invokeMethod(this, "ResetStatistics", Qt::QueuedConnection, Q_ARG(int, id)); } @@ -134,7 +134,7 @@ void CollectionBackend::LoadDirectories() { } -void CollectionBackend::ChangeDirPath(int id, const QString &old_path, const QString &new_path) { +void CollectionBackend::ChangeDirPath(const int id, const QString &old_path, const QString &new_path) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); @@ -202,7 +202,7 @@ DirectoryList CollectionBackend::GetAllDirectories() { } -SubdirectoryList CollectionBackend::SubdirsInDirectory(int id) { +SubdirectoryList CollectionBackend::SubdirsInDirectory(const int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db = db_->Connect(); @@ -210,7 +210,7 @@ SubdirectoryList CollectionBackend::SubdirsInDirectory(int id) { } -SubdirectoryList CollectionBackend::SubdirsInDirectory(int id, QSqlDatabase &db) { +SubdirectoryList CollectionBackend::SubdirsInDirectory(const int id, QSqlDatabase &db) { QSqlQuery q(db); q.prepare(QString("SELECT path, mtime FROM %1 WHERE directory_id = :dir").arg(subdirs_table_)); @@ -328,7 +328,7 @@ void CollectionBackend::RemoveDirectory(const Directory &dir) { } -SongList CollectionBackend::FindSongsInDirectory(int id) { +SongList CollectionBackend::FindSongsInDirectory(const int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); @@ -582,7 +582,7 @@ void CollectionBackend::DeleteSongs(const SongList &songs) { } -void CollectionBackend::MarkSongsUnavailable(const SongList &songs, bool unavailable) { +void CollectionBackend::MarkSongsUnavailable(const SongList &songs, const bool unavailable) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); @@ -701,7 +701,7 @@ SongList CollectionBackend::ExecCollectionQuery(CollectionQuery *query) { } -Song CollectionBackend::GetSongById(int id) { +Song CollectionBackend::GetSongById(const int id) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); return GetSongById(id, db); @@ -750,7 +750,7 @@ SongList CollectionBackend::GetSongsByForeignId(const QStringList &ids, const QS } -Song CollectionBackend::GetSongById(int id, QSqlDatabase &db) { +Song CollectionBackend::GetSongById(const int id, QSqlDatabase &db) { SongList list = GetSongsById(QStringList() << QString::number(id), db); if (list.isEmpty()) return Song(); return list.first(); @@ -1168,7 +1168,7 @@ void CollectionBackend::UpdateManualAlbumArt(const QString &artist, const QStrin } -void CollectionBackend::ForceCompilation(const QString &album, const QList &artists, bool on) { +void CollectionBackend::ForceCompilation(const QString &album, const QList &artists, const bool on) { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); @@ -1179,7 +1179,7 @@ void CollectionBackend::ForceCompilation(const QString &album, const QListCheckErrors(q->Exec(db_->Connect(), songs_table_, fts_table_)); } -void CollectionBackend::IncrementPlayCount(int id) { +void CollectionBackend::IncrementPlayCount(const int id) { if (id == -1) return; @@ -1243,7 +1243,7 @@ void CollectionBackend::IncrementPlayCount(int id) { } -void CollectionBackend::IncrementSkipCount(int id, float progress) { +void CollectionBackend::IncrementSkipCount(const int id, const float progress) { Q_UNUSED(progress); @@ -1263,7 +1263,7 @@ void CollectionBackend::IncrementSkipCount(int id, float progress) { } -void CollectionBackend::ResetStatistics(int id) { +void CollectionBackend::ResetStatistics(const int id) { if (id == -1) return; diff --git a/src/collection/collectionbackend.h b/src/collection/collectionbackend.h index 35fe17141..c96e4cfde 100644 --- a/src/collection/collectionbackend.h +++ b/src/collection/collectionbackend.h @@ -80,10 +80,10 @@ class CollectionBackendInterface : public QObject { virtual void UpdateTotalArtistCountAsync() = 0; virtual void UpdateTotalAlbumCountAsync() = 0; - virtual SongList FindSongsInDirectory(int id) = 0; - virtual SubdirectoryList SubdirsInDirectory(int id) = 0; + virtual SongList FindSongsInDirectory(const int id) = 0; + virtual SubdirectoryList SubdirsInDirectory(const int id) = 0; virtual DirectoryList GetAllDirectories() = 0; - virtual void ChangeDirPath(int id, const QString &old_path, const QString &new_path) = 0; + virtual void ChangeDirPath(const int id, const QString &old_path, const QString &new_path) = 0; virtual QStringList GetAllArtists(const QueryOptions &opt = QueryOptions()) = 0; virtual QStringList GetAllArtistsWithAlbums(const QueryOptions &opt = QueryOptions()) = 0; @@ -99,7 +99,7 @@ class CollectionBackendInterface : public QObject { virtual void UpdateManualAlbumArtAsync(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url) = 0; virtual Album GetAlbumArt(const QString &artist, const QString &albumartist, const QString &album) = 0; - virtual Song GetSongById(int id) = 0; + virtual Song GetSongById(const int id) = 0; // Returns all sections of a song with the given filename. If there's just one section the resulting list will have it's size equal to 1. virtual SongList GetSongsByUrl(const QUrl &url) = 0; @@ -195,7 +195,7 @@ class CollectionBackend : public CollectionBackendInterface { void AddOrUpdateSongs(const SongList &songs); void UpdateMTimesOnly(const SongList &songs); void DeleteSongs(const SongList &songs); - void MarkSongsUnavailable(const SongList &songs, bool unavailable = true); + void MarkSongsUnavailable(const SongList &songs, const bool unavailable = true); void AddOrUpdateSubdirs(const SubdirectoryList &subdirs); void UpdateCompilations(); void UpdateManualAlbumArt(const QString &artist, const QString &albumartist, const QString &album, const QUrl &cover_url); diff --git a/src/collection/collectionview.cpp b/src/collection/collectionview.cpp index 55fb41f1c..afef9ec19 100644 --- a/src/collection/collectionview.cpp +++ b/src/collection/collectionview.cpp @@ -247,7 +247,7 @@ void CollectionView::SetApplication(Application *app) { void CollectionView::SetFilter(CollectionFilterWidget *filter) { filter_ = filter; } -void CollectionView::TotalSongCountUpdated(int count) { +void CollectionView::TotalSongCountUpdated(const int count) { int old = total_song_count_; total_song_count_ = count; @@ -262,7 +262,7 @@ void CollectionView::TotalSongCountUpdated(int count) { } -void CollectionView::TotalArtistCountUpdated(int count) { +void CollectionView::TotalArtistCountUpdated(const int count) { int old = total_artist_count_; total_artist_count_ = count; @@ -277,7 +277,7 @@ void CollectionView::TotalArtistCountUpdated(int count) { } -void CollectionView::TotalAlbumCountUpdated(int count) { +void CollectionView::TotalAlbumCountUpdated(const int count) { int old = total_album_count_; total_album_count_ = count; @@ -446,7 +446,7 @@ void CollectionView::ShowInVarious() { ShowInVarious(true); } void CollectionView::NoShowInVarious() { ShowInVarious(false); } -void CollectionView::ShowInVarious(bool on) { +void CollectionView::ShowInVarious(const bool on) { if (!context_menu_index_.isValid()) return; @@ -454,7 +454,7 @@ void CollectionView::ShowInVarious(bool on) { // We put through "Various Artists" changes one album at a time, // to make sure the old album node gets removed (due to all children removed), before the new one gets added QMultiMap albums; - for (const Song& song : GetSelectedSongs()) { + for (const Song &song : GetSelectedSongs()) { if (albums.find(song.album(), song.artist()) == albums.end()) albums.insert(song.album(), song.artist()); } @@ -473,7 +473,7 @@ void CollectionView::ShowInVarious(bool on) { if (other_artists.count() > 0) { if (QMessageBox::question(this, tr("There are other songs in this album"), - tr("Would you like to move the other songs in this album to Various Artists as well?"), + tr("Would you like to move the other songs on this album to Various Artists as well?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) { for (const QString &s : other_artists) { diff --git a/src/collection/collectionview.h b/src/collection/collectionview.h index 77d9a040d..723acb9e2 100644 --- a/src/collection/collectionview.h +++ b/src/collection/collectionview.h @@ -70,9 +70,9 @@ class CollectionView : public AutoExpandingTreeView { int TotalAlbums(); public slots: - void TotalSongCountUpdated(int count); - void TotalArtistCountUpdated(int count); - void TotalAlbumCountUpdated(int count); + void TotalSongCountUpdated(const int count); + void TotalArtistCountUpdated(const int count); + void TotalAlbumCountUpdated(const int count); void ReloadSettings(); void FilterReturnPressed(); @@ -88,7 +88,7 @@ class CollectionView : public AutoExpandingTreeView { void TotalSongCountUpdated_(); void TotalArtistCountUpdated_(); void TotalAlbumCountUpdated_(); - void Error(const QString &message); + void Error(QString); protected: // QWidget @@ -114,7 +114,7 @@ class CollectionView : public AutoExpandingTreeView { private: void RecheckIsEmpty(); - void ShowInVarious(bool on); + void ShowInVarious(const bool on); bool RestoreLevelFocus(const QModelIndex &parent = QModelIndex()); void SaveContainerPath(const QModelIndex &child); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index fc90131c9..b4aa21474 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -132,7 +132,7 @@ QList PlaylistManager::GetAllPlaylists() const { } -QItemSelection PlaylistManager::selection(int id) const { +QItemSelection PlaylistManager::selection(const int id) const { QMap::const_iterator it = playlists_.find(id); return it->selection; } diff --git a/src/playlist/playlistmanager.h b/src/playlist/playlistmanager.h index dcfd39e04..e8a862e21 100644 --- a/src/playlist/playlistmanager.h +++ b/src/playlist/playlistmanager.h @@ -53,7 +53,7 @@ class PlaylistManagerInterface : public QObject { virtual int current_id() const = 0; virtual int active_id() const = 0; - virtual Playlist *playlist(int id) const = 0; + virtual Playlist *playlist(const int id) const = 0; virtual Playlist *current() const = 0; virtual Playlist *active() const = 0; @@ -107,12 +107,12 @@ class PlaylistManagerInterface : public QObject { void PlaylistManagerInitialized(); void AllPlaylistsLoaded(); - void PlaylistAdded(int id, QString name, bool favorite); - void PlaylistDeleted(int id); - void PlaylistClosed(int id); - void PlaylistRenamed(int id, QString new_name); - void PlaylistFavorited(int id, bool favorite); - void CurrentChanged(Playlist *new_playlist, int scroll_position = 0); + void PlaylistAdded(const int id, QString name, const bool favorite); + void PlaylistDeleted(const int id); + void PlaylistClosed(const int id); + void PlaylistRenamed(const int id, QString new_name); + void PlaylistFavorited(const int id, const bool favorite); + void CurrentChanged(Playlist *new_playlist, const int scroll_position = 0); void ActiveChanged(Playlist *new_playlist); void Error(QString message); @@ -158,8 +158,8 @@ class PlaylistManager : public PlaylistManagerInterface { QItemSelection current_selection() const override { return selection(current_id()); } QItemSelection active_selection() const override { return selection(active_id()); } - QString GetPlaylistName(int index) const override { return playlists_[index].name; } - bool IsPlaylistFavorite(int index) const { return playlists_[index].p->is_favorite(); } + QString GetPlaylistName(const int index) const override { return playlists_[index].name; } + bool IsPlaylistFavorite(const int index) const { return playlists_[index].p->is_favorite(); } void Init(CollectionBackend *collection_backend, PlaylistBackend *playlist_backend, PlaylistSequence *sequence, PlaylistContainer *playlist_container);