Beispiel #1
0
 def __init__(self, selectionManager, tabmode=False, filtermode=False):
     QWidget.__init__(self)
     self.tabmode = tabmode
     self.filtermode = filtermode
     # setup model and views
     self.viewid = TABLEVIEW_ID
     self.model = NodeListModel(selection=selectionManager)
     self.tableview = NodeTableView(self)
     self.listview = NodeListView(self)
     self.tableview.setModel(self.model)
     self.tableview.setColumnWidth(0, 180)
     self.listview.setModel(self.model)
     # Keep track of model list in case of filtering
     self.initialist = []
     # setup graphic stuff
     self.createMainLayout()
     self.createViewLayout()
     self.createStack()
     self.createScrollbar()
     self.createConnections()
     self.menuManager(selectionManager)
     self.connect(self.model, SIGNAL("dataChanged"), self.dataChanged)
Beispiel #2
0
 def __init__(self, selectionManager, tabmode=False, filtermode=False):
     QWidget.__init__(self)
     self.tabmode = tabmode
     self.filtermode = filtermode
     # setup model and views
     self.viewid = TABLEVIEW_ID
     self.model = NodeListModel(selection=selectionManager)
     self.tableview = NodeTableView(self)
     self.listview = NodeListView(self)
     self.tableview.setModel(self.model)
     self.tableview.setColumnWidth(0, 180)
     self.listview.setModel(self.model)
     # Keep track of model list in case of filtering
     self.initialist = []
     # setup graphic stuff
     self.createMainLayout()
     self.createViewLayout()
     self.createStack()
     self.createScrollbar()
     self.createConnections()
     self.menuManager(selectionManager)
     self.connect(self.model, SIGNAL("dataChanged"), self.dataChanged)
Beispiel #3
0
class NodeWidget(QWidget):
    """
    This Widget provide a list model with various view
    """
    def __init__(self, selectionManager, tabmode=False, filtermode=False):
        QWidget.__init__(self)
        self.tabmode = tabmode
        self.filtermode = filtermode
        # setup model and views
        self.viewid = TABLEVIEW_ID
        self.model = NodeListModel(selection=selectionManager)
        self.tableview = NodeTableView(self)
        self.listview = NodeListView(self)
        self.tableview.setModel(self.model)
        self.tableview.setColumnWidth(0, 180)
        self.listview.setModel(self.model)
        # Keep track of model list in case of filtering
        self.initialist = []
        # setup graphic stuff
        self.createMainLayout()
        self.createViewLayout()
        self.createStack()
        self.createScrollbar()
        self.createConnections()
        self.menuManager(selectionManager)
        self.connect(self.model, SIGNAL("dataChanged"), self.dataChanged)

    def menuManager(self, selectionManager):
        self.menumanager = MenuManager(selectionManager, self.model)

    def refreshIconSize(self, factor):
        self.tableview.factor = factor
        self.tableview.configure()
        self.listview.factor = factor
        self.listview.configure()
        self.refreshVisible()

    def dataChanged(self, x, y):
        self.viewstack.currentWidget().dataChanged(x, y)

    def createMainLayout(self):
        self.vlayout = QVBoxLayout(self)
        self.vlayout.setSpacing(0)
        self.vlayout.setMargin(0)

    def createViewLayout(self):
        container = QWidget()
        self.hlayout = QHBoxLayout()
        self.hlayout.setSpacing(0)
        self.hlayout.setMargin(0)
        container.setLayout(self.hlayout)
        self.vlayout.addWidget(container)

    def createStack(self):
        self.viewstack = QStackedWidget()
        self.viewstack.addWidget(self.tableview)
        self.viewstack.addWidget(self.listview)
        self.hlayout.addWidget(self.viewstack, 99)

    def createScrollbar(self):
        self.scrollbar = ScrollBar(self)
        self.hlayout.addWidget(self.scrollbar, 1)
        self.scrollbar.lower()

    def refreshVisible(self):
        view = self.viewstack.currentWidget()
        view.refreshVisible()

    def createConnections(self):
        self.connect(self, SIGNAL("changeView"), self.changeView)
        self.connect(self.tableview, SIGNAL("nodeListClicked"),
                     self.nodelistclicked)
        self.connect(self.tableview, SIGNAL("nodeListDoubleClicked"),
                     self.nodelistDoubleclicked)
        self.connect(self.model, SIGNAL("nodeListClicked"),
                     self.nodelistclicked)
        self.connect(self.tableview, SIGNAL("enterDirectory"),
                     self.enterDirectory)
        self.connect(self.listview, SIGNAL("enterDirectory"),
                     self.enterDirectory)
        self.connect(self.listview, SIGNAL("nodeListClicked"),
                     self.nodelistclicked)
        self.connect(self.listview, SIGNAL("nodeListDoubleClicked"),
                     self.nodelistDoubleclicked)
        self.connect(self.model, SIGNAL("nodeAppended"), self.refreshVisible)

    def enterDirectory(self, sourcenode):
        if sourcenode != None:
            if (not self.tabmode) and (not self.filtermode):
                self.model.emit(SIGNAL("changeList"), sourcenode.children())
                self.emit(SIGNAL("pathChanged"), sourcenode)
                if len(self.model.list()) > 0:
                    self.nodelistclicked(0)
            if self.filtermode:
                self.emit(SIGNAL("enterFilter"), sourcenode)
            if self.tabmode:
                self.openAsNewTab(sourcenode)

        self.refreshVisible()

    def nodelistclicked(self, button):
        if button == Qt.RightButton:
            self.menumanager.createMenu()
        else:
            node = self.model.currentNode()
            self.emit(SIGNAL("nodePressed"), node)

    def nodelistDoubleclicked(self, node):
        self.menumanager.openDefault(node)

    def changeView(self, index):
        self.viewid = index
        if index == TABLEVIEW_ID:
            self.viewstack.setCurrentWidget(self.tableview)
            self.model.refresh(self.model.currentRow())
            self.scrollbar.setMaximum(self.scrollbar.value() - 2)
        elif index == LISTVIEW_ID:
            self.viewstack.setCurrentWidget(self.listview)
            self.model.refresh(self.model.currentRow())
            self.scrollbar.setMaximum(self.scrollbar.value() + 2)
        self.refreshVisible()

    def openAsNewTab(self, rootnode):
        QApplication.instance().mainWindow.addNodeBrowser(rootpath=rootnode)
Beispiel #4
0
class NodeWidget(QWidget):
    """
    This Widget provide a list model with various view
    """
    def __init__(self, selectionManager, tabmode=False, filtermode=False):
        QWidget.__init__(self)
        self.tabmode = tabmode
        self.filtermode = filtermode
        # setup model and views
        self.viewid = TABLEVIEW_ID
        self.model = NodeListModel(selection=selectionManager)
        self.tableview = NodeTableView(self)
        self.listview = NodeListView(self)
        self.tableview.setModel(self.model)
        self.tableview.setColumnWidth(0, 180)
        self.listview.setModel(self.model)
        # Keep track of model list in case of filtering
        self.initialist = []
        # setup graphic stuff
        self.createMainLayout()
        self.createViewLayout()
        self.createStack()
        self.createScrollbar()
        self.createConnections()
        self.menuManager(selectionManager)
        self.connect(self.model, SIGNAL("dataChanged"), self.dataChanged)

    def menuManager(self, selectionManager):
        self.menumanager = MenuManager(selectionManager, self.model)

    def refreshIconSize(self, factor):
        self.tableview.factor = factor
        self.tableview.configure()
        self.listview.factor = factor
        self.listview.configure()
        self.refreshVisible()

    def dataChanged(self, x, y):
        self.viewstack.currentWidget().dataChanged(x, y)

    def createMainLayout(self):
        self.vlayout = QVBoxLayout(self)
        self.vlayout.setSpacing(0)
        self.vlayout.setMargin(0)
        
    def createViewLayout(self):
        container = QWidget()
        self.hlayout = QHBoxLayout()
        self.hlayout.setSpacing(0)
        self.hlayout.setMargin(0)
        container.setLayout(self.hlayout)
        self.vlayout.addWidget(container)

    def createStack(self):
        self.viewstack = QStackedWidget()
        self.viewstack.addWidget(self.tableview)
        self.viewstack.addWidget(self.listview)
        self.hlayout.addWidget(self.viewstack, 99)

    def createScrollbar(self):
        self.scrollbar = ScrollBar(self)
        self.hlayout.addWidget(self.scrollbar, 1)
        self.scrollbar.lower()

    def refreshVisible(self):
        view = self.viewstack.currentWidget()
        view.refreshVisible()

    def createConnections(self):
        self.connect(self, SIGNAL("changeView"), self.changeView)
        self.connect(self.tableview, SIGNAL("nodeListClicked"), self.nodelistclicked)
        self.connect(self.tableview, SIGNAL("nodeListDoubleClicked"), self.nodelistDoubleclicked)
        self.connect(self.model, SIGNAL("nodeListClicked"), self.nodelistclicked)
        self.connect(self.tableview, SIGNAL("enterDirectory"), self.enterDirectory)
        self.connect(self.listview, SIGNAL("enterDirectory"), self.enterDirectory)
        self.connect(self.listview, SIGNAL("nodeListClicked"), self.nodelistclicked)
        self.connect(self.listview, SIGNAL("nodeListDoubleClicked"), self.nodelistDoubleclicked)
        self.connect(self.model, SIGNAL("nodeAppended"), self.refreshVisible)

    def enterDirectory(self, sourcenode):
        if sourcenode != None:
            if (not self.tabmode) and (not self.filtermode):
                self.model.emit(SIGNAL("changeList"), sourcenode.children())
                self.emit(SIGNAL("pathChanged"), sourcenode)
                if len(self.model.list()) > 0:
                    self.nodelistclicked(0)
            if self.filtermode:
                self.emit(SIGNAL("enterFilter"), sourcenode)
            if self.tabmode:
                self.openAsNewTab(sourcenode)
                
        self.refreshVisible()

    def nodelistclicked(self, button):
        if button == Qt.RightButton:
            self.menumanager.createMenu()
        else:
            node = self.model.currentNode()
            self.emit(SIGNAL("nodePressed"), node)

    def nodelistDoubleclicked(self, node):
        self.menumanager.openDefault(node)

    def changeView(self, index):
        self.viewid = index
        if index == TABLEVIEW_ID:
            self.viewstack.setCurrentWidget(self.tableview)
            self.model.refresh(self.model.currentRow())
            self.scrollbar.setMaximum(self.scrollbar.value() - 2)
        elif index == LISTVIEW_ID:
            self.viewstack.setCurrentWidget(self.listview)
            self.model.refresh(self.model.currentRow())
            self.scrollbar.setMaximum(self.scrollbar.value() + 2)
        self.refreshVisible()

    def openAsNewTab(self, rootnode):
        QApplication.instance().mainWindow.addNodeBrowser(rootpath=rootnode)