diff options
author | Andras Mantia <andras@kdab.com> | 2017-12-21 12:10:07 +0200 |
---|---|---|
committer | Andras Mantia <andras@kdab.com> | 2018-01-03 09:51:52 +0000 |
commit | b264f1057c813d35f559ec2e48fb8051a20c00e7 (patch) | |
tree | dd15cc5cc7622e364f12560ca9779bb64adfcc09 /src/Authoring/Studio/Palettes/Timeline | |
parent | e7f657ce720b1aa3a816bc295311cfdcd0129878 (diff) |
Use non-shared pointers
These are also QObject instances and they delete themselves when the parent (main)
row is deleted.
Change-Id: Ib51cd3ca8129d27f55b1f109f28cee746d25dd28
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Timeline')
-rw-r--r-- | src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp | 20 | ||||
-rw-r--r-- | src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h | 4 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp index f19898f0..06bcd9de 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.cpp @@ -78,7 +78,7 @@ QVariant TimelineObjectModel::data(const QModelIndex &index, int role) const return {}; } - auto propertyRow = dynamic_cast<CPropertyRow *>(timelineRow.data()); + auto propertyRow = dynamic_cast<CPropertyRow *>(timelineRow); if (propertyRow) { return dataForProperty(propertyRow, index, role); } @@ -86,7 +86,7 @@ QVariant TimelineObjectModel::data(const QModelIndex &index, int role) const auto timelineItemBinding = timelineRow->GetTimelineItemBinding(); switch (role) { case TimelineRowRole: { - return QVariant::fromValue(timelineRow.data()); + return QVariant::fromValue(timelineRow); } case SelectedRole: { return timelineRow->IsSelected(); @@ -220,23 +220,23 @@ void TimelineObjectModel::setTimelineItemBinding(ITimelineItemBinding *inTimelin m_timelineItemBinding = inTimelineItem; } -QSharedPointer<CTimelineRow> TimelineObjectModel::timelineRowForIndex(const QModelIndex &index) +CTimelineRow* TimelineObjectModel::timelineRowForIndex(const QModelIndex &index) { if (!index.parent().isValid()) { if (!m_slideRow) { m_slideRow.reset(new CSlideRow(nullptr)); Q_ASSERT(m_timelineItemBinding); m_slideRow->Initialize(m_timelineItemBinding); - m_rows[m_baseHandle.GetHandleValue()] = m_slideRow; + m_rows[m_baseHandle.GetHandleValue()] = m_slideRow.data(); } - return m_slideRow; + return m_slideRow.data(); } else { 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()); + auto parentRow = dynamic_cast<CBaseStateRow*>(timelineRowForIndex(index.parent())); Q_ASSERT(parentRow); auto parentBinding = parentRow->GetTimelineItemBinding(); @@ -250,7 +250,9 @@ QSharedPointer<CTimelineRow> TimelineObjectModel::timelineRowForIndex(const QMod emit dataChanged(index, index, {TimeInfoRole, KeyframesRole}); }); - m_rows[handle].reset(propertyRow); + m_rows[handle] = propertyRow; + + return propertyRow; } else { // TODO: // the second "true" argument assumes it is loaded, avoids calling LoadChildren @@ -260,7 +262,7 @@ QSharedPointer<CTimelineRow> TimelineObjectModel::timelineRowForIndex(const QMod itemBinding->setCreateUIRow(false); stateRow->Initialize(itemBinding); itemBinding->SetParent(parentBinding); // KDAB_TODO do we really need it? - m_rows[handle].reset(stateRow); + m_rows[handle] = stateRow; connect(stateRow, &CTimelineRow::selectedChanged, this, [this, index] { emit dataChanged(index, index, {SelectedRole}); @@ -273,6 +275,8 @@ QSharedPointer<CTimelineRow> TimelineObjectModel::timelineRowForIndex(const QMod connect(stateRow, &CTimelineRow::dirtyChanged, this, [this, index] { emit dataChanged(index, index, {}); }); + + return stateRow; } } diff --git a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h index 351c5b77..32c5d698 100644 --- a/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h +++ b/src/Authoring/Studio/Palettes/Timeline/TimelineObjectModel.h @@ -94,7 +94,7 @@ public: void setTimelineItemBinding(ITimelineItemBinding *inTimelineItem); - QSharedPointer<CTimelineRow> timelineRowForIndex(const QModelIndex &index); + CTimelineRow* timelineRowForIndex(const QModelIndex &index); void addProperty(qt3dsdm::Qt3DSDMInstanceHandle parentInstance, qt3dsdm::Qt3DSDMPropertyHandle property); @@ -112,7 +112,7 @@ private: QSharedPointer<CSlideRow> m_slideRow; ITimelineItemBinding *m_timelineItemBinding = nullptr; - QHash<int, QSharedPointer<CTimelineRow> > m_rows; + QHash<int, CTimelineRow* > m_rows; mutable QHash<int, QVector<qt3dsdm::Qt3DSDMInstanceHandle> > m_properties; }; |