From 8fb6c9c508f72370fd47b91a40fb9fbf0dbf6a8c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sun, 22 Jan 2017 10:32:01 +0200 Subject: [PATCH] Code that converts VPiece to VLayoutDetail moved to static function. --HG-- branch : feature --- src/app/valentina/mainwindowsnogui.cpp | 32 +---------------------- src/libs/vlayout/vlayoutdetail.cpp | 35 ++++++++++++++++++++++++++ src/libs/vlayout/vlayoutdetail.h | 2 ++ 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 30630d0c3..c996b5427 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -475,37 +475,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *det QHash::const_iterator i = details->constBegin(); while (i != details->constEnd()) { - VLayoutDetail det = VLayoutDetail(); - const VPiece d = i.value(); - det.SetCountourPoints(d.MainPathPoints(pattern)); - det.SetSeamAllowencePoints(d.SeamAllowancePoints(pattern), d.IsSeamAllowance(), false); - det.setName(d.GetName()); - const VPatternPieceData& data = d.GetPatternPieceData(); - if (data.IsVisible() == true) - { - det.SetDetail(d.GetName(), data, qApp->font()); - } - const VPatternInfoGeometry& geom = d.GetPatternInfo(); - if (geom.IsVisible() == true) - { - VAbstractPattern* pDoc = qApp->getCurrentDocument(); - QDate date; - if (pDoc->IsDateVisible() == true) - { - date = QDate::currentDate(); - } - det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height()); - } - const VGrainlineGeometry& grainlineGeom = d.GetGrainlineGeometry(); - if (grainlineGeom.IsVisible() == true) - { - det.SetGrainline(grainlineGeom, *pattern); - } - det.setWidth(qApp->toPixel(d.GetSAWidth())); - det.CreateTextItems(); - det.setForbidFlipping(d.IsForbidFlipping()); - - listDetails.append(det); + listDetails.append(VLayoutDetail::Create(i.value(), pattern)); ++i; } } diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 08e6ea135..c2042aa33 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -83,6 +83,41 @@ VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail) VLayoutDetail::~VLayoutDetail() {} +//--------------------------------------------------------------------------------------------------------------------- +VLayoutDetail VLayoutDetail::Create(const VPiece &piece, const VContainer *pattern) +{ + VLayoutDetail det = VLayoutDetail(); + det.SetCountourPoints(piece.MainPathPoints(pattern)); + det.SetSeamAllowencePoints(piece.SeamAllowancePoints(pattern), piece.IsSeamAllowance(), false); + det.setName(piece.GetName()); + const VPatternPieceData& data = piece.GetPatternPieceData(); + if (data.IsVisible() == true) + { + det.SetDetail(piece.GetName(), data, qApp->font()); + } + const VPatternInfoGeometry& geom = piece.GetPatternInfo(); + if (geom.IsVisible() == true) + { + VAbstractPattern* pDoc = qApp->getCurrentDocument(); + QDate date; + if (pDoc->IsDateVisible() == true) + { + date = QDate::currentDate(); + } + det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height()); + } + const VGrainlineGeometry& grainlineGeom = piece.GetGrainlineGeometry(); + if (grainlineGeom.IsVisible() == true) + { + det.SetGrainline(grainlineGeom, *pattern); + } + det.setWidth(qApp->toPixel(piece.GetSAWidth())); + det.CreateTextItems(); + det.setForbidFlipping(piece.IsForbidFlipping()); + + return det; +} + //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction QVector VLayoutDetail::GetContourPoints() const diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index e23924dcf..f72e67473 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -68,6 +68,8 @@ public: VLayoutDetail &operator=(const VLayoutDetail &detail); virtual ~VLayoutDetail() Q_DECL_OVERRIDE; + static VLayoutDetail Create(const VPiece &piece, const VContainer *pattern); + QVector GetContourPoints() const; void SetCountourPoints(const QVector &points);