コード例 #1
0
class QVersionTreeView(QInteractiveGraphicsView):
    """
    QVersionTreeView inherits from QInteractiveGraphicsView that will
    handle drawing of versions layout output from Dotty
    
    """

    def __init__(self, parent=None):
        """ QVersionTreeView(parent: QWidget) -> QVersionTreeView
        Initialize the graphics view and its properties
        
        """
        QInteractiveGraphicsView.__init__(self, parent)
        self.setWindowTitle('Version Tree')
        self.setScene(QVersionTreeScene(self))
        self.versionProp = QVersionPropOverlay(self, self.viewport())
        self.versionProp.hide()

    def selectModules(self):
        """ selectModules() -> None
        Overrides parent class to disable text items if you click on background

        """
        if self.canSelectRectangle:
            br = self.selectionBox.sceneBoundingRect()
        else:
            br = QtCore.QRectF(self.startSelectingPos,
                              self.startSelectingPos)
        items = self.scene().items(br)
        if len(items)==0 or items==[self.selectionBox]:
            for item in self.scene().selectedItems():
                if type(item) == gui.version_view.QGraphicsVersionItem:
                    item.text.clearFocus()
                    item.text.hide()
        qt_super(QVersionTreeView, self).selectModules()
コード例 #2
0
ファイル: version_view.py プロジェクト: painter1/vistrails
 def __init__(self, parent=None):
     """ QVersionTreeView(parent: QWidget) -> QVersionTreeView
     Initialize the graphics view and its properties
     
     """
     QInteractiveGraphicsView.__init__(self, parent)
     BaseView.__init__(self)
     self.controller = None
     self.set_title('Version Tree')
     self.setScene(QVersionTreeScene(self))
     self.versionProp = QVersionPropOverlay(self, self.viewport())
     self.versionProp.hide()
コード例 #3
0
 def __init__(self, parent=None):
     """ QVersionTreeView(parent: QWidget) -> QVersionTreeView
     Initialize the graphics view and its properties
     
     """
     QInteractiveGraphicsView.__init__(self, parent)
     self.setWindowTitle('Version Tree')
     self.setScene(QVersionTreeScene(self))
     self.versionProp = QVersionPropOverlay(self, self.viewport())
     self.versionProp.hide()
コード例 #4
0
class QVersionTreeView(QInteractiveGraphicsView, BaseView):
    """
    QVersionTreeView inherits from QInteractiveGraphicsView that will
    handle drawing of versions layout output from Dotty
    
    """

    def __init__(self, parent=None):
        """ QVersionTreeView(parent: QWidget) -> QVersionTreeView
        Initialize the graphics view and its properties
        
        """
        QInteractiveGraphicsView.__init__(self, parent)
        BaseView.__init__(self)
        self.controller = None
        self.set_title('Version Tree')
        self.setScene(QVersionTreeScene(self))
        self.versionProp = QVersionPropOverlay(self, self.viewport())
        self.versionProp.hide()

    def set_default_layout(self):
        from gui.collection.workspace import QWorkspaceWindow
        from gui.version_prop import QVersionProp
        self.set_palette_layout(
            {QtCore.Qt.LeftDockWidgetArea: QWorkspaceWindow,
             QtCore.Qt.RightDockWidgetArea: QVersionProp,
             })
            
    def set_action_links(self):
        self.action_links = \
            {
             'publishWeb' : ('version_changed', self.check_publish_db),
             'publishPaper': ('version_changed', self.check_publish),
             'redo': ('version_changed', self.can_redo),
             'undo': ('version_changed', self.can_undo),
             'execute': ('pipeline_changed', self.can_execute)
            }
        
    def set_action_defaults(self):
        self.action_defaults['execute'] = \
            [('setEnabled', True, self.set_action_execute_default)]

    def set_action_execute_default(self):
        if self.controller:
            if self.controller.current_pipeline:
                return len(self.controller.current_pipeline.modules) > 0
        return False
    
    def check_publish_db(self, versionId):
        loc = self.controller.locator
        result = False
        if hasattr(loc,'host'):
            result = True    
        return result and self.check_publish(versionId)
    
    def check_publish(self, versionId):
        return versionId > 0 

    def can_redo(self, versionId):
        return self.controller and self.controller.can_redo()

    def can_undo(self, versionId):
        return self.controller and self.controller.can_undo()
    
    def can_execute(self, pipeline):
        return pipeline is not None and len(pipeline.modules) > 0
    
    def execute(self):
        res = self.controller.execute_current_workflow()
        from gui.vistrails_window import _app
        if len(res[0][0].errors) > 0:
            _app.qactions['pipeline'].trigger()
        _app.notify('execution_updated')
        
    def publish_to_web(self):
        from gui.publishing import QVersionEmbed
        panel = QVersionEmbed.instance()
        panel.switchType('Wiki')
        panel.set_visible(True)
        
    def publish_to_paper(self):
        from gui.publishing import QVersionEmbed
        panel = QVersionEmbed.instance()
        panel.switchType('Latex')
        panel.set_visible(True)
        
    def selectModules(self):
        """ selectModules() -> None
        Overrides parent class to disable text items if you click on background

        """
        if self.canSelectRectangle:
            br = self.selectionBox.sceneBoundingRect()
        else:
            br = QtCore.QRectF(self.startSelectingPos,
                               self.startSelectingPos)
        items = self.scene().items(br)
        if len(items)==0 or items==[self.selectionBox]:
            for item in self.scene().selectedItems():
                if type(item) == gui.version_view.QGraphicsVersionItem:
                    item.text.clearFocus()
        qt_super(QVersionTreeView, self).selectModules()
                
    def set_title(self, title):
        BaseView.set_title(self, title)
        self.setWindowTitle(title)

    def set_controller(self, controller):
        oldController = self.controller
        if oldController != controller:
            if oldController != None:
                self.disconnect(oldController,
                                QtCore.SIGNAL('vistrailChanged()'),
                                self.vistrailChanged)
                self.disconnect(oldController,
                                QtCore.SIGNAL('invalidateSingleNodeInVersionTree'),
                                self.single_node_changed)
                self.disconnect(oldController,
                                QtCore.SIGNAL('notesChanged()'),
                                self.notesChanged)
            self.controller = controller
            self.scene().controller = controller
            self.connect(controller,
                         QtCore.SIGNAL('vistrailChanged()'),
                         self.vistrailChanged)
            self.connect(controller,
                         QtCore.SIGNAL('invalidateSingleNodeInVersionTree'),
                         self.single_node_changed)
            self.connect(controller,
                         QtCore.SIGNAL("notesChanged()"),
                         self.notesChanged)
            if controller:
                self.versionProp.updateController(controller)
                self.scene().setupScene(controller)
                # self.vistrailChanged()
                # self.versionProp.updateController(controller)
                # self.versionView.versionProp.updateController(controller)

    def vistrailChanged(self):
        """ vistrailChanged() -> None
        An action was performed on the current vistrail
        
        """
        from gui.vistrails_window import _app
        select_node = True
        if _app._previous_view and _app._previous_view.window() != self.window():
            select_node = False
        self.scene().setupScene(self.controller, select_node)
        if self.controller and self.controller.reset_version_view:
            self.scene().fitToAllViews()
        if self.controller:
            # self.versionProp.updateVersion(self.controller.current_version)
            self.versionProp.updateVersion(self.controller.current_version)
        self.emit(QtCore.SIGNAL("vistrailChanged()"))

    def single_node_changed(self, old_version, new_version):
        """ single_node_changed(old_version, new_version)
        Handle single node change on version tree by not recomputing
        entire scene.

        """
        self.scene().update_scene_single_node_change(self.controller,
                                                     old_version,
                                                     new_version)
        if self.controller and self.controller.reset_version_view:
            self.scene().fitToAllViews()
        if self.controller:
            # self.versionProp.updateVersion(self.controller.current_version)
            self.versionProp.updateVersion(self.controller.current_version)
        self.emit(QtCore.SIGNAL("vistrailChanged()"))

    def notesChanged(self):
        """ notesChanged() -> None
        The notes for the current vistrail version changed

        """
        if self.controller:
            self.versionProp.updateVersion(self.controller.current_version)

    def select_current_version(self):
        self.scene().setupScene(self.controller)
コード例 #5
0
ファイル: version_view.py プロジェクト: painter1/vistrails
class QVersionTreeView(QInteractiveGraphicsView, BaseView):
    """
    QVersionTreeView inherits from QInteractiveGraphicsView that will
    handle drawing of versions layout output from Dotty
    
    """
    def __init__(self, parent=None):
        """ QVersionTreeView(parent: QWidget) -> QVersionTreeView
        Initialize the graphics view and its properties
        
        """
        QInteractiveGraphicsView.__init__(self, parent)
        BaseView.__init__(self)
        self.controller = None
        self.set_title('Version Tree')
        self.setScene(QVersionTreeScene(self))
        self.versionProp = QVersionPropOverlay(self, self.viewport())
        self.versionProp.hide()

    def set_default_layout(self):
        from gui.collection.workspace import QWorkspaceWindow
        from gui.version_prop import QVersionProp
        self.set_palette_layout({
            QtCore.Qt.LeftDockWidgetArea: QWorkspaceWindow,
            QtCore.Qt.RightDockWidgetArea: QVersionProp,
        })

    def set_action_links(self):
        self.action_links = \
            {
             'publishWeb' : ('version_changed', self.check_publish_db),
             'publishPaper': ('version_changed', self.check_publish),
             'redo': ('version_changed', self.can_redo),
             'undo': ('version_changed', self.can_undo),
             'execute': ('pipeline_changed', self.can_execute)
            }

    def set_action_defaults(self):
        self.action_defaults['execute'] = \
            [('setEnabled', True, self.set_action_execute_default)]

    def set_action_execute_default(self):
        if self.controller:
            if self.controller.current_pipeline:
                return len(self.controller.current_pipeline.modules) > 0
        return False

    def check_publish_db(self, versionId):
        loc = self.controller.locator
        result = False
        if hasattr(loc, 'host'):
            result = True
        return result and self.check_publish(versionId)

    def check_publish(self, versionId):
        return versionId > 0

    def can_redo(self, versionId):
        return self.controller and self.controller.can_redo()

    def can_undo(self, versionId):
        return self.controller and self.controller.can_undo()

    def can_execute(self, pipeline):
        return pipeline is not None and len(pipeline.modules) > 0

    def execute(self):
        res = self.controller.execute_current_workflow()
        from gui.vistrails_window import _app
        if len(res[0][0].errors) > 0:
            _app.qactions['pipeline'].trigger()
        _app.notify('execution_updated')

    def publish_to_web(self):
        from gui.publishing import QVersionEmbed
        panel = QVersionEmbed.instance()
        panel.switchType('Wiki')
        panel.set_visible(True)

    def publish_to_paper(self):
        from gui.publishing import QVersionEmbed
        panel = QVersionEmbed.instance()
        panel.switchType('Latex')
        panel.set_visible(True)

    def selectModules(self):
        """ selectModules() -> None
        Overrides parent class to disable text items if you click on background

        """
        if self.canSelectRectangle:
            br = self.selectionBox.sceneBoundingRect()
        else:
            br = QtCore.QRectF(self.startSelectingPos, self.startSelectingPos)
        items = self.scene().items(br)
        if len(items) == 0 or items == [self.selectionBox]:
            for item in self.scene().selectedItems():
                if type(item) == gui.version_view.QGraphicsVersionItem:
                    item.text.clearFocus()
        qt_super(QVersionTreeView, self).selectModules()

    def set_title(self, title):
        BaseView.set_title(self, title)
        self.setWindowTitle(title)

    def set_controller(self, controller):
        oldController = self.controller
        if oldController != controller:
            if oldController != None:
                self.disconnect(oldController,
                                QtCore.SIGNAL('vistrailChanged()'),
                                self.vistrailChanged)
                self.disconnect(
                    oldController,
                    QtCore.SIGNAL('invalidateSingleNodeInVersionTree'),
                    self.single_node_changed)
                self.disconnect(oldController, QtCore.SIGNAL('notesChanged()'),
                                self.notesChanged)
            self.controller = controller
            self.scene().controller = controller
            self.connect(controller, QtCore.SIGNAL('vistrailChanged()'),
                         self.vistrailChanged)
            self.connect(controller,
                         QtCore.SIGNAL('invalidateSingleNodeInVersionTree'),
                         self.single_node_changed)
            self.connect(controller, QtCore.SIGNAL("notesChanged()"),
                         self.notesChanged)
            if controller:
                self.versionProp.updateController(controller)
                self.scene().setupScene(controller)
                # self.vistrailChanged()
                # self.versionProp.updateController(controller)
                # self.versionView.versionProp.updateController(controller)

    def vistrailChanged(self):
        """ vistrailChanged() -> None
        An action was performed on the current vistrail
        
        """
        from gui.vistrails_window import _app
        select_node = True
        if _app._previous_view and _app._previous_view.window() != self.window(
        ):
            select_node = False
        self.scene().setupScene(self.controller, select_node)
        if self.controller and self.controller.reset_version_view:
            self.scene().fitToAllViews()
        if self.controller:
            # self.versionProp.updateVersion(self.controller.current_version)
            self.versionProp.updateVersion(self.controller.current_version)
        self.emit(QtCore.SIGNAL("vistrailChanged()"))

    def single_node_changed(self, old_version, new_version):
        """ single_node_changed(old_version, new_version)
        Handle single node change on version tree by not recomputing
        entire scene.

        """
        self.scene().update_scene_single_node_change(self.controller,
                                                     old_version, new_version)
        if self.controller and self.controller.reset_version_view:
            self.scene().fitToAllViews()
        if self.controller:
            # self.versionProp.updateVersion(self.controller.current_version)
            self.versionProp.updateVersion(self.controller.current_version)
        self.emit(QtCore.SIGNAL("vistrailChanged()"))

    def notesChanged(self):
        """ notesChanged() -> None
        The notes for the current vistrail version changed

        """
        if self.controller:
            self.versionProp.updateVersion(self.controller.current_version)

    def select_current_version(self):
        self.scene().setupScene(self.controller)