diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-13 15:33:14 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-15 08:07:00 +0000 |
commit | a0e0fc6736499957b5833af57b04aa6fa13bd6a9 (patch) | |
tree | f01a04515e91e17edb051a587557e02360e95e3e /src/Authoring/Studio/Palettes/Slide | |
parent | 8a3b5e92f1d24d56160f7206701be760f14c8000 (diff) |
Optimize data input indicator handling
The data input indicators were getting updated redundantly.
Changed it so that only EndDataModelNotifications event triggers
update for data input indicator in timeline toolbar and slide view.
Rest of the event triggers for the update were redundant as they
were always accompanied by this event.
Also now we only update the indicators if the data input actually
changes, saving us from continuously updating the style sheet.
Task-number: QT3DS-1902
Change-Id: I619eeccc43e417fc17c35d5d38b01f8a2fe4fffa
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Slide')
-rw-r--r-- | src/Authoring/Studio/Palettes/Slide/SlideView.cpp | 44 | ||||
-rw-r--r-- | src/Authoring/Studio/Palettes/Slide/SlideView.h | 4 |
2 files changed, 26 insertions, 22 deletions
diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp index fd1a31bd..431282d7 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp @@ -206,7 +206,6 @@ void SlideView::OnNewPresentation() // slide datainput control CDispatch *theDispatch = g_StudioApp.GetCore()->GetDispatch(); theDispatch->AddDataModelListener(this); - updateDataInputStatus(false); } void SlideView::OnClosingPresentation() @@ -338,7 +337,7 @@ void SlideView::onDataInputChange(int handle, int instance, const QString &dataI // Set the state of slide control based on scene or component // controlledproperty -void SlideView::updateDataInputStatus(bool isViaDispatch) +void SlideView::updateDataInputStatus() { CDoc *doc = g_StudioApp.GetCore()->GetDoc(); CClientDataModelBridge *bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); @@ -357,23 +356,28 @@ void SlideView::updateDataInputStatus(bool isViaDispatch) qt3dsdm::SValue controlledPropertyVal; doc->GetStudioSystem()->GetPropertySystem()->GetInstancePropertyValue( slideRoot, ctrldProp, controlledPropertyVal); - auto existingCtrl = qt3dsdm::get<QString>(controlledPropertyVal); - if (existingCtrl.contains("@slide")) { - int slideStrPos = existingCtrl.indexOf("@slide"); + + QString newController; + int slideStrPos = existingCtrl.indexOf("@slide"); + if (slideStrPos != -1) { int ctrStrPos = existingCtrl.lastIndexOf("$", slideStrPos - 2); - m_currentController = existingCtrl.mid(ctrStrPos + 1, slideStrPos - ctrStrPos - 2); - m_toolTip = tr("Slide Controller:\n") + m_currentController; - m_controlled = true; - } else { - m_currentController.clear(); - m_toolTip = tr("No controller"); - m_controlled = false; + newController = existingCtrl.mid(ctrStrPos + 1, slideStrPos - ctrStrPos - 2); + } + if (newController != m_currentController) { + m_currentController = newController; + if (!m_currentController.isEmpty()) { + m_toolTip = tr("Slide Controller:\n") + m_currentController; + m_controlled = true; + } else { + m_currentController.clear(); + m_toolTip = tr("No controller"); + m_controlled = false; + } + // update UI + UpdateSlideViewTitleColor(); + Q_EMIT controlledChanged(); } - - // update UI - UpdateSlideViewTitleColor(); - Q_EMIT controlledChanged(); } void SlideView::initialize() { @@ -463,7 +467,6 @@ void SlideView::rebuildSlideList(const qt3dsdm::Qt3DSDMSlideHandle &inActiveSlid row++; } } - updateDataInputStatus(true); } CDoc *SlideView::GetDoc() @@ -497,18 +500,19 @@ void SlideView::OnBeginDataModelNotifications() void SlideView::OnEndDataModelNotifications() { - updateDataInputStatus(true); + updateDataInputStatus(); } void SlideView::OnImmediateRefreshInstanceSingle(qt3dsdm::Qt3DSDMInstanceHandle inInstance) { - updateDataInputStatus(true); + Q_UNUSED(inInstance) } void SlideView::OnImmediateRefreshInstanceMultiple( qt3dsdm::Qt3DSDMInstanceHandle *inInstance, long inInstanceCount) { - updateDataInputStatus(true); + Q_UNUSED(inInstance) + Q_UNUSED(inInstanceCount) } // Notify the user about control state change also with slide view diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.h b/src/Authoring/Studio/Palettes/Slide/SlideView.h index 4bf5f14f..5034c035 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.h +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.h @@ -105,7 +105,7 @@ protected: virtual void OnSlideRearranged(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inOldIndex, int inNewIndex); - void updateDataInputStatus(bool isViaDispatch); + void updateDataInputStatus(); void UpdateSlideViewTitleColor(); private: @@ -134,7 +134,7 @@ private: qt3dsdm::Qt3DSDMInstanceHandle m_ActiveRoot; ///< the object containing the slides to be inspected. qt3dsdm::Qt3DSDMSlideHandle m_ActiveSlideHandle; ///< the active slide handle - bool m_controlled; // Are slides in this slide set controlled by datainput? + bool m_controlled = false; // Are slides in this slide set controlled by datainput? QString m_currentController; QString m_toolTip; }; |