diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 8baa50294..106b9af7c 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -528,7 +528,6 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd connect(app_->player(), SIGNAL(Stopped()), SLOT(MediaStopped())); connect(app_->player(), SIGNAL(Seeked(qlonglong)), SLOT(Seeked(qlonglong))); connect(app_->player(), SIGNAL(TrackSkipped(PlaylistItemPtr)), SLOT(TrackSkipped(PlaylistItemPtr))); - connect(this, SIGNAL(IntroPointReached()), app_->player(), SLOT(IntroPointReached())); connect(app_->player(), SIGNAL(VolumeChanged(int)), SLOT(VolumeChanged(int))); connect(app_->player(), SIGNAL(Paused()), ui_->playlist, SLOT(ActivePaused())); @@ -1365,14 +1364,14 @@ void MainWindow::ResumePlaybackSeek(const int playback_position) { } -void MainWindow::PlayIndex(const QModelIndex &index) { +void MainWindow::PlayIndex(const QModelIndex &idx) { - if (!index.isValid()) return; + if (!idx.isValid()) return; - int row = index.row(); - if (index.model() == app_->playlist_manager()->current()->proxy()) { + int row = idx.row(); + if (idx.model() == app_->playlist_manager()->current()->proxy()) { // The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model. - row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); + row = app_->playlist_manager()->current()->proxy()->mapToSource(idx).row(); } app_->playlist_manager()->SetActiveToCurrent(); @@ -1380,14 +1379,14 @@ void MainWindow::PlayIndex(const QModelIndex &index) { } -void MainWindow::PlaylistDoubleClick(const QModelIndex &index) { +void MainWindow::PlaylistDoubleClick(const QModelIndex &idx) { - if (!index.isValid()) return; + if (!idx.isValid()) return; - int row = index.row(); - if (index.model() == app_->playlist_manager()->current()->proxy()) { + int row = idx.row(); + if (idx.model() == app_->playlist_manager()->current()->proxy()) { // The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model. - row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); + row = app_->playlist_manager()->current()->proxy()->mapToSource(idx).row(); } switch (doubleclick_playlist_addmode_) { @@ -1397,7 +1396,7 @@ void MainWindow::PlaylistDoubleClick(const QModelIndex &index) { break; case BehaviourSettingsPage::PlaylistAddBehaviour_Enqueue: - app_->playlist_manager()->current()->queue()->ToggleTracks(QModelIndexList() << index); + app_->playlist_manager()->current()->queue()->ToggleTracks(QModelIndexList() << idx); if (app_->player()->GetState() != Engine::Playing) { app_->player()->PlayAt(app_->playlist_manager()->current()->queue()->TakeNext(), Engine::Manual, true); } @@ -1482,7 +1481,7 @@ void MainWindow::FilePathChanged(const QString &path) { settings_.setValue("file_path", path); } -void MainWindow::Seeked(qlonglong microseconds) { +void MainWindow::Seeked(const qlonglong microseconds) { const int position = microseconds / kUsecPerSec; const int length = app_->player()->GetCurrentItem()->Metadata().length_nanosec() / kNsecPerSec; @@ -1528,7 +1527,7 @@ void MainWindow::UpdateTrackSliderPosition() { } -void MainWindow::ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const { +void MainWindow::ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const { switch (b) { case BehaviourSettingsPage::AddBehaviour_Append: @@ -1552,7 +1551,7 @@ void MainWindow::ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeDa } } -void MainWindow::ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const { +void MainWindow::ApplyPlayBehaviour(const BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const { switch (b) { case BehaviourSettingsPage::PlayBehaviour_Always: @@ -1973,10 +1972,10 @@ void MainWindow::RenumberTracks() { } -void MainWindow::SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index) { +void MainWindow::SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx) { - if (reply->is_successful() && index.isValid()) { - app_->playlist_manager()->current()->ReloadItems(QList()<< index.row()); + if (reply->is_successful() && idx.isValid()) { + app_->playlist_manager()->current()->ReloadItems(QList()<< idx.row()); } reply->deleteLater(); @@ -2133,8 +2132,8 @@ void MainWindow::PlaylistClearCurrent() { } -void MainWindow::PlaylistEditFinished(const QModelIndex &index) { - if (index == playlist_menu_index_) SelectionSetValue(); +void MainWindow::PlaylistEditFinished(const QModelIndex &idx) { + if (idx == playlist_menu_index_) SelectionSetValue(); } void MainWindow::CommandlineOptionsReceived(const quint32 instanceId, const QByteArray &string_options) { diff --git a/src/core/mainwindow.h b/src/core/mainwindow.h index 99bc2e604..7449cff91 100644 --- a/src/core/mainwindow.h +++ b/src/core/mainwindow.h @@ -100,14 +100,14 @@ class MainWindow : public QMainWindow, public PlatformInterface { Q_OBJECT public: - explicit MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd, const CommandlineOptions& options, QWidget *parent = nullptr); + explicit MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent = nullptr); ~MainWindow() override; static const char *kSettingsGroup; static const char *kAllFilesFilterSpec; void SetHiddenInTray(const bool hidden); - void CommandlineOptionsReceived(const CommandlineOptions& options); + void CommandlineOptionsReceived(const CommandlineOptions &options); protected: void keyPressEvent(QKeyEvent *event) override; @@ -120,7 +120,7 @@ class MainWindow : public QMainWindow, public PlatformInterface { // PlatformInterface void Activate() override; - bool LoadUrl(const QString& url) override; + bool LoadUrl(const QString &url) override; signals: void AlbumCoverReady(const Song &song, const QImage &image); @@ -128,23 +128,21 @@ class MainWindow : public QMainWindow, public PlatformInterface { // Signals that stop playing after track was toggled. void StopAfterToggled(bool stop); - void IntroPointReached(); - void AuthorizationUrlReceived(const QUrl &url); private slots: - void FilePathChanged(const QString& path); + void FilePathChanged(const QString &path); void EngineChanged(Engine::EngineType enginetype); void MediaStopped(); void MediaPaused(); void MediaPlaying(); void TrackSkipped(PlaylistItemPtr item); - void ForceShowOSD(const Song& song, const bool toggle); + void ForceShowOSD(const Song &song, const bool toggle); void PlaylistMenuHidden(); - void PlaylistRightClick(const QPoint& global_pos, const QModelIndex& index); - void PlaylistCurrentChanged(const QModelIndex& current); + void PlaylistRightClick(const QPoint &global_pos, const QModelIndex &index); + void PlaylistCurrentChanged(const QModelIndex ¤t); void PlaylistViewSelectionModelChanged(); void PlaylistPlay(); void PlaylistStopAfter(); @@ -152,7 +150,7 @@ class MainWindow : public QMainWindow, public PlatformInterface { void PlaylistQueuePlayNext(); void PlaylistSkip(); void PlaylistRemoveCurrent(); - void PlaylistEditFinished(const QModelIndex& index); + void PlaylistEditFinished(const QModelIndex &idx); void PlaylistClearCurrent(); void RescanSongs(); void EditTracks(); @@ -175,17 +173,17 @@ class MainWindow : public QMainWindow, public PlatformInterface { void ChangeCollectionQueryMode(QAction *action); - void PlayIndex(const QModelIndex& index); - void PlaylistDoubleClick(const QModelIndex& index); + void PlayIndex(const QModelIndex &idx); + void PlaylistDoubleClick(const QModelIndex &idx); void StopAfterCurrent(); - void SongChanged(const Song& song); + void SongChanged(const Song &song); void VolumeChanged(const int volume); - void CopyFilesToCollection(const QList& urls); - void MoveFilesToCollection(const QList& urls); - void CopyFilesToDevice(const QList& urls); - void EditFileTags(const QList& urls); + void CopyFilesToCollection(const QList &urls); + void MoveFilesToCollection(const QList &urls); + void CopyFilesToDevice(const QList &urls); + void EditFileTags(const QList &urls); void AddToPlaylist(QMimeData *q_mimedata); void AddToPlaylist(QAction *action); @@ -217,12 +215,12 @@ class MainWindow : public QMainWindow, public PlatformInterface { void PlayingWidgetPositionChanged(const bool above_status_bar); - void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex& index); + void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx); void ShowCoverManager(); void ShowAboutDialog(); - void ShowErrorDialog(const QString& message); + void ShowErrorDialog(const QString &message); void ShowTranscodeDialog(); SettingsDialog *CreateSettingsDialog(); EditTagDialog *CreateEditTagDialog(); @@ -270,8 +268,8 @@ class MainWindow : public QMainWindow, public PlatformInterface { void SaveSettings(); - void ApplyAddBehaviour(BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const; - void ApplyPlayBehaviour(BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const; + void ApplyAddBehaviour(const BehaviourSettingsPage::AddBehaviour b, MimeData *mimedata) const; + void ApplyPlayBehaviour(const BehaviourSettingsPage::PlayBehaviour b, MimeData *mimedata) const; void CheckFullRescanRevisions(); diff --git a/src/core/player.cpp b/src/core/player.cpp index 0c8cd91fc..51a977b26 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -354,7 +354,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) { void Player::Next() { NextInternal(Engine::Manual); } -void Player::NextInternal(Engine::TrackChangeFlags change) { +void Player::NextInternal(const Engine::TrackChangeFlags change) { if (HandleStopAfter()) return; @@ -362,7 +362,7 @@ void Player::NextInternal(Engine::TrackChangeFlags change) { } -void Player::NextItem(Engine::TrackChangeFlags change) { +void Player::NextItem(const Engine::TrackChangeFlags change) { Playlist *active_playlist = app_->playlist_manager()->active(); @@ -487,7 +487,7 @@ bool Player::PreviousWouldRestartTrack() const { void Player::Previous() { PreviousItem(Engine::Manual); } -void Player::PreviousItem(Engine::TrackChangeFlags change) { +void Player::PreviousItem(const Engine::TrackChangeFlags change) { const bool ignore_repeat_track = change & Engine::Manual; @@ -514,7 +514,7 @@ void Player::PreviousItem(Engine::TrackChangeFlags change) { } -void Player::EngineStateChanged(Engine::State state) { +void Player::EngineStateChanged(const Engine::State state) { if (Engine::Error == state) { nb_errors_received_++; @@ -542,7 +542,7 @@ void Player::EngineStateChanged(Engine::State state) { } -void Player::SetVolume(int value) { +void Player::SetVolume(const int value) { int old_volume = engine_->volume(); @@ -558,7 +558,7 @@ void Player::SetVolume(int value) { int Player::GetVolume() const { return engine_->volume(); } -void Player::PlayAt(int index, Engine::TrackChangeFlags change, bool reshuffle) { +void Player::PlayAt(const int index, Engine::TrackChangeFlags change, const bool reshuffle) { if (current_item_ && change == Engine::Manual && engine_->position_nanosec() != engine_->length_nanosec()) { emit TrackSkipped(current_item_); @@ -611,7 +611,7 @@ void Player::CurrentMetadataChanged(const Song &metadata) { } -void Player::SeekTo(int seconds) { +void Player::SeekTo(const int seconds) { const qint64 length_nanosec = engine_->length_nanosec(); @@ -662,7 +662,7 @@ void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle) { } -PlaylistItemPtr Player::GetItemAt(int pos) const { +PlaylistItemPtr Player::GetItemAt(const int pos) const { if (pos < 0 || pos >= app_->playlist_manager()->active()->rowCount()) return PlaylistItemPtr(); @@ -763,8 +763,6 @@ void Player::TrackAboutToEnd() { } -void Player::IntroPointReached() { NextInternal(Engine::Intro); } - void Player::FatalError() { nb_errors_received_ = 0; Stop(); diff --git a/src/core/player.h b/src/core/player.h index ae27155af..702b8f2b9 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -72,7 +72,7 @@ class PlayerInterface : public QObject { virtual void ReloadSettings() = 0; // Manual track change to the specified track - virtual void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) = 0; + virtual void PlayAt(const int row, Engine::TrackChangeFlags change, const bool reshuffle) = 0; // If there's currently a song playing, pause it, otherwise play the track that was playing last, or the first one on the playlist virtual void PlayPause() = 0; @@ -82,10 +82,10 @@ class PlayerInterface : public QObject { virtual void Next() = 0; virtual void Previous() = 0; - virtual void SetVolume(int value) = 0; + virtual void SetVolume(const int value) = 0; virtual void VolumeUp() = 0; virtual void VolumeDown() = 0; - virtual void SeekTo(int seconds) = 0; + virtual void SeekTo(const int seconds) = 0; // Moves the position of the currently playing song five seconds forward. virtual void SeekForward() = 0; // Moves the position of the currently playing song five seconds backwards. @@ -109,14 +109,14 @@ class PlayerInterface : public QObject { void PlaylistFinished(); void VolumeEnabled(bool); void VolumeChanged(int volume); - void Error(const QString &message); + void Error(QString message); void TrackSkipped(PlaylistItemPtr old_track); // Emitted when there's a manual change to the current's track position. void Seeked(qlonglong microseconds); // Emitted when Player has processed a request to play another song. // This contains the URL of the song and a flag saying whether it was able to play the song. - void SongChangeRequestProcessed(const QUrl &url, bool valid); + void SongChangeRequestProcessed(QUrl url, bool valid); // The toggle parameter is true when user requests to toggle visibility for Pretty OSD void ForceShowOSD(Song, bool toggle); @@ -158,15 +158,15 @@ class Player : public PlayerInterface { public slots: void ReloadSettings() override; - void PlayAt(int i, Engine::TrackChangeFlags change, bool reshuffle) override; + void PlayAt(const int row, Engine::TrackChangeFlags change, const bool reshuffle) override; void PlayPause() override; void RestartOrPrevious() override; void Next() override; void Previous() override; - void SetVolume(int value) override; + void SetVolume(const int value) override; void VolumeUp() override { SetVolume(GetVolume() + 5); } void VolumeDown() override { SetVolume(GetVolume() - 5); } - void SeekTo(int seconds) override; + void SeekTo(const int seconds) override; void SeekForward() override; void SeekBackward() override; @@ -176,7 +176,6 @@ class Player : public PlayerInterface { void Pause() override; void Stop(bool stop_after = false) override; void StopAfterCurrent(); - void IntroPointReached(); void Play() override; void ShowOSD() override; void TogglePrettyOSD(); @@ -187,15 +186,15 @@ class Player : public PlayerInterface { void EngineChanged(Engine::EngineType enginetype); private slots: - void EngineStateChanged(Engine::State); + void EngineStateChanged(const Engine::State); void EngineMetadataReceived(const Engine::SimpleMetaBundle &bundle); void TrackAboutToEnd(); void TrackEnded(); // Play the next item on the playlist - disregarding radio stations like last.fm that might have more tracks. - void NextItem(Engine::TrackChangeFlags change); - void PreviousItem(Engine::TrackChangeFlags change); + void NextItem(const Engine::TrackChangeFlags change); + void PreviousItem(const Engine::TrackChangeFlags change); - void NextInternal(Engine::TrackChangeFlags); + void NextInternal(const Engine::TrackChangeFlags); void FatalError(); void ValidSongRequested(const QUrl&); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index f42ae2b54..3149d8fc8 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -111,7 +111,7 @@ const int Playlist::kUndoItemLimit = 500; const qint64 Playlist::kMinScrobblePointNsecs = 31ll * kNsecPerSec; const qint64 Playlist::kMaxScrobblePointNsecs = 240ll * kNsecPerSec; -Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, int id, const QString &special_type, bool favorite, QObject *parent) +Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, const int id, const QString &special_type, const bool favorite, QObject *parent) : QAbstractListModel(parent), is_loading_(false), proxy_(new PlaylistFilter(this)), @@ -161,7 +161,7 @@ Playlist::~Playlist() { } template -void Playlist::InsertSongItems(const SongList &songs, int pos, bool play_now, bool enqueue, bool enqueue_next) { +void Playlist::InsertSongItems(const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) { PlaylistItemList items; @@ -360,38 +360,38 @@ QVariant Playlist::data(const QModelIndex &idx, int role) const { } #ifdef HAVE_MOODBAR -void Playlist::MoodbarUpdated(const QModelIndex& index) { - emit dataChanged(index.sibling(index.row(), Column_Mood), index.sibling(index.row(), Column_Mood)); +void Playlist::MoodbarUpdated(const QModelIndex &idx) { + emit dataChanged(idx.sibling(idx.row(), Column_Mood), idx.sibling(idx.row(), Column_Mood)); } #endif -bool Playlist::setData(const QModelIndex &index, const QVariant &value, int role) { +bool Playlist::setData(const QModelIndex &idx, const QVariant &value, int role) { Q_UNUSED(role); - int row = index.row(); + int row = idx.row(); PlaylistItemPtr item = item_at(row); Song song = item->OriginalMetadata(); - if (index.data() == value) return false; + if (idx.data() == value) return false; - if (!set_column_value(song, static_cast(index.column()), value)) return false; + if (!set_column_value(song, static_cast(idx.column()), value)) return false; TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); - NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(index)); + NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(idx)); return true; } -void Playlist::SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index) { +void Playlist::SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &idx) { - if (reply->is_successful() && index.isValid()) { + if (reply->is_successful() && idx.isValid()) { if (reply->message().save_file_response().success()) { - PlaylistItemPtr item = item_at(index.row()); + PlaylistItemPtr item = item_at(idx.row()); if (!item) return; QFuture future = item->BackgroundReload(); - NewClosure(future, this, SLOT(ItemReloadComplete(QPersistentModelIndex)), index); + NewClosure(future, this, SLOT(ItemReloadComplete(QPersistentModelIndex)), idx); } else { emit Error(tr("An error occurred writing metadata to '%1'").arg(QString::fromStdString(reply->request_message().save_file_request().filename()))); @@ -401,17 +401,17 @@ void Playlist::SongSaveComplete(TagReaderReply *reply, const QPersistentModelInd } -void Playlist::ItemReloadComplete(const QPersistentModelIndex &index) { +void Playlist::ItemReloadComplete(const QPersistentModelIndex &idx) { - if (index.isValid()) { + if (idx.isValid()) { - PlaylistItemPtr item = item_at(index.row()); + PlaylistItemPtr item = item_at(idx.row()); if (item && item->HasTemporaryMetadata()) { // Update temporary metadata. item->UpdateTemporaryMetadata(item->OriginalMetadata()); } - emit dataChanged(index, index); - emit EditingFinished(index); + emit dataChanged(idx, idx); + emit EditingFinished(idx); } } @@ -428,18 +428,18 @@ int Playlist::last_played_row() const { return last_played_item_index_.isValid() ? last_played_item_index_.row() : -1; } -void Playlist::ShuffleModeChanged(PlaylistSequence::ShuffleMode mode) { +void Playlist::ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode) { is_shuffled_ = (mode != PlaylistSequence::Shuffle_Off); ReshuffleIndices(); } -bool Playlist::FilterContainsVirtualIndex(int i) const { +bool Playlist::FilterContainsVirtualIndex(const int i) const { if (i < 0 || i >= virtual_items_.count()) return false; return proxy_->filterAcceptsRow(virtual_items_[i], QModelIndex()); } -int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const { +int Playlist::NextVirtualIndex(int i, const bool ignore_repeat_track) const { PlaylistSequence::RepeatMode repeat_mode = playlist_sequence_->repeat_mode(); PlaylistSequence::ShuffleMode shuffle_mode = playlist_sequence_->shuffle_mode(); @@ -483,7 +483,7 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const { } -int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const { +int Playlist::PreviousVirtualIndex(int i, const bool ignore_repeat_track) const { PlaylistSequence::RepeatMode repeat_mode = playlist_sequence_->repeat_mode(); PlaylistSequence::ShuffleMode shuffle_mode = playlist_sequence_->shuffle_mode(); @@ -521,7 +521,7 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const { } -int Playlist::next_row(bool ignore_repeat_track) const { +int Playlist::next_row(const bool ignore_repeat_track) const { // Any queued items take priority if (!queue_->is_empty()) { @@ -553,7 +553,7 @@ int Playlist::next_row(bool ignore_repeat_track) const { } -int Playlist::previous_row(bool ignore_repeat_track) const { +int Playlist::previous_row(const bool ignore_repeat_track) const { int prev_virtual_index = PreviousVirtualIndex(current_virtual_index_,ignore_repeat_track); @@ -580,7 +580,7 @@ int Playlist::previous_row(bool ignore_repeat_track) const { } -void Playlist::set_current_row(int i, bool is_stopping) { +void Playlist::set_current_row(const int i, const bool is_stopping) { QModelIndex old_current_item_index = current_item_index_; @@ -643,13 +643,13 @@ void Playlist::set_current_row(int i, bool is_stopping) { } -Qt::ItemFlags Playlist::flags(const QModelIndex &index) const { +Qt::ItemFlags Playlist::flags(const QModelIndex &idx) const { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - if (column_is_editable(static_cast(index.column()))) flags |= Qt::ItemIsEditable; + if (column_is_editable(static_cast(idx.column()))) flags |= Qt::ItemIsEditable; - if (index.isValid()) return flags | Qt::ItemIsDragEnabled; + if (idx.isValid()) return flags | Qt::ItemIsDragEnabled; return Qt::ItemIsDropEnabled; @@ -758,7 +758,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro } -void Playlist::InsertUrls(const QList &urls, int pos, bool play_now, bool enqueue, bool enqueue_next) { +void Playlist::InsertUrls(const QList &urls, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) { SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_, backend_->app()->player()); connect(inserter, SIGNAL(Error(QString)), SIGNAL(Error(QString))); @@ -767,7 +767,7 @@ void Playlist::InsertUrls(const QList &urls, int pos, bool play_now, bool } -void Playlist::MoveItemWithoutUndo(int source, int dest) { +void Playlist::MoveItemWithoutUndo(const int source, const int dest) { MoveItemsWithoutUndo(QList() << source, dest); } @@ -871,7 +871,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList &dest_rows) { } -void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_now, bool enqueue, bool enqueue_next) { +void Playlist::InsertItems(const PlaylistItemList &itemsIn, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) { if (itemsIn.isEmpty()) return; @@ -931,7 +931,7 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n } -void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, int pos, bool enqueue, bool enqueue_next) { +void Playlist::InsertItemsWithoutUndo(const PlaylistItemList &items, const int pos, const bool enqueue, const bool enqueue_next) { if (items.isEmpty()) return; @@ -1071,11 +1071,11 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const { QList urls; QList rows; - for (const QModelIndex &index : indexes) { - if (index.column() != first_column) continue; + for (const QModelIndex &idx : indexes) { + if (idx.column() != first_column) continue; - urls << items_[index.row()]->Url(); - rows << index.row(); + urls << items_[idx.row()]->Url(); + rows << idx.row(); } QBuffer buf; @@ -1097,7 +1097,7 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const { } -bool Playlist::CompareItems(int column, Qt::SortOrder order, std::shared_ptr _a, std::shared_ptr _b) { +bool Playlist::CompareItems(const int column, const Qt::SortOrder order, std::shared_ptr _a, std::shared_ptr _b) { std::shared_ptr a = order == Qt::AscendingOrder ? _a : _b; std::shared_ptr b = order == Qt::AscendingOrder ? _b : _a; @@ -1148,7 +1148,7 @@ bool Playlist::CompareItems(int column, Qt::SortOrder order, std::shared_ptr _a, std::shared_ptr _b) { +bool Playlist::ComparePathDepths(const Qt::SortOrder order, std::shared_ptr _a, std::shared_ptr _b) { std::shared_ptr a = order == Qt::AscendingOrder ? _a : _b; std::shared_ptr b = order == Qt::AscendingOrder ? _b : _a; @@ -1201,7 +1201,7 @@ QString Playlist::column_name(Column column) { } -QString Playlist::abbreviated_column_name(Column column) { +QString Playlist::abbreviated_column_name(const Column column) { const QString &column_name = Playlist::column_name(column); @@ -1276,7 +1276,7 @@ void Playlist::Paused() { SetCurrentIsPaused(true); } void Playlist::Stopped() { SetCurrentIsPaused(false); } -void Playlist::SetCurrentIsPaused(bool paused) { +void Playlist::SetCurrentIsPaused(const bool paused) { if (paused == current_is_paused_) return; @@ -1469,7 +1469,7 @@ PlaylistItemList Playlist::RemoveItemsWithoutUndo(const int row, const int count } -void Playlist::StopAfter(int row) { +void Playlist::StopAfter(const int row) { QModelIndex old_stop_after = stop_after_; @@ -1661,7 +1661,7 @@ void Playlist::Shuffle() { } namespace { -bool AlbumShuffleComparator(const QMap &album_key_positions, const QMap &album_keys, int left, int right) { +bool AlbumShuffleComparator(const QMap &album_key_positions, const QMap &album_keys, const int left, const int right) { const int left_pos = album_key_positions[album_keys[left]]; const int right_pos = album_key_positions[album_keys[right]]; @@ -1777,7 +1777,7 @@ quint64 Playlist::GetTotalLength() const { } -PlaylistItemList Playlist::collection_items_by_id(int id) const { +PlaylistItemList Playlist::collection_items_by_id(const int id) const { return collection_items_by_id_.values(id); } @@ -1791,15 +1791,15 @@ void Playlist::TracksAboutToBeDequeued(const QModelIndex&, int begin, int end) { void Playlist::TracksDequeued() { - for (const QModelIndex &index : temp_dequeue_change_indexes_) { - emit dataChanged(index, index); + for (const QModelIndex &idx : temp_dequeue_change_indexes_) { + emit dataChanged(idx, idx); } temp_dequeue_change_indexes_.clear(); emit QueueChanged(); } -void Playlist::TracksEnqueued(const QModelIndex&, int begin, int end) { +void Playlist::TracksEnqueued(const QModelIndex&, const int begin, const int end) { const QModelIndex &b = queue_->mapToSource(queue_->index(begin, Column_Title)); const QModelIndex &e = queue_->mapToSource(queue_->index(end, Column_Title)); @@ -1810,8 +1810,8 @@ void Playlist::TracksEnqueued(const QModelIndex&, int begin, int end) { void Playlist::QueueLayoutChanged() { for (int i = 0; i < queue_->rowCount(); ++i) { - const QModelIndex &index = queue_->mapToSource(queue_->index(i, Column_Title)); - emit dataChanged(index, index); + const QModelIndex &idx = queue_->mapToSource(queue_->index(i, Column_Title)); + emit dataChanged(idx, idx); } } @@ -1954,7 +1954,7 @@ void Playlist::RemoveUnavailableSongs() { } -bool Playlist::ApplyValidityOnCurrentSong(const QUrl &url, bool valid) { +bool Playlist::ApplyValidityOnCurrentSong(const QUrl &url, const bool valid) { PlaylistItemPtr current = current_item(); diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 81291029a..2ed43d131 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -93,7 +93,7 @@ class Playlist : public QAbstractListModel { friend class PlaylistUndoCommands::ReOrderItems; public: - explicit Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, int id, const QString &special_type = QString(), bool favorite = false, QObject *parent = nullptr); + explicit Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, const int id, const QString &special_type = QString(), const bool favorite = false, QObject *parent = nullptr); ~Playlist() override; void SkipTracks(const QModelIndexList &source_indexes); @@ -166,7 +166,7 @@ class Playlist : public QAbstractListModel { static const qint64 kMinScrobblePointNsecs; static const qint64 kMaxScrobblePointNsecs; - static bool CompareItems(int column, Qt::SortOrder order, PlaylistItemPtr a, PlaylistItemPtr b); + static bool CompareItems(const int column, const Qt::SortOrder order, PlaylistItemPtr a, PlaylistItemPtr b); static QString column_name(Column column); static QString abbreviated_column_name(Column column); @@ -186,13 +186,13 @@ class Playlist : public QAbstractListModel { const QString &ui_path() const { return ui_path_; } void set_ui_path(const QString &path) { ui_path_ = path; } bool is_favorite() const { return favorite_; } - void set_favorite(bool favorite) { favorite_ = favorite; } + void set_favorite(const bool favorite) { favorite_ = favorite; } int current_row() const; int last_played_row() const; void reset_last_played() { last_played_item_index_ = QPersistentModelIndex(); } - int next_row(bool ignore_repeat_track = false) const; - int previous_row(bool ignore_repeat_track = false) const; + int next_row(const bool ignore_repeat_track = false) const; + int previous_row(const bool ignore_repeat_track = false) const; const QModelIndex current_index() const; @@ -201,15 +201,15 @@ class Playlist : public QAbstractListModel { QString special_type() const { return special_type_; } void set_special_type(const QString &v) { special_type_ = v; } - const PlaylistItemPtr &item_at(int index) const { return items_[index]; } - bool has_item_at(int index) const { return index >= 0 && index < rowCount(); } + const PlaylistItemPtr &item_at(const int index) const { return items_[index]; } + bool has_item_at(const int index) const { return index >= 0 && index < rowCount(); } PlaylistItemPtr current_item() const; PlaylistItem::Options current_item_options() const; Song current_item_metadata() const; - PlaylistItemList collection_items_by_id(int id) const; + PlaylistItemList collection_items_by_id(const int id) const; SongList GetAllSongs() const; PlaylistItemList GetAllItems() const; @@ -222,8 +222,8 @@ class Playlist : public QAbstractListModel { bool scrobbled() const { return scrobbled_; } bool nowplaying() const { return nowplaying_; } - void set_scrobbled(bool state) { scrobbled_ = state; } - void set_nowplaying(bool state) { nowplaying_ = state; } + void set_scrobbled(const bool state) { scrobbled_ = state; } + void set_nowplaying(const bool state) { nowplaying_ = state; } void set_editing(const int row) { editing_ = row; } qint64 scrobble_point_nanosec() const { return scrobble_point_; } void UpdateScrobblePoint(const qint64 seek_point_nanosec = 0); @@ -248,7 +248,7 @@ class Playlist : public QAbstractListModel { // Removes from the playlist all local files that don't exist anymore. void RemoveDeletedSongs(); - void StopAfter(int row); + void StopAfter(const int row); void ReloadItems(const QList &rows); void InformOfCurrentSongChange(); @@ -259,16 +259,16 @@ class Playlist : public QAbstractListModel { // Just emits the dataChanged() signal so the mood column is repainted. #ifdef HAVE_MOODBAR - void MoodbarUpdated(const QModelIndex& index); + void MoodbarUpdated(const QModelIndex &idx); #endif // QAbstractListModel int rowCount(const QModelIndex& = QModelIndex()) const override { return items_.count(); } int columnCount(const QModelIndex& = QModelIndex()) const override { return ColumnCount; } QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override; - bool setData(const QModelIndex &index, const QVariant &value, int role) override; + bool setData(const QModelIndex &idx, const QVariant &value, int role) override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - Qt::ItemFlags flags(const QModelIndex &index) const override; + Qt::ItemFlags flags(const QModelIndex &idx) const override; QStringList mimeTypes() const override; Qt::DropActions supportedDropActions() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; @@ -279,11 +279,11 @@ class Playlist : public QAbstractListModel { static bool ComparePathDepths(Qt::SortOrder, PlaylistItemPtr, PlaylistItemPtr); public slots: - void set_current_row(int index, bool is_stopping = false); + void set_current_row(const int i, const bool is_stopping = false); void Paused(); void Playing(); void Stopped(); - void IgnoreSorting(bool value) { ignore_sorting_ = value; } + void IgnoreSorting(const bool value) { ignore_sorting_ = value; } void ClearStreamMetadata(); void SetStreamMetadata(const QUrl &url, const Song &song, const bool minor); @@ -295,7 +295,7 @@ class Playlist : public QAbstractListModel { void RemoveUnavailableSongs(); void Shuffle(); - void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode); + void ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode); void SetColumnAlignment(const ColumnAlignmentMap &alignment); @@ -306,34 +306,34 @@ class Playlist : public QAbstractListModel { signals: void RestoreFinished(); void PlaylistLoaded(); - void CurrentSongChanged(const Song &metadata); - void SongMetadataChanged(const Song &metadata); - void EditingFinished(const QModelIndex &index); - void PlayRequested(const QModelIndex &index); + void CurrentSongChanged(Song metadata); + void SongMetadataChanged(Song metadata); + void EditingFinished(QModelIndex idx); + void PlayRequested(QModelIndex idx); // Signals that the underlying list of items was changed, meaning that something was added to it, removed from it or the ordering changed. void PlaylistChanged(); void DynamicModeChanged(bool dynamic); - void Error(const QString &message); + void Error(QString message); // Signals that the queue has changed, meaning that the remaining queued items should update their position. void QueueChanged(); private: - void SetCurrentIsPaused(bool paused); - int NextVirtualIndex(int i, bool ignore_repeat_track) const; - int PreviousVirtualIndex(int i, bool ignore_repeat_track) const; - bool FilterContainsVirtualIndex(int i) const; + void SetCurrentIsPaused(const bool paused); + int NextVirtualIndex(int i, const bool ignore_repeat_track) const; + int PreviousVirtualIndex(int i, const bool ignore_repeat_track) const; + bool FilterContainsVirtualIndex(const int i) const; template - void InsertSongItems(const SongList &songs, int pos, bool play_now, bool enqueue, bool enqueue_next = false); + void InsertSongItems(const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next = false); // Modify the playlist without changing the undo stack. These are used by our friends in PlaylistUndoCommands void InsertItemsWithoutUndo(const PlaylistItemList &items, int pos, bool enqueue = false, bool enqueue_next = false); PlaylistItemList RemoveItemsWithoutUndo(const int row, const int count); void MoveItemsWithoutUndo(const QList &source_rows, int pos); - void MoveItemWithoutUndo(int source, int dest); + void MoveItemWithoutUndo(const int source, const int dest); void MoveItemsWithoutUndo(int start, const QList &dest_rows); void ReOrderWithoutUndo(const PlaylistItemList &new_items); @@ -343,9 +343,9 @@ class Playlist : public QAbstractListModel { bool removeRows(QList &rows); private slots: - void TracksAboutToBeDequeued(const QModelIndex&, int begin, int end); + void TracksAboutToBeDequeued(const QModelIndex&, const int begin, const int end); void TracksDequeued(); - void TracksEnqueued(const QModelIndex&, int begin, int end); + void TracksEnqueued(const QModelIndex&, const int begin, const int end); void QueueLayoutChanged(); void SongSaveComplete(TagReaderReply *reply, const QPersistentModelIndex &index); void ItemReloadComplete(const QPersistentModelIndex &index); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 950140409..baaf28b7d 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -98,7 +98,7 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken connect(collection_backend_, SIGNAL(SongsStatisticsChanged(SongList)), SLOT(SongsDiscovered(SongList))); for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) { - playlists_loading_++; + ++playlists_loading_; Playlist *ret = AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite); connect(ret, SIGNAL(PlaylistLoaded()), SLOT(PlaylistLoaded())); } @@ -115,7 +115,7 @@ void PlaylistManager::PlaylistLoaded() { Playlist *playlist = qobject_cast(sender()); if (!playlist) return; disconnect(playlist, SIGNAL(PlaylistLoaded()), this, SLOT(PlaylistLoaded())); - playlists_loading_--; + --playlists_loading_; if (playlists_loading_ == 0) emit AllPlaylistsLoaded(); } @@ -137,7 +137,7 @@ QItemSelection PlaylistManager::selection(int id) const { return it->selection; } -Playlist *PlaylistManager::AddPlaylist(int id, const QString &name, const QString &special_type, const QString &ui_path, bool favorite) { +Playlist *PlaylistManager::AddPlaylist(const int id, const QString &name, const QString &special_type, const QString &ui_path, const bool favorite) { Playlist *ret = new Playlist(playlist_backend_, app_->task_manager(), collection_backend_, id, special_type, favorite); ret->set_sequence(sequence_); @@ -206,7 +206,7 @@ void PlaylistManager::Load(const QString &filename) { } -void PlaylistManager::Save(int id, const QString &filename, Playlist::Path path_type) { +void PlaylistManager::Save(const int id, const QString &filename, const Playlist::Path path_type) { if (playlists_.contains(id)) { parser_->Save(playlist(id)->GetAllSongs(), filename, path_type); @@ -219,13 +219,13 @@ void PlaylistManager::Save(int id, const QString &filename, Playlist::Path path_ } -void PlaylistManager::ItemsLoadedForSavePlaylist(QFuture future, const QString &filename, Playlist::Path path_type) { +void PlaylistManager::ItemsLoadedForSavePlaylist(QFuture future, const QString &filename, const Playlist::Path path_type) { parser_->Save(future.result(), filename, path_type); } -void PlaylistManager::SaveWithUI(int id, const QString &playlist_name) { +void PlaylistManager::SaveWithUI(const int id, const QString &playlist_name) { QSettings settings; settings.beginGroup(Playlist::kSettingsGroup); @@ -291,7 +291,7 @@ void PlaylistManager::SaveWithUI(int id, const QString &playlist_name) { } -void PlaylistManager::Rename(int id, const QString &new_name) { +void PlaylistManager::Rename(const int id, const QString &new_name) { Q_ASSERT(playlists_.contains(id)); @@ -302,7 +302,7 @@ void PlaylistManager::Rename(int id, const QString &new_name) { } -void PlaylistManager::Favorite(int id, bool favorite) { +void PlaylistManager::Favorite(const int id, const bool favorite) { if (playlists_.contains(id)) { // If playlists_ contains this playlist, its means it's opened: star or unstar it. @@ -319,7 +319,7 @@ void PlaylistManager::Favorite(int id, bool favorite) { } -bool PlaylistManager::Close(int id) { +bool PlaylistManager::Close(const int id) { // Won't allow removing the last playlist if (playlists_.count() <= 1 || !playlists_.contains(id)) return false; @@ -349,7 +349,7 @@ bool PlaylistManager::Close(int id) { } -void PlaylistManager::Delete(int id) { +void PlaylistManager::Delete(const int id) { if (!Close(id)) { return; @@ -364,7 +364,7 @@ void PlaylistManager::OneOfPlaylistsChanged() { emit PlaylistChanged(qobject_cast(sender())); } -void PlaylistManager::SetCurrentPlaylist(int id) { +void PlaylistManager::SetCurrentPlaylist(const int id) { Q_ASSERT(playlists_.contains(id)); @@ -379,7 +379,7 @@ void PlaylistManager::SetCurrentPlaylist(int id) { } -void PlaylistManager::SetActivePlaylist(int id) { +void PlaylistManager::SetActivePlaylist(const int id) { Q_ASSERT(playlists_.contains(id)); @@ -489,7 +489,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) { } // When Player has processed the new song chosen by the user... -void PlaylistManager::SongChangeRequestProcessed(const QUrl &url, bool valid) { +void PlaylistManager::SongChangeRequestProcessed(const QUrl &url, const bool valid) { for (Playlist *playlist : GetAllPlaylists()) { if (playlist->ApplyValidityOnCurrentSong(url, valid)) { @@ -499,7 +499,7 @@ void PlaylistManager::SongChangeRequestProcessed(const QUrl &url, bool valid) { } -void PlaylistManager::InsertUrls(int id, const QList &urls, int pos, bool play_now, bool enqueue) { +void PlaylistManager::InsertUrls(const int id, const QList &urls, const int pos, const bool play_now, const bool enqueue) { Q_ASSERT(playlists_.contains(id)); @@ -507,7 +507,7 @@ void PlaylistManager::InsertUrls(int id, const QList &urls, int pos, bool } -void PlaylistManager::InsertSongs(int id, const SongList &songs, int pos, bool play_now, bool enqueue) { +void PlaylistManager::InsertSongs(const int id, const SongList &songs, const int pos, const bool play_now, const bool enqueue) { Q_ASSERT(playlists_.contains(id)); @@ -515,7 +515,7 @@ void PlaylistManager::InsertSongs(int id, const SongList &songs, int pos, bool p } -void PlaylistManager::RemoveItemsWithoutUndo(int id, const QList &indices) { +void PlaylistManager::RemoveItemsWithoutUndo(const int id, const QList &indices) { Q_ASSERT(playlists_.contains(id)); @@ -577,7 +577,7 @@ QString PlaylistManager::GetNameForNewPlaylist(const SongList &songs) { } -void PlaylistManager::Open(int id) { +void PlaylistManager::Open(const int id) { if (playlists_.contains(id)) { return; @@ -592,13 +592,13 @@ void PlaylistManager::Open(int id) { } -void PlaylistManager::SetCurrentOrOpen(int id) { +void PlaylistManager::SetCurrentOrOpen(const int id) { Open(id); SetCurrentPlaylist(id); } -bool PlaylistManager::IsPlaylistOpen(int id) { +bool PlaylistManager::IsPlaylistOpen(const int id) { return playlists_.contains(id); } diff --git a/src/playlist/playlistmanager.h b/src/playlist/playlistmanager.h index cc5d18e4d..279cf5fa6 100644 --- a/src/playlist/playlistmanager.h +++ b/src/playlist/playlistmanager.h @@ -64,11 +64,11 @@ class PlaylistManagerInterface : public QObject { // Removes all deleted songs from all playlists. virtual void RemoveDeletedSongs() = 0; - virtual QItemSelection selection(int id) const = 0; + virtual QItemSelection selection(const int id) const = 0; virtual QItemSelection current_selection() const = 0; virtual QItemSelection active_selection() const = 0; - virtual QString GetPlaylistName(int index) const = 0; + virtual QString GetPlaylistName(const int index) const = 0; virtual CollectionBackend *collection_backend() const = 0; virtual PlaylistBackend *playlist_backend() const = 0; @@ -79,17 +79,17 @@ class PlaylistManagerInterface : public QObject { public slots: virtual void New(const QString &name, const SongList& songs = SongList(), const QString &special_type = QString()) = 0; virtual void Load(const QString &filename) = 0; - virtual void Save(int id, const QString &filename, Playlist::Path path_type) = 0; - virtual void Rename(int id, const QString &new_name) = 0; - virtual void Delete(int id) = 0; - virtual bool Close(int id) = 0; - virtual void Open(int id) = 0; + virtual void Save(const int id, const QString &filename, const Playlist::Path path_type) = 0; + virtual void Rename(const int id, const QString &new_name) = 0; + virtual void Delete(const int id) = 0; + virtual bool Close(const int id) = 0; + virtual void Open(const int id) = 0; virtual void ChangePlaylistOrder(const QList& ids) = 0; - virtual void SongChangeRequestProcessed(const QUrl &url, bool valid) = 0; + virtual void SongChangeRequestProcessed(const QUrl &url, const bool valid) = 0; - virtual void SetCurrentPlaylist(int id) = 0; - virtual void SetActivePlaylist(int id) = 0; + virtual void SetCurrentPlaylist(const int id) = 0; + virtual void SetActivePlaylist(const int id) = 0; virtual void SetActiveToCurrent() = 0; virtual void SelectionChanged(const QItemSelection &selection) = 0; @@ -107,25 +107,25 @@ class PlaylistManagerInterface : public QObject { void PlaylistManagerInitialized(); void AllPlaylistsLoaded(); - void PlaylistAdded(int id, const QString &name, bool favorite); + void PlaylistAdded(int id, QString name, bool favorite); void PlaylistDeleted(int id); void PlaylistClosed(int id); - void PlaylistRenamed(int id, const QString &new_name); + void PlaylistRenamed(int id, QString new_name); void PlaylistFavorited(int id, bool favorite); - void CurrentChanged(Playlist *new_playlist, const int scroll_position = 0); + void CurrentChanged(Playlist *new_playlist, int scroll_position = 0); void ActiveChanged(Playlist *new_playlist); - void Error(const QString &message); - void SummaryTextChanged(const QString &summary); + void Error(QString message); + void SummaryTextChanged(QString summary); // Forwarded from individual playlists - void CurrentSongChanged(const Song& song); - void SongMetadataChanged(const Song& song); + void CurrentSongChanged(Song song); + void SongMetadataChanged(Song song); // Signals that one of manager's playlists has changed (new items, new ordering etc.) - the argument shows which. void PlaylistChanged(Playlist *playlist); - void EditingFinished(const QModelIndex& index); - void PlayRequested(const QModelIndex& index); + void EditingFinished(QModelIndex idx); + void PlayRequested(QModelIndex idx); }; class PlaylistManager : public PlaylistManagerInterface { @@ -138,7 +138,7 @@ class PlaylistManager : public PlaylistManagerInterface { int current_id() const override { return current_; } int active_id() const override { return active_; } - Playlist *playlist(int id) const override { return playlists_[id].p; } + Playlist *playlist(const int id) const override { return playlists_[id].p; } Playlist *current() const override { return playlist(current_id()); } Playlist *active() const override { return playlist(active_id()); } @@ -149,12 +149,12 @@ class PlaylistManager : public PlaylistManagerInterface { // Removes all deleted songs from all playlists. void RemoveDeletedSongs() override; // Returns true if the playlist is open - bool IsPlaylistOpen(int id); + bool IsPlaylistOpen(const int id); // Returns a pretty automatic name for playlist created from the given list of songs. static QString GetNameForNewPlaylist(const SongList& songs); - QItemSelection selection(int id) const override; + QItemSelection selection(const int id) const override; QItemSelection current_selection() const override { return selection(current_id()); } QItemSelection active_selection() const override { return selection(active_id()); } @@ -172,24 +172,24 @@ class PlaylistManager : public PlaylistManagerInterface { public slots: void New(const QString &name, const SongList &songs = SongList(), const QString &special_type = QString()) override; void Load(const QString &filename) override; - void Save(int id, const QString &filename, Playlist::Path path_type) override; + void Save(const int id, const QString &filename, const Playlist::Path path_type) override; // Display a file dialog to let user choose a file before saving the file - void SaveWithUI(int id, const QString &playlist_name); - void Rename(int id, const QString &new_name) override; - void Favorite(int id, bool favorite); - void Delete(int id) override; - bool Close(int id) override; - void Open(int id) override; + void SaveWithUI(const int id, const QString &playlist_name); + void Rename(const int id, const QString &new_name) override; + void Favorite(const int id, bool favorite); + void Delete(const int id) override; + bool Close(const int id) override; + void Open(const int id) override; void ChangePlaylistOrder(const QList& ids) override; - void SetCurrentPlaylist(int id) override; - void SetActivePlaylist(int id) override; + void SetCurrentPlaylist(const int id) override; + void SetActivePlaylist(const int id) override; void SetActiveToCurrent() override; void SelectionChanged(const QItemSelection &selection) override; // Makes a playlist current if it's open already, or opens it and makes it current if it is hidden. - void SetCurrentOrOpen(int id); + void SetCurrentOrOpen(const int id); // Convenience slots that defer to either current() or active() void ClearCurrent() override; @@ -198,12 +198,12 @@ class PlaylistManager : public PlaylistManagerInterface { void RemoveUnavailableCurrent() override; //void SetActiveStreamMetadata(const QUrl& url, const Song& song); - void SongChangeRequestProcessed(const QUrl& url, bool valid) override; + void SongChangeRequestProcessed(const QUrl& url, const bool valid) override; - void InsertUrls(int id, const QList& urls, int pos = -1, bool play_now = false, bool enqueue = false); - void InsertSongs(int id, const SongList& songs, int pos = -1, bool play_now = false, bool enqueue = false); + void InsertUrls(const int id, const QList& urls, const int pos = -1, const bool play_now = false, const bool enqueue = false); + void InsertSongs(const int id, const SongList& songs, const int pos = -1, const bool play_now = false, const bool enqueue = false); // Removes items with given indices from the playlist. This operation is not undoable. - void RemoveItemsWithoutUndo(int id, const QList& indices); + void RemoveItemsWithoutUndo(const int id, const QList& indices); // Remove the current playing song void RemoveCurrentSong(); @@ -215,15 +215,15 @@ class PlaylistManager : public PlaylistManagerInterface { void OneOfPlaylistsChanged(); void UpdateSummaryText(); void SongsDiscovered(const SongList& songs); - void ItemsLoadedForSavePlaylist(QFuture future, const QString& filename, Playlist::Path path_type); + void ItemsLoadedForSavePlaylist(QFuture future, const QString& filename, const Playlist::Path path_type); void PlaylistLoaded(); private: - Playlist *AddPlaylist(int id, const QString& name, const QString &special_type, const QString& ui_path, bool favorite); + Playlist *AddPlaylist(const int id, const QString &name, const QString &special_type, const QString &ui_path, const bool favorite); private: struct Data { - explicit Data(Playlist *_p = nullptr, const QString& _name = QString()) : p(_p), name(_name), scroll_position(0) {} + explicit Data(Playlist *_p = nullptr, const QString &_name = QString()) : p(_p), name(_name), scroll_position(0) {} Playlist *p; QString name; QItemSelection selection; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 0aec0b443..01809279b 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -406,15 +406,15 @@ void PlaylistView::drawTree(QPainter *painter, const QRegion ®ion) const { } -void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { +void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const { QStyleOptionViewItem opt(option); - bool is_current = index.data(Playlist::Role_IsCurrent).toBool(); - bool is_paused = index.data(Playlist::Role_IsPaused).toBool(); + bool is_current = idx.data(Playlist::Role_IsCurrent).toBool(); + bool is_paused = idx.data(Playlist::Role_IsPaused).toBool(); if (is_current) { - const_cast(this)->last_current_item_ = index; + const_cast(this)->last_current_item_ = idx; const_cast(this)->last_glow_rect_ = opt.rect; int step = glow_intensity_step_; @@ -433,7 +433,7 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option middle.setRight(middle.right() - currenttrack_bar_right_[0].width()); // Selection - if (selectionModel()->isSelected(index)) + if (selectionModel()->isSelected(idx)) painter->fillRect(opt.rect, opt.palette.color(QPalette::Highlight)); // Draw the bar @@ -453,7 +453,7 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option opt.decorationSize = QSize(20, 20); // Draw the actual row data on top. We cache this, because it's fairly expensive (1-2ms), and we do it many times per second. - const bool cache_dirty = cached_current_row_rect_ != opt.rect || cached_current_row_row_ != index.row() || cached_current_row_.isNull(); + const bool cache_dirty = cached_current_row_rect_ != opt.rect || cached_current_row_row_ != idx.row() || cached_current_row_.isNull(); // We can't update the cache if we're not drawing the entire region, // QTreeView clips its drawing to only the columns in the region, so it wouldn't update the whole pixmap properly. @@ -464,31 +464,31 @@ void PlaylistView::drawRow(QPainter *painter, const QStyleOptionViewItem &option } else { if (whole_region) { - const_cast(this)->UpdateCachedCurrentRowPixmap(opt, index); + const_cast(this)->UpdateCachedCurrentRowPixmap(opt, idx); painter->drawPixmap(opt.rect, cached_current_row_); } else { - QTreeView::drawRow(painter, opt, index); + QTreeView::drawRow(painter, opt, idx); } } } else { - QTreeView::drawRow(painter, opt, index); + QTreeView::drawRow(painter, opt, idx); } } -void PlaylistView::UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &index) { +void PlaylistView::UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &idx) { cached_current_row_rect_ = option.rect; - cached_current_row_row_ = index.row(); + cached_current_row_row_ = idx.row(); option.rect.moveTo(0, 0); cached_current_row_ = QPixmap(option.rect.size()); cached_current_row_.fill(Qt::transparent); QPainter p(&cached_current_row_); - QTreeView::drawRow(&p, option, index); + QTreeView::drawRow(&p, option, idx); } @@ -611,15 +611,15 @@ void PlaylistView::RemoveSelected() { int new_row = last_row - rows_removed; // Index of the first column for the row to select - QModelIndex new_index = model()->index(new_row, 0); + QModelIndex new_idx = model()->index(new_row, 0); // Select the new current item, we want always the item after the last selected - if (new_index.isValid()) { + if (new_idx.isValid()) { // Workaround to update keyboard selected row, if it's not the first row (this also triggers selection) if (new_row != 0) keyPressEvent(new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier)); // Update visual selection with the entire row - selectionModel()->select(new_index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + selectionModel()->select(new_idx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } else { // We're removing the last item, select the new last row @@ -634,8 +634,8 @@ QList PlaylistView::GetEditableColumns() { QHeaderView *h = header(); for (int col = 0; col < h->count(); col++) { if (h->isSectionHidden(col)) continue; - QModelIndex index = model()->index(0, col); - if (index.flags() & Qt::ItemIsEditable) columns << h->visualIndex(col); + QModelIndex idx = model()->index(0, col); + if (idx.flags() & Qt::ItemIsEditable) columns << h->visualIndex(col); } std::sort(columns.begin(), columns.end()); return columns; @@ -646,12 +646,12 @@ QModelIndex PlaylistView::NextEditableIndex(const QModelIndex ¤t) { QList columns = GetEditableColumns(); QHeaderView *h = header(); - int index = columns.indexOf(h->visualIndex(current.column())); + int idx = columns.indexOf(h->visualIndex(current.column())); - if (index + 1 >= columns.size()) + if (idx + 1 >= columns.size()) return model()->index(current.row() + 1, h->logicalIndex(columns.first())); - return model()->index(current.row(), h->logicalIndex(columns[index + 1])); + return model()->index(current.row(), h->logicalIndex(columns[idx + 1])); } @@ -659,20 +659,20 @@ QModelIndex PlaylistView::PrevEditableIndex(const QModelIndex ¤t) { QList columns = GetEditableColumns(); QHeaderView *h = header(); - int index = columns.indexOf(h->visualIndex(current.column())); + int idx = columns.indexOf(h->visualIndex(current.column())); - if (index - 1 < 0) + if (idx - 1 < 0) return model()->index(current.row() - 1, h->logicalIndex(columns.last())); - return model()->index(current.row(), h->logicalIndex(columns[index - 1])); + return model()->index(current.row(), h->logicalIndex(columns[idx - 1])); } -bool PlaylistView::edit(const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event) { +bool PlaylistView::edit(const QModelIndex &idx, QAbstractItemView::EditTrigger trigger, QEvent *event) { - bool result = QAbstractItemView::edit(index, trigger, event); + bool result = QAbstractItemView::edit(idx, trigger, event); if (result && trigger == QAbstractItemView::AllEditTriggers && !event) { - playlist_->set_editing(index.row()); + playlist_->set_editing(idx.row()); } return result; @@ -685,19 +685,19 @@ void PlaylistView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHi } else if (hint == QAbstractItemDelegate::EditNextItem || hint == QAbstractItemDelegate::EditPreviousItem) { - QModelIndex index; + QModelIndex idx; if (hint == QAbstractItemDelegate::EditNextItem) - index = NextEditableIndex(currentIndex()); + idx = NextEditableIndex(currentIndex()); else - index = PrevEditableIndex(currentIndex()); + idx = PrevEditableIndex(currentIndex()); - if (!index.isValid()) { + if (!idx.isValid()) { QTreeView::closeEditor(editor, QAbstractItemDelegate::SubmitModelCache); } else { QTreeView::closeEditor(editor, QAbstractItemDelegate::NoHint); - setCurrentIndex(index); - QAbstractItemView::edit(index); + setCurrentIndex(idx); + QAbstractItemView::edit(idx); } } else { @@ -787,7 +787,6 @@ void PlaylistView::JumpToCurrentlyPlayingTrack() { // Scroll to the item scrollTo(current, QAbstractItemView::PositionAtCenter); - currently_autoscrolling_ = false; } @@ -975,12 +974,12 @@ void PlaylistView::dragMoveEvent(QDragMoveEvent *event) { QTreeView::dragMoveEvent(event); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QModelIndex index(indexAt(event->position().toPoint())); + QModelIndex idx(indexAt(event->position().toPoint())); #else - QModelIndex index(indexAt(event->pos())); + QModelIndex idx(indexAt(event->pos())); #endif - drop_indicator_row_ = index.isValid() ? index.row() : 0; + drop_indicator_row_ = idx.isValid() ? idx.row() : 0; } @@ -1154,7 +1153,7 @@ void PlaylistView::SaveSettings() { } -void PlaylistView::StretchChanged(bool stretch) { +void PlaylistView::StretchChanged(const bool stretch) { if (!initialized_) return; setHorizontalScrollBarPolicy(stretch ? Qt::ScrollBarAlwaysOff : Qt::ScrollBarAsNeeded); @@ -1205,7 +1204,7 @@ ColumnAlignmentMap PlaylistView::DefaultColumnAlignment() { } -void PlaylistView::SetColumnAlignment(int section, Qt::Alignment alignment) { +void PlaylistView::SetColumnAlignment(const int section, const Qt::Alignment alignment) { if (section < 0) return; @@ -1327,7 +1326,7 @@ void PlaylistView::set_background_image(const QImage &image) { } -void PlaylistView::FadePreviousBackgroundImage(qreal value) { +void PlaylistView::FadePreviousBackgroundImage(const qreal value) { previous_background_image_opacity_ = value; if (qFuzzyCompare(previous_background_image_opacity_, qreal(0.0))) { diff --git a/src/playlist/playlistview.h b/src/playlist/playlistview.h index 1a4520217..17ba6ec07 100644 --- a/src/playlist/playlistview.h +++ b/src/playlist/playlistview.h @@ -118,19 +118,19 @@ class PlaylistView : public QTreeView { void ReloadSettings(); void SaveGeometry(); void SaveSettings(); - void SetColumnAlignment(int section, Qt::Alignment alignment); + void SetColumnAlignment(const int section, const Qt::Alignment alignment); void JumpToCurrentlyPlayingTrack(); - void edit(const QModelIndex &index) { return QAbstractItemView::edit(index); } + void edit(const QModelIndex &idx) { return QAbstractItemView::edit(idx); } signals: - void PlayItem(const QModelIndex &index); + void PlayItem(QModelIndex idx); void PlayPause(); - void RightClicked(const QPoint &global_pos, const QModelIndex &index); + void RightClicked(QPoint global_pos, QModelIndex idx); void SeekForward(); void SeekBackward(); void FocusOnFilterSignal(QKeyEvent *event); void BackgroundPropertyChanged(); - void ColumnAlignmentChanged(const ColumnAlignmentMap &alignment); + void ColumnAlignmentChanged(ColumnAlignmentMap alignment); protected: // QWidget @@ -152,14 +152,14 @@ class PlaylistView : public QTreeView { // QTreeView void drawTree(QPainter *painter, const QRegion ®ion) const; - void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; // QAbstractScrollArea void scrollContentsBy(int dx, int dy) override; // QAbstractItemView void rowsInserted(const QModelIndex &parent, int start, int end) override; - bool edit(const QModelIndex &index, QAbstractItemView::EditTrigger trigger, QEvent *event) override; + bool edit(const QModelIndex &idx, QAbstractItemView::EditTrigger trigger, QEvent *event) override; void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) override; private slots: @@ -167,8 +167,8 @@ class PlaylistView : public QTreeView { void MaybeAutoscroll(); void InvalidateCachedCurrentPixmap(); void PlaylistDestroyed(); - void StretchChanged(bool stretch); - void FadePreviousBackgroundImage(qreal value); + void StretchChanged(const bool stretch); + void FadePreviousBackgroundImage(const qreal value); void StopGlowing(); void StartGlowing(); void JumpToLastPlayedTrack(); @@ -182,7 +182,7 @@ class PlaylistView : public QTreeView { void LoadGeometry(); void ReloadBarPixmaps(); QList LoadBarPixmap(const QString &filename); - void UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &index); + void UpdateCachedCurrentRowPixmap(QStyleOptionViewItem option, const QModelIndex &idx); void set_background_image_type(AppearanceSettingsPage::BackgroundImageType bg) { background_image_type_ = bg;