summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2018-05-31 11:00:40 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2018-05-31 09:12:07 +0000
commita8abfd9a8cb360e7dd350fdc9f64088ae6f32e9e (patch)
tree23d782c94b12f9abe73faa7118282710896208fe
parentb22d495bdbc27712da7329bf60294f25a4d5fcbb (diff)
Fix some DnD insertion issues
Fix some cases where the DnD insertion mark doesn't appear although the insertion position is valid. Task-number: QT3DS-1829 Change-Id: If6ca415158282a625e57cc0ae23a8c33bd518c5a Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp52
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h4
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp10
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h1
4 files changed, 49 insertions, 18 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp
index 7b215686..cdb2ab41 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp
@@ -170,7 +170,24 @@ RowTree *RowMover::getRowAtPos(const QPointF &scenePos)
return nullptr;
}
-bool RowMover::isSourceRowsDescendant(const RowTree *row) const
+bool RowMover::isNextSiblingRow(RowTree *rowMain, RowTree *rowSibling) const
+{
+ // order matters, rowSibling is below rowMain
+ return rowMain->parentRow() == rowSibling->parentRow()
+ && rowSibling->index() - rowMain->index() == 1;
+}
+
+bool RowMover::sourceRowsHasMaster() const
+{
+ for (auto sourceRow : qAsConst(m_sourceRows)) {
+ if (sourceRow->isMaster() && sourceRow->rowType() != OBJTYPE_LAYER)
+ return true;
+ }
+
+ return false;
+}
+
+bool RowMover::isSourceRowsDescendant(RowTree *row) const
{
if (row) {
for (auto sourceRow : qAsConst(m_sourceRows)) {
@@ -209,8 +226,7 @@ void RowMover::updateTargetRow(const QPointF &scenePos, EStudioObjectType rowTyp
}
// calc insertion depth
- bool inAComponent = static_cast<RowTree *>(m_scene->layoutTree()->itemAt(1))
- ->rowType() == OBJTYPE_COMPONENT;
+ bool inAComponent = static_cast<RowTree *>(m_scene->layoutTree()->itemAt(1))->isComponent();
int depth;
int depthMin = 2;
if (rowInsert2)
@@ -219,11 +235,19 @@ void RowMover::updateTargetRow(const QPointF &scenePos, EStudioObjectType rowTyp
depthMin = 3;
int depthMax = rowInsert1->depth();
- if (!rowInsert1->locked() && rowInsert1->isContainer()
- && !m_sourceRows.contains(rowInsert1)) {
+ bool srcHasMaster = sourceRowsHasMaster();
+ if (!rowInsert1->locked() && rowInsert1->isContainer() && !m_sourceRows.contains(rowInsert1)
+ // prevent insertion a master row under a non-master unless under a component root
+ && (!(srcHasMaster && !rowInsert1->isMaster()) || rowInsert1->isComponent())) {
depthMax++; // Container: allow insertion as a child
} else if (rowInsert1->isPropertyOrMaterial() && !rowInsert1->parentRow()->isContainer()) {
depthMax--; // non-container with properties and/or a material
+ } else if (srcHasMaster) {
+ RowTree *row = rowInsert1->parentRow();
+ while (row && !row->isMaster() && !row->isComponent()) {
+ depthMax--;
+ row = row->parentRow();
+ }
}
if (theRowType == OBJTYPE_LAYER) {
@@ -250,16 +274,12 @@ void RowMover::updateTargetRow(const QPointF &scenePos, EStudioObjectType rowTyp
valid = false;
}
- // Don't insert master slide object into non-master slide object
- // or object under itself, or under unacceptable parent
for (auto sourceRow : qAsConst(m_sourceRows)) {
- if ((sourceRow->isMaster() && sourceRow->rowType() != OBJTYPE_LAYER
- && !m_insertionParent->isMaster()
- && insertParent->rowType() != OBJTYPE_COMPONENT)
- || m_insertionParent->isDecendentOf(sourceRow)
- || m_insertionParent == sourceRow
- || !CStudioObjectTypes::AcceptableParent(sourceRow->rowType(),
- m_insertionParent->rowType())) {
+ if (m_insertionParent == sourceRow
+ || m_insertionParent->isDecendentOf(sourceRow)
+ || !CStudioObjectTypes::AcceptableParent(sourceRow->rowType(),
+ m_insertionParent->rowType())) {
+ // prevent insertion under itself, or under unacceptable parent
valid = false;
break;
}
@@ -294,9 +314,9 @@ void RowMover::updateTargetRow(const QPointF &scenePos, EStudioObjectType rowTyp
if (m_sourceRows.size() == 1
&& (m_insertionTarget == m_sourceRows[0]
|| ((m_insertType == Q3DStudio::DocumentEditorInsertType::NextSibling
- && m_sourceRows[0]->index() - m_insertionTarget->index() == 1)
+ && isNextSiblingRow(m_insertionTarget, m_sourceRows[0]))
|| (m_insertType == Q3DStudio::DocumentEditorInsertType::PreviousSibling
- && m_insertionTarget->index() - m_sourceRows[0]->index() == 1)))) {
+ && isNextSiblingRow(m_sourceRows[0], m_insertionTarget))))) {
valid = false;
}
if (valid) {
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h
index 7daba482..b2d3f058 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.h
@@ -59,7 +59,9 @@ private:
void updateState(int depth, double y);
void resetInsertionParent(RowTree *newParent = nullptr);
RowTree *getRowAtPos(const QPointF &scenePos);
- bool isSourceRowsDescendant(const RowTree *row) const;
+ bool isSourceRowsDescendant(RowTree *row) const;
+ bool sourceRowsHasMaster() const;
+ bool isNextSiblingRow(RowTree *r1, RowTree *r2) const;
TimelineGraphicsScene *m_scene = nullptr;
RowTree *m_insertionTarget = nullptr; // insertion target
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
index 85a65b76..d6af8295 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
@@ -897,6 +897,9 @@ RowTree::DnDState RowTree::getDnDState() const
bool RowTree::isContainer() const
{
+ if (isComponent() && m_indexInLayout == 1) // root element inside a component
+ return true;
+
return !m_isProperty
&& m_rowType != OBJTYPE_ALIAS
&& m_rowType != OBJTYPE_MATERIAL
@@ -925,7 +928,12 @@ RowTree *RowTree::getPropertyRow(const QString &type) const
bool RowTree::isPropertyOrMaterial() const
{
- return m_isProperty || rowType() == OBJTYPE_MATERIAL || rowType() == OBJTYPE_IMAGE;
+ return m_isProperty || m_rowType == OBJTYPE_MATERIAL || m_rowType == OBJTYPE_IMAGE;
+}
+
+bool RowTree::isComponent() const
+{
+ return m_rowType == OBJTYPE_COMPONENT;
}
bool RowTree::isMaster() const
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
index 05a0987c..547d8cc1 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
@@ -97,6 +97,7 @@ public:
bool isContainer() const;
bool isProperty() const;
bool isPropertyOrMaterial() const;
+ bool isComponent() const;
bool isMaster() const;
bool hasPropertyChildren() const;
bool empty() const; // has zero child rows (and zero properties)