Revamp Queued Custom Type Ex: Add const when applicable

Task-number: QTBUG-117147
Pick-to: 6.6 6.5
Change-Id: I2fe342fa585f8c1203fa64d2a9ceabc07070cc77
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Rym Bouabid 2023-09-20 18:12:29 +02:00
parent aa95294080
commit 34ff72d0ba
3 changed files with 12 additions and 12 deletions

View File

@ -48,8 +48,8 @@ QImage createImage(int width, int height)
int x = 0;
int y = 0;
int starWidth = image.width()/3;
int starHeight = image.height()/3;
const int starWidth = image.width()/3;
const int starHeight = image.height()/3;
QRect rect(x, y, starWidth, starHeight);

View File

@ -35,21 +35,21 @@ void RenderThread::processImage(const QImage &image)
void RenderThread::run()
{
int size = qMax(m_image.width()/20, m_image.height()/20);
const int size = qMax(m_image.width()/20, m_image.height()/20);
for (int s = size; s > 0; --s) {
for (int c = 0; c < 400; ++c) {
//![processing the image (start)]
int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
int x2 = qMin(x1 + s/2 + 1, m_image.width());
int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
int y2 = qMin(y1 + s/2 + 1, m_image.height());
const int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
const int x2 = qMin(x1 + s/2 + 1, m_image.width());
const int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
const int y2 = qMin(y1 + s/2 + 1, m_image.height());
int n = 0;
int red = 0;
int green = 0;
int blue = 0;
for (int i = y1; i < y2; ++i) {
for (int j = x1; j < x2; ++j) {
QRgb pixel = m_image.pixel(j, i);
const QRgb pixel = m_image.pixel(j, i);
red += qRed(pixel);
green += qGreen(pixel);
blue += qBlue(pixel);
@ -57,7 +57,7 @@ void RenderThread::run()
}
}
//![processing the image (finish)]
Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1),
const Block block(QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1),
QColor(red/n, green/n, blue/n));
emit sendBlock(block);
if (m_abort)

View File

@ -60,13 +60,13 @@ void Window::loadImage()
if (format.toLower() == format)
formats.append(QLatin1String("*.") + QString::fromLatin1(format));
QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
const QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
path, tr("Image files (%1)").arg(formats.join(' ')));
if (newPath.isEmpty())
return;
QImage image(newPath);
const QImage image(newPath);
if (!image.isNull()) {
loadImage(image);
path = newPath;
@ -76,7 +76,7 @@ void Window::loadImage()
void Window::loadImage(const QImage &image)
{
QImage useImage;
QRect space = QGuiApplication::primaryScreen()->availableGeometry();
const QRect space = QGuiApplication::primaryScreen()->availableGeometry();
if (image.width() > 0.75*space.width() || image.height() > 0.75*space.height())
useImage = image.scaled(0.75*space.width(), 0.75*space.height(),
Qt::KeepAspectRatio, Qt::SmoothTransformation);