summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2019-02-19 14:56:41 +0200
committerMahmoud Badri <mahmoud.badri@qt.io>2019-02-20 10:24:27 +0000
commit303002cac0e5122ce13f74401d18b9c71f876f28 (patch)
tree2b310ab0866efa0c2b4c7e0b98e2cc9406de6bde
parentf4644d1880260d362502ec0801708ea2fe66499a (diff)
Implement variants UI on the timeline rows
Also some related fixes and tweaks. Task-number: QT3DS-3081 Change-Id: I7fd86479500fbbca247fb8a6517165ff6d0f742a Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.cpp6
-rw-r--r--src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp15
-rw-r--r--src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h35
-rw-r--r--src/Authoring/Studio/Application/ProjectFile.cpp107
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp6
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp17
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp75
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h2
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp24
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h4
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp2
11 files changed, 203 insertions, 90 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
index a7730603..9f1f4dca 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
@@ -729,18 +729,14 @@ qt3dsdm::Qt3DSDMInstanceHandle CDoc::GetFirstSelectableLayer()
QVector<qt3dsdm::Qt3DSDMInstanceHandle> CDoc::getLayers()
{
- CClientDataModelBridge *bridge = m_StudioSystem->GetClientDataModelBridge();
-
Q3DStudio::CGraphIterator layerIterator;
GetAssetChildren(this, m_SceneInstance, layerIterator, OBJTYPE_LAYER);
QVector<qt3dsdm::Qt3DSDMInstanceHandle> layerList;
for (; !layerIterator.IsDone(); ++layerIterator) {
- if (m_StudioSystem->IsInstance(layerIterator.GetCurrent())
- && !bridge->IsLockedAtAll(layerIterator.GetCurrent())) {
+ if (m_StudioSystem->IsInstance(layerIterator.GetCurrent()))
layerList.append(layerIterator.GetCurrent());
- }
}
return layerList;
diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp
index e842b0a1..e6931f37 100644
--- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp
+++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp
@@ -316,6 +316,7 @@ struct DataConstructor<SObjectRefType>
#define QT3DS_WCHAR_T_lightmapradiosity L"lightmapradiosity"
#define QT3DS_WCHAR_T_lightmapshadow L"lightmapshadow"
#define QT3DS_WCHAR_T_controlledproperty L"controlledproperty"
+#define QT3DS_WCHAR_T_variants L"variants"
const wchar_t *ComposerObjectTypes::Convert(ComposerObjectTypes::Enum inType)
{
@@ -337,7 +338,7 @@ ComposerObjectTypes::Enum ComposerObjectTypes::Convert(const wchar_t *inType)
{
#define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) \
- if (AreEqual(QT3DS_WCHAR_T_##name, inType)) \
+ if (AreEqual(QT3DS_WCHAR_T_##name, inType)) \
return ComposerObjectTypes::name;
ITERATE_COMPOSER_OBJECT_TYPES
#undef HANDLE_COMPOSER_OBJECT_TYPE
@@ -385,7 +386,7 @@ ComposerPropertyNames::Enum ComposerPropertyNames::Convert(const wchar_t *inType
{
#define HANDLE_COMPOSER_PROPERTY_DUPLICATE(name, memberName, type, defaultValue)
#define HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) \
- if (AreEqual(inType, QT3DS_WCHAR_T_##name)) \
+ if (AreEqual(inType, QT3DS_WCHAR_T_##name)) \
return name;
#define HANDLE_COMPOSER_PROPERTY(name, memberName, type, defaultValue) \
HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type)
@@ -450,11 +451,11 @@ ComposerPropertyNames::Enum ComposerPropertyNames::Convert(const char8_t *inType
#define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) \
SComposerTypePropertyDefinition<ComposerObjectTypes::name>::SComposerTypePropertyDefinition( \
- IDataCore &inCore, Qt3DSDMInstanceHandle inInstance) \
- : reserved(false) propmacro \
- { \
- Q_UNUSED(inCore);\
- Q_UNUSED(inInstance);\
+ IDataCore &inCore, Qt3DSDMInstanceHandle inInstance) \
+ : reserved(false) propmacro \
+ { \
+ Q_UNUSED(inCore); \
+ Q_UNUSED(inInstance); \
}
ITERATE_COMPOSER_OBJECT_TYPES
#undef HANDLE_COMPOSER_OBJECT_TYPE
diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h
index 832e76ff..bc665b22 100644
--- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h
+++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h
@@ -70,7 +70,7 @@ class IPropertySystem;
HANDLE_COMPOSER_OBJECT_TYPE(Model, ITERATE_COMPOSER_MODEL_PROPERTIES) \
HANDLE_COMPOSER_OBJECT_TYPE(Light, ITERATE_COMPOSER_LIGHT_PROPERTIES) \
HANDLE_COMPOSER_OBJECT_TYPE(Camera, ITERATE_COMPOSER_CAMERA_PROPERTIES) \
- HANDLE_COMPOSER_OBJECT_TYPE(Component, ITERATE_COMPOSER_COMPONENT_PROPERTIES) \
+ HANDLE_COMPOSER_OBJECT_TYPE(Component, ITERATE_COMPOSER_COMPONENT_PROPERTIES) \
HANDLE_COMPOSER_OBJECT_TYPE(Text, ITERATE_COMPOSER_TEXT_PROPERTIES) \
HANDLE_COMPOSER_OBJECT_TYPE(RenderPlugin, ITERATE_COMPOSER_NO_ADDITIONAL_PROPERTIES) \
HANDLE_COMPOSER_OBJECT_TYPE(Alias, ITERATE_COMPOSER_ALIAS_PROPERTIES) \
@@ -93,8 +93,8 @@ class IPropertySystem;
HANDLE_COMPOSER_PROPERTY(importid, m_ImportId, TDataStrPtr, L"") \
HANDLE_COMPOSER_PROPERTY(importfile, m_ImportFile, TDataStrPtr, L"") \
HANDLE_COMPOSER_PROPERTY(fileid, m_FileId, TDataStrPtr, L"") \
- HANDLE_COMPOSER_PROPERTY(starttime, m_StartTime, qt3ds::QT3DSI32, 0) \
- HANDLE_COMPOSER_PROPERTY(endtime, m_EndTime, qt3ds::QT3DSI32, 10000) \
+ HANDLE_COMPOSER_PROPERTY(starttime, m_StartTime, qt3ds::QT3DSI32, 0) \
+ HANDLE_COMPOSER_PROPERTY(endtime, m_EndTime, qt3ds::QT3DSI32, 10000) \
HANDLE_COMPOSER_PROPERTY(eyeball, m_Eyeball, bool, true) \
HANDLE_COMPOSER_PROPERTY(shy, m_Shy, bool, false) \
HANDLE_COMPOSER_PROPERTY(locked, m_Locked, bool, false) \
@@ -118,12 +118,12 @@ class IPropertySystem;
HANDLE_COMPOSER_PROPERTY(opacity, m_Opacity, float, 100.f) \
HANDLE_COMPOSER_PROPERTY(rotationorder, m_RotationOrder, TDataStrPtr, L"YXZ") \
HANDLE_COMPOSER_PROPERTY(orientation, m_Orientation, TDataStrPtr, L"Left Handed") \
- HANDLE_COMPOSER_PROPERTY(boneid, m_BoneId, qt3ds::QT3DSI32, 0) \
+ HANDLE_COMPOSER_PROPERTY(boneid, m_BoneId, qt3ds::QT3DSI32, 0) \
HANDLE_COMPOSER_PROPERTY(ignoresparent, m_IgnoresParent, bool, false) \
HANDLE_COMPOSER_PROPERTY_DUPLICATE(controlledproperty, m_ControlledProperty, TDataStrPtr, L"")
#define ITERATE_COMPOSER_MODEL_PROPERTIES \
- HANDLE_COMPOSER_PROPERTY(poseroot, m_PoseRoot, qt3ds::QT3DSI32, -1) \
+ HANDLE_COMPOSER_PROPERTY(poseroot, m_PoseRoot, qt3ds::QT3DSI32, -1) \
HANDLE_COMPOSER_PROPERTY(tessellation, m_Tessellation, TDataStrPtr, L"None") \
HANDLE_COMPOSER_PROPERTY(edgetess, m_EdgeTess, float, 1.0) \
HANDLE_COMPOSER_PROPERTY(innertess, m_InnerTess, float, 1.0) \
@@ -219,7 +219,7 @@ class IPropertySystem;
HANDLE_COMPOSER_PROPERTY(aodistance, m_AoDistance, float, 0) \
HANDLE_COMPOSER_PROPERTY(aosoftness, m_AoSoftness, float, 0) \
HANDLE_COMPOSER_PROPERTY(aobias, m_AoBias, float, 0) \
- HANDLE_COMPOSER_PROPERTY(aosamplerate, m_AoSamplerate, qt3ds::QT3DSI32, 1) \
+ HANDLE_COMPOSER_PROPERTY(aosamplerate, m_AoSamplerate, qt3ds::QT3DSI32, 1) \
HANDLE_COMPOSER_PROPERTY(aodither, m_AoDither, bool, false) \
HANDLE_COMPOSER_PROPERTY(shadowstrength, m_ShadowStrength, float, 0) \
HANDLE_COMPOSER_PROPERTY(shadowdist, m_ShadowDist, float, 0) \
@@ -234,6 +234,7 @@ class IPropertySystem;
HANDLE_COMPOSER_PROPERTY(probe2fade, m_Probe2Fade, float, 1) \
HANDLE_COMPOSER_PROPERTY(probe2window, m_Probe2Window, float, 1) \
HANDLE_COMPOSER_PROPERTY(probe2pos, m_Probe2Pos, float, 0.5f) \
+ HANDLE_COMPOSER_PROPERTY(variants, m_variants, TDataStrPtr, L"") \
HANDLE_COMPOSER_PROPERTY_DUPLICATE(controlledproperty, m_ControlledProperty, TDataStrPtr, L"")
#define ITERATE_COMPOSER_LIGHT_PROPERTIES \
@@ -250,7 +251,7 @@ class IPropertySystem;
HANDLE_COMPOSER_PROPERTY(castshadow, m_CastShadow, bool, false) \
HANDLE_COMPOSER_PROPERTY(shdwbias, m_ShadowBias, float, 0.0f) \
HANDLE_COMPOSER_PROPERTY(shdwfactor, m_ShadowFactor, float, 5.0f) \
- HANDLE_COMPOSER_PROPERTY(shdwmapres, m_ShadowMapRes, qt3ds::QT3DSI32, 9) \
+ HANDLE_COMPOSER_PROPERTY(shdwmapres, m_ShadowMapRes, qt3ds::QT3DSI32, 9) \
HANDLE_COMPOSER_PROPERTY(shdwmapfar, m_ShadowMapFar, float, 5000.0f) \
HANDLE_COMPOSER_PROPERTY(shdwmapfov, m_ShadowMapFov, float, 90.0f) \
HANDLE_COMPOSER_PROPERTY(shdwfilter, m_ShadowFilter, float, 35.0f) \
@@ -280,10 +281,10 @@ class IPropertySystem;
HANDLE_COMPOSER_PROPERTY(dropshadow, m_DropShadow, bool, false) \
HANDLE_COMPOSER_PROPERTY(dropshadowstrength, m_DropShadowStrength, float, 80.f) \
HANDLE_COMPOSER_PROPERTY(dropshadowoffset, m_DropShadowOffset, float, 10.f) \
- HANDLE_COMPOSER_PROPERTY(dropshadowoffsetx, m_DropShadowOffsetX, float, 0.f) \
- HANDLE_COMPOSER_PROPERTY(dropshadowoffsety, m_DropShadowOffsetY, float, 0.f) \
- HANDLE_COMPOSER_PROPERTY(dropshadowhorzalign, m_DropShadowHorizontalAlignment, TDataStrPtr, L"Right") \
- HANDLE_COMPOSER_PROPERTY(dropshadowvertalign, m_DropShadowVerticalAlignment, TDataStrPtr, L"Bottom") \
+ HANDLE_COMPOSER_PROPERTY(dropshadowoffsetx, m_DropShadowOffsetX, float, 0.f) \
+ HANDLE_COMPOSER_PROPERTY(dropshadowoffsety, m_DropShadowOffsetY, float, 0.f) \
+ HANDLE_COMPOSER_PROPERTY(dropshadowhorzalign, m_DropShadowHorizontalAlignment, TDataStrPtr, L"Right") \
+ HANDLE_COMPOSER_PROPERTY(dropshadowvertalign, m_DropShadowVerticalAlignment, TDataStrPtr, L"Bottom") \
HANDLE_COMPOSER_PROPERTY(wordwrap, m_WordWrap, TDataStrPtr, L"WrapWord") \
HANDLE_COMPOSER_PROPERTY(boundingbox, m_BoundingBox, SFloat2, SFloat2(0, 0)) \
HANDLE_COMPOSER_PROPERTY(elide, m_Elide, TDataStrPtr, L"ElideNone") \
@@ -376,14 +377,14 @@ struct DataTypeToTypeMap
bool force_compile_error;
};
-#define QT3DSDM_DEFINE_TYPE_TO_DATA_TYPE(enumName, type) \
+#define QT3DSDM_DEFINE_TYPE_TO_DATA_TYPE(enumName, type) \
template <> \
struct TypeToDataTypeMap<type> \
{ \
- static DataModelDataType::Value GetDataType() { return enumName; } \
+ static DataModelDataType::Value GetDataType() { return enumName; } \
}; \
template <> \
- struct DataTypeToTypeMap<enumName> \
+ struct DataTypeToTypeMap<enumName> \
{ \
typedef type TDataType; \
};
@@ -452,9 +453,9 @@ struct SComposerTypePropertyDefinition
template <> \
struct SComposerTypePropertyDefinition<ComposerObjectTypes::name> \
{ \
- bool reserved; \
+ bool reserved; \
propmacro SComposerTypePropertyDefinition(IDataCore &inCore, \
- Qt3DSDMInstanceHandle inInstance); \
+ Qt3DSDMInstanceHandle inInstance); \
};
ITERATE_COMPOSER_OBJECT_TYPES
@@ -936,7 +937,7 @@ public:
IDataCore &inDataCore,
IMetaData &inMetaData /*, ISlideCore& inSlideCore, IPropertySystem& inPropertySystem */);
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////
// RTTI API
bool IsA(Qt3DSDMInstanceHandle inInstance, ComposerObjectTypes::Enum inType);
// Could easily return None, meaning we can't identify the object type.
diff --git a/src/Authoring/Studio/Application/ProjectFile.cpp b/src/Authoring/Studio/Application/ProjectFile.cpp
index 21b26b8c..bd79e64b 100644
--- a/src/Authoring/Studio/Application/ProjectFile.cpp
+++ b/src/Authoring/Studio/Application/ProjectFile.cpp
@@ -1116,21 +1116,21 @@ void ProjectFile::renameVariantTag(const QString &group, const QString &oldTag,
// update the property
CDoc *doc = g_StudioApp.GetCore()->GetDoc();
- auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
- int instance = doc->GetSelectedInstance();
- auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
-
- if (instance != 0 && bridge->IsLayerInstance(instance)) {
- int property = propertySystem->GetAggregateInstancePropertyByName(instance, L"variants");
+ const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
+ const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ const auto layers = doc->getLayers();
+ auto property = bridge->GetLayer().m_variants;
+ for (auto layer : layers) {
qt3dsdm::SValue sValue;
- if (propertySystem->GetInstancePropertyValue(instance, property, sValue)) {
- QString val = QString::fromWCharArray(
- qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)->GetData());
- if (val.contains(group + QLatin1Char(':') + oldTag)) {
- val.replace(group + QLatin1Char(':') + oldTag, group + QLatin1Char(':') + newTag);
+ if (propertySystem->GetInstancePropertyValue(layer, property, sValue)) {
+ QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
+ ->GetData());
+ QString oldGroupTagPair = QStringLiteral("%1:%2").arg(group).arg(oldTag);
+ if (propVal.contains(oldGroupTagPair)) {
+ propVal.replace(oldGroupTagPair, QStringLiteral("%1:%2").arg(group).arg(newTag));
qt3dsdm::SValue sVal
- = std::make_shared<qt3dsdm::CDataStr>(Q3DStudio::CString::fromQString(val));
- propertySystem->SetInstancePropertyValue(instance, property, sVal);
+ = std::make_shared<qt3dsdm::CDataStr>(Q3DStudio::CString::fromQString(propVal));
+ propertySystem->SetInstancePropertyValue(layer, property, sVal);
}
}
}
@@ -1179,21 +1179,21 @@ void ProjectFile::renameVariantGroup(const QString &oldGroup, const QString &new
// update the property
CDoc *doc = g_StudioApp.GetCore()->GetDoc();
- auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
- int instance = doc->GetSelectedInstance();
- auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
-
- if (instance != 0 && bridge->IsLayerInstance(instance)) {
- int property = propertySystem->GetAggregateInstancePropertyByName(instance, L"variants");
+ const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
+ const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ const auto layers = doc->getLayers();
+ auto property = bridge->GetLayer().m_variants;
+ for (auto layer : layers) {
qt3dsdm::SValue sValue;
- if (propertySystem->GetInstancePropertyValue(instance, property, sValue)) {
- QString val = QString::fromWCharArray(
- qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)->GetData());
- if (val.contains(oldGroup + QLatin1Char(':'))) {
- val.replace(oldGroup + QLatin1Char(':'), newGroup + QLatin1Char(':'));
- qt3dsdm::SValue sVal
- = std::make_shared<qt3dsdm::CDataStr>(Q3DStudio::CString::fromQString(val));
- propertySystem->SetInstancePropertyValue(instance, property, sVal);
+ if (propertySystem->GetInstancePropertyValue(layer, property, sValue)) {
+ QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
+ ->GetData());
+ QString oldGroupWithColon = QStringLiteral("%1:").arg(oldGroup);
+ if (propVal.contains(oldGroupWithColon)) {
+ propVal.replace(oldGroupWithColon, QStringLiteral("%1:").arg(newGroup));
+ qt3dsdm::SValue sVal = std::make_shared<qt3dsdm::CDataStr>(
+ Q3DStudio::CString::fromQString(propVal));
+ propertySystem->SetInstancePropertyValue(layer, property, sVal);
}
}
}
@@ -1255,24 +1255,23 @@ void ProjectFile::deleteVariantGroup(const QString &group)
deleteGroupFromUip(doc->GetDocumentPath(), group);
// delete the group from the property (if set)
- auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
- auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
- int instance = doc->GetSelectedInstance();
- int property = propertySystem->GetAggregateInstancePropertyByName(instance, L"variants");
- QString propVal;
- if (instance != 0 && bridge->IsLayerInstance(instance)) {
+ const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
+ const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ const auto layers = doc->getLayers();
+ auto property = bridge->GetLayer().m_variants;
+ for (auto layer : layers) {
qt3dsdm::SValue sValue;
- if (propertySystem->GetInstancePropertyValue(instance, property, sValue)) {
- propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
- ->GetData());
- if (propVal.contains(group + QLatin1Char(':'))) {
+ if (propertySystem->GetInstancePropertyValue(layer, property, sValue)) {
+ QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
+ ->GetData());
+ if (propVal.contains(QStringLiteral("%1:").arg(group))) {
// property has the deleted group, need to update it, else the deleted group
// will be saved the uip if the user saves the presentation.
- QRegExp rgx(group + ":\\w*,*|," + group + ":\\w*");
+ QRegExp rgx(QStringLiteral("%1:\\w*,*|,%1:\\w*").arg(group));
propVal.replace(rgx, {});
qt3dsdm::SValue sVal = std::make_shared<qt3dsdm::CDataStr>(
Q3DStudio::CString::fromQString(propVal));
- propertySystem->SetInstancePropertyValue(instance, property, sVal);
+ propertySystem->SetInstancePropertyValue(layer, property, sVal);
}
}
}
@@ -1506,6 +1505,7 @@ bool ProjectFile::isVariantTagUnique(const QString &group, const QString &tag) c
void ProjectFile::deleteVariantTag(const QString &group, const QString &tag)
{
+ CDoc *doc = g_StudioApp.GetCore()->GetDoc();
QDomDocument domDoc;
QSaveFile file(getProjectFilePath());
if (!StudioUtils::openDomDocumentSave(file, domDoc))
@@ -1519,7 +1519,7 @@ void ProjectFile::deleteVariantTag(const QString &group, const QString &tag)
for (int i = 0; i < presElems.count(); ++i) {
QString pPath = m_fileInfo.path() + QLatin1Char('/')
+ presElems.at(i).toElement().attribute(QStringLiteral("src"));
- if (pPath != g_StudioApp.GetCore()->GetDoc()->GetDocumentPath()
+ if (pPath != doc->GetDocumentPath()
&& tagExistsInUip(pPath, group, tag)) {
inUseIdx = i;
break;
@@ -1540,7 +1540,7 @@ void ProjectFile::deleteVariantTag(const QString &group, const QString &tag)
for (int i = inUseIdx; i < presElems.count(); ++i) {
QString pPath = m_fileInfo.path() + QLatin1Char('/')
+ presElems.at(i).toElement().attribute(QStringLiteral("src"));
- if (pPath != g_StudioApp.GetCore()->GetDoc()->GetDocumentPath())
+ if (pPath != doc->GetDocumentPath())
deleteTagFromUip(pPath, group, tag);
}
break;
@@ -1552,11 +1552,34 @@ void ProjectFile::deleteVariantTag(const QString &group, const QString &tag)
}
// delete the tag from current doc, if exists
- deleteTagFromUip(g_StudioApp.GetCore()->GetDoc()->GetDocumentPath(), group, tag);
+ deleteTagFromUip(doc->GetDocumentPath(), group, tag);
QDomNodeList groupsElems = domDoc.documentElement()
.firstChildElement(QStringLiteral("variants"))
.elementsByTagName(QStringLiteral("variantgroup"));
+
+ // delete the tag from the property (if set)
+ const auto propertySystem = doc->GetStudioSystem()->GetPropertySystem();
+ const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge();
+ const auto layers = doc->getLayers();
+ auto property = bridge->GetLayer().m_variants;
+ for (auto layer : layers) {
+ qt3dsdm::SValue sValue;
+ if (propertySystem->GetInstancePropertyValue(layer, property, sValue)) {
+ QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
+ ->GetData());
+ if (propVal.contains(QStringLiteral("%1:%2").arg(group).arg(tag))) {
+ // property has the deleted tag, need to update it, else the deleted tag will be
+ // saved in the uip if the user saves the presentation.
+ QRegExp rgx(QStringLiteral("%1:%2,*|,%1:%2").arg(group).arg(tag));
+ propVal.replace(rgx, {});
+ qt3dsdm::SValue sVal = std::make_shared<qt3dsdm::CDataStr>(
+ Q3DStudio::CString::fromQString(propVal));
+ propertySystem->SetInstancePropertyValue(layer, property, sVal);
+ }
+ }
+ }
+
// update and save the uia
bool deleted = false;
for (int i = 0; i < groupsElems.count(); ++i) {
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index 230c0d0e..0dda40aa 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -60,6 +60,9 @@
#include "Qt3DSDMSlides.h"
#include "VariantsGroupModel.h"
#include "VariantTagDialog.h"
+#include "Views.h"
+#include "MainFrm.h"
+#include "TimelineWidget.h"
#include <QtCore/qtimer.h>
#include <QtQml/qqmlcontext.h>
@@ -476,6 +479,7 @@ void InspectorControlView::showTagContextMenu(int x, int y, const QString &group
auto actionDelete = theContextMenu.addAction(QObject::tr("Delete Tag"));
connect(actionDelete, &QAction::triggered, this, [&]() {
g_StudioApp.GetCore()->getProjectFile().deleteVariantTag(group, tag);
+ g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants();
});
theContextMenu.exec(mapToGlobal({x, y}));
@@ -493,6 +497,7 @@ void InspectorControlView::showGroupContextMenu(int x, int y, const QString &gro
VariantTagDialog dlg(VariantTagDialog::RenameGroup, {}, group);
if (dlg.exec() == QDialog::Accepted) {
projectFile.renameVariantGroup(dlg.getNames().first, dlg.getNames().second);
+ g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants();
}
});
@@ -506,6 +511,7 @@ void InspectorControlView::showGroupContextMenu(int x, int y, const QString &gro
auto actionDelete = theContextMenu.addAction(QObject::tr("Delete Group"));
connect(actionDelete, &QAction::triggered, this, [&]() {
projectFile.deleteVariantGroup(group);
+ g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants();
});
theContextMenu.exec(mapToGlobal({x, y}));
diff --git a/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp b/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp
index 37814b56..d43232d2 100644
--- a/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/VariantsGroupModel.cpp
@@ -30,7 +30,6 @@
#include "VariantsTagModel.h"
#include "StudioApp.h"
#include "Core.h"
-#include "QDebug" // TODO: remove
#include "Qt3DSDMStudioSystem.h"
#include "ClientDataModelBridge.h"
#include "IDocumentEditor.h"
@@ -56,24 +55,20 @@ void VariantsGroupModel::refresh()
return;
}
- auto propertySystem = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem()->GetPropertySystem();
+ auto propertySystem = g_StudioApp.GetCore()->GetDoc()->GetPropertySystem();
m_instance = instance;
- m_property = propertySystem->GetAggregateInstancePropertyByName(instance, L"variants");
+ m_property = bridge->GetLayer().m_variants.m_Property;
qt3dsdm::SValue sValue;
if (propertySystem->GetInstancePropertyValue(m_instance, m_property, sValue)) {
beginResetModel();
m_data.clear();
- QString val = QString::fromWCharArray(
- qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)->GetData());
- // TODO: remove qDebug when the variants work is fully done.
-// qDebug() << "\x1b[42m \x1b[1m" << __FUNCTION__
-// << ", val=" << val
-// << "\x1b[m";
+ QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
+ ->GetData());
QHash<QString, QStringList> propTags;
- if (!val.isEmpty()) {
- const QStringList propTagsList = val.split(QChar(','));
+ if (!propVal.isEmpty()) {
+ const QStringList propTagsList = propVal.split(QChar(','));
for (auto &propTag : propTagsList) {
const QStringList propTagPair = propTag.split(QChar(':'));
propTags[propTagPair[0]].append(propTagPair[1]);
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
index ee7d4bee..15366742 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
@@ -751,6 +751,28 @@ void TimelineWidget::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance
m_subpresentationChanges.insert(inInstance);
if (!m_asyncUpdateTimer.isActive())
m_asyncUpdateTimer.start();
+ } else if (inProperty == m_bridge->GetLayer().m_variants) {
+ qt3dsdm::SValue sValue;
+ if (doc->GetPropertySystem()->GetInstancePropertyValue(inInstance, inProperty, sValue)) {
+ QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
+ ->GetData());
+ if (!propVal.isEmpty()) {
+ QStringList tagPairs = propVal.split(QLatin1Char(','));
+ QStringList groups;
+ for (int i = 0; i < tagPairs.size(); ++i) {
+ QString group = tagPairs[i].left(tagPairs[i].indexOf(QLatin1Char(':')));
+ if (!groups.contains(group))
+ groups.append(group);
+ }
+
+ m_variantsMap[inInstance] = groups;
+ } else {
+ m_variantsMap[inInstance].clear();
+ }
+
+ if (!m_asyncUpdateTimer.isActive())
+ m_asyncUpdateTimer.start();
+ }
}
}
@@ -774,11 +796,11 @@ void TimelineWidget::onAsyncUpdate()
m_graphicsScene->updateController();
onSelectionChange(doc->GetSelectedValue());
m_toolbar->setNewLayerEnabled(!m_graphicsScene->rowManager()->isComponentRoot());
+ refreshVariants();
// update suppresentation indicators
- for (auto *row : m_handlesMap)
+ for (auto *row : qAsConst(m_handlesMap))
row->updateSubpresentations();
-
} else {
if (!m_moveMap.isEmpty()) {
// Flip the hash around so that we collect moves by parent.
@@ -922,10 +944,22 @@ void TimelineWidget::onAsyncUpdate()
}
m_graphicsScene->updateSnapSteps();
}
+
+ if (!m_variantsMap.isEmpty()) {
+ const auto instances = m_variantsMap.keys();
+ for (int instance : instances) {
+ RowTree *row = m_handlesMap[instance];
+ if (row) {
+ const auto groups = m_variantsMap.value(instance); // variants groups names
+ row->updateVariants(groups);
+ }
+ }
+ }
}
m_dirtyProperties.clear();
m_moveMap.clear();
m_actionChanges.clear();
+ m_variantsMap.clear();
m_subpresentationChanges.clear();
m_keyframeChangesMap.clear();
m_graphicsScene->rowManager()->finalizeRowDeletions();
@@ -1116,7 +1150,7 @@ Qt3DSDMTimelineItemBinding *TimelineWidget::getBindingForHandle(int handle,
const QList<ITimelineItemBinding *> children = binding->GetChildren();
for (auto child : children) {
Qt3DSDMTimelineItemBinding *b = getBindingForHandle(handle,
- static_cast<Qt3DSDMTimelineItemBinding *>(child));
+ static_cast<Qt3DSDMTimelineItemBinding *>(child));
if (b)
return b;
@@ -1140,6 +1174,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event)
void TimelineWidget::mouseReleaseEvent(QMouseEvent *event)
{
+ Q_UNUSED(event)
m_splitterPressed = false;
}
@@ -1198,8 +1233,8 @@ void TimelineWidget::onTimeBarColorChanged(const QColor &color)
void TimelineWidget::setSelectedTimeBarsColor(const QColor &color, bool preview)
{
using namespace Q3DStudio; // Needed for SCOPED_DOCUMENT_EDITOR macro
- auto rows = selectedRows();
- for (RowTree *row : qAsConst(rows)) {
+ const auto rows = selectedRows();
+ for (RowTree *row : rows) {
row->rowTimeline()->setBarColor(color);
if (!preview) {
Qt3DSDMTimelineItemBinding *timelineItemBinding =
@@ -1210,3 +1245,33 @@ void TimelineWidget::setSelectedTimeBarsColor(const QColor &color, bool preview)
}
}
}
+
+void TimelineWidget::refreshVariants()
+{
+ const auto propertySystem = g_StudioApp.GetCore()->GetDoc()->GetPropertySystem();
+ const auto layers = g_StudioApp.GetCore()->GetDoc()->getLayers();
+ for (auto layer : layers) {
+ if (!m_handlesMap[layer])
+ continue;
+
+ qt3dsdm::SValue sValue;
+ if (propertySystem->GetInstancePropertyValue(layer, m_bridge->GetLayer().m_variants,
+ sValue)) {
+ QString propVal = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(sValue)
+ ->GetData());
+ if (!propVal.isEmpty()) {
+ QStringList tagPairs = propVal.split(QLatin1Char(','));
+ QStringList groups;
+ for (int i = 0; i < tagPairs.size(); ++i) {
+ QString group = tagPairs[i].left(tagPairs[i].indexOf(QLatin1Char(':')));
+ if (!groups.contains(group))
+ groups.append(group);
+ }
+
+ m_handlesMap[layer]->updateVariants(groups);
+ } else {
+ m_handlesMap[layer]->updateVariants({});
+ }
+ }
+ }
+}
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h
index 83193ac2..ac01367a 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.h
@@ -73,6 +73,7 @@ public:
void openBarColorDialog();
void onTimeBarColorChanged(const QColor &color);
void setSelectedTimeBarsColor(const QColor &color, bool preview);
+ void refreshVariants();
void enableDnD(bool b = true);
bool dndActive() const;
bool blockMousePress() const;
@@ -158,6 +159,7 @@ private:
QSize m_preferredSize;
QMultiHash<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMPropertyHandle> m_dirtyProperties;
QHash<int, int> m_moveMap; // key: child handle, value: parent handle
+ QHash<int, QStringList> m_variantsMap; // key: obj handle, value: variant groups
QSet<int> m_actionChanges; // key: object handle
QSet<int> m_subpresentationChanges; // key: object handle
QMultiHash<int, int> m_keyframeChangesMap; // key: object handle, value: property handle
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
index 91d33fdf..c3b2595a 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
@@ -325,10 +325,18 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
painter->drawPixmap(0, 0, hiResIcons ? pixCompAction2x : pixCompAction);
}
+ // variants indicator
+ if (m_variantsGroups.size() > 0) {
+ const auto variantsDef = g_StudioApp.GetCore()->getProjectFile().variantsDef();
+ for (int i = 0; i < m_variantsGroups.size(); ++i) {
+ painter->fillRect(QRect(clipX() + 2 + i * 9, 6, 6, 6),
+ variantsDef[m_variantsGroups[i]].m_color);
+ }
+ }
+
// The following items need to be clipped so that they do not draw overlapping shy etc. buttons
- painter->setClipRect(0, 0, treeWidth() - TimelineConstants::TREE_ICONS_W,
- TimelineConstants::ROW_H);
+ painter->setClipRect(0, 0, clipX(), TimelineConstants::ROW_H);
// expand/collapse arrow
static const QPixmap pixArrow = QPixmap(":/images/arrow.png");
@@ -469,6 +477,12 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
painter->drawPixmap(m_rectType, pixRowType);
}
+void RowTree::updateVariants(const QStringList &groups)
+{
+ m_variantsGroups = groups;
+ update();
+}
+
int RowTree::treeWidth() const
{
return m_scene->treeWidth() - m_scene->getScrollbarOffsets().x();
@@ -512,6 +526,12 @@ void RowTree::setBinding(ITimelineItemBinding *binding)
updateFromBinding();
}
+// x value where label should clip
+int RowTree::clipX() const
+{
+ return treeWidth() - TimelineConstants::TREE_ICONS_W - m_variantsGroups.size() * 9 - 2;
+}
+
ITimelineItemProperty *RowTree::propBinding()
{
return m_PropBinding;
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
index 845cdbcf..4524f345 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
@@ -140,6 +140,7 @@ public:
void updateLabel();
void setRowVisible(bool visible);
void setDnDHover(bool val);
+ void updateVariants(const QStringList &groups);
DnDState getDnDState() const;
ITimelineItemBinding *getBinding() const;
@@ -148,6 +149,8 @@ public:
void updateFilter();
void updateLock(bool state);
void updateSubpresentations(int updateParentsOnlyVal = 0);
+ int clipX() const;
+
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
@@ -194,6 +197,7 @@ private:
QString m_label;
QList<RowTree *> m_childRows;
QList<RowTree *> m_childProps;
+ QStringList m_variantsGroups;
ITimelineItemBinding *m_binding = nullptr;
ITimelineItemProperty *m_PropBinding = nullptr; // for property rows
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
index cfd0ddd8..1029c00a 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.cpp
@@ -146,7 +146,7 @@ QRectF RowTreeLabelItem::boundingRect() const
if (!m_rowTree)
return QGraphicsTextItem::boundingRect();
- double w = m_rowTree->treeWidth() - x() - TimelineConstants::TREE_ICONS_W;
+ double w = m_rowTree->clipX() - x();
// Bounding rect width must be at least 1
w = std::max(w, 1.0);
return QRectF(0, 0, w, TimelineConstants::ROW_H);