diff options
author | Janne Kangas <janne.kangas@qt.io> | 2018-08-22 10:31:47 +0300 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2018-08-30 09:25:35 +0000 |
commit | 0bb5569387e355fd9d21543bb297d073cd88f9dd (patch) | |
tree | 972dbdd19541661be6875f8abb859f214a3b62ab /src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp | |
parent | 56e2804ef706806b210471d84bfaff6c1cc1b8c0 (diff) |
Allow item(s) DnD to component directly from scene
Insert dragged items into a component and remove them from the current
scene. The items are inserted into master slide for the component (with
original start/end time values regardless of the time context change).
Task-ID: QT3DS-706
Change-Id: I33d43900e42dcb407524e12ec7690457cd641081
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp index 70ef517e..73a23354 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp @@ -87,6 +87,16 @@ QVector<RowTree *> RowMover::sourceRows() const return m_sourceRows; } +void RowMover::removeSourceRow(RowTree *row) +{ + m_sourceRows.remove(m_sourceRows.indexOf(row)); +} + +bool RowMover::shouldDeleteAfterMove() const +{ + return m_deleteAfterMove; +} + void RowMover::resetInsertionParent(RowTree *newParent) { if (m_insertionParent) { @@ -109,6 +119,7 @@ bool RowMover::isActive() void RowMover::start(const QVector<RowTree *> &rows) { + m_deleteAfterMove = false; m_sourceRows.clear(); if (!rows.isEmpty()) { // Remove rows that have an ancestor included in the selection or ones that are of @@ -139,6 +150,7 @@ void RowMover::end(bool force) m_active = false; for (auto row : qAsConst(m_sourceRows)) row->setDnDState(RowTree::DnDState::None, RowTree::DnDState::Any, true); + m_sourceRows.clear(); if (m_insertionTarget) @@ -280,8 +292,20 @@ void RowMover::updateTargetRow(const QPointF &scenePos, EStudioObjectType rowTyp } // calc insertion parent RowTree *insertParent = rowInsert1; - for (int i = rowInsert1->depth(); i >= depth; --i) - insertParent = insertParent->parentRow(); + // If we are dragging objects to a component, + // let insertParent be the component itself, not + // the parent for the component and set the source rows + // to be deleted soon (their duplicates will be inserted + // in the component). Do this only if m_active is true + // i.e. user is dragging a row within timeline (not from object/project panel) + // AND drop depth is larger than for the component (user is dropping items _in_ + // the component, not at the same depth as the component itself) + if (insertParent->isComponent() && depth > insertParent->depth() && m_active) { + m_deleteAfterMove = true; + } else { + for (int i = rowInsert1->depth(); i >= depth; --i) + insertParent = insertParent->parentRow(); + } resetInsertionParent(insertParent); |