From 5978df26296650fa693c79958914550858c3e425 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 27 Jul 2019 09:02:41 +0300 Subject: [PATCH] Fix bug with nesting a descending group. Together with "Nest quantity" and limited space Valentina removes all duplicates except first for each next paper sheet. --HG-- branch : develop --- src/libs/vlayout/vbank.cpp | 33 +++++++++++---------------------- src/libs/vlayout/vbank.h | 27 +++++++++++++-------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/src/libs/vlayout/vbank.cpp b/src/libs/vlayout/vbank.cpp index aeef4f4cd..6dbe14ab6 100644 --- a/src/libs/vlayout/vbank.cpp +++ b/src/libs/vlayout/vbank.cpp @@ -32,7 +32,6 @@ #include "../vmisc/diagnostic.h" #include "../vmisc/vabstractapplication.h" -#include "vlayoutpiece.h" #include "vlayoutdef.h" #include "../ifc/exception/vexception.h" #include "../vpatterndb/floatItemData/floatitemdef.h" @@ -95,7 +94,8 @@ int CountDetails(const T &container) } //--------------------------------------------------------------------------------------------------------------------- -bool NotArrangedDetail(QMap> &container, QMap> &unsorted, int i) +bool NotArrangedDetail(QMap> &container, QMap> &unsorted, + int i) { QMutableMapIterator> iterator(container); while (iterator.hasNext()) @@ -122,19 +122,20 @@ bool NotArrangedDetail(QMap> &container, QMap> &container, QMap> &unsorted, int i) +bool NotArrangedDetail(QMap> &container, QMap> &unsorted, + int i) { QMutableMapIterator> iterator(container); while (iterator.hasNext()) { iterator.next(); auto containerGroup = container.value(iterator.key()); - auto detailIterator = std::find(containerGroup.cbegin(), containerGroup.cend(), i); - if (detailIterator != containerGroup.cend()) + auto detailIterator = std::find(containerGroup.begin(), containerGroup.end(), i); + if (detailIterator != containerGroup.end()) { Insert(unsorted, iterator.key(), i, detailIterator.key()); + containerGroup.erase(detailIterator); - containerGroup.remove(detailIterator.key()); if (not containerGroup.isEmpty()) { container.insert(iterator.key(), containerGroup); @@ -165,18 +166,6 @@ int TakeFirstForPriority(const QMap> &container, uint p //--------------------------------------------------------------------------------------------------------------------- VBank::VBank() - : details(), - unsorted(), - big(), - middle(), - small(), - desc(), - groups(), - arranged(), - layoutWidth(0), - caseType(Cases::CaseDesc), - prepare(false), - diagonal(0) {} //--------------------------------------------------------------------------------------------------------------------- @@ -622,7 +611,7 @@ void VBank::SqMaxMin(qint64 &sMax, qint64 &sMin, uint priority) const } //--------------------------------------------------------------------------------------------------------------------- -bool VBank::ArrangedDetail(QMap> &container, int i) +bool VBank::ArrangedDetail(QMap > &container, int i) { QMutableMapIterator> iterator(container); while (iterator.hasNext()) @@ -655,11 +644,11 @@ bool VBank::ArrangedDetail(QMap> &container, int i) { iterator.next(); auto containerGroup = container.value(iterator.key()); - auto detailIterator = std::find(containerGroup.cbegin(), containerGroup.cend(), i); - if (detailIterator != containerGroup.cend()) + auto detailIterator = std::find(containerGroup.begin(), containerGroup.end(), i); + if (detailIterator != containerGroup.end()) { arranged.append(details.at(detailIterator.value()).GetId()); - containerGroup.remove(detailIterator.key(), detailIterator.value()); + containerGroup.erase(detailIterator); if (not containerGroup.isEmpty()) { diff --git a/src/libs/vlayout/vbank.h b/src/libs/vlayout/vbank.h index a47281151..b564b95c7 100644 --- a/src/libs/vlayout/vbank.h +++ b/src/libs/vlayout/vbank.h @@ -37,6 +37,7 @@ #include #include "../vmisc/typedef.h" +#include "vlayoutpiece.h" // An annoying char define, from the Windows team in // #define small char @@ -48,8 +49,6 @@ Q_DECLARE_LOGGING_CATEGORY(lBank) -class VLayoutPiece; - enum class Cases : char { CaseThreeGroup = 0, CaseTwoGroup, CaseDesc, UnknownCase}; class VBank @@ -88,22 +87,22 @@ public: private: Q_DISABLE_COPY(VBank) - QVector details; + QVector details{}; - QMap> unsorted; - QMap> big; - QMap> middle; - QMap> small; - QMap> desc; + QMap> unsorted{}; + QMap> big{}; + QMap> middle{}; + QMap> small{}; + QMap> desc{}; - QVector groups; - QVector arranged; + QVector groups{}; + QVector arranged{}; - qreal layoutWidth; + qreal layoutWidth{0}; - Cases caseType; - bool prepare; - qreal diagonal; + Cases caseType{Cases::CaseDesc}; + bool prepare{false}; + qreal diagonal{0}; bool m_nestQuantity{false}; bool m_manualPriority{false};