diff options
author | Janne Kangas <janne.kangas@qt.io> | 2018-08-22 10:31:47 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2018-09-19 05:58:45 +0000 |
commit | 8dd70dd8db835816bf919a00bb8d41a76a05220f (patch) | |
tree | 09ec9f077102091efc40d4e6bdf0749ed95348e5 | |
parent | cab6de18b04b29ec7688f969b355dbee4ef35f9e (diff) |
Preserve original start/end times when making objects into component
Store each individual start/end time before moving objects into a new
component and reset the time range afterwards.
Change-Id: I891a900640816f8ee9873a659ddc078830391048
Task-Id: QT3DS-2350
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r-- | src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index 9a93889e..0b9b4d8f 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -2567,6 +2567,13 @@ public: return Qt3DSDMInstanceHandle(); qt3dsdm::TInstanceHandleList theInstances = ToGraphOrdering(inInstances); + + // Get the original start/end times + QList<std::pair<long, long>> theStartEndTimes; + + for (auto instance : qAsConst(theInstances)) + theStartEndTimes.append(GetTimeRange(instance)); + // Do this in reverse order. // first add new component. Qt3DSDMSlideHandle theSlide = GetAssociatedSlide(theInstances[0]); @@ -2575,12 +2582,6 @@ public: ComposerObjectTypes::Component, theInstances[0], theSlide, DocumentEditorInsertType::NextSibling, CPt(), PRIMITIVETYPE_UNKNOWN, 0); - // After consultation with Stephen Mendoza about this we decided *not* to move the start - // position to the component. - // as this breaks embedded animations unless you move the position animations to the - // component as well. - pair<long, long> theStartEndTimes = GetTimeRange(theInstances[0]); - CString theName = GetName(theInstances[0]); // now cut the group @@ -2591,11 +2592,20 @@ public: Qt3DSDMSlideHandle theComponentSlide(m_Bridge.GetComponentActiveSlide(component)); // Paste into the master slide of the new component - theSerializer->SerializeSceneGraphObject(*theReader, m_Doc.GetDocumentDirectory(), - component, - m_SlideSystem.GetMasterSlide(theComponentSlide)); + TInstanceHandleList insertedHandles = theSerializer->SerializeSceneGraphObject( + *theReader,m_Doc.GetDocumentDirectory(), component, + m_SlideSystem.GetMasterSlide(theComponentSlide)); + + // Restore the original time range for all objects. + if (insertedHandles.size()) { + 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); + } + } + } - SetTimeRange(component, theStartEndTimes.first, theStartEndTimes.second); SetName(component, theName); m_Doc.SelectDataModelObject(component); |