Refactoring.
Avoid unnecessary copy by using a "const" reference.
This commit is contained in:
parent
0080ce8ef5
commit
1ddb07f2ee
|
@ -95,7 +95,7 @@ auto LinesToString(const QVector<QLineF> &lines) -> QString
|
||||||
{
|
{
|
||||||
QStringList l;
|
QStringList l;
|
||||||
l.reserve(lines.size());
|
l.reserve(lines.size());
|
||||||
for (auto line : lines)
|
for (const auto &line : lines)
|
||||||
{
|
{
|
||||||
l.append(LineToString(line));
|
l.append(LineToString(line));
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,7 +611,7 @@ auto VAbstractCurve::ShowDirection(const QVector<DirectionArrow> &arrows, qreal
|
||||||
{
|
{
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
for (auto arrow : arrows)
|
for (const auto &arrow : arrows)
|
||||||
{
|
{
|
||||||
if (not arrow.first.isNull() && not arrow.second.isNull())
|
if (not arrow.first.isNull() && not arrow.second.isNull())
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace
|
||||||
auto PassmarkShapeToJson(const QVector<QLineF> &shape) -> QJsonArray
|
auto PassmarkShapeToJson(const QVector<QLineF> &shape) -> QJsonArray
|
||||||
{
|
{
|
||||||
QJsonArray shapeArray;
|
QJsonArray shapeArray;
|
||||||
for (auto line : shape)
|
for (const auto &line : shape)
|
||||||
{
|
{
|
||||||
QJsonObject const lineObject{
|
QJsonObject const lineObject{
|
||||||
{"type", "QLineF"},
|
{"type", "QLineF"},
|
||||||
|
|
|
@ -51,7 +51,7 @@ auto SourceToObjects(const QVector<SourceItem> &source) -> QVector<quint32>
|
||||||
QVector<quint32> ids;
|
QVector<quint32> ids;
|
||||||
ids.reserve(source.size());
|
ids.reserve(source.size());
|
||||||
|
|
||||||
for (auto s : source)
|
for (const auto &s : source)
|
||||||
{
|
{
|
||||||
ids.append(s.id);
|
ids.append(s.id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TST_VPoster::TST_VPoster(QObject *parent) :
|
TST_VPoster::TST_VPoster(QObject *parent)
|
||||||
QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ TST_VPoster::TST_VPoster(QObject *parent) :
|
||||||
void TST_VPoster::BigPoster()
|
void TST_VPoster::BigPoster()
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
printer.setResolution(static_cast<int>(PrintDPI));// By default
|
printer.setResolution(static_cast<int>(PrintDPI)); // By default
|
||||||
printer.setPageSize(QPageSize(QPageSize::A4));
|
printer.setPageSize(QPageSize(QPageSize::A4));
|
||||||
printer.setFullPage(true);
|
printer.setFullPage(true);
|
||||||
// We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux
|
// We need to set full page because otherwise QPrinter->pageRect returns different values in Windows and Linux
|
||||||
|
|
||||||
//sets the margins to 0 to perform the test.
|
// sets the margins to 0 to perform the test.
|
||||||
printer.setPageMargins(QMarginsF(), QPageLayout::Millimeter);
|
printer.setPageMargins(QMarginsF(), QPageLayout::Millimeter);
|
||||||
|
|
||||||
const QSize image(2622, 3178); // Little bit bigger than A1
|
const QSize image(2622, 3178); // Little bit bigger than A1
|
||||||
|
@ -59,7 +59,7 @@ void TST_VPoster::BigPoster()
|
||||||
|
|
||||||
QCOMPARE(poster.size(), 12);
|
QCOMPARE(poster.size(), 12);
|
||||||
|
|
||||||
for (auto p : poster)
|
for (const auto &p : poster)
|
||||||
{
|
{
|
||||||
QCOMPARE(p.rect.size(), PageRect(printer).size());
|
QCOMPARE(p.rect.size(), PageRect(printer).size());
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ void TST_VPoster::BigPoster()
|
||||||
void TST_VPoster::SmallPoster()
|
void TST_VPoster::SmallPoster()
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
printer.setResolution(96);// By default
|
printer.setResolution(96); // By default
|
||||||
printer.setPageSize(QPageSize(QPageSize::A4));
|
printer.setPageSize(QPageSize(QPageSize::A4));
|
||||||
|
|
||||||
const QSize image(700, 1000); // Little bit less than A4
|
const QSize image(700, 1000); // Little bit less than A4
|
||||||
|
@ -89,8 +89,8 @@ auto TST_VPoster::PageRect(const QPrinter &printer) const -> QRect
|
||||||
// we can't use method pageRect(QPrinter::Point). Our dpi different can be different.
|
// we can't use method pageRect(QPrinter::Point). Our dpi different can be different.
|
||||||
// We convert value yourself to pixels.
|
// We convert value yourself to pixels.
|
||||||
const QRectF rect = printer.pageRect(QPrinter::Millimeter);
|
const QRectF rect = printer.pageRect(QPrinter::Millimeter);
|
||||||
QRect pageRect(qFloor(ToPixel(rect.x())), qFloor(ToPixel(rect.y())),
|
QRect pageRect(qFloor(ToPixel(rect.x())), qFloor(ToPixel(rect.y())), qFloor(ToPixel(rect.width())),
|
||||||
qFloor(ToPixel(rect.width())), qFloor(ToPixel(rect.height())));
|
qFloor(ToPixel(rect.height())));
|
||||||
return pageRect;
|
return pageRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user