diff --git a/sources/print/projectprintwindow.cpp b/sources/print/projectprintwindow.cpp index 6522020d3..4b234e418 100644 --- a/sources/print/projectprintwindow.cpp +++ b/sources/print/projectprintwindow.cpp @@ -234,9 +234,9 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter { ////Prepare the print//// - //Deselect all + // Deselect all diagram->deselectAll(); - //Disable focus flags + // Disable focus flags QList focusable_items; for (auto qgi : diagram->items()) { if (qgi->flags() & QGraphicsItem::ItemIsFocusable) { @@ -244,7 +244,7 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter qgi->setFlag(QGraphicsItem::ItemIsFocusable, false); } } - //Disable interaction + // Disable interaction for (auto view : diagram->views()) { view->setInteractive(false); } @@ -254,7 +254,7 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter auto full_page = printer->fullPage(); - auto diagram_rect = diagramRect(diagram, option); + auto diagram_rect = QRectF(diagramRect(diagram, option)); if (fit_page) { diagram->render(painter, QRectF(), diagram_rect, Qt::KeepAspectRatio); } else { @@ -266,57 +266,58 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter #pragma message("@TODO remove code for QT 6 or later") #endif qDebug()<<"Help code for QT 6 or later"; - auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter) : printer->pageRect(QPrinter::Millimeter); + auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter) : + printer->pageRect(QPrinter::Millimeter); #endif auto used_width = printed_rect.width(); auto used_height = printed_rect.height(); auto h_pages_count = horizontalPagesCount(diagram, option, full_page); auto v_pages_count = verticalPagesCount(diagram, option, full_page); - QVector> page_grid; - //The diagram is printed on a matrix of sheet - //scrolls through the rows of the matrix + QVector> page_grid; + // The diagram is printed on a matrix of sheet + // scrolls through the rows of the matrix auto y_offset = 0; - for (auto i=0 ; i(); - //scrolls through the lines of sheet + page_grid << QVector(); + // scrolls through the lines of sheet auto x_offset = 0; for (auto j=0 ; j page_to_print; + // Retains only the pages to be printed + QVector page_to_print; for (auto i=0 ; i < v_pages_count ; ++i) { for (int j=0 ; j < h_pages_count ; ++j) { page_to_print << page_grid.at(i).at(j); } } - //Scrolls through the page for print + // Scrolls through the page for print bool first_ = true; - for (auto page : page_to_print) + for (auto& page : page_to_print) { first_ ? first_ = false : m_printer->newPage(); - diagram->render(painter, QRect(QPoint(0,0), page.size()), page.translated(diagram_rect.topLeft()), Qt::KeepAspectRatio); + diagram->render( + painter, + QRectF(QPoint(0, 0), page.size()), + page.translated(diagram_rect.topLeft()), + Qt::KeepAspectRatio); } } - ////Print is finished, restore diagram and graphics item properties + ////Print is finished, restore diagram and graphics item properties for (auto view : diagram->views()) { view->setInteractive(true); }