From 3133ae160922cc562acaf57c9401afd2c9779df5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 16 Oct 2020 12:02:32 +0300 Subject: [PATCH] Clean code. --- src/libs/vpatterndb/vcontainer.cpp | 82 +------------------- src/libs/vpatterndb/vcontainer.h | 9 --- src/test/ValentinaTest/tst_vmeasurements.cpp | 29 ++++--- 3 files changed, 20 insertions(+), 100 deletions(-) diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 81f797bf4..2a4169ece 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -65,8 +65,6 @@ Q_LOGGING_CATEGORY(vCon, "v.container") QT_WARNING_POP QMap VContainer::_id = QMap(); -QMap VContainer::_size = QMap(); -QMap VContainer::_height = QMap(); QMap> VContainer::uniqueNames = QMap>(); QMap VContainer::copyCounter = QMap(); @@ -92,16 +90,6 @@ VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit, co _id[d->nspace] = NULL_ID; } - if (not _size.contains(d->nspace)) - { - _size[d->nspace] = 50; - } - - if (not _height.contains(d->nspace)) - { - _height[d->nspace] = 176; - } - if (not uniqueNames.contains(d->nspace)) { uniqueNames[d->nspace] = QSet(); @@ -167,7 +155,7 @@ QString VContainer::UniqueNamespace() { candidate = QUuid::createUuid().toString(); } - while(_size.contains(candidate)); + while(_id.contains(candidate)); return candidate; } @@ -176,8 +164,6 @@ QString VContainer::UniqueNamespace() void VContainer::ClearNamespace(const QString &nspace) { _id.remove(nspace); - _size.remove(nspace); - _height.remove(nspace); uniqueNames.remove(nspace); } @@ -734,72 +720,6 @@ void VContainer::ClearExceptUniqueIncrementNames() const } } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief SetSize set value of size - * @param size value of size - */ -void VContainer::SetSize(qreal size) const -{ - _size[d->nspace] = size; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief SetGrowth set value of growth - * @param height value of height - */ -void VContainer::SetHeight(qreal height) const -{ - _height[d->nspace] = height; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief size return size - * @return size in mm - */ -qreal VContainer::size() const -{ - return VContainer::size(d->nspace); -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VContainer::size(const QString &nspace) -{ - if (_size.contains(nspace)) - { - return _size.value(nspace); - } - else - { - throw VException(QStringLiteral("Unknown namespace")); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief height return height - * @return height in pattern units - */ -qreal VContainer::height() const -{ - return VContainer::height(d->nspace); -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VContainer::height(const QString &nspace) -{ - if (_height.contains(nspace)) - { - return _height.value(nspace); - } - else - { - throw VException(QStringLiteral("Unknown namespace")); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief data container with datagObjects return container of gObjects diff --git a/src/libs/vpatterndb/vcontainer.h b/src/libs/vpatterndb/vcontainer.h index 03f6bcd9e..a4e987da1 100644 --- a/src/libs/vpatterndb/vcontainer.h +++ b/src/libs/vpatterndb/vcontainer.h @@ -190,13 +190,6 @@ public: void ClearUniqueIncrementNames() const; void ClearExceptUniqueIncrementNames() const; - void SetSize(qreal size) const; - void SetHeight(qreal height) const; - qreal size() const; - static qreal size(const QString &nspace); - qreal height() const; - static qreal height(const QString &nspace); - void RemoveIncrement(const QString& name); const QHash > *CalculationGObjects() const; @@ -227,8 +220,6 @@ private: * @brief _id current id. New object will have value +1. For empty class equal 0. */ static QMap _id; - static QMap _size; - static QMap _height; static QMap> uniqueNames; static QMap copyCounter; diff --git a/src/test/ValentinaTest/tst_vmeasurements.cpp b/src/test/ValentinaTest/tst_vmeasurements.cpp index 46761aeac..79a32e474 100644 --- a/src/test/ValentinaTest/tst_vmeasurements.cpp +++ b/src/test/ValentinaTest/tst_vmeasurements.cpp @@ -48,16 +48,20 @@ TST_VMeasurements::TST_VMeasurements(QObject *parent) : void TST_VMeasurements::CreateEmptyMultisizeFile() { Unit mUnit = Unit::Cm; - const int height = 176; - const int size = 50; QSharedPointer data = QSharedPointer(new VContainer(nullptr, &mUnit, VContainer::UniqueNamespace())); - data->SetHeight(height); - data->SetSize(size); + auto m_xDimension = QSharedPointer::create(mUnit, 50, 200, 6); + m_xDimension->SetBaseValue(176); + + auto m_yDimension = QSharedPointer::create(mUnit, 2, 22, 72); + m_yDimension->SetBaseValue(50); + m_yDimension->SetCircumference(true); + + QVector dimensions{m_xDimension, m_yDimension}; QSharedPointer m = - QSharedPointer(new VMeasurements(mUnit, /*size, height,*/ data.data())); + QSharedPointer(new VMeasurements(mUnit, dimensions, data.data())); QTemporaryFile file; QString fileName; @@ -138,16 +142,21 @@ void TST_VMeasurements::CreateEmptyIndividualFile() void TST_VMeasurements::ValidPMCodesMultisizeFile() { Unit mUnit = Unit::Cm; - const int height = 176; - const int size = 50; QSharedPointer data = QSharedPointer(new VContainer(nullptr, &mUnit, VContainer::UniqueNamespace())); - data->SetHeight(height); - data->SetSize(size); + + auto m_xDimension = QSharedPointer::create(mUnit, 50, 200, 6); + m_xDimension->SetBaseValue(176); + + auto m_yDimension = QSharedPointer::create(mUnit, 2, 22, 72); + m_yDimension->SetBaseValue(50); + m_yDimension->SetCircumference(true); + + QVector dimensions{m_xDimension, m_yDimension}; QSharedPointer m = - QSharedPointer(new VMeasurements(mUnit, /*size, height,*/ data.data())); + QSharedPointer(new VMeasurements(mUnit, dimensions, data.data())); const QStringList listSystems = ListPMSystems(); for (int i = 0; i < listSystems.size(); ++i)