Fix various clazy warnings

This commit is contained in:
Jonas Kvinge
2021-03-21 04:47:11 +01:00
parent 20c1c1d4be
commit 78588d8cdf
92 changed files with 337 additions and 234 deletions

View File

@@ -866,7 +866,7 @@ void Playlist::MoveItemWithoutUndo(const int source, const int dest) {
void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
layoutAboutToBeChanged();
emit layoutAboutToBeChanged();
PlaylistItemList moved_items;
if (pos < 0) {
@@ -909,14 +909,14 @@ void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
}
current_virtual_index_ = virtual_items_.indexOf(current_row());
layoutChanged();
emit layoutChanged();
Save();
}
void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
layoutAboutToBeChanged();
emit layoutAboutToBeChanged();
PlaylistItemList moved_items;
int pos = start;
@@ -959,7 +959,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
}
current_virtual_index_ = virtual_items_.indexOf(current_row());
layoutChanged();
emit layoutChanged();
Save();
}
@@ -1357,7 +1357,7 @@ void Playlist::sort(int column, Qt::SortOrder order) {
void Playlist::ReOrderWithoutUndo(const PlaylistItemList &new_items) {
layoutAboutToBeChanged();
emit layoutAboutToBeChanged();
PlaylistItemList old_items = items_;
items_ = new_items;
@@ -1372,7 +1372,7 @@ void Playlist::ReOrderWithoutUndo(const PlaylistItemList &new_items) {
changePersistentIndex(idx, index(new_rows[item], idx.column(), idx.parent()));
}
layoutChanged();
emit layoutChanged();
emit PlaylistChanged();
Save();
@@ -1392,7 +1392,7 @@ void Playlist::SetCurrentIsPaused(const bool paused) {
current_is_paused_ = paused;
if (current_item_index_.isValid())
dataChanged(index(current_item_index_.row(), 0), index(current_item_index_.row(), ColumnCount - 1));
emit dataChanged(index(current_item_index_.row(), 0), index(current_item_index_.row(), ColumnCount - 1));
}
void Playlist::Save() const {

View File

@@ -298,7 +298,7 @@ class Playlist : public QAbstractListModel {
void set_auto_sort(const bool auto_sort) { auto_sort_ = auto_sort; }
public slots:
void set_current_row(const int i, const AutoScroll autoscroll = AutoScroll_Maybe, const bool is_stopping = false, const bool force_inform = false);
void set_current_row(const int i, const Playlist::AutoScroll autoscroll = Playlist::AutoScroll_Maybe, const bool is_stopping = false, const bool force_inform = false);
void Paused();
void Playing();
void Stopped();

View File

@@ -131,7 +131,13 @@ void PlaylistItem::RemoveBackgroundColor(short priority) {
background_colors_.remove(priority);
}
QColor PlaylistItem::GetCurrentBackgroundColor() const {
return background_colors_.isEmpty() ? QColor() : background_colors_[background_colors_.keys().last()];
if (background_colors_.isEmpty()) return QColor();
else {
QList<short> background_colors_keys = background_colors_.keys();
return background_colors_[background_colors_keys.last()];
}
}
bool PlaylistItem::HasCurrentBackgroundColor() const {
return !background_colors_.isEmpty();
@@ -147,7 +153,13 @@ void PlaylistItem::RemoveForegroundColor(short priority) {
foreground_colors_.remove(priority);
}
QColor PlaylistItem::GetCurrentForegroundColor() const {
return foreground_colors_.isEmpty() ? QColor() : foreground_colors_[foreground_colors_.keys().last()];
if (foreground_colors_.isEmpty()) return QColor();
else {
QList<short> foreground_colors_keys = foreground_colors_.keys();
return foreground_colors_[foreground_colors_keys.last()];
}
}
bool PlaylistItem::HasCurrentForegroundColor() const {
return !foreground_colors_.isEmpty();

View File

@@ -432,7 +432,7 @@ void PlaylistListContainer::Delete() {
}
// Unfavorite the playlists
for (int id : ids) {
for (const int id : qAsConst(ids)) {
app_->playlist_manager()->Favorite(id, false);
}

View File

@@ -130,7 +130,7 @@ void PlaylistListModel::RowsAboutToBeRemoved(const QModelIndex &parent, const in
switch (idx.data(Role_Type).toInt()) {
case Type_Playlist: {
const int id = idx.data(Role_PlaylistId).toInt();
QMap<int, QStandardItem*>::Iterator it = playlists_by_id_.find(id);
QMap<int, QStandardItem*>::iterator it = playlists_by_id_.find(id);
if (it != playlists_by_id_.end() && it.value() == item) {
playlists_by_id_.erase(it);
}

View File

@@ -84,9 +84,10 @@ PlaylistManager::PlaylistManager(Application *app, QObject *parent)
}
PlaylistManager::~PlaylistManager() {
for (const Data &data : playlists_.values()) {
delete data.p;
}
QList<Data> datas = playlists_.values();
for (const Data &data : datas) delete data.p;
}
void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBackend *playlist_backend, PlaylistSequence *sequence, PlaylistContainer *playlist_container) {
@@ -130,7 +131,8 @@ QList<Playlist*> PlaylistManager::GetAllPlaylists() const {
QList<Playlist*> result;
for (const Data &data : playlists_.values()) {
QList<Data> datas = playlists_.values();
for (const Data &data : datas) {
result.append(data.p);
}
@@ -339,7 +341,8 @@ bool PlaylistManager::Close(const int id) {
if (playlists_.count() <= 1 || !playlists_.contains(id)) return false;
int next_id = -1;
for (int possible_next_id : playlists_.keys()) {
QList<int> playlist_ids = playlists_.keys();
for (const int possible_next_id : playlist_ids) {
if (possible_next_id != id) {
next_id = possible_next_id;
break;
@@ -491,7 +494,7 @@ void PlaylistManager::SongsDiscovered(const SongList &songs) {
// Some songs might've changed in the collection, let's update any playlist items we have that match those songs
for (const Song &song : songs) {
for (const Data &data : playlists_) {
for (const Data &data : qAsConst(playlists_)) {
PlaylistItemList items = data.p->collection_items_by_id(song.id());
for (PlaylistItemPtr item : items) {
if (item->Metadata().directory_id() != song.directory_id()) continue;
@@ -582,11 +585,13 @@ QString PlaylistManager::GetNameForNewPlaylist(const SongList &songs) {
result = tr("Various artists");
}
else {
result = artists.values().first();
QStringList artist_names = artists.values();
result = artist_names.first();
}
if (!various_artists && albums.size() == 1) {
result += " - " + albums.values().first();
QStringList album_names = albums.values();
result += " - " + album_names.first();
}
return result;