summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-12 11:32:38 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-09-12 10:30:54 +0000
commita0223ae7dfd7f6d636192a057c0d88d5540d98e9 (patch)
treeb4b398b0446a69a99ef9549b982aefe535f23897
parent8eb7f186634e6b848513db47c05f3503191fd100 (diff)
Check for name uniqueness when dragging objects into a component
Task-number: QT3DS-2305 Change-Id: Iff636074edae93eec9175d4d771c43065e35da98 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index c064dc04..65f73b83 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -2469,8 +2469,10 @@ public:
|| inInsertType == DocumentEditorInsertType::NextSibling)
theParent = GetParent(inDest);
- if (m_Bridge.IsComponentInstance(theParent) && moveIntoComponent(inInstances, theParent))
+ if (m_Bridge.IsComponentInstance(theParent)
+ && moveIntoComponent(inInstances, theParent, checkUniqueName)) {
return;
+ }
for (size_t idx = 0, end = sortableList.size(); idx < end; ++idx) {
qt3dsdm::Qt3DSDMInstanceHandle theInstance(sortableList[idx]);
@@ -2598,7 +2600,7 @@ public:
// Returns true if move was done. Returns false if instances are already in target component,
// which means a regular rearrange can be done.
bool moveIntoComponent(const qt3dsdm::TInstanceHandleList &inInstances,
- const Qt3DSDMInstanceHandle targetComponent)
+ const Qt3DSDMInstanceHandle targetComponent, bool checkUniqueName)
{
if (inInstances.empty())
return false;
@@ -2610,10 +2612,10 @@ public:
if (rootInstance == targetComponent)
return false;
- qt3dsdm::TInstanceHandleList theInstances = ToGraphOrdering(inInstances);
+ const qt3dsdm::TInstanceHandleList theInstances = ToGraphOrdering(inInstances);
QList<std::pair<long, long>> theStartEndTimes;
- for (auto instance : qAsConst(theInstances))
+ for (auto instance : theInstances)
theStartEndTimes.append(GetTimeRange(instance));
// Now cut the group from the scene.
@@ -2631,13 +2633,25 @@ public:
targetComponent,
m_SlideSystem.GetMasterSlide(theComponentSlide));
- // Restore the original time range for all objects.
if (insertedHandles.size()) {
+ // Restore the original time range for all objects.
for (int i = 0; i < theStartEndTimes.size(); i++) {
if (theStartEndTimes.at(i) != std::make_pair(0L, 0L))
SetTimeRange(insertedHandles.at(i), theStartEndTimes.at(i).first,
theStartEndTimes.at(i).second);
}
+ // Check for name uniqueness
+ if (checkUniqueName) {
+ for (auto instance : insertedHandles) {
+ CString currName = m_Bridge.GetName(instance);
+ if (!m_Bridge.CheckNameUnique(targetComponent, instance, currName)) {
+ CString newName = m_Bridge.GetUniqueChildName(
+ targetComponent, instance, currName);
+ m_Doc.getMoveRenameHandler()->displayMessageBox(currName, newName);
+ SetName(instance, newName);
+ }
+ }
+ }
}
return true;
}