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

@@ -96,7 +96,7 @@ void MoodbarItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
}
QPixmap MoodbarItemDelegate::PixmapForIndex(const QModelIndex &idx, const QSize &size) {
QPixmap MoodbarItemDelegate::PixmapForIndex(const QModelIndex &idx, const QSize size) {
// Pixmaps are keyed off URL.
const QUrl url = idx.sibling(idx.row(), Playlist::Column_Filename).data().toUrl();

View File

@@ -76,7 +76,7 @@ class MoodbarItemDelegate : public QItemDelegate {
};
private:
QPixmap PixmapForIndex(const QModelIndex &idx, const QSize &size);
QPixmap PixmapForIndex(const QModelIndex &idx, const QSize size);
void StartLoadingData(const QUrl &url, Data *data);
void StartLoadingColors(const QUrl &url, const QByteArray &bytes, Data *data);
void StartLoadingImage(const QUrl &url, Data *data);

View File

@@ -18,6 +18,7 @@
#include "moodbarloader.h"
#include <memory>
#include <chrono>
#include <QtGlobal>
#include <QObject>
@@ -45,6 +46,8 @@
#include "settings/moodbarsettingspage.h"
using namespace std::chrono_literals;
#ifdef Q_OS_WIN32
# include <windows.h>
#endif
@@ -199,7 +202,7 @@ void MoodbarLoader::RequestFinished(MoodbarPipeline *request, const QUrl &url) {
requests_.remove(url);
active_requests_.remove(url);
QTimer::singleShot(1000, request, &MoodbarLoader::deleteLater);
QTimer::singleShot(1s, request, &MoodbarLoader::deleteLater);
MaybeTakeNextRequest();

View File

@@ -37,8 +37,8 @@
bool MoodbarPipeline::sIsAvailable = false;
const int MoodbarPipeline::kBands = 128;
MoodbarPipeline::MoodbarPipeline(const QUrl &local_filename)
: QObject(nullptr),
MoodbarPipeline::MoodbarPipeline(const QUrl &local_filename, QObject *parent)
: QObject(parent),
local_filename_(local_filename),
pipeline_(nullptr),
convert_element_(nullptr),

View File

@@ -36,7 +36,7 @@ class MoodbarPipeline : public QObject {
Q_OBJECT
public:
explicit MoodbarPipeline(const QUrl &local_filename);
explicit MoodbarPipeline(const QUrl &local_filename, QObject *parent = nullptr);
~MoodbarPipeline() override;
static bool IsAvailable();

View File

@@ -50,7 +50,7 @@ const int MoodbarProxyStyle::kBorderSize = 1;
const int MoodbarProxyStyle::kArrowWidth = 17;
const int MoodbarProxyStyle::kArrowHeight = 13;
MoodbarProxyStyle::MoodbarProxyStyle(Application *app, QSlider *slider)
MoodbarProxyStyle::MoodbarProxyStyle(Application *app, QSlider *slider, QObject*)
: QProxyStyle(nullptr),
app_(app),
slider_(slider),
@@ -335,7 +335,7 @@ void MoodbarProxyStyle::DrawArrow(const QStyleOptionSlider *option, QPainter *pa
}
QPixmap MoodbarProxyStyle::MoodbarPixmap(const ColorVector &colors, const QSize &size, const QPalette &palette, const QStyleOptionSlider *opt) {
QPixmap MoodbarProxyStyle::MoodbarPixmap(const ColorVector &colors, const QSize size, const QPalette &palette, const QStyleOptionSlider *opt) {
Q_UNUSED(opt);
@@ -367,7 +367,7 @@ QPixmap MoodbarProxyStyle::MoodbarPixmap(const ColorVector &colors, const QSize
}
void MoodbarProxyStyle::ShowContextMenu(const QPoint &pos) {
void MoodbarProxyStyle::ShowContextMenu(const QPoint pos) {
if (!context_menu_) {
context_menu_ = new QMenu(slider_);

View File

@@ -48,7 +48,7 @@ class MoodbarProxyStyle : public QProxyStyle {
Q_OBJECT
public:
explicit MoodbarProxyStyle(Application *app, QSlider *slider);
explicit MoodbarProxyStyle(Application *app, QSlider *slider, QObject *parent = nullptr);
// QProxyStyle
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override;
@@ -78,9 +78,9 @@ class MoodbarProxyStyle : public QProxyStyle {
void Render(ComplexControl control, const QStyleOptionSlider *option, QPainter *painter, const QWidget *widget);
void EnsureMoodbarRendered(const QStyleOptionSlider *opt);
void DrawArrow(const QStyleOptionSlider *option, QPainter *painter) const;
void ShowContextMenu(const QPoint &pos);
void ShowContextMenu(const QPoint pos);
QPixmap MoodbarPixmap(const ColorVector &colors, const QSize &size, const QPalette &palette, const QStyleOptionSlider *opt);
QPixmap MoodbarPixmap(const ColorVector &colors, const QSize size, const QPalette &palette, const QStyleOptionSlider *opt);
private slots:
void ReloadSettings();

View File

@@ -73,7 +73,7 @@ ColorVector MoodbarRenderer::Colors(const QByteArray &data, const MoodbarStyle s
memset(hue_distribution, 0, sizeof(hue_distribution));
ColorVector colors;
colors.reserve(samples);
// Read the colors, keeping track of some histograms
for (int i = 0; i < samples; ++i) {
QColor color;
@@ -110,10 +110,11 @@ ColorVector MoodbarRenderer::Colors(const QByteArray &data, const MoodbarStyle s
return colors;
}
void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect &rect) {
void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect rect) {
// Sample the colors and map them to screen pixels.
ColorVector screen_colors;
screen_colors.reserve(rect.width());
for (int x = 0; x < rect.width(); ++x) {
int r = 0;
int g = 0;
@@ -139,8 +140,8 @@ void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect
int h = 0, s = 0, v = 0;
screen_colors[x].getHsv(&h, &s, &v);
for (int y = 0; y <= rect.height() / 2; y++) {
float coeff = float(y) / float(rect.height() / 2);
for (int y = 0; y <= rect.height() / 2; ++y) {
float coeff = float(y) / float(rect.height() / 2); // NOLINT(bugprone-integer-division)
float coeff2 = 1.0f - ((1.0f - coeff) * (1.0f - coeff));
coeff = 1.0f - (1.0f - coeff) / 2.0f;
coeff2 = 1.f - (1.f - coeff2) / 2.0f;
@@ -153,7 +154,7 @@ void MoodbarRenderer::Render(const ColorVector &colors, QPainter *p, const QRect
}
}
QImage MoodbarRenderer::RenderToImage(const ColorVector &colors, const QSize &size) {
QImage MoodbarRenderer::RenderToImage(const ColorVector &colors, const QSize size) {
QImage image(size, QImage::Format_ARGB32_Premultiplied);
QPainter p(&image);

View File

@@ -50,8 +50,8 @@ class MoodbarRenderer {
static QString StyleName(const MoodbarStyle style);
static ColorVector Colors(const QByteArray &data, const MoodbarStyle style, const QPalette &palette);
static void Render(const ColorVector &colors, QPainter *p, const QRect &rect);
static QImage RenderToImage(const ColorVector &colors, const QSize &size);
static void Render(const ColorVector &colors, QPainter *p, const QRect rect);
static QImage RenderToImage(const ColorVector &colors, const QSize size);
private:
explicit MoodbarRenderer();