summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-05-23 16:42:44 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-05-25 07:52:05 +0000
commit3a61e4375f630020ed54b660d71cb63f6da50043 (patch)
tree59e1bdff8db55421cdf1d0b0bb8fe067b96f0fe8 /src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
parent4397efee9938fb4e83a78ea301c2fa3947d033ee (diff)
Make moving rows asynchronous
This is the simplest way to ensure row indices stay in sync with asset graph indices in cases where multiple children are added to indices beyond the current child count (e.g. undoing a multiselection delete/move). This change also makes multiselection moves quite a bit more efficient, though in release builds the effect is barely noticeable. Also optimized a frequently used function getBindingForHandle to first look for the binding using the m_handlesMap as pretty much every time, except when called from onAssetCreated, the handle can be found from m_handlesMap. Task-number: QT3DS-1758 Change-Id: Ie95aef5f5f54c794db6a5d9c7515314b3182b65e Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp')
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp50
1 files changed, 14 insertions, 36 deletions
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
index 7b70458f..999062da 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
@@ -755,44 +755,22 @@ int Qt3DSDMTimelineItemBinding::getAnimatedPropertyIndex(int propertyHandle) con
return -1;
}
-// Converts global asset graph index of a child into local time context index or vice versa
-int Qt3DSDMTimelineItemBinding::convertIndex(int index, bool isAssetGraphIndex) const
-{
- // If we are not a master slide object or scene root, global and local indexes always match
- int retval = 0;
- if (!IsMaster() && GetObjectType() != OBJTYPE_SCENE) {
- retval = index;
- } else {
- qt3dsdm::Qt3DSDMInstanceHandle instance = GetInstance();
- if (instance.Valid()) {
- Q3DStudio::CGraphIterator currentChildren;
- Qt3DSDMSlideHandle activeSlide = m_TransMgr->GetDoc()->GetActiveSlide();
- GetAssetChildrenInTimeParent(instance, m_TransMgr->GetDoc(), AmITimeParent(),
- currentChildren, activeSlide);
-
- Q3DStudio::CGraphIterator allChildren;
- GetAssetChildren(m_TransMgr->GetDoc(), instance, allChildren);
-
- // Compare children to adjust the index
- size_t skip = 0;
- size_t maxCurrentIndex = currentChildren.GetCount() - 1;
- size_t count = qMin(allChildren.GetCount(), size_t(index));
- for (size_t current = 0; current < count; ++current) {
- size_t skipIndex = current - skip;
- if (skipIndex > maxCurrentIndex || allChildren.GetResult(current)
- != currentChildren.GetResult(skipIndex)) {
- ++skip;
- }
- }
- retval = index;
- if (isAssetGraphIndex)
- retval -= int(skip);
- else
- retval += int(skip);
+void Qt3DSDMTimelineItemBinding::getTimeContextIndices(const QSet<int> &children,
+ QMap<int, int> &indexMap)
+{
+ qt3dsdm::Qt3DSDMInstanceHandle instance = GetInstance();
+ if (instance.Valid()) {
+ Q3DStudio::CGraphIterator graphChildren;
+ Qt3DSDMSlideHandle activeSlide = m_TransMgr->GetDoc()->GetActiveSlide();
+ GetAssetChildrenInTimeParent(instance, m_TransMgr->GetDoc(), AmITimeParent(),
+ graphChildren, activeSlide);
+ const size_t count = graphChildren.GetCount();
+ for (size_t current = 0; current < count; ++current) {
+ auto handle = graphChildren.GetResult(current);
+ if (children.contains(handle))
+ indexMap.insert(current, int(handle));
}
}
-
- return retval;
}
void Qt3DSDMTimelineItemBinding::InsertKeyframe()