Add const

This commit is contained in:
Jonas Kvinge 2020-09-10 22:05:12 +02:00
parent 2a048502cc
commit e3587d369e
6 changed files with 41 additions and 41 deletions

View File

@ -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<QString> &artists, bool on) {
void CollectionBackend::ForceCompilation(const QString &album, const QList<QString> &artists, const bool on) {
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
@ -1179,7 +1179,7 @@ void CollectionBackend::ForceCompilation(const QString &album, const QList<QStri
CollectionQuery query;
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
query.AddWhere("album", album);
if (!artist.isNull() && !artist.isEmpty()) query.AddWhere("artist", artist);
if (!artist.isEmpty()) query.AddWhere("artist", artist);
if (!ExecQuery(&query)) return;
@ -1224,7 +1224,7 @@ bool CollectionBackend::ExecQuery(CollectionQuery *q) {
return !db_->CheckErrors(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;

View File

@ -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);

View File

@ -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<QString, QString> 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) {

View File

@ -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);

View File

@ -132,7 +132,7 @@ QList<Playlist*> PlaylistManager::GetAllPlaylists() const {
}
QItemSelection PlaylistManager::selection(int id) const {
QItemSelection PlaylistManager::selection(const int id) const {
QMap<int, Data>::const_iterator it = playlists_.find(id);
return it->selection;
}

View File

@ -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);