diff options
Diffstat (limited to 'src/Authoring/Studio')
11 files changed, 318 insertions, 53 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp index 4a6b368a..ee27114d 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp @@ -28,6 +28,7 @@ #include "ObjectListModel.h" +#include "ClientDataModelBridge.h" #include "Core.h" #include "Doc.h" #include "GraphUtils.h" @@ -87,30 +88,41 @@ QVariant ObjectListModel::data(const QModelIndex &index, int role) const if (!hasIndex(index.row(), index.column(), index.parent())) return {}; + auto handle = handleForIndex(index); + + auto studioSystem = m_core->GetDoc()->GetStudioSystem(); + auto propertySystem = studioSystem->GetPropertySystem(); + qt3dsdm::SValue typeValue; + propertySystem->GetInstancePropertyValue(handle, + studioSystem->GetClientDataModelBridge() + ->GetTypeProperty(), typeValue); + qt3dsdm::DataModelDataType::Value valueType(qt3dsdm::GetValueType(typeValue)); + if (valueType == qt3dsdm::DataModelDataType::None) + return {}; + switch (role) { case NameRole: { - return nameForHandle(handleForIndex(index)); + return nameForHandle(handle); } case PathReferenceRole: { Q3DStudio::CString data(m_objRefHelper->GetObjectReferenceString( - m_baseHandle, CRelativePathTools::EPATHTYPE_RELATIVE, handleForIndex(index))); + m_baseHandle, CRelativePathTools::EPATHTYPE_RELATIVE, handle)); return data.toQString(); } case AbsolutePathRole: { Q3DStudio::CString data(m_objRefHelper->GetObjectReferenceString( - m_baseHandle, CRelativePathTools::EPATHTYPE_GUID, handleForIndex(index))); + m_baseHandle, CRelativePathTools::EPATHTYPE_GUID, handle)); return data.toQString(); } case HandleRole: { return (int)handleForIndex(index); } case IconRole: { - auto info = m_objRefHelper->GetInfo(handleForIndex(index)); + auto info = m_objRefHelper->GetInfo(handle); return resourceImageUrl() + CStudioObjectTypes::GetNormalIconName(info.m_Type); } case TextColorRole: { 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)) @@ -179,9 +191,12 @@ bool ObjectListModel::selectable(const qt3dsdm::Qt3DSDMInstanceHandle &handle) c return !m_excludeTypes.contains(objType); } -qt3dsdm::TInstanceHandleList ObjectListModel::childrenList(const qt3dsdm::Qt3DSDMSlideHandle &slideHandle, const qt3dsdm::Qt3DSDMInstanceHandle &handle) const + +qt3dsdm::TInstanceHandleList ObjectListModel::childrenList(const qt3dsdm::Qt3DSDMSlideHandle &slideHandle, + const qt3dsdm::Qt3DSDMInstanceHandle &handle) const { - auto slideSystem = m_core->GetDoc()->GetStudioSystem()->GetSlideSystem(); + auto studioSystem = m_core->GetDoc()->GetStudioSystem(); + auto slideSystem = studioSystem->GetSlideSystem(); auto currentMaster = slideSystem->GetMasterSlide(slideHandle); qt3dsdm::TInstanceHandleList children; @@ -360,6 +375,34 @@ void FlatObjectListModel::setSourceModel(ObjectListModel *sourceModel) emit dataChanged(mapFromSource(start), mapFromSource(end), roles); }); + connect(sourceModel, &QAbstractListModel::rowsAboutToBeInserted, this, + [this](const QModelIndex &parent, int start, int end) { + auto idx = mapFromSource(parent); + beginInsertRows(idx, idx.row() + start, idx.row() + end); + // TODO implement + }); + connect(sourceModel, &QAbstractListModel::rowsInserted, this, + [this](const QModelIndex &parent, int start, int end) { + endInsertRows(); + + }); + connect(sourceModel, &QAbstractListModel::rowsAboutToBeRemoved, this, + [this](const QModelIndex &parent, int start, int end) { + auto idx = mapFromSource(parent); + beginRemoveRows(idx, idx.row() + start, idx.row() + end); + // TODO implement + }); + connect(sourceModel, &QAbstractListModel::rowsRemoved, this, + [this](const QModelIndex &parent, int start, int end) { + endRemoveRows(); + + }); + connect(sourceModel, &QAbstractListModel::modelReset, this, + [this]() { + beginResetModel(); + m_sourceInfo = collectSourceIndexes({}, 0); + endResetModel(); + }); m_sourceModel = sourceModel; m_sourceInfo = collectSourceIndexes({}, 0); endResetModel(); diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h index b4e50de1..840c089c 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h @@ -74,8 +74,8 @@ public: protected: qt3dsdm::Qt3DSDMInstanceHandle handleForIndex(const QModelIndex &index) const; - qt3dsdm::TInstanceHandleList childrenList(const qt3dsdm::Qt3DSDMSlideHandle &slideHandle, - const qt3dsdm::Qt3DSDMInstanceHandle &handle) const; + virtual qt3dsdm::TInstanceHandleList childrenList(const qt3dsdm::Qt3DSDMSlideHandle &slideHandle, + const qt3dsdm::Qt3DSDMInstanceHandle &handle) const; QString nameForHandle(const qt3dsdm::Qt3DSDMInstanceHandle &handle) const; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h index d251f530..bac7136c 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h @@ -127,6 +127,11 @@ public: // Properties virtual void RemoveProperty(ITimelineItemProperty *inProperty) = 0; virtual void LoadProperties() = 0; + + void setCreateUIRow(bool create) { m_createUIRow = create; } + +protected: + bool m_createUIRow = true; // control creation of UI row for old style timeline UI }; //============================================================================= diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp index c15e4ed0..11fa0504 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp @@ -873,12 +873,12 @@ Qt3DSDMTimelineItemBinding::GetOrCreatePropertyBinding(Qt3DSDMPropertyHandle inP * @param inAppend true to skip the check to find where to insert. ( true if this is a * loading/initializing step, where the call is already done in order ) */ -void Qt3DSDMTimelineItemBinding::AddPropertyRow(Qt3DSDMPropertyHandle inPropertyHandle, - bool inAppend /*= false */) +CPropertyRow *Qt3DSDMTimelineItemBinding::AddPropertyRow(Qt3DSDMPropertyHandle inPropertyHandle, + bool inAppend /*= false */) { ITimelineItemProperty *theTimelineProperty = GetPropertyBinding(inPropertyHandle); if (theTimelineProperty && theTimelineProperty->GetRow()) // if created, bail - return; + return {}; if (!theTimelineProperty) theTimelineProperty = GetOrCreatePropertyBinding(inPropertyHandle); @@ -909,12 +909,22 @@ void Qt3DSDMTimelineItemBinding::AddPropertyRow(Qt3DSDMPropertyHandle inProperty } } } + + CPropertyRow *propertyRow = nullptr; // Create a new property row - m_TransMgr->CreateNewPropertyRow(theTimelineProperty, m_Row, - theNextProperty ? theNextProperty->GetRow() : nullptr); + if (m_createUIRow) { + propertyRow = m_TransMgr->CreateNewPropertyRow(theTimelineProperty, m_Row, + theNextProperty ? theNextProperty->GetRow() : nullptr); + } else { + propertyRow = new CPropertyRow(theTimelineProperty, m_Row); + m_Row->AddPropertyRow(propertyRow, theNextProperty ? theNextProperty->GetRow() : nullptr); + theTimelineProperty->Bind(propertyRow); + } // Update keyframes AddKeyframes(theTimelineProperty); + + return propertyRow; } void Qt3DSDMTimelineItemBinding::RemovePropertyRow(Qt3DSDMPropertyHandle inPropertyHandle) diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h index 2be935bc..81e0df0b 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h @@ -179,8 +179,8 @@ public: long inInstanceCount) override; void RefreshStateRow(bool inRefreshChildren = false); - virtual void AddPropertyRow(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, - bool inAppend = false); + virtual CPropertyRow* AddPropertyRow(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, + bool inAppend = false); virtual void RemovePropertyRow(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); virtual void RefreshPropertyKeyframe(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, qt3dsdm::Qt3DSDMKeyframeHandle, @@ -205,10 +205,11 @@ public: // Bridge between asset & DataModel. Ideally we should be fully DataModel virtual qt3dsdm::Qt3DSDMInstanceHandle GetInstance() const; + + ITimelineItemProperty *GetOrCreatePropertyBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); + ITimelineItemProperty *GetPropertyBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); protected: virtual ITimelineTimebar *CreateTimelineTimebar(); - ITimelineItemProperty *GetPropertyBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); - ITimelineItemProperty *GetOrCreatePropertyBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); void RemoveAllPropertyBindings(); void AddKeyframes(ITimelineItemProperty *inPropertyBinding); bool diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp index 1107bf99..bc10a373 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp @@ -136,15 +136,15 @@ ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHa * Create a new CPropertyRow that maps to this ITimelineItemProperty. * The caller is assumed to have ensured that this is only called once per property binding. */ -void CTimelineTranslationManager::CreateNewPropertyRow( +CPropertyRow *CTimelineTranslationManager::CreateNewPropertyRow( ITimelineItemProperty *inTimelineItemPropertyBinding, CBaseStateRow *inParentRow, CPropertyRow *inNextRow) { if (!inParentRow || !inTimelineItemPropertyBinding) - return; + return {}; - TimelineUIFactory::instance()->createPropertyRow(inParentRow, inNextRow, - inTimelineItemPropertyBinding); + return TimelineUIFactory::instance()->createPropertyRow(inParentRow, inNextRow, + inTimelineItemPropertyBinding); } //============================================================================== diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h index 663cbc1f..14e34f4b 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.h @@ -94,7 +94,7 @@ public: public: ITimelineItemBinding *GetOrCreate(qt3dsdm::Qt3DSDMInstanceHandle inInstance); - void CreateNewPropertyRow(ITimelineItemProperty *inTimelineItemPropertyBinding, + CPropertyRow *CreateNewPropertyRow(ITimelineItemProperty *inTimelineItemPropertyBinding, CBaseStateRow *inParentRow, CPropertyRow *inNextRow); void RemovePropertyRow(ITimelineItemProperty *inTimelineItemPropertyBinding); diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp index 2dce96f3..086b7f48 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp @@ -27,7 +27,10 @@ ****************************************************************************/ #include "TimelineObjectModel.h" +#include "ClientDataModelBridge.h" #include "ColorControl.h" +#include "Core.h" +#include "Doc.h" #include "IKeyframe.h" #include "SlideRow.h" #include "StateRow.h" @@ -35,11 +38,17 @@ #include "Bindings/ITimelineItemBinding.h" #include "Bindings/ITimelineItem.h" #include "Bindings/ITimelineTimebar.h" - +#include "Bindings/Qt3DSDMTimelineItemBinding.h" +#include "Qt3DSDMAnimation.h" +#include "Qt3DSDMDataCore.h" +#include "Qt3DSDMHandles.h" +#include "Qt3DSDMStudioSystem.h" #include "StudioUtils.h" +#include "StudioPreferences.h" #include <QDebug> + TimelineObjectModel::~TimelineObjectModel() { m_rows.clear(); @@ -64,8 +73,17 @@ QVariant TimelineObjectModel::data(const QModelIndex &index, int role) const return {}; auto timelineRow = const_cast<TimelineObjectModel*>(this)->timelineRowForIndex(index); - auto timelineItemBinding = timelineRow->GetTimelineItemBinding(); + if (!timelineRow) { + return {}; + } + + auto propertyRow = dynamic_cast<CPropertyRow *>(timelineRow.data()); + if (propertyRow) { + return dataForProperty(propertyRow, index, role); + } + + auto timelineItemBinding = timelineRow->GetTimelineItemBinding(); switch (role) { case TimelineRowRole: { return QVariant::fromValue(timelineRow.data()); @@ -102,31 +120,100 @@ QVariant TimelineObjectModel::data(const QModelIndex &index, int role) const } case KeyframesRole: { QVariantList keyframes; - const auto timeRatio = timelineRow->GetTimeRatio(); long keyframeCount = timelineItemBinding->GetKeyframeCount(); for (long i = 0; i < keyframeCount; ++i) { auto key = timelineItemBinding->GetKeyframeByIndex(i); + appendKey(keyframes, key, timeRatio); + } + + + return keyframes; + } + + default: ; + } + + return ObjectListModel::data(index, role); +} - KeyframeInfo keyInfo; - keyInfo.m_time = key->GetTime(); - keyInfo.m_selected = key->IsSelected(); - keyInfo.m_dynamic = key->IsDynamic(); - keyInfo.m_position = ::TimeToPos(keyInfo.m_time, timeRatio); +QVariant TimelineObjectModel::dataForProperty(CPropertyRow *propertyRow, const QModelIndex &index, int role) const +{ + auto timelineItemProperty = propertyRow->GetProperty(); + if (!timelineItemProperty) + return {}; + + switch (role) { + case TimelineRowRole: { + return QVariant::fromValue(propertyRow); + } + case SelectedRole: { + return propertyRow->IsSelected(); + } + case ItemColorRole: { + return propertyRow->GetTimebarBackgroundColor().getQColor().name(); + } + case SelectedColorRole: { + return propertyRow->GetTimebarHighlightBackgroundColor().getQColor().name(); + } + case TimeInfoRole: { + return data(index.parent(), role); + } + case KeyframesRole: { + QVariantList keyframes; + const auto timeRatio = propertyRow->GetTimeRatio(); - keyframes.append(QVariant::fromValue(keyInfo)); + auto timelineItemProperty = propertyRow->GetProperty(); + long keyframeCount = timelineItemProperty->GetKeyframeCount(); + for (long i = 0; i < keyframeCount; ++i) { + auto key = timelineItemProperty->GetKeyframeByIndex(i); + appendKey(keyframes, key, timeRatio); } return keyframes; } + // roles from ObjectListModel + case NameRole: { + return timelineItemProperty->GetName().toQString(); + } + + case IconRole: { + return resourceImageUrl() + "Objects-Property-Normal.png"; + } + case TextColorRole: { + auto textColor = CStudioPreferences::GetNormalColor(); + if (timelineItemProperty->IsMaster()) + textColor = CStudioPreferences::GetMasterColor(); + + return textColor.getQColor().name(); + } + + case PathReferenceRole: + case AbsolutePathRole: + return {}; + default: ; } return ObjectListModel::data(index, role); } +QModelIndex TimelineObjectModel::parent(const QModelIndex &index) const +{ + const auto handle = handleForIndex(index); + auto it = m_properties.constBegin(); + while (it != m_properties.constEnd()) { + if (it->contains(handle)) { + return indexForHandle(it.key()); + } + ++it; + } + + return ObjectListModel::parent(index); +} + void TimelineObjectModel::setTimelineItemBinding(ITimelineItemBinding *inTimelineItem) { Q_ASSERT(inTimelineItem); @@ -147,30 +234,42 @@ QSharedPointer<CTimelineRow> TimelineObjectModel::timelineRowForIndex(const QMod const auto handle = handleForIndex(index).GetHandleValue(); if (!m_rows.contains(handle)) { + int propertyCount = m_properties.value(handleForIndex(index.parent()), {}).count(); + auto parentRow = dynamic_cast<CBaseStateRow*>(timelineRowForIndex(index.parent()).data()); Q_ASSERT(parentRow); - // TODO: - // the second "true" argument assumes it is loaded, avoids calling LoadChildren - // this is temporary here, as long as the old timeline code is still used - auto stateRow = new CStateRow(parentRow, true); auto parentBinding = parentRow->GetTimelineItemBinding(); - auto itemBinding = parentBinding->GetChild(index.row()); - stateRow->Initialize(itemBinding); - parentRow->AddStateRow(stateRow, nullptr); - itemBinding->SetParent(parentBinding); // KDAB_TODO do we really need it? - m_rows[handle].reset(stateRow); - - connect(stateRow, &CTimelineRow::selectedChanged, this, [this, index] { - emit dataChanged(index, index, {SelectedRole}); - }); - - connect(stateRow, &CTimelineRow::timeRatioChanged, this, [this, index] { - emit dataChanged(index, index, {TimeInfoRole}); - }); - - connect(stateRow, &CTimelineRow::dirtyChanged, this, [this, index] { - emit dataChanged(index, index, {}); - }); + + if (propertyCount > 0 && index.row() < propertyCount && + dynamic_cast<Qt3DSDMTimelineItemBinding *>(parentBinding)) { + auto binding = static_cast<Qt3DSDMTimelineItemBinding *>(parentBinding); + + auto propertyRow = binding->AddPropertyRow(handle); + + m_rows[handle].reset(propertyRow); + } else { + // TODO: + // the second "true" argument assumes it is loaded, avoids calling LoadChildren + // this is temporary here, as long as the old timeline code is still used + auto stateRow = new CStateRow(parentRow, true); + auto itemBinding = parentBinding->GetChild(index.row() - propertyCount); + itemBinding->setCreateUIRow(false); + stateRow->Initialize(itemBinding); + itemBinding->SetParent(parentBinding); // KDAB_TODO do we really need it? + m_rows[handle].reset(stateRow); + + connect(stateRow, &CTimelineRow::selectedChanged, this, [this, index] { + emit dataChanged(index, index, {SelectedRole}); + }); + + connect(stateRow, &CTimelineRow::timeRatioChanged, this, [this, index] { + emit dataChanged(index, index, {TimeInfoRole}); + }); + + connect(stateRow, &CTimelineRow::dirtyChanged, this, [this, index] { + emit dataChanged(index, index, {}); + }); + } } return m_rows[handle]; @@ -179,3 +278,66 @@ QSharedPointer<CTimelineRow> TimelineObjectModel::timelineRowForIndex(const QMod Q_ASSERT(0); return nullptr; } + +void TimelineObjectModel::addProperty(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property) +{ + auto parentIndex = indexForHandle(parentInstance); + auto propertyCount = m_properties.value(parentInstance.GetHandleValue(), {}).count(); + + // Now we rely on rowCount calling childrenList, thus getting the new rows automatically + beginInsertRows(parentIndex, propertyCount, propertyCount); + endInsertRows(); +} + +void TimelineObjectModel::removeProperty(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property) +{ + auto parentIndex = indexForHandle(parentInstance); + auto properties = m_properties.value(parentInstance.GetHandleValue(), {}); + auto propertyIndex = properties.indexOf(property); + + // Now we rely on rowCount calling childrenList, thus getting the new rows automatically + beginRemoveRows(parentIndex, propertyIndex, propertyIndex); + endRemoveRows(); +} + +qt3dsdm::TInstanceHandleList TimelineObjectModel::childrenList(const qt3dsdm::Qt3DSDMSlideHandle &slideHandle, const qt3dsdm::Qt3DSDMInstanceHandle &handle) const +{ + auto studioSystem = m_core->GetDoc()->GetStudioSystem(); + auto propertySystem = studioSystem->GetPropertySystem(); + qt3dsdm::SValue typeValue; + propertySystem->GetInstancePropertyValue(handle, studioSystem->GetClientDataModelBridge() + ->GetTypeProperty(), typeValue); + qt3dsdm::DataModelDataType::Value valueType(qt3dsdm::GetValueType(typeValue)); + if (valueType == qt3dsdm::DataModelDataType::None) + return {}; + + auto children = ObjectListModel::childrenList(slideHandle, handle); + + qt3dsdm::TPropertyHandleList properties; + propertySystem->GetAggregateInstanceProperties(handle, properties); + auto it = children.begin(); + QVector<qt3dsdm::Qt3DSDMInstanceHandle> animatedProperties; + for (const auto &propertyHandle: properties) { + if (studioSystem->GetAnimationSystem()->IsPropertyAnimated( + handle, propertyHandle)) { + animatedProperties.append(propertyHandle); + it = children.insert(it, propertyHandle); + } + } + m_properties[handle] = animatedProperties; + + return children; +} + +void TimelineObjectModel::appendKey(QVariantList &keyframes, IKeyframe *key, double timeRatio) const +{ + KeyframeInfo keyInfo; + keyInfo.m_time = key->GetTime(); + keyInfo.m_selected = key->IsSelected(); + keyInfo.m_dynamic = key->IsDynamic(); + keyInfo.m_position = ::TimeToPos(keyInfo.m_time, timeRatio); + + keyframes.append(QVariant::fromValue(keyInfo)); +} diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h index 8114c390..351c5b77 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h @@ -35,6 +35,8 @@ #include <QSharedPointer> class CSlideRow; +class CPropertyRow; +class IKeyframe; class ITimelineItemBinding; struct TimebarTimeInfo { @@ -86,16 +88,32 @@ public: }; QHash<int, QByteArray> roleNames() const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QVariant dataForProperty(CPropertyRow *propertyRow, const QModelIndex &index, + int role = Qt::DisplayRole) const; + QModelIndex parent(const QModelIndex &index) const override; void setTimelineItemBinding(ITimelineItemBinding *inTimelineItem); QSharedPointer<CTimelineRow> timelineRowForIndex(const QModelIndex &index); + void addProperty(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property); + void removeProperty(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property); + +protected: + qt3dsdm::TInstanceHandleList childrenList(const qt3dsdm::Qt3DSDMSlideHandle &slideHandle, + const qt3dsdm::Qt3DSDMInstanceHandle &handle) const override; + + + private: + void appendKey(QVariantList &keyframes, IKeyframe *key, double timeRatio) const; QSharedPointer<CSlideRow> m_slideRow; ITimelineItemBinding *m_timelineItemBinding = nullptr; QHash<int, QSharedPointer<CTimelineRow> > m_rows; + mutable QHash<int, QVector<qt3dsdm::Qt3DSDMInstanceHandle> > m_properties; }; Q_DECLARE_METATYPE(CTimelineRow *); diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp index f076a724..10707e21 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineView.cpp @@ -83,6 +83,13 @@ void TimelineView::OnNewPresentation() CDispatch *theDispatch = g_StudioApp.GetCore()->GetDispatch(); m_Connections.push_back(theDispatch->ConnectSelectionChange( std::bind(&TimelineView::OnSelectionChange, this, std::placeholders::_1))); + + m_Connections.push_back(theSignalProvider->ConnectAnimationCreated( + std::bind(&TimelineView::OnAnimationCreated, this, + std::placeholders::_2, std::placeholders::_3))); + m_Connections.push_back(theSignalProvider->ConnectAnimationDeleted( + std::bind(&TimelineView::OnAnimationDeleted, this, + std::placeholders::_2, std::placeholders::_3))); } void TimelineView::OnClosingPresentation() @@ -112,6 +119,20 @@ void TimelineView::select(int index, Qt::KeyboardModifiers modifiers) setSelection(index); } +void TimelineView::OnAnimationCreated(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property) +{ + if (m_objectListModel) + m_objectListModel->addProperty(parentInstance, property); +} + +void TimelineView::OnAnimationDeleted(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property) +{ + if (m_objectListModel) + m_objectListModel->removeProperty(parentInstance, property); +} + void TimelineView::OnActiveSlide(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inIndex, const qt3dsdm::Qt3DSDMSlideHandle &inSlide) { if (m_activeSlide == inSlide) diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineView.h b/src/Authoring/Studio/Palettes/Timeline/TimelineView.h index 730fcfad..1981f649 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineView.h +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineView.h @@ -64,6 +64,7 @@ public: Q_INVOKABLE void select(int index, Qt::KeyboardModifiers modifiers); + Q_SIGNALS: void objectModelChanged(); void selectionChanged(); @@ -72,6 +73,10 @@ protected: // DataModel callbacks virtual void OnActiveSlide(const qt3dsdm::Qt3DSDMSlideHandle &inMaster, int inIndex, const qt3dsdm::Qt3DSDMSlideHandle &inSlide); + void OnAnimationDeleted(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property); + void OnAnimationCreated(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, + qt3dsdm::Qt3DSDMPropertyHandle property); private: void initialize(); |