Resolved issue #790. Generate unique name for each detail.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-12-30 22:19:49 +02:00
parent a1c1192c61
commit ae39a2b488
3 changed files with 27 additions and 0 deletions

View File

@ -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.

View File

@ -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<VPlaceLabelItem>(id);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogSeamAllowance::GetDefaultPieceName() const
{
QList<VPiece> pieces = data->DataPieces()->values();
QSet<QString> 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;
}

View File

@ -276,6 +276,8 @@ private:
VPiecePath CurrentPath(quint32 id) const;
VPlaceLabelItem CurrentPlaceLabel(quint32 id) const;
QString GetDefaultPieceName() const;
};
#endif // DIALOGSEAMALLOWANCE_H