diff --git a/src/printsupport/dialogs/qprintpreviewdialog.cpp b/src/printsupport/dialogs/qprintpreviewdialog.cpp index 97acbb79a1..435f8869c4 100644 --- a/src/printsupport/dialogs/qprintpreviewdialog.cpp +++ b/src/printsupport/dialogs/qprintpreviewdialog.cpp @@ -250,8 +250,8 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer) zoomEditor->setValidator(new ZoomFactorValidator(1, 1000, 1, zoomEditor)); zoomFactor->setLineEdit(zoomEditor); static const short factorsX2[] = { 25, 50, 100, 200, 250, 300, 400, 800, 1600 }; - for (int i = 0; i < int(sizeof(factorsX2) / sizeof(factorsX2[0])); ++i) - zoomFactor->addItem(QPrintPreviewDialog::tr("%1%").arg(factorsX2[i] / 2.0)); + for (auto factorX2 : factorsX2) + zoomFactor->addItem(QPrintPreviewDialog::tr("%1%").arg(factorX2 / 2.0)); QObject::connect(zoomFactor->lineEdit(), SIGNAL(editingFinished()), q, SLOT(_q_zoomFactorChanged())); QObject::connect(zoomFactor, SIGNAL(currentIndexChanged(int)), diff --git a/src/printsupport/kernel/qpaintengine_alpha.cpp b/src/printsupport/kernel/qpaintengine_alpha.cpp index 4922d210f2..939322cc07 100644 --- a/src/printsupport/kernel/qpaintengine_alpha.cpp +++ b/src/printsupport/kernel/qpaintengine_alpha.cpp @@ -336,8 +336,8 @@ void QAlphaPaintEngine::flushAndInit(bool init) d->resetState(painter()); // fill in the alpha images - for (int i=0; idrawAlphaImage(rects.at(i)); + for (const auto &rect : qAsConst(rects)) + d->drawAlphaImage(rect); d->m_alphargn = QRegion(); diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp index 29dd0d6529..26799a6f13 100644 --- a/src/printsupport/kernel/qprintdevice.cpp +++ b/src/printsupport/kernel/qprintdevice.cpp @@ -283,10 +283,10 @@ void QPrintDevice::format(QDebug debug) const << ", defaultColorMode="<< defaultColorMode(); # ifndef QT_NO_MIMETYPE const QList mimeTypes = supportedMimeTypes(); - if (const int mimeTypeCount = mimeTypes.size()) { + if (!mimeTypes.isEmpty()) { debug << ", supportedMimeTypes=("; - for (int i = 0; i < mimeTypeCount; ++i) - debug << " \"" << mimeTypes.at(i).name() << '"'; + for (const auto &mimeType : mimeTypes) + debug << " \"" << mimeType.name() << '"'; debug << ')'; } # endif // !QT_NO_MIMETYPE diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index cc4c8244ae..cbab151ea0 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -1946,13 +1946,12 @@ int QPrinter::winPageSize() const QList QPrinter::supportedResolutions() const { Q_D(const QPrinter); - QList varlist + const QList varlist = d->printEngine->property(QPrintEngine::PPK_SupportedResolutions).toList(); QList intlist; - const int numSupportedResolutions = varlist.size(); - intlist.reserve(numSupportedResolutions); - for (int i = 0; i < numSupportedResolutions; ++i) - intlist << varlist.at(i).toInt(); + intlist.reserve(varlist.size()); + for (auto var : varlist) + intlist << var.toInt(); return intlist; } @@ -2015,10 +2014,11 @@ QList QPrinter::supportedPaperSources() const Q_D(const QPrinter); QVariant v = d->printEngine->property(QPrintEngine::PPK_PaperSources); - QList variant_list = v.toList(); + const QList variant_list = v.toList(); QList int_list; - for (int i=0; iviewport()->rect(); - QList items = graphicsView->items(viewRect); - for (int i=0; i(items.at(i)); + const QList items = graphicsView->items(viewRect); + for (auto *item : items) { + PageItem* pg = static_cast(item); QRect overlap = graphicsView->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect; int area = overlap.width() * overlap.height(); if (area > maxArea) { @@ -335,17 +335,17 @@ void QPrintPreviewWidgetPrivate::init() void QPrintPreviewWidgetPrivate::populateScene() { // remove old pages - for (int i = 0; i < pages.size(); i++) - scene->removeItem(pages.at(i)); + for (auto *page : qAsConst(pages)) + scene->removeItem(page); qDeleteAll(pages); pages.clear(); - int numPages = pictures.count(); QSize paperSize = printer->pageLayout().fullRectPixels(printer->resolution()).size(); QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution()); - for (int i = 0; i < numPages; i++) { - PageItem* item = new PageItem(i+1, pictures.at(i), paperSize, pageRect); + int page = 1; + for (auto *picture : qAsConst(pictures)) { + PageItem* item = new PageItem(page++, picture, paperSize, pageRect); scene->addItem(item); pages.append(item); }