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

@@ -20,6 +20,7 @@
*/
#include <functional>
#include <chrono>
#include <QtGlobal>
#include <QThread>
@@ -45,6 +46,8 @@
# include "transcoder/transcoder.h"
#endif
using namespace std::chrono_literals;
class OrganizeFormat;
const int Organize::kBatchSize = 10;
@@ -52,8 +55,9 @@ const int Organize::kBatchSize = 10;
const int Organize::kTranscodeProgressInterval = 500;
#endif
Organize::Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganizeFormat &format, bool copy, bool overwrite, bool mark_as_listened, bool albumcover, const NewSongInfoList &songs_info, bool eject_after, const QString &playlist)
: thread_(nullptr),
Organize::Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool mark_as_listened, const bool albumcover, const NewSongInfoList &songs_info, const bool eject_after, const QString &playlist, QObject *parent)
: QObject(parent),
thread_(nullptr),
task_manager_(task_manager),
#ifdef HAVE_GSTREAMER
transcoder_(new Transcoder(this)),
@@ -77,9 +81,10 @@ Organize::Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> dest
original_thread_ = thread();
process_files_timer_->setSingleShot(true);
process_files_timer_->setInterval(100);
process_files_timer_->setInterval(100ms);
QObject::connect(process_files_timer_, &QTimer::timeout, this, &Organize::ProcessSomeFiles);
tasks_pending_.reserve(songs_info.count());
for (const NewSongInfo &song_info : songs_info) {
tasks_pending_ << Task(song_info);
}
@@ -87,10 +92,12 @@ Organize::Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> dest
}
Organize::~Organize() {
if (thread_) {
thread_->quit();
thread_->deleteLater();
}
}
void Organize::Start() {
@@ -380,7 +387,7 @@ void Organize::timerEvent(QTimerEvent *e) {
}
void Organize::LogLine(const QString message) {
void Organize::LogLine(const QString &message) {
QString date(QDateTime::currentDateTime().toString(Qt::TextDate));
log_.append(QString("%1: %2").arg(date, message));

View File

@@ -60,7 +60,7 @@ class Organize : public QObject {
};
typedef QList<NewSongInfo> NewSongInfoList;
explicit Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganizeFormat &format, bool copy, bool overwrite, bool mark_as_listened, bool albumcover, const NewSongInfoList &songs, bool eject_after, const QString &playlist = QString());
explicit Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool mark_as_listened, const bool albumcover, const NewSongInfoList &songs, const bool eject_after, const QString &playlist = QString(), QObject *parent = nullptr);
~Organize() override;
static const int kBatchSize;
@@ -81,7 +81,7 @@ class Organize : public QObject {
private slots:
void ProcessSomeFiles();
void FileTranscoded(const QString &input, const QString &output, bool success);
void LogLine(const QString message);
void LogLine(const QString &message);
private:
void SetSongProgress(float progress, bool transcoded = false);

View File

@@ -369,7 +369,7 @@ bool OrganizeDialog::SetSongs(const SongList &songs) {
}
songs_future_ = QFuture<SongList>();
return songs_.count();
return !songs_.isEmpty();
}
@@ -465,7 +465,7 @@ Organize::NewSongInfoList OrganizeDialog::ComputeNewSongsFilenames(const SongLis
// Better to rename them: e.g. foo.bar -> foo(2).bar
QHash<QString, int> filenames;
Organize::NewSongInfoList new_songs_info;
new_songs_info.reserve(songs.count());
for (const Song &song : songs) {
QString new_filename = format.GetFilenameForSong(song, extension);
if (filenames.contains(new_filename)) {
@@ -552,11 +552,13 @@ void OrganizeDialog::UpdatePreviews() {
}
void OrganizeDialog::OrganizeFinished(const QStringList files_with_errors, const QStringList log) {
void OrganizeDialog::OrganizeFinished(const QStringList &files_with_errors, const QStringList &log) {
if (files_with_errors.isEmpty()) return;
error_dialog_.reset(new OrganizeErrorDialog);
error_dialog_->Show(OrganizeErrorDialog::Type_Copy, files_with_errors, log);
}
void OrganizeDialog::AllowExtASCII(const bool checked) {

View File

@@ -100,7 +100,7 @@ class OrganizeDialog : public QDialog {
void InsertTag(const QString &tag);
void UpdatePreviews();
void OrganizeFinished(const QStringList files_with_errors, const QStringList log);
void OrganizeFinished(const QStringList &files_with_errors, const QStringList &log);
void AllowExtASCII(const bool checked);

View File

@@ -54,6 +54,7 @@ OrganizeErrorDialog::~OrganizeErrorDialog() {
void OrganizeErrorDialog::Show(OperationType type, const SongList &songs_with_errors, const QStringList &log) {
QStringList files;
files.reserve(songs_with_errors.count());
for (const Song &song : songs_with_errors) {
files << song.url().toLocalFile();
}

View File

@@ -68,13 +68,13 @@ class OrganizeFormat {
bool IsValid() const;
QString GetFilenameForSong(const Song &song, QString extension = QString()) const;
class Validator : public QValidator {
class Validator : public QValidator { // clazy:exclude=missing-qobject-macro
public:
explicit Validator(QObject *parent = nullptr);
QValidator::State validate(QString &input, int&) const override;
};
class SyntaxHighlighter : public QSyntaxHighlighter {
class SyntaxHighlighter : public QSyntaxHighlighter { // clazy:exclude=missing-qobject-macro
public:
static const QRgb kValidTagColorLight;
static const QRgb kInvalidTagColorLight;