diff options
author | David Schulz <david.schulz@digia.com> | 2012-11-22 13:40:51 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-22 13:56:25 +0100 |
commit | ab0a007cb369a8e9a1bf43c9386a77d36199759b (patch) | |
tree | 495cbe311be5b5a7cda956b556e0a67b53bf523c /examples/widgets/itemviews/pixelator/mainwindow.cpp | |
parent | 49a4d058cc1ee38adcd292e67d49a8644538394c (diff) |
QtBase: examples/widgets/itemviews code style
Change-Id: I78a7745f7dc3add3fd7780220118d1b35b50a941
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'examples/widgets/itemviews/pixelator/mainwindow.cpp')
-rw-r--r-- | examples/widgets/itemviews/pixelator/mainwindow.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/examples/widgets/itemviews/pixelator/mainwindow.cpp b/examples/widgets/itemviews/pixelator/mainwindow.cpp index 3c2efa151b..cae9711135 100644 --- a/examples/widgets/itemviews/pixelator/mainwindow.cpp +++ b/examples/widgets/itemviews/pixelator/mainwindow.cpp @@ -38,16 +38,16 @@ ** ****************************************************************************/ +#include "imagemodel.h" +#include "mainwindow.h" +#include "pixeldelegate.h" + #include <QtWidgets> #ifndef QT_NO_PRINTER #include <QPrinter> #include <QPrintDialog> #endif -#include "imagemodel.h" -#include "mainwindow.h" -#include "pixeldelegate.h" - //! [0] MainWindow::MainWindow() { @@ -155,8 +155,7 @@ void MainWindow::openImage(const QString &fileName) void MainWindow::printImage() { #ifndef QT_NO_PRINTER - if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) - > 90000) { + if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) > 90000) { QMessageBox::StandardButton answer; answer = QMessageBox::question(this, tr("Large Image Size"), tr("The printed image may be very large. Are you sure that " @@ -179,26 +178,26 @@ void MainWindow::printImage() int rows = model->rowCount(QModelIndex()); int columns = model->columnCount(QModelIndex()); - int sourceWidth = (columns+1) * ItemSize; - int sourceHeight = (rows+1) * ItemSize; + int sourceWidth = (columns + 1) * ItemSize; + int sourceHeight = (rows + 1) * ItemSize; painter.save(); - double xscale = printer.pageRect().width()/double(sourceWidth); - double yscale = printer.pageRect().height()/double(sourceHeight); + double xscale = printer.pageRect().width() / double(sourceWidth); + double yscale = printer.pageRect().height() / double(sourceHeight); double scale = qMin(xscale, yscale); - painter.translate(printer.paperRect().x() + printer.pageRect().width()/2, - printer.paperRect().y() + printer.pageRect().height()/2); + painter.translate(printer.paperRect().x() + printer.pageRect().width() / 2, + printer.paperRect().y() + printer.pageRect().height() / 2); painter.scale(scale, scale); - painter.translate(-sourceWidth/2, -sourceHeight/2); + painter.translate(-sourceWidth / 2, -sourceHeight / 2); QStyleOptionViewItem option; QModelIndex parent = QModelIndex(); QProgressDialog progress(tr("Printing..."), tr("Cancel"), 0, rows, this); progress.setWindowModality(Qt::ApplicationModal); - float y = ItemSize/2; + float y = ItemSize / 2; for (int row = 0; row < rows; ++row) { progress.setValue(row); @@ -206,7 +205,7 @@ void MainWindow::printImage() if (progress.wasCanceled()) break; - float x = ItemSize/2; + float x = ItemSize / 2; for (int column = 0; column < columns; ++column) { option.rect = QRect(int(x), int(y), ItemSize, ItemSize); |