From 0052a883a45c62fcf6302bef349c60c6d86ae3a6 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 18 May 2016 16:44:23 +0300 Subject: [PATCH] Better way to check suffix. --HG-- branch : feature --- .../core/vtooloptionspropertybrowser.cpp | 14 +++--- .../drawTools/operation/vtoolrotation.cpp | 46 ------------------- .../tools/drawTools/operation/vtoolrotation.h | 1 - 3 files changed, 7 insertions(+), 54 deletions(-) diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index cdbc80c06..b67b0f1d0 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -682,18 +682,18 @@ void VToolOptionsPropertyBrowser::SetOperationSuffix(const QString &suffix) } QRegularExpression rx(NameRegExp()); - const QVector names = item->GetNames(suffix); - for (int i=0; i < names.size(); ++i) + const QStringList uniqueNames = VContainer::AllUniqueNames(); + for (int i=0; i < uniqueNames.size(); ++i) { - if (not rx.match(names.at(i)).hasMatch() || not VContainer::IsUnique(names.at(i))) + const QString name = uniqueNames.at(i) + suffix; + if (not rx.match(name).hasMatch() || not VContainer::IsUnique(name)) { idToProperty[AttrSuffix]->setValue(item->Suffix()); - } - else - { - item->SetSuffix(suffix); + return; } } + + item->SetSuffix(suffix); } else { diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 4837ba21b..1a8a65a83 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -351,52 +351,6 @@ void VToolRotation::ExtractData(VAbstractPattern *doc, const QDomElement &domEle } } -//--------------------------------------------------------------------------------------------------------------------- -QVector VToolRotation::GetNames(const QString &suffix) const -{ - QVector names; - for (int i = 0; i < source.size(); ++i) - { - const QSharedPointer obj = VAbstractTool::data.GetGObject(source.at(i)); - - // This check helps to find missed objects in the switch - Q_STATIC_ASSERT_X(static_cast(GOType::Unknown) == 7, "Not all objects were handled."); - -#if defined(Q_CC_GNU) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wswitch-default" -#endif - switch(static_cast(obj->getType())) - { - case GOType::Point: - { - const QSharedPointer point = VAbstractTool::data.GeometricObject(source.at(i)); - names.append(point->name() + suffix); - break; - } - case GOType::Arc: - case GOType::EllipticalArc: - case GOType::Spline: - case GOType::SplinePath: - case GOType::CubicBezier: - case GOType::CubicBezierPath: - { - const QSharedPointer curve = - VAbstractTool::data.GeometricObject(source.at(i)); - names.append(curve->name() + suffix); - break; - } - case GOType::Unknown: - break; - } -#if defined(Q_CC_GNU) -#pragma GCC diagnostic pop -#endif - } - - return names; -} - //--------------------------------------------------------------------------------------------------------------------- QString VToolRotation::getTagName() const { diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h index 9556b7d03..ca6fb4d7f 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h @@ -59,7 +59,6 @@ public: const Document &parse, const Source &typeCreation); static void ExtractData(VAbstractPattern *doc, const QDomElement &domElement, QVector &source, QVector &destination); - QVector GetNames(const QString &suffix) const; static const QString ToolType; static const QString TagItem; static const QString TagSource;