Clang-Tidy and Clazy fixes

This commit is contained in:
Jonas Kvinge
2021-06-20 19:04:08 +02:00
parent 755abec636
commit 1295033fae
374 changed files with 1304 additions and 900 deletions

View File

@@ -58,6 +58,8 @@ class InternetPlaylistItem : public PlaylistItem {
private:
Song::Source source_;
Song metadata_;
Q_DISABLE_COPY(InternetPlaylistItem)
};
#endif // INTERNETPLAYLISTITEM_H

View File

@@ -31,6 +31,8 @@ class QModelIndex;
class InternetSearchView;
class InternetSearchItemDelegate : public CollectionItemDelegate {
Q_OBJECT
public:
explicit InternetSearchItemDelegate(InternetSearchView *view);

View File

@@ -294,6 +294,7 @@ void InternetSearchModel::Clear() {
InternetSearchView::ResultList InternetSearchModel::GetChildResults(const QModelIndexList &indexes) const {
QList<QStandardItem*> items;
items.reserve(indexes.count());
for (const QModelIndex &idx : indexes) {
items << itemFromIndex(idx);
}
@@ -363,7 +364,7 @@ void GatherResults(const QStandardItem *parent, InternetSearchView::ResultList *
}
}
void InternetSearchModel::SetGroupBy(const CollectionModel::Grouping &grouping, const bool regroup_now) {
void InternetSearchModel::SetGroupBy(const CollectionModel::Grouping grouping, const bool regroup_now) {
const CollectionModel::Grouping old_group_by = group_by_;
group_by_ = grouping;
@@ -388,6 +389,8 @@ MimeData *InternetSearchModel::LoadTracks(const InternetSearchView::ResultList &
SongList songs;
QList<QUrl> urls;
songs.reserve(results.count());
urls.reserve(results.count());
for (const InternetSearchView::Result &result : results) {
songs << result.metadata_;
urls << result.metadata_.url();

View File

@@ -64,7 +64,7 @@ class InternetSearchModel : public QStandardItemModel {
void set_proxy(QSortFilterProxyModel *proxy) { proxy_ = proxy; }
void set_use_pretty_covers(const bool pretty) { use_pretty_covers_ = pretty; }
void SetGroupBy(const CollectionModel::Grouping &grouping, const bool regroup_now);
void SetGroupBy(const CollectionModel::Grouping grouping, const bool regroup_now);
void Clear();

View File

@@ -27,6 +27,8 @@ class QObject;
class QModelIndex;
class InternetSearchSortModel : public QSortFilterProxyModel {
Q_OBJECT
public:
explicit InternetSearchSortModel(QObject *parent = nullptr);

View File

@@ -364,7 +364,7 @@ void InternetSearchView::timerEvent(QTimerEvent *e) {
QMap<int, DelayedSearch>::iterator it = delayed_searches_.find(e->timerId());
if (it != delayed_searches_.end()) {
SearchAsync(it.value().id_, it.value().query_, it.value().type_);
delayed_searches_.erase(it);
delayed_searches_.erase(it); // clazy:exclude=strict-iterators
return;
}
@@ -497,6 +497,7 @@ void InternetSearchView::SearchDone(const int service_id, const SongList &songs,
}
ResultList results;
results.reserve(songs.count());
for (const Song &song : songs) {
Result result;
result.metadata_ = song;
@@ -518,7 +519,7 @@ void InternetSearchView::CancelSearch(const int id) {
for (it = delayed_searches_.begin(); it != delayed_searches_.end(); ++it) {
if (it.value().id_ == id) {
killTimer(it.key());
delayed_searches_.erase(it);
delayed_searches_.erase(it); // clazy:exclude=strict-iterators
return;
}
}
@@ -592,7 +593,7 @@ MimeData *InternetSearchView::SelectedMimeData() {
for (int i = 0 ; i < front_proxy_->rowCount() ; ++i) {
QModelIndex idx = front_proxy_->index(i, 0);
if (!idx.data(CollectionModel::Role_IsDivider).toBool()) {
indexes << idx;
indexes << idx; // clazy:exclude=reserve-candidates
ui_->results->setCurrentIndex(idx);
break;
}
@@ -607,7 +608,7 @@ MimeData *InternetSearchView::SelectedMimeData() {
// Get items for these indexes
QList<QStandardItem*> items;
for (const QModelIndex &idx : indexes) {
items << (front_model_->itemFromIndex(front_proxy_->mapToSource(idx)));
items << (front_model_->itemFromIndex(front_proxy_->mapToSource(idx))); // clazy:exclude=reserve-candidates
}
// Get a MimeData for these items
@@ -687,7 +688,7 @@ void InternetSearchView::GroupByClicked(QAction *action) {
}
void InternetSearchView::SetGroupBy(const CollectionModel::Grouping &g) {
void InternetSearchView::SetGroupBy(const CollectionModel::Grouping g) {
// Clear requests: changing "group by" on the models will cause all the items to be removed/added again,
// so all the QModelIndex here will become invalid. New requests will be created for those

View File

@@ -91,7 +91,7 @@ class InternetSearchView : public QWidget {
protected:
struct PendingState {
PendingState() : orig_id_(-1) {}
PendingState(int orig_id, QStringList tokens) : orig_id_(orig_id), tokens_(tokens) {}
PendingState(int orig_id, const QStringList &tokens) : orig_id_(orig_id), tokens_(tokens) {}
int orig_id_;
QStringList tokens_;
@@ -170,7 +170,7 @@ class InternetSearchView : public QWidget {
void SearchAlbumsClicked(const bool);
void SearchSongsClicked(const bool);
void GroupByClicked(QAction *action);
void SetGroupBy(const CollectionModel::Grouping &g);
void SetGroupBy(const CollectionModel::Grouping g);
void AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderResult &albumcover_result);

View File

@@ -60,7 +60,7 @@ void InternetServices::RemoveService(InternetService *service) {
}
InternetService *InternetServices::ServiceBySource(const Song::Source &source) {
InternetService *InternetServices::ServiceBySource(const Song::Source source) {
if (services_.contains(source)) return services_.value(source);
return nullptr;

View File

@@ -40,7 +40,7 @@ class InternetServices : public QObject {
explicit InternetServices(QObject *parent = nullptr);
~InternetServices() override;
InternetService *ServiceBySource(const Song::Source &source);
InternetService *ServiceBySource(const Song::Source source);
template <typename T>
T *Service() {
return static_cast<T*>(this->ServiceBySource(T::kSource));

View File

@@ -30,7 +30,7 @@ class InternetSongMimeData : public MimeData {
Q_OBJECT
public:
explicit InternetSongMimeData(InternetService *_service) : service(_service) {}
explicit InternetSongMimeData(InternetService *_service, QObject* = nullptr) : service(_service) {}
InternetService *service;
SongList songs;