Add const and std::as_const

This commit is contained in:
Jonas Kvinge
2024-04-23 17:15:42 +02:00
parent 24c8d06d41
commit 426de61525
67 changed files with 273 additions and 192 deletions

View File

@@ -88,6 +88,8 @@ void MoodbarBuilder::AddFrame(const double *magnitudes, int size) {
void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
const QList<Rgb> rgb_vals = *vals;
double mini = vals->at(0).*member;
double maxi = vals->at(0).*member;
for (int i = 1; i < vals->count(); i++) {
@@ -101,7 +103,7 @@ void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
}
double avg = 0;
for (const Rgb &rgb : *vals) {
for (const Rgb &rgb : rgb_vals) {
const double value = rgb.*member;
if (value != mini && value != maxi) {
avg += value / static_cast<double>(vals->count());
@@ -112,7 +114,7 @@ void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
double tb = 0;
double avgu = 0;
double avgb = 0;
for (const Rgb &rgb : *vals) {
for (const Rgb &rgb : rgb_vals) {
const double value = rgb.*member;
if (value != mini && value != maxi) {
if (value > avg) {
@@ -132,7 +134,7 @@ void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
tb = 0;
double avguu = 0;
double avgbb = 0;
for (const Rgb &rgb : *vals) {
for (const Rgb &rgb : rgb_vals) {
const double value = rgb.*member;
if (value != mini && value != maxi) {
if (value > avgu) {

View File

@@ -16,6 +16,7 @@
*/
#include <algorithm>
#include <utility>
#include <QApplication>
#include <QtConcurrentRun>
@@ -177,7 +178,8 @@ bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl &url, Data
void MoodbarItemDelegate::ReloadAllColors() {
for (const QUrl &url : data_.keys()) {
const QList<QUrl> urls = data_.keys();
for (const QUrl &url : urls) {
Data *data = data_[url];
if (data->state_ == Data::State::Loaded) {

View File

@@ -114,7 +114,8 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl &url, const bool has_cue, Q
// Check if a mood file exists for this file already
const QString filename(url.toLocalFile());
for (const QString &possible_mood_file : MoodFilenames(filename)) {
const QStringList possible_mood_files = MoodFilenames(filename);
for (const QString &possible_mood_file : possible_mood_files) {
QFile f(possible_mood_file);
if (f.exists()) {
if (f.open(QIODevice::ReadOnly)) {

View File

@@ -391,7 +391,8 @@ void MoodbarProxyStyle::ShowContextMenu(const QPoint pos) {
}
// Update the currently selected style
for (QAction *action : style_action_group_->actions()) {
const QList<QAction*> actions = style_action_group_->actions();
for (QAction *action : actions) {
if (static_cast<MoodbarRenderer::MoodbarStyle>(action->data().toInt()) == moodbar_style_) {
action->setChecked(true);
break;