def registViewMediator(cls, view, mediatorCls):
        mediator = mediatorCls(view)
        #删除旧的mediator和ui
        oldMediator = GameFacade().retrieveMediator(mediatorCls.NAME)
        if oldMediator:
            GameFacade.getInstance().removeMediator(mediatorCls.NAME)
            try:
                oldMediator.viewComponent.destroy()
            except:
                print("旧view component已删除")

        GameFacade().registerMediator(mediator)

        #绑定删除
        oldViewDestroy = None
        if hasattr(view, "destroy"):
            oldViewDestroy = getattr(view, "destroy")

        def onViewDestroy(self, destroyWindow=True, destroySubWindows=True):
            if oldViewDestroy:
                oldViewDestroy(destroyWindow, destroySubWindows)
            if mediatorCls.NAME and mediatorCls.NAME != "" and isinstance(
                    mediatorCls.NAME, str):
                GameFacade.getInstance().removeMediator(mediatorCls.NAME)

        from types import MethodType
        view.destroy = MethodType(onViewDestroy, view)
Beispiel #2
0
 def RemoveFileEvent(self, item):
     print("remove file event", item.text(0))
     item_data = self.getClickFileData(item)
     node_path = item_data.open_path + "/" + item_data.file_name
     if self.treedata and isinstance(self.treedata, Tree):
         treenode = self.treedata.find_child_by_path(node_path)
         open_path = item_data.open_path
         edit_tree_data = add_to_edit_tree_data(open_path=open_path,
                                                tree_node=treenode)
         GameFacade.getInstance().sendNotification(
             EditCommand.remove_file_from_target_dir_cmd, edit_tree_data)
Beispiel #3
0
 def AddFileEvent(self, item):
     print("add file event", item.text(0))
     item_data = self.getClickFileData(item)
     node_path = item_data.open_path + "/" + item_data.file_name
     if self.treedata and isinstance(self.treedata, Tree):
         treenode = self.treedata.find_child_by_path(node_path)
         open_path = item_data.open_path
         if open_path.find(modified_tree_root) > -1:
             open_path = open_path.replace(modified_tree_root, self.dir1)
         edit_tree_data = add_to_edit_tree_data(open_path=open_path,
                                                tree_node=treenode)
         GameFacade.getInstance().sendNotification(
             EditCommand.add_file_to_target_dir_cmd, edit_tree_data)
Beispiel #4
0
 def RemoveFileEvent(self):
     item_data = self.preview_data
     print("remove file event", item_data)
     treenode = TreeNode(item_data.file_name)
     edit_tree_data = add_to_edit_tree_data(open_path=item_data.open_path, tree_node=treenode)
     GameFacade.getInstance().sendNotification(EditCommand.remove_file_from_target_dir_cmd, edit_tree_data)
 def onViewDestroy(self, destroyWindow=True, destroySubWindows=True):
     if oldViewDestroy:
         oldViewDestroy(destroyWindow, destroySubWindows)
     if mediatorCls.NAME and mediatorCls.NAME != "" and isinstance(
             mediatorCls.NAME, str):
         GameFacade.getInstance().removeMediator(mediatorCls.NAME)