Clang-Tidy and Clazy fixes
This commit is contained in:
@@ -133,7 +133,7 @@ void SCollection::Exit() {
|
||||
|
||||
void SCollection::ExitReceived() {
|
||||
|
||||
QObject *obj = qobject_cast<QObject*>(sender());
|
||||
QObject *obj = sender();
|
||||
QObject::disconnect(obj, nullptr, this, nullptr);
|
||||
qLog(Debug) << obj << "successfully exited.";
|
||||
wait_for_exit_.removeAll(obj);
|
||||
|
||||
@@ -768,7 +768,8 @@ SongList CollectionBackend::GetSongsById(const QList<int> &ids) {
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
QStringList str_ids;
|
||||
for (int id : ids) {
|
||||
str_ids.reserve(ids.count());
|
||||
for (const int id : ids) {
|
||||
str_ids << QString::number(id);
|
||||
}
|
||||
|
||||
@@ -915,6 +916,7 @@ Song CollectionBackend::GetSongBySongId(const QString &song_id, QSqlDatabase &db
|
||||
SongList CollectionBackend::GetSongsBySongId(const QStringList &song_ids, QSqlDatabase &db) {
|
||||
|
||||
QStringList song_ids2;
|
||||
song_ids2.reserve(song_ids.count());
|
||||
for (const QString &song_id : song_ids) {
|
||||
song_ids2 << "'" + song_id + "'";
|
||||
}
|
||||
@@ -1164,7 +1166,7 @@ CollectionBackend::AlbumList CollectionBackend::GetAlbums(const QString &artist,
|
||||
|
||||
}
|
||||
|
||||
return albums.values();
|
||||
return albums.values(); // clazy:exclude=qt6-deprecated-api-fixes
|
||||
|
||||
}
|
||||
|
||||
@@ -1570,6 +1572,7 @@ void CollectionBackend::UpdateSongsRating(const QList<int> &id_list, const doubl
|
||||
QSqlDatabase db(db_->Connect());
|
||||
|
||||
QStringList id_str_list;
|
||||
id_str_list.reserve(id_list.count());
|
||||
for (int i : id_list) {
|
||||
id_str_list << QString::number(i);
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ QActionGroup *CollectionFilterWidget::CreateGroupByActions(QObject *parent) {
|
||||
|
||||
}
|
||||
|
||||
QAction *CollectionFilterWidget::CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping &grouping) {
|
||||
QAction *CollectionFilterWidget::CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping grouping) {
|
||||
|
||||
QAction *ret = new QAction(text, parent);
|
||||
ret->setCheckable(true);
|
||||
@@ -354,7 +354,7 @@ void CollectionFilterWidget::GroupByClicked(QAction *action) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionFilterWidget::GroupingChanged(const CollectionModel::Grouping &g) {
|
||||
void CollectionFilterWidget::GroupingChanged(const CollectionModel::Grouping g) {
|
||||
|
||||
if (!settings_group_.isEmpty()) {
|
||||
// Save the settings
|
||||
@@ -372,7 +372,7 @@ void CollectionFilterWidget::GroupingChanged(const CollectionModel::Grouping &g)
|
||||
|
||||
}
|
||||
|
||||
void CollectionFilterWidget::CheckCurrentGrouping(const CollectionModel::Grouping &g) {
|
||||
void CollectionFilterWidget::CheckCurrentGrouping(CollectionModel::Grouping g) {
|
||||
|
||||
for (QAction *action : group_by_group_->actions()) {
|
||||
if (action->property("group_by").isNull()) continue;
|
||||
|
||||
@@ -96,7 +96,7 @@ class CollectionFilterWidget : public QWidget {
|
||||
void keyReleaseEvent(QKeyEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void GroupingChanged(const CollectionModel::Grouping &g);
|
||||
void GroupingChanged(const CollectionModel::Grouping g);
|
||||
void GroupByClicked(QAction *action);
|
||||
void SaveGroupBy();
|
||||
void ShowGroupingManager();
|
||||
@@ -105,8 +105,8 @@ class CollectionFilterWidget : public QWidget {
|
||||
void FilterDelayTimeout();
|
||||
|
||||
private:
|
||||
static QAction *CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping &grouping);
|
||||
void CheckCurrentGrouping(const CollectionModel::Grouping &g);
|
||||
static QAction *CreateGroupByAction(const QString &text, QObject *parent, const CollectionModel::Grouping grouping);
|
||||
void CheckCurrentGrouping(CollectionModel::Grouping g);
|
||||
|
||||
private:
|
||||
Ui_CollectionFilterWidget *ui_;
|
||||
|
||||
@@ -50,6 +50,9 @@ class CollectionItem : public SimpleTreeItem<CollectionItem> {
|
||||
int container_level;
|
||||
Song metadata;
|
||||
CollectionItem *compilation_artist_node_;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(CollectionItem)
|
||||
};
|
||||
|
||||
#endif // COLLECTIONITEM_H
|
||||
|
||||
@@ -125,10 +125,9 @@ bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vie
|
||||
|
||||
if (!event || !view) return false;
|
||||
|
||||
QHelpEvent *he = static_cast<QHelpEvent*>(event);
|
||||
QString text = displayText(idx.data(), QLocale::system());
|
||||
|
||||
if (text.isEmpty() || !he) return false;
|
||||
if (text.isEmpty() || !event) return false;
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::ToolTip: {
|
||||
@@ -138,12 +137,12 @@ bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vie
|
||||
bool is_elided = displayed_text.width() < real_text.width();
|
||||
|
||||
if (is_elided) {
|
||||
QToolTip::showText(he->globalPos(), text, view);
|
||||
QToolTip::showText(event->globalPos(), text, view);
|
||||
}
|
||||
else if (idx.data(Qt::ToolTipRole).isValid()) {
|
||||
// If the item has a tooltip text, display it
|
||||
QString tooltip_text = idx.data(Qt::ToolTipRole).toString();
|
||||
QToolTip::showText(he->globalPos(), tooltip_text, view);
|
||||
QToolTip::showText(event->globalPos(), tooltip_text, view);
|
||||
}
|
||||
else {
|
||||
// in case that another text was previously displayed
|
||||
@@ -156,7 +155,7 @@ bool CollectionItemDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vie
|
||||
return true;
|
||||
|
||||
case QEvent::WhatsThis:
|
||||
QWhatsThis::showText(he->globalPos(), text, view);
|
||||
QWhatsThis::showText(event->globalPos(), text, view);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -159,7 +159,7 @@ void CollectionModel::set_show_dividers(const bool show_dividers) {
|
||||
|
||||
}
|
||||
|
||||
void CollectionModel::SaveGrouping(QString name) {
|
||||
void CollectionModel::SaveGrouping(const QString &name) {
|
||||
|
||||
qLog(Debug) << "Model, save to: " << name;
|
||||
|
||||
@@ -571,7 +571,7 @@ void CollectionModel::SongsDeleted(const SongList &songs) {
|
||||
QMap<quint64, ItemAndCacheKey>::iterator i = pending_art_.begin();
|
||||
while (i != pending_art_.end()) {
|
||||
if (i.value().first == node) {
|
||||
i = pending_art_.erase(i);
|
||||
i = pending_art_.erase(i); // clazy:exclude=strict-iterators
|
||||
}
|
||||
else {
|
||||
++i;
|
||||
@@ -1846,7 +1846,7 @@ bool CollectionModel::canFetchMore(const QModelIndex &parent) const {
|
||||
|
||||
}
|
||||
|
||||
void CollectionModel::SetGroupBy(const Grouping &g) {
|
||||
void CollectionModel::SetGroupBy(const Grouping g) {
|
||||
|
||||
group_by_ = g;
|
||||
|
||||
@@ -1916,7 +1916,7 @@ void CollectionModel::ExpandAll(CollectionItem *item) const {
|
||||
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping &g) {
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping g) {
|
||||
s << quint32(g.first) << quint32(g.second) << quint32(g.third);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class CollectionDirectoryModel;
|
||||
class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS(GroupBy)
|
||||
Q_ENUMS(GroupBy) // clazy:exclude=qenums
|
||||
|
||||
public:
|
||||
explicit CollectionModel(CollectionBackend *backend, Application *app, QObject *parent = nullptr);
|
||||
@@ -118,10 +118,10 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
|
||||
const GroupBy &operator[](const int i) const;
|
||||
GroupBy &operator[](const int i);
|
||||
bool operator==(const Grouping &other) const {
|
||||
bool operator==(const Grouping other) const {
|
||||
return first == other.first && second == other.second && third == other.third;
|
||||
}
|
||||
bool operator!=(const Grouping &other) const { return !(*this == other); }
|
||||
bool operator!=(const Grouping other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
struct QueryResult {
|
||||
@@ -162,7 +162,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
void set_show_dividers(const bool show_dividers);
|
||||
|
||||
// Save the current grouping
|
||||
void SaveGrouping(QString name);
|
||||
void SaveGrouping(const QString &name);
|
||||
|
||||
// Reload settings.
|
||||
void ReloadSettings();
|
||||
@@ -195,8 +195,8 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
|
||||
void ExpandAll(CollectionItem *item = nullptr) const;
|
||||
|
||||
const CollectionModel::Grouping &GetGroupBy() const { return group_by_; }
|
||||
void SetGroupBy(const CollectionModel::Grouping &g);
|
||||
const CollectionModel::Grouping GetGroupBy() const { return group_by_; }
|
||||
void SetGroupBy(const CollectionModel::Grouping g);
|
||||
|
||||
signals:
|
||||
void TotalSongCountUpdated(int count);
|
||||
@@ -317,7 +317,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
|
||||
Q_DECLARE_METATYPE(CollectionModel::Grouping)
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping &g);
|
||||
QDataStream &operator<<(QDataStream &s, const CollectionModel::Grouping g);
|
||||
QDataStream &operator>>(QDataStream &s, CollectionModel::Grouping &g);
|
||||
|
||||
#endif // COLLECTIONMODEL_H
|
||||
|
||||
@@ -56,6 +56,9 @@ class CollectionPlaylistItem : public PlaylistItem {
|
||||
|
||||
protected:
|
||||
Song song_;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(CollectionPlaylistItem)
|
||||
};
|
||||
|
||||
#endif // COLLECTIONPLAYLISTITEM_H
|
||||
|
||||
@@ -134,8 +134,10 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con
|
||||
|
||||
// Ignore 'literal' for IN
|
||||
if (!op.compare("IN", Qt::CaseInsensitive)) {
|
||||
QStringList values = value.toStringList();
|
||||
QStringList final;
|
||||
for (const QString &single_value : value.toStringList()) {
|
||||
final.reserve(values.count());
|
||||
for (const QString &single_value : values) {
|
||||
final.append("?");
|
||||
bound_values_ << single_value;
|
||||
}
|
||||
|
||||
@@ -564,13 +564,16 @@ SongList CollectionView::GetSelectedSongs() const {
|
||||
|
||||
void CollectionView::Organize() {
|
||||
|
||||
if (!organize_dialog_)
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), app_->collection_backend(), this));
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
organize_dialog_->SetCopy(false);
|
||||
if (organize_dialog_->SetSongs(GetSelectedSongs()))
|
||||
const SongList songs = GetSelectedSongs();
|
||||
if (organize_dialog_->SetSongs(songs)) {
|
||||
organize_dialog_->show();
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(this, tr("Error"), tr("None of the selected songs were suitable for copying to a device"));
|
||||
}
|
||||
@@ -583,7 +586,8 @@ void CollectionView::EditTracks() {
|
||||
edit_tag_dialog_.reset(new EditTagDialog(app_, this));
|
||||
QObject::connect(edit_tag_dialog_.get(), &EditTagDialog::Error, this, &CollectionView::EditTagError);
|
||||
}
|
||||
edit_tag_dialog_->SetSongs(GetSelectedSongs());
|
||||
const SongList songs = GetSelectedSongs();
|
||||
edit_tag_dialog_->SetSongs(songs);
|
||||
edit_tag_dialog_->show();
|
||||
|
||||
}
|
||||
@@ -634,6 +638,7 @@ void CollectionView::ShowInBrowser() {
|
||||
|
||||
SongList songs = GetSelectedSongs();
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
urls << song.url();
|
||||
}
|
||||
@@ -658,6 +663,7 @@ void CollectionView::Delete() {
|
||||
|
||||
SongList selected_songs = GetSelectedSongs();
|
||||
QStringList files;
|
||||
files.reserve(selected_songs.count());
|
||||
for (const Song &song : selected_songs) {
|
||||
files << song.url().toString();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cassert>
|
||||
|
||||
#include <QObject>
|
||||
@@ -65,6 +66,8 @@
|
||||
#undef RemoveDirectory
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace {
|
||||
static const char *kNoMediaFile = ".nomedia";
|
||||
static const char *kNoMusicFile = ".nomusic";
|
||||
@@ -95,7 +98,7 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
|
||||
|
||||
original_thread_ = thread();
|
||||
|
||||
rescan_timer_->setInterval(2000);
|
||||
rescan_timer_->setInterval(2s);
|
||||
rescan_timer_->setSingleShot(true);
|
||||
|
||||
periodic_scan_timer_->setInterval(86400 * kMsecPerSec);
|
||||
@@ -789,6 +792,7 @@ SongList CollectionWatcher::ScanNewFile(const QString &file, const QString &path
|
||||
// Playlist parser for CUEs considers every entry in sheet valid and we don't want invalid media getting into collection!
|
||||
QString file_nfd = file.normalized(QString::NormalizationForm_D);
|
||||
SongList cue_congs = cue_parser_->Load(&cue_file, matching_cue, path, false);
|
||||
songs.reserve(cue_congs.count());
|
||||
for (Song &cue_song : cue_congs) {
|
||||
cue_song.set_source(source_);
|
||||
cue_song.set_fingerprint(fingerprint);
|
||||
|
||||
@@ -122,7 +122,7 @@ void GroupByDialog::accept() {
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void GroupByDialog::CollectionGroupingChanged(const CollectionModel::Grouping &g) {
|
||||
void GroupByDialog::CollectionGroupingChanged(const CollectionModel::Grouping g) {
|
||||
ui_->combobox_first->setCurrentIndex(p_->mapping_.get<tag_group_by>().find(g[0])->combo_box_index);
|
||||
ui_->combobox_second->setCurrentIndex(p_->mapping_.get<tag_group_by>().find(g[1])->combo_box_index);
|
||||
ui_->combobox_third->setCurrentIndex(p_->mapping_.get<tag_group_by>().find(g[2])->combo_box_index);
|
||||
|
||||
@@ -45,7 +45,7 @@ class GroupByDialog : public QDialog {
|
||||
~GroupByDialog() override;
|
||||
|
||||
public slots:
|
||||
void CollectionGroupingChanged(const CollectionModel::Grouping &g);
|
||||
void CollectionGroupingChanged(const CollectionModel::Grouping g);
|
||||
void accept() override;
|
||||
|
||||
signals:
|
||||
|
||||
@@ -73,7 +73,7 @@ SavedGroupingManager::~SavedGroupingManager() {
|
||||
delete model_;
|
||||
}
|
||||
|
||||
QString SavedGroupingManager::GroupByToString(const CollectionModel::GroupBy &g) {
|
||||
QString SavedGroupingManager::GroupByToString(const CollectionModel::GroupBy g) {
|
||||
|
||||
switch (g) {
|
||||
case CollectionModel::GroupBy_None:
|
||||
|
||||
@@ -46,7 +46,7 @@ class SavedGroupingManager : public QDialog {
|
||||
void UpdateModel();
|
||||
void SetFilter(CollectionFilterWidget *filter) { filter_ = filter; }
|
||||
|
||||
static QString GroupByToString(const CollectionModel::GroupBy &g);
|
||||
static QString GroupByToString(const CollectionModel::GroupBy g);
|
||||
|
||||
private slots:
|
||||
void UpdateButtonState();
|
||||
|
||||
Reference in New Issue
Block a user