From ae39a2b48814b0562bb8b363c50d50e9d6fcb337 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 30 Dec 2017 22:19:49 +0200 Subject: [PATCH] Resolved issue #790. Generate unique name for each detail. --HG-- branch : develop --- ChangeLog.txt | 1 + .../tools/piece/dialogseamallowance.cpp | 24 +++++++++++++++++++ .../dialogs/tools/piece/dialogseamallowance.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 42b55e294..7a63ca82d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -34,6 +34,7 @@ - [#774] New feature. Matching Parentheses. - [#779] Add more roll paper size templates. - [#783] Flipping control. +- [#790] Generate unique name for each detail. # Version 0.5.1 - [#683] Tool Seam allowance's dialog is off screen on small resolutions. diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 391b3db3c..74272a766 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -2863,6 +2863,8 @@ void DialogSeamAllowance::InitLabelsTab() connect(uiTabLabels->pushButtonShowPLHeight, &QPushButton::clicked, this, &DialogSeamAllowance::DeployPLHeight); connect(uiTabLabels->pushButtonShowPLAngle, &QPushButton::clicked, this, &DialogSeamAllowance::DeployPLAngle); + uiTabLabels->lineEditName->setText(GetDefaultPieceName()); + EnabledPatternLabel(); } @@ -3247,3 +3249,25 @@ VPlaceLabelItem DialogSeamAllowance::CurrentPlaceLabel(quint32 id) const { return m_newPlaceLabels.contains(id) ? m_newPlaceLabels.value(id) : *data->GeometricObject(id); } + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogSeamAllowance::GetDefaultPieceName() const +{ + QList pieces = data->DataPieces()->values(); + QSet names; + + for (int i = 0; i < pieces.size(); ++i) + { + names.insert(pieces.at(i).GetName()); + } + + const QString defName = tr("Detail"); + QString name = defName; + int i = 0; + + while(names.contains(name)) + { + name = defName + QString("_%1").arg(++i); + } + return name; +} diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index a9c2fbeda..1dfebe12b 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -276,6 +276,8 @@ private: VPiecePath CurrentPath(quint32 id) const; VPlaceLabelItem CurrentPlaceLabel(quint32 id) const; + + QString GetDefaultPieceName() const; }; #endif // DIALOGSEAMALLOWANCE_H