Ejemplo n.º 1
0
    def __init__(self, parent=None):
        """ __init__(parent: QWidget) -> QBookmarksWindow
        Construct a window with menus, toolbar, and floating toolwindow
        
        """
        QtGui.QMainWindow.__init__(self, parent)
        
        self.setWindowTitle('VisTrails Bookmarks')
        self.setStatusBar(QtGui.QStatusBar(self))
        self.setDockNestingEnabled(True)

        self.bookmarkPanel = QBookmarkPanel(self,BookmarksManager)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea,
                           self.bookmarkPanel.toolWindow())

        self.bookmarkAliasPanel = QBookmarkAliasPanel(self,BookmarksManager)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.bookmarkAliasPanel.toolWindow())

        self.aliasExplorePanel = QAliasExplorationPanel(self,BookmarksManager)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.aliasExplorePanel.toolWindow())
        
        self.createActions()
        self.createMenu()
        self.createToolBar()

        self.connectSignals()
        self.setVisible(False)
Ejemplo n.º 2
0
class QBookmarksWindow(QtGui.QMainWindow):
    """
    QBookmarksWindow is a main widget containing several tool windows
    for interacting with bookmarked vistrails pipelines without having to use 
    the builder.
    It is based on QBuilderWindow visual style.
        
    """
    def __init__(self, parent=None):
        """ __init__(parent: QWidget) -> QBookmarksWindow
        Construct a window with menus, toolbar, and floating toolwindow
        
        """
        QtGui.QMainWindow.__init__(self, parent)
        
        self.setWindowTitle('VisTrails Bookmarks')
        self.setStatusBar(QtGui.QStatusBar(self))
        self.setDockNestingEnabled(True)

        self.bookmarkPanel = QBookmarkPanel(self,BookmarksManager)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea,
                           self.bookmarkPanel.toolWindow())

        self.bookmarkAliasPanel = QBookmarkAliasPanel(self,BookmarksManager)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.bookmarkAliasPanel.toolWindow())

        self.aliasExplorePanel = QAliasExplorationPanel(self,BookmarksManager)
        self.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                           self.aliasExplorePanel.toolWindow())
        
        self.createActions()
        self.createMenu()
        self.createToolBar()

        self.connectSignals()
        self.setVisible(False)

    def sizeHint(self):
        """ sizeHint() -> QRect
        Return the recommended size of the bookmarks window
        
        """
        return QtCore.QSize(800, 600)

    def keyPressEvent(self, event):
        if (event.key() == QtCore.Qt.Key_Enter or 
            event.key() == QtCore.Qt.Key_Return) and \
            (event.modifiers() & QtCore.Qt.ControlModifier):
            if self.bookmarkPanel.isVisible():          
                self.bookmarkPanel.executeAction.trigger()

    def createActions(self):
        """ createActions() -> None
        Construct all menu/toolbar actions for bookmarks panel
        
        """
        pass
                
    def createMenu(self):
        """ createMenu() -> None
        Initialize menu bar of bookmarks window
        
        """
        self.viewMenu = self.menuBar().addMenu('&View')
        self.viewMenu.addAction(
            self.bookmarkPanel.toolWindow().toggleViewAction())
        self.viewMenu.addAction(
            self.bookmarkAliasPanel.toolWindow().toggleViewAction())
        self.viewMenu.addAction(
            self.aliasExplorePanel.toolWindow().toggleViewAction())
        
    def createToolBar(self):
        """ createToolBar() -> None
        Create a default toolbar for bookmarks window
        
        """
        pass

    def closeEvent(self, e):
        """closeEvent(e) -> None
        Event handler called when the window is about to close."""
        self.hide()
        self.emit(QtCore.SIGNAL("bookmarksHidden()"))

    def showEvent(self, e):
        """showEvent(e: QShowEvent) -> None
        Event handler called immediately before the window is shown.
        Checking if the bookmarks list is sync with the Collection """
        if BookmarksManager.collection.updateGUI:
            self.bookmarkPanel.updateBookmarkPalette()
            BookmarksManager.collection.updateGUI = False

    def connectSignals(self):
        """ connectSignals() -> None
        Map signals between various GUI components        
        
        """
        self.connect(BookmarksManager, 
                     QtCore.SIGNAL("updateAliasGUI"),
                     self.bookmarkAliasPanel.updateAliasTable)
        self.connect(BookmarksManager, 
                     QtCore.SIGNAL("updateBookmarksGUI"),
                     self.bookmarkPanel.updateBookmarkPalette)
        self.connect(self.bookmarkAliasPanel.parameters,
                     QtCore.SIGNAL("rowRemoved"),
                     self.aliasExplorePanel.removeAlias)