summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMäättä Antti <antti.maatta@qt.io>2017-11-27 14:57:30 +0200
committerAntti Määttä <antti.maatta@qt.io>2017-11-29 09:12:45 +0000
commitb418ff891a4d661fbcaa2e762c9ae165fe810a33 (patch)
treed7b1e8f544d005f7a803385f2cb3f389aa52671b
parentb62597d54867fe1cbd46ed1055f15ad0c2310a51 (diff)
Fix alias object creation and reference
Disallow adding alias objects to nodes, which do not make sense. Also disable alias referencing to other aliases and objects that can not be made to alias. Task-number: QT3DS-185 Change-Id: I1a179409eacba916857a9a50ad9b7bc4a7187da8 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp6
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp11
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ObjectBrowser.qml11
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp7
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h1
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp23
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h6
7 files changed, 57 insertions, 8 deletions
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
index fae06273..58a35eb7 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
@@ -69,8 +69,6 @@ bool CStudioObjectTypes::AcceptableParent(EStudioObjectType inChild, EStudioObje
// Skip the break because these cases have the same parent.
case OBJTYPE_GROUP:
// Skip the break because these cases have the same parent.
- case OBJTYPE_ALIAS:
- // Skip the break because these cases have the same parent.
case OBJTYPE_PATH:
// Skip the break because these cases have the same parent.
case OBJTYPE_COMPONENT:
@@ -80,6 +78,10 @@ bool CStudioObjectTypes::AcceptableParent(EStudioObjectType inChild, EStudioObje
|| (inParent == OBJTYPE_PATH);
break;
+ case OBJTYPE_ALIAS:
+ theAcceptible = (inParent == OBJTYPE_LAYER) || (inParent == OBJTYPE_GROUP)
+ || (inParent == OBJTYPE_COMPONENT) || (inParent == OBJTYPE_PATH);
+ break;
case OBJTYPE_IMAGE:
theAcceptible = false;
break;
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index db8276d8..d6026579 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -423,6 +423,17 @@ QObject *InspectorControlView::showObjectReference(int handle, int instance, con
m_objectReferenceView = new ObjectBrowserView(this);
m_objectReferenceView->setModel(m_objectReferenceModel);
+ if (doc->GetStudioSystem()->GetClientDataModelBridge()
+ ->GetObjectType(instance) == OBJTYPE_ALIAS) {
+ QVector<EStudioObjectType> exclude;
+ exclude << OBJTYPE_ALIAS << OBJTYPE_BEHAVIOR << OBJTYPE_CUSTOMMATERIAL
+ << OBJTYPE_EFFECT << OBJTYPE_GUIDE << OBJTYPE_IMAGE << OBJTYPE_LAYER
+ << OBJTYPE_MATERIAL << OBJTYPE_REFERENCEDMATERIAL << OBJTYPE_SCENE;
+ m_objectReferenceModel->excludeObjectTypes(exclude);
+ } else {
+ m_objectReferenceModel->excludeObjectTypes(QVector<EStudioObjectType>());
+ }
+
disconnect(m_objectReferenceView);
IObjectReferenceHelper *objRefHelper = doc->GetDataModelObjectReferenceHelper();
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowser.qml b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowser.qml
index db27c45b..299a4757 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowser.qml
+++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowser.qml
@@ -126,10 +126,15 @@ Rectangle {
id: delegateArea
anchors.fill: parent
- onClicked: browserList.currentIndex = model.index
+ onClicked: {
+ if (_objectBrowserView.selectable(model.index))
+ browserList.currentIndex = model.index;
+ }
onDoubleClicked: {
- browserList.currentIndex = model.index;
- _objectBrowserView.close();
+ if (_objectBrowserView.selectable(model.index)) {
+ browserList.currentIndex = model.index;
+ _objectBrowserView.close();
+ }
}
}
}
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp
index 4260e4c5..6fa3f0a3 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp
@@ -77,6 +77,13 @@ QString ObjectBrowserView::path(int index) const
return m_model->index(index, 0).data(ObjectListModel::PathReferenceRole).toString();
}
+bool ObjectBrowserView::selectable(int index) const
+{
+ auto handleId = m_model->index(index, 0).data(ObjectListModel::HandleRole).toInt();
+ auto handle = qt3dsdm::Qt3DSDMInstanceHandle(handleId);
+ return m_model->sourceModel()->selectable(handle);
+}
+
void ObjectBrowserView::selectAndExpand(const qt3dsdm::Qt3DSDMInstanceHandle &handle)
{
QModelIndex index = m_model->sourceModel()->indexForHandle(handle);
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h
index 1c7cc503..ba9a752e 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h
+++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.h
@@ -63,6 +63,7 @@ public:
Q_INVOKABLE QString name(int index) const;
Q_INVOKABLE QString path(int index) const;
+ Q_INVOKABLE bool selectable(int index) const;
void selectAndExpand(const qt3dsdm::Qt3DSDMInstanceHandle &handle);
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp
index ef84eafb..5ce96e11 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp
@@ -37,6 +37,7 @@
#include "StudioObjectTypes.h"
#include "StudioPreferences.h"
#include "Qt3DSDMStudioSystem.h"
+#include "ClientDataModelBridge.h"
#include <QCoreApplication>
#include <QColor>
@@ -108,8 +109,13 @@ QVariant ObjectListModel::data(const QModelIndex &index, int role) const
return resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(info.m_Type);
}
case TextColorRole: {
- auto info = m_objRefHelper->GetInfo(handleForIndex(index));
- if (info.m_Master)
+ auto bridge = m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
+ auto handle = handleForIndex(index);
+ auto objType = bridge->GetObjectType(handle);
+ auto info = m_objRefHelper->GetInfo(handle);
+ if (m_excludeTypes.contains(objType))
+ return QVariant::fromValue(CStudioPreferences::disabledColor());
+ else if (info.m_Master)
return QVariant::fromValue(CStudioPreferences::masterColor());
else
return QVariant::fromValue(CStudioPreferences::textColor());
@@ -161,6 +167,18 @@ qt3dsdm::Qt3DSDMInstanceHandle ObjectListModel::handleForIndex(const QModelIndex
return static_cast<qt3dsdm::Qt3DSDMInstanceHandle>(index.internalId());
}
+void ObjectListModel::excludeObjectTypes(const QVector<EStudioObjectType> &types)
+{
+ m_excludeTypes = types;
+}
+
+bool ObjectListModel::selectable(const qt3dsdm::Qt3DSDMInstanceHandle &handle) const
+{
+ auto bridge = m_core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge();
+ auto objType = bridge->GetObjectType(handle);
+ return !m_excludeTypes.contains(objType);
+}
+
qt3dsdm::TInstanceHandleList ObjectListModel::childrenList(const qt3dsdm::Qt3DSDMSlideHandle &slideHandle, const qt3dsdm::Qt3DSDMInstanceHandle &handle) const
{
auto slideSystem = m_core->GetDoc()->GetStudioSystem()->GetSlideSystem();
@@ -373,4 +391,3 @@ int FlatObjectListModel::rowForSourceIndex(const QModelIndex &sourceIndex)
}
return -1;
}
-
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h
index 6b8aa338..e0b0395c 100644
--- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h
+++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h
@@ -33,6 +33,7 @@
#include <QAbstractListModel>
#include "Qt3DSDMHandles.h"
+#include "StudioObjectTypes.h"
class IObjectReferenceHelper;
class CCore;
@@ -66,6 +67,10 @@ public:
QModelIndex indexForHandle(const qt3dsdm::Qt3DSDMInstanceHandle &handle,
const QModelIndex &startIndex = {}) const;
+ bool selectable(const qt3dsdm::Qt3DSDMInstanceHandle &handle) const;
+
+ void excludeObjectTypes(const QVector<EStudioObjectType> &types);
+
private:
qt3dsdm::Qt3DSDMInstanceHandle handleForIndex(const QModelIndex &index) const;
@@ -78,6 +83,7 @@ private:
qt3dsdm::Qt3DSDMSlideHandle m_slideHandle;
qt3dsdm::Qt3DSDMInstanceHandle m_baseHandle;
IObjectReferenceHelper *m_objRefHelper;
+ QVector<EStudioObjectType> m_excludeTypes;
};
class FlatObjectListModel : public QAbstractListModel