Exemplo n.º 1
0
 def init_view(self):
     self.btree_scene = QGraphicsScene()
     self.btree_view = NodeEditorView(self.btree_scene)
     self.btree_view.setAttribute(Qt.WA_DeleteOnClose)
     self.btree_scene.setSceneRect(AREA)
     self.vm = NodeObserverVM(self.model, self.btree_view, self.btree_scene,
                              self)
Exemplo n.º 2
0
class GraphInstanceVM(BTreeInstanceVM):
    @classmethod
    def get_full_path(cls, file_name):
        file_path = os.path.join(config.src_path, file_name)
        return file_path

    @classmethod
    def get_model(cls, full_path):
        if os.path.exists(full_path):
            model = BTreeModel.load_file(full_path)
            return model
        else:
            return None

    def init_view(self):
        self.btree_scene = QGraphicsScene()
        self.btree_view = NodeEditorView(self.btree_scene)
        self.btree_view.setAttribute(Qt.WA_DeleteOnClose)
        self.btree_scene.setSceneRect(AREA)
        self.vm = NodeObserverVM(self.model, self.btree_view, self.btree_scene,
                                 self)

    def close_handler(self, ev):
        self.parent.remove_instance(self)

    def set_dirty(self):
        pass
Exemplo n.º 3
0
class GraphInstanceVM(BTreeInstanceVM):
    @classmethod
    def get_full_path(cls, file_name):
        file_path = os.path.join(config.src_path, file_name)
        return file_path

    @classmethod
    def get_model(cls, full_path):
        if os.path.exists(full_path):
            model = BTreeModel.load_file(full_path)
            return model
        else:
            return None

    def init_view(self):
        self.btree_scene = QGraphicsScene()
        self.btree_view = NodeEditorView(self.btree_scene)
        self.btree_view.setAttribute(Qt.WA_DeleteOnClose)
        self.btree_scene.setSceneRect(AREA)
        self.vm = NodeObserverVM(self.model, self.btree_view, self.btree_scene, self)

    def close_handler(self, ev):
        self.parent.remove_instance(self)

    def set_dirty(self):
        pass
Exemplo n.º 4
0
 def init_view(self):
     self.btree_scene = QGraphicsScene()
     self.btree_view = NodeEditorView(self.btree_scene)
     self.btree_view.setAttribute(Qt.WA_DeleteOnClose)
     self.btree_scene.setSceneRect(AREA)
     self.vm = NodeEditorVM(self.model, self.btree_view, self.btree_scene, self)
Exemplo n.º 5
0
class BTreeInstanceVM(object):
    def __init__(self, model, parent, file_name):
        self.file_name = file_name
        self.file_path = os.path.abspath(file_name)
        self.modified = False
        self.model = model
        self.parent = parent
        self.current_graphics_node = None

        self.init_view()
        self.sub_window = parent.mdi.addSubWindow(self.btree_view)
        self.sub_window.instance = self
        self.sub_window.setAttribute(Qt.WA_DeleteOnClose)
        self.update_title()
        self.btree_view.closeEvent = self.close_handler
        parent.add_instance(self)
        self.sub_window.show()

        self.vm.refresh()

    def init_view(self):
        self.btree_scene = QGraphicsScene()
        self.btree_view = NodeEditorView(self.btree_scene)
        self.btree_view.setAttribute(Qt.WA_DeleteOnClose)
        self.btree_scene.setSceneRect(AREA)
        self.vm = NodeEditorVM(self.model, self.btree_view, self.btree_scene, self)

    def set_dirty(self):
        self.set_modified(True)

    def set_modified(self, b):
        self.modified = b
        self.sub_window.setWindowModified(b)

    def update_title(self):
        self.sub_window.setWindowTitle(self.file_path + "[*]")

    def close_handler(self, ev):

        if self.modified:
            ret = QMessageBox().question(
                self.btree_view, "Confirm",
                "close without saving?",
                QMessageBox.Yes | QMessageBox.No)
            if ret == QMessageBox.No:
                ev.ignore()
                return
        self.parent.remove_instance(self)

    def activation_handler(self):
        #print("%s about to be activated" % self)
        pass

    def deactivation_handler(self):
        #print("%s about to be deactivated" % self)
        self.vm.cancel_selection()

    def focus_on(self, node_id):
        self.parent.mdi.setActiveSubWindow(self.sub_window)
        node = self.model.get_node(node_id)
        if node is None:
            return False
        self.vm.selected_node = node
        self.vm.refresh()
        return True
Exemplo n.º 6
0
class BTreeInstanceVM(object):
    def __init__(self, model, parent, file_name):
        self.file_name = file_name
        self.file_path = os.path.abspath(file_name)
        self.modified = False
        self.model = model
        self.parent = parent
        self.current_graphics_node = None

        self.init_view()
        self.sub_window = parent.mdi.addSubWindow(self.btree_view)
        self.sub_window.instance = self
        self.sub_window.setAttribute(Qt.WA_DeleteOnClose)
        self.update_title()
        self.btree_view.closeEvent = self.close_handler
        parent.add_instance(self)
        self.sub_window.show()

        self.vm.refresh()

    def init_view(self):
        self.btree_scene = QGraphicsScene()
        self.btree_view = NodeEditorView(self.btree_scene)
        self.btree_view.setAttribute(Qt.WA_DeleteOnClose)
        self.btree_scene.setSceneRect(AREA)
        self.vm = NodeEditorVM(self.model, self.btree_view, self.btree_scene,
                               self)

    def set_dirty(self):
        self.set_modified(True)

    def set_modified(self, b):
        self.modified = b
        self.sub_window.setWindowModified(b)

    def update_title(self):
        self.sub_window.setWindowTitle(self.file_path + "[*]")

    def close_handler(self, ev):

        if self.modified:
            ret = QMessageBox().question(self.btree_view, "Confirm",
                                         "close without saving?",
                                         QMessageBox.Yes | QMessageBox.No)
            if ret == QMessageBox.No:
                ev.ignore()
                return
        self.parent.remove_instance(self)

    def activation_handler(self):
        #print("%s about to be activated" % self)
        pass

    def deactivation_handler(self):
        #print("%s about to be deactivated" % self)
        self.vm.cancel_selection()

    def focus_on(self, node_id):
        self.parent.mdi.setActiveSubWindow(self.sub_window)
        node = self.model.get_node(node_id)
        if node is None:
            return False
        self.vm.selected_node = node
        self.vm.refresh()
        return True