From eb6ece64222561bf9a0eaab2e5b56d268b6e0380 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 27 Apr 2021 11:54:17 +0200 Subject: [PATCH] avoid adding children to TaskItem --- .../project_manager/project_manager/model.py | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/openpype/tools/project_manager/project_manager/model.py b/openpype/tools/project_manager/project_manager/model.py index 5e497b755d..88ae8f841b 100644 --- a/openpype/tools/project_manager/project_manager/model.py +++ b/openpype/tools/project_manager/project_manager/model.py @@ -319,14 +319,30 @@ class HierarchyModel(QtCore.QAbstractItemModel): # Move under parent before or after if before is None elif direction == 1: - if src_parent.rowCount() == 1: + src_row_count = src_parent.rowCount() + if src_row_count == 1: return - if item.row() == 0: - parent_row = item.row() + 1 - else: - parent_row = item.row() - 1 - dst_parent = src_parent.child(parent_row) + item_row = item.row() + dst_parent = None + for row in reversed(range(item_row)): + if row == item_row: + continue + _item = src_parent.child(row) + if not isinstance(_item, TaskItem): + dst_parent = _item + break + + if dst_parent is None: + for row in range(item_row + 1, src_row_count + 2): + _item = src_parent.child(row) + if not isinstance(_item, TaskItem): + dst_parent = _item + break + + if dst_parent is None: + return + dst_row = dst_parent.rowCount() if src_parent is dst_parent: @@ -655,3 +671,6 @@ class TaskItem(BaseItem): if cls._name_icon is None: cls._name_icon = qtawesome.icon("fa.file-o", color="#333333") return cls._name_icon + + def add_child(self, item, row=None): + raise AssertionError("BUG: Can't add children to Task")