[Fix-Warnings] Local variable can be made const

This commit is contained in:
Brübach, Lukas 2025-11-29 15:11:22 +01:00
parent 8abd04dab1
commit f2d3e81331
214 changed files with 1375 additions and 1355 deletions

View file

@ -11,14 +11,14 @@ BarWidget::BarWidget(QString label, int value, int total, QColor barColor, QWidg
QSize BarWidget::sizeHint() const
{
QFontMetrics metrics(font());
int labelHeight = metrics.height();
int valueHeight = metrics.height();
const QFontMetrics metrics(font());
const int labelHeight = metrics.height();
const int valueHeight = metrics.height();
// Calculate the height dynamically based on the total
int barHeight = (total > 0) ? (value * 200 / total) : 20; // Scale height proportionally
int totalHeight = barHeight + labelHeight + valueHeight + 30; // Extra space for text
return QSize(60, totalHeight); // Allow width to expand
const int barHeight = (total > 0) ? (value * 200 / total) : 20; // Scale height proportionally
const int totalHeight = barHeight + labelHeight + valueHeight + 30; // Extra space for text
return QSize(60, totalHeight); // Allow width to expand
}
void BarWidget::paintEvent(QPaintEvent *event)
@ -26,13 +26,13 @@ void BarWidget::paintEvent(QPaintEvent *event)
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
int widgetWidth = width();
int widgetHeight = height();
const int widgetWidth = width();
const int widgetHeight = height();
// Calculate bar dimensions
int barWidth = widgetWidth * 0.8; // Use 80% of the available width
int fullBarHeight = widgetHeight - 40; // Leave space for labels
int valueBarHeight = (total > 0) ? (value * fullBarHeight / total) : 0;
const int barWidth = widgetWidth * 0.8; // Use 80% of the available width
const int fullBarHeight = widgetHeight - 40; // Leave space for labels
const int valueBarHeight = (total > 0) ? (value * fullBarHeight / total) : 0;
// Draw full bar background (gray)
painter.setBrush(QColor(200, 200, 200));
@ -44,12 +44,12 @@ void BarWidget::paintEvent(QPaintEvent *event)
// Draw the CMC label
painter.setPen(Qt::white);
QRect textRect(0, widgetHeight - 30, widgetWidth, 20);
const QRect textRect(0, widgetHeight - 30, widgetWidth, 20);
painter.drawText(textRect, Qt::AlignCenter, label);
// Draw the value count
painter.setPen(Qt::black);
QRect valueRect(0, 10, widgetWidth, 20);
const QRect valueRect(0, 10, widgetWidth, 20);
painter.drawText(valueRect, Qt::AlignCenter, QString::number(value));
(void)event; // Suppress unused parameter warning