summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Client/Code/Core/Doc
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-08-22 10:31:47 +0300
committerJanne Kangas <janne.kangas@qt.io>2018-08-31 09:48:12 +0000
commitb369f0e12959129e8b92569879d40004113ea90b (patch)
tree9c22a9c12e6057519fc70465d797cba25530ef03 /src/Authoring/Client/Code/Core/Doc
parentdb7502ca4e8d5a6d153b557cc81f3c24192e3ec8 (diff)
Check allowable datainput types when changing existing datainput type
Property datatypes are now stored when datainput is bound as a controller to a property, and allowable datatypes are checked when entering the datainput edit dialog. User is given a clarification on why certain datatypes are grayed out. Change-Id: I1cfec1d3c1b2d656e51596e557b400789399b121 Task-Id: QT3DS-1916 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Client/Code/Core/Doc')
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.cpp30
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.h7
2 files changed, 35 insertions, 2 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
index e487e052..6ad06e00 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
@@ -1276,8 +1276,10 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
// TODO: implement a pre-change signal that can be used to extract
// controlledproperty string before and after the change, so we know exactly
// what happened to the element
- for (auto &it : qAsConst(g_StudioApp.m_dataInputDialogItems))
+ for (auto &it : qAsConst(g_StudioApp.m_dataInputDialogItems)) {
it->controlledElems.clear();
+ it->boundTypes.clear();
+ }
UpdateDatainputMap(m_Core->GetDoc()->GetActiveRootInstance());
}
@@ -2881,6 +2883,8 @@ QString CDoc::GetDocumentUIAFile(bool master)
return file.isEmpty() ? masterFile : file;
}
+// TODO: use ProjectFile class framework to parse subpresentations and add datainput use
+// information from them to the map as well
void CDoc::UpdateDatainputMap(
const qt3dsdm::Qt3DSDMInstanceHandle inInstance,
QMultiMap<QString,
@@ -2899,12 +2903,34 @@ void CDoc::UpdateDatainputMap(
QStringList splitStr = currCtrldPropsStr.toQString().split(' ');
for (int i = 0; i < splitStr.size() - 1; i += 2) {
QString diName = splitStr[i].startsWith('$') ? splitStr[i].remove(0, 1) : splitStr[i];
+ QString propName = splitStr[i+1];
+
+ auto propHandle = propSystem->GetAggregateInstancePropertyByName(
+ inInstance, propName.toStdWString().c_str());
+ auto propType = propSystem->GetDataType(propHandle);
+ // Update the controlled elements and property types for
+ // verified, existing datainputs. Note that for @timeline and
+ // @slide controllers the property type is not found as these
+ // are pseudo-properties, and return from GetDataType will be invalid.
+ // For slide control, type is strictly set to String. For timeline,
+ // the datainput is strictly Ranged Number which cannot be represented
+ // with object property datatypes, so will be handled separately
+ // when allowable datainput types are checked.
if (g_StudioApp.m_dataInputDialogItems.contains(diName)) {
g_StudioApp.m_dataInputDialogItems[diName]->
controlledElems.append(inInstance);
+ if (propType) {
+ g_StudioApp.m_dataInputDialogItems[diName]->boundTypes.append(
+ QPair<qt3dsdm::DataModelDataType::Value, bool>(propType, false));
+ } else if (propName == QLatin1String("@slide")) {
+ g_StudioApp.m_dataInputDialogItems[diName]
+ ->boundTypes.append(QPair<qt3dsdm::DataModelDataType::Value, bool>
+ (qt3dsdm::DataModelDataType::Value::String, true));
+
+ }
} else if (outMap != nullptr) {
// Do multi insert as single datainput name can
- // be found in several elements
+ // be found in several elements.
qt3dsdm::Qt3DSDMPropertyHandle prop
= propSystem->GetAggregateInstancePropertyByName(
inInstance, splitStr[i+1].toStdWString().c_str());
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h
index 9909f921..5b11acd7 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.h
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.h
@@ -161,6 +161,13 @@ public:
QString name;
int type;
QVector<qt3dsdm::Qt3DSDMInstanceHandle> controlledElems;
+ // The type of property/properties that this datainput controls
+ // for the purposes of limiting allowed datainput type changes.
+ // Note that there can be more than one type being controlled
+ // f.ex with Variant type. Boolean signifies "strict" type requirement
+ // i.e. only the exact equivalent mapping from datainput type to
+ // property type is allowed (float to float, string to string etc.)
+ QVector<QPair<qt3dsdm::DataModelDataType::Value, bool>> boundTypes;
};
//==============================================================================