def execute(self, note): tree_model_proxy = self.facade.retrieveProxy(TreeModel2Proxy.NAME) """:type :TreeModel2Proxy""" tree_view_mediator = self.facade.retrieveMediator( TreeView2Mediator.NAME) """:type :TreeView2Mediator""" parent_node = tree_view_mediator.get_current_node() """:type :TreeNode""" cur_q_index = tree_view_mediator.get_current_q_index() """:type :QModelIndex""" if parent_node is None: parent_node = tree_model_proxy.get_root() child = TreeNode(ActionGroup()) index = 0 tree_model_proxy.get_model().beginInsertRows( cur_q_index, index, index) parent_node.add(child, index) tree_model_proxy.get_model().endInsertRows() return tree_view_mediator.viewComponent.setExpanded(cur_q_index, True) parent_type = parent_node.get_type() is_action = parent_type == UI.ACTION is_group = parent_type == UI.ACTION_GROUP is_expanded = parent_node.get_is_expanded() child = None index = len(parent_node.child_nodes) if is_action and is_expanded: child = TreeNode(StepItem()) """:type :TreeNode""" elif is_action and not is_expanded: child = TreeNode(StepItem()) """:type :TreeNode""" elif is_group and is_expanded: child = TreeNode(Action()) """:type :TreeNode""" elif is_group and not is_expanded: child = TreeNode(Action()) """:type :TreeNode""" if child: tree_model_proxy.get_model().beginInsertRows( cur_q_index, index, index) parent_node.add(child, index) tree_model_proxy.get_model().endInsertRows()
def add(self, parent_node, index): """ :type parent_node: TreeNode :type index: int """ """:type :$class""" if parent_node is None: child = TreeNode(ActionGroup()) self.get_root().add(child, 0) """:type :TreeNode"""
def __init__(self, parent=None): """ :type parent: PySide.QtCore.QObject """ super(TreeModel, self).__init__(parent) self.root_node = TreeNode(ActionRoot()) # TODO: allow dragging more than one item self.drag_q_indexes = None """:type :list of QModelIndex""" self.target_q_index = None """:type :QModelIndex""" self.target_node = None """:type :TreeNode""" self.target_i = None