From 47b3eab0adab2191f42c2a25a4a930e2fdf11a5b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 21 Mar 2020 17:31:12 +0200 Subject: [PATCH] Refactoring for VPoster class. Pass QSize instead QRect. To calculate tiles we need width and size only. --- src/libs/vlayout/vposter.cpp | 4 ++-- src/libs/vlayout/vposter.h | 4 ++-- src/test/ValentinaTest/tst_vposter.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index 6f3bda890..82069b214 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -124,7 +124,7 @@ VPoster::VPoster(const QPrinter *printer) } //--------------------------------------------------------------------------------------------------------------------- -QVector VPoster::Calc(const QRect &imageRect, int page, PageOrientation orientation) const +QVector VPoster::Calc(const QSize &imageRect, int page, PageOrientation orientation) const { QVector poster; @@ -390,7 +390,7 @@ int VPoster::CountColumns(int width, PageOrientation orientation) const } //--------------------------------------------------------------------------------------------------------------------- -PosterData VPoster::Cut(int i, int j, const QRect &imageRect, PageOrientation orientation) const +PosterData VPoster::Cut(int i, int j, const QSize &imageRect, PageOrientation orientation) const { Q_UNUSED(imageRect) diff --git a/src/libs/vlayout/vposter.h b/src/libs/vlayout/vposter.h index 4860765f3..056b5fb3b 100644 --- a/src/libs/vlayout/vposter.h +++ b/src/libs/vlayout/vposter.h @@ -68,7 +68,7 @@ class VPoster public: explicit VPoster(const QPrinter *printer); - QVector Calc(const QRect &imageRect, int page, PageOrientation orientation) const; + QVector Calc(const QSize &imageRect, int page, PageOrientation orientation) const; QVector Tile(QGraphicsItem *parent, const PosterData &img, int sheets, const VWatermarkData &watermarkData, const QString &watermarkPath) const; @@ -84,7 +84,7 @@ private: int CountRows(int height, PageOrientation orientation) const; int CountColumns(int width, PageOrientation orientation) const; - PosterData Cut(int i, int j, const QRect &imageRect, PageOrientation orientation) const; + PosterData Cut(int i, int j, const QSize &imageRect, PageOrientation orientation) const; QRect PageRect() const; diff --git a/src/test/ValentinaTest/tst_vposter.cpp b/src/test/ValentinaTest/tst_vposter.cpp index 5613ad178..6f7ae25e6 100644 --- a/src/test/ValentinaTest/tst_vposter.cpp +++ b/src/test/ValentinaTest/tst_vposter.cpp @@ -55,7 +55,7 @@ void TST_VPoster::BigPoster() printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter); - const QRect image(0, 0, 2622, 3178); // Little bit bigger than A1 + const QSize image(2622, 3178); // Little bit bigger than A1 VPoster posterazor(&printer); const QVector poster = posterazor.Calc(image, 0, PageOrientation::Portrait); @@ -75,7 +75,7 @@ void TST_VPoster::SmallPoster() printer.setResolution(96);// By default printer.setPageSize(QPageSize(QPageSize::A4)); - const QRect image(0, 0, 700, 1000); // Little bit less than A4 + const QSize image(700, 1000); // Little bit less than A4 VPoster posterazor(&printer); const QVector poster = posterazor.Calc(image, 0, PageOrientation::Portrait);