summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-04-17 12:26:24 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-04-19 12:17:46 +0000
commit5e05211fc97c805bcb265e3ef6b84602c544cf33 (patch)
treeffaee6ef15ada0d0e647cfa85caf1c3e662fd6c9
parentc0a956c8fbe88a9743a3fc909bda8cae14d4f33b (diff)
Force object name to unique on name change
Do not ask for user confirmation, just show a notification that the name was made unique. Allowing non-unique object names breaks Aliases and other elementpath references. Change-Id: Id35c6bb42c0a1c9982343005af7d5f218401cdda Task-Id: QT3DS-1463 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
index b21bf949..00a35c99 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
@@ -347,28 +347,25 @@ void Qt3DSDMTimelineItemBinding::SetName(const Q3DStudio::CString &inName)
}
CClientDataModelBridge *theBridge = m_StudioSystem->GetClientDataModelBridge();
+ // Display warning if we had to modify the user-given name to make it unique
if (!theBridge->CheckNameUnique(m_DataHandle, inName)) {
- QString theTitle = QObject::tr("Rename Object Error");
- QString theString = QObject::tr("The object name is duplicated under its parent, do you "
- "want to make it unique?");
- int theUserChoice = g_StudioApp.GetDialogs()->DisplayChoiceBox(
- theTitle, theString, Qt3DSMessageBox::ICON_WARNING);
- if (theUserChoice == IDYES) {
- // Set with the unique name
- Q3DStudio::SCOPED_DOCUMENT_EDITOR(
- *m_TransMgr->GetDoc(), QObject::tr("Set Name"))
- ->SetName(m_DataHandle, inName, true);
- return;
- }
+ // Find unique name based on the input string
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(
+ *m_TransMgr->GetDoc(), QObject::tr("Set Name"))->SetName(m_DataHandle, inName, true);
+
+ QString theTitle = QObject::tr("Warning");
+ QString theString = QObject::tr("Object %1 was renamed to %2 because "
+ "original name was duplicated "
+ "under its parent.")
+ .arg(inName.toQString())
+ .arg(theBridge->GetName(m_DataHandle).toQString());
+ g_StudioApp.GetDialogs()->DisplayMessageBox(theTitle, theString,
+ Qt3DSMessageBox::ICON_WARNING, false);
+ return;
}
- // Set the name no matter it's unique or not
- Qt3DSDMPropertyHandle theNamePropHandle =
- m_StudioSystem->GetPropertySystem()->GetAggregateInstancePropertyByName(m_DataHandle,
- L"name");
- Q3DStudio::SCOPED_DOCUMENT_EDITOR(*m_TransMgr->GetDoc(), QObject::tr("Set Name"))
- ->SetInstancePropertyValue(m_DataHandle, theNamePropHandle,
- std::make_shared<CDataStr>(inName));
+ Q3DStudio::SCOPED_DOCUMENT_EDITOR(
+ *m_TransMgr->GetDoc(), QObject::tr("Set Name"))->SetName(m_DataHandle, inName, true);
}
ITimelineItem *Qt3DSDMTimelineItemBinding::GetTimelineItem()