summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Client/Code/Core/Doc/Doc.cpp
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-02-07 14:14:36 +0200
committerJanne Kangas <janne.kangas@qt.io>2018-02-19 12:08:24 +0000
commit9d84b269e30d01ae619d8ac014f5b4339d032758 (patch)
tree030b5ea13a6cef2c04eed2c339901303057a0eb0 /src/Authoring/Client/Code/Core/Doc/Doc.cpp
parent07813048fd054494abfa11add99d2345bf143771 (diff)
Fix Datainput undo/redo
Creates proper undo stack when datainput control is set on or off. Also, removes extra connection pointer and uses existing connection pointer list for inspector item. Only checks datainput control UI status for properties that are actually controllable (currently only textstring in Text element.) Change-Id: Iae35bed53f492a5ec25c66a50b40278830717ce9 Task-Id: QT3DS-1077 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Client/Code/Core/Doc/Doc.cpp')
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
index cc39c7c1..2972697f 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
@@ -238,6 +238,69 @@ void CDoc::SetInstancePropertyValue(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
thePropertySystem->SetInstancePropertyValue(inInstance, theProperty, inValue);
}
+// Set a property in an instance to be controlled by datainput.
+void CDoc::SetInstancePropertyControlled(
+ qt3dsdm::Qt3DSDMInstanceHandle instance, Q3DStudio::CString instancepath,
+ qt3dsdm::Qt3DSDMPropertyHandle propName, Q3DStudio::CString controller,
+ bool controlled)
+{
+ qt3dsdm::SComposerObjectDefinitions &theDefinitions(
+ GetStudioSystem()->GetClientDataModelBridge()->GetObjectDefinitions());
+ qt3dsdm::IPropertySystem *thePropertySystem = GetStudioSystem()->GetPropertySystem();
+ // get the name of controlled property
+ auto metadataHandle
+ = GetStudioSystem()->GetActionMetaData()->GetMetaDataProperty(instance, propName);
+ auto metadata
+ = GetStudioSystem()->GetActionMetaData()->GetMetaDataPropertyInfo(metadataHandle);
+
+ qt3dsdm::SValue controlledProperty;
+ qt3dsdm::SValue controllerName;
+
+ // Build controller - controlled property string.
+ if (controlled) {
+ Q3DStudio::CString controlledElemStr = controller;
+ controlledElemStr.append(" ");
+ controlledElemStr.append(metadata->m_Name.c_str());
+ controlledProperty = std::make_shared<qt3dsdm::CDataStr>(controlledElemStr);
+ } else {
+ // TODO: this is Text element-specific at the moment
+ // Get controller - property -pair for this element
+ qt3dsdm::SValue currentControlledProperty;
+ thePropertySystem->GetInstancePropertyValue(
+ instance, theDefinitions.m_Text.m_ControlledProperty, currentControlledProperty);
+
+ Q3DStudio::CString controllerNameStr
+ = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currentControlledProperty)->GetData();
+
+ // Check if this property has a controlling datainput before trying
+ // to delete it from the list of controlled properties
+ if (controllerNameStr.size()) {
+ // Set controller - property -string empty for this element.
+ // We need to explicitly set controlledProperty with an empty string initializer,
+ // otherwise it will have type "None" instead of "String".
+ // TODO: for now only a single textstring property can be controlled. For
+ // control of several properties in a single element, we must only remove
+ // a specific controller - property pair from controlledProperty string, not all.
+ controlledProperty = std::make_shared<qt3dsdm::CDataStr>(Q3DStudio::CString());
+
+ // Set the textstring content to default when disabling datainput control
+ // TODO: restore the previous text content prior to setting it to controlled
+ controllerName = theDefinitions.m_Text.m_TextString.m_DefaultValue.getValue();
+ } else {
+ // We are trying to turn control off for property that had no existing control.
+ // Nothing to do except to make sure that we set the
+ // controlledProperty to an empty string.
+ controlledProperty = std::make_shared<qt3dsdm::CDataStr>(Q3DStudio::CString());
+ }
+ }
+
+ // Set the controlledproperty string in the controlled element
+ Q3DStudio::ScopedDocumentEditor(*this, L"Set controlled", __FILE__, __LINE__)
+ ->SetInstancePropertyValue(instance,
+ theDefinitions.m_Text.m_ControlledProperty,
+ controlledProperty);
+}
+
Q3DStudio::IDocumentBufferCache &CDoc::GetBufferCache()
{
if (!m_DocumentBufferCache)