def createViews(self): self.views = [] self.splitter = QSplitter(self) self.browserview = self.createNodeWidget(self.selection) self.connect(self.browserview, SIGNAL("nodePressed"), self.nodePressed) # append self.views.append(self.browserview) self.viewpan.addWidget(self.browserview) self.leftpan = QStackedWidget() if self.mode == ADVANCED: # Tree view self.treeview = NodeTreeView(self) self.treemodel = TreeModel(self, self.selection) self.treeview.setModel(self.treemodel) self.leftpan.addWidget(self.treeview) self.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.nodetreeclicked) self.navigation.connect(self.browserview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.navigation.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.navigation.pathChanged) # Search view self.searchview = self.createNodeWidget(self.selection, tabmode=True) self.connect(self.searchview, SIGNAL("nodePressed"), self.nodePressed) self.views.append(self.searchview) self.viewpan.addWidget(self.searchview) # Filter view self.filterview = self.createNodeWidget(self.selection, filtermode=True) self.connect(self.filterview, SIGNAL("enterFilter"), self.enterFilter) self.connect(self.filterview, SIGNAL("nodePressed"), self.nodePressed) if self.mode == ADVANCED: self.navigation.connect(self.filterview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.views.append(self.filterview) self.viewpan.addWidget(self.filterview) if self.mode == ADVANCED: self.searchwidget = SearchPanel(self, self.searchview) self.leftpan.addWidget(self.searchwidget) self.splitter.addWidget(self.leftpan) self.splitter.addWidget(self.viewstack) self.splitter.addWidget(self.attributes) self.splitter.setStretchFactor(0, 25) self.splitter.setStretchFactor(1, 60) self.splitter.setStretchFactor(2, 15) self.mainlayout.addWidget(self.splitter, 50)
def createViews(self): self.views = [] self.splitter = QSplitter(self) self.browserview = self.createNodeWidget(self.selection) self.connect(self.browserview, SIGNAL("nodePressed"), self.nodePressed) # append self.views.append(self.browserview) self.viewpan.addWidget(self.browserview) self.leftpan = QStackedWidget() if self.mode == ADVANCED: # Tree view self.treeview = NodeTreeView(self) self.treemodel = TreeModel(self, self.selection) self.treeview.setModel(self.treemodel) self.leftpan.addWidget(self.treeview) self.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.nodetreeclicked) self.navigation.connect(self.browserview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.navigation.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.navigation.pathChanged) # Search view self.searchview = self.createNodeWidget(self.selection,tabmode=True) self.connect(self.searchview, SIGNAL("nodePressed"), self.nodePressed) self.views.append(self.searchview) self.viewpan.addWidget(self.searchview) # Filter view self.filterview = self.createNodeWidget(self.selection, filtermode=True) self.connect(self.filterview, SIGNAL("enterFilter"), self.enterFilter) self.connect(self.filterview, SIGNAL("nodePressed"), self.nodePressed) if self.mode == ADVANCED: self.navigation.connect(self.filterview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.views.append(self.filterview) self.viewpan.addWidget(self.filterview) if self.mode == ADVANCED: self.searchwidget = SearchPanel(self, self.searchview) self.leftpan.addWidget(self.searchwidget) self.splitter.addWidget(self.leftpan) self.splitter.addWidget(self.viewstack) self.splitter.addWidget(self.attributes) self.splitter.setStretchFactor(0, 25) self.splitter.setStretchFactor(1, 60) self.splitter.setStretchFactor(2, 15) self.mainlayout.addWidget(self.splitter, 50)
class NodeListWidgets(Ui_BrowserToolBar, QWidget, EventHandler): def __init__(self, parent=None, mode=ADVANCED): EventHandler.__init__(self) super(QWidget, self).__init__(parent) self.setupUi(self) self.type = "filebrowser" self.icon = None self.name = "nodebrowser" self.setObjectName(self.name) #Define browser functions self.mode = mode self.mainwindow = QApplication.instance().mainWindow # Main layout self.mainlayout = QVBoxLayout() self.mainlayout.setSpacing(0) self.mainlayout.setMargin(0) self.createSelection() self.attributes = PropertyTable(self) if mode == ADVANCED: self.createNavigationHeader() self.createToolbar() self.createViewPan() self.createViews() self.setLayout(self.mainlayout) self.VFS = VFS.Get() self.VFS.connection(self) self.connect(self, SIGNAL("refreshList"), self.refreshList) self.bookManager = BookmarkManager(self.model()) def __del__(self): self.VFS.deconnection(self) self.treemodel.VFS.deconnection(self.treemodel) def Event(self, e): """ Add e.value, which is a Variant containing a Node, in the tree (only if it has children or is a directory). """ self.emit(SIGNAL("refreshList"), e) def refreshList(self, e): if e.value != None: if self.mode == ADVANCED: node = e.value.value() if node == None or self.navigation.currentNode == None: return try: parent = node.parent() navnode = self.navigation.currentNode # XXX Identify event type (add node or apply module) if navnode.absolute() == parent.absolute(): child = parent.children() elif navnode.absolute() == parent.parent().absolute(): child = parent.parent().children() else: return self.currentView().model.changeList(child) self.currentView().refreshVisible() except: pass def createSelection(self): self.selection = SelectionManager() self.connect(self.selection, SIGNAL("selectionChanged()"), self.refreshModels) def createNavigationHeader(self): self.header = QSplitter(Qt.Horizontal) self.navigation = NavigationBar(self) self.navigationtoolbar = self.navigation.getPathbar() self.header.addWidget(self.navigationtoolbar) self.header.setStretchFactor(0, 60) self.mainlayout.addWidget(self.header, 0) def createToolbar(self): self.toolbar = QToolBar() self.toolbar.setMaximumHeight(32) self.toolbar.addAction(self.actionFactorMinus) self.connect(self.factorSlider, SIGNAL("valueChanged(int)"), self.refreshIconSize) self.toolbar.addWidget(self.factorSlider) self.toolbar.addAction(self.actionFactorPlus) self.connect(self.actionFactorMinus, SIGNAL("triggered()"), self.factorminus) self.connect(self.actionFactorPlus, SIGNAL("triggered()"), self.factorplus) self.toolbar.addWidget(self.changeView) self.connect(self.changeView, SIGNAL("currentIndexChanged(int)"), self.viewChanged) self.toolbar.addAction(self.actionAttributes) self.connect(self.actionAttributes, SIGNAL("triggered()"), self.selectAttributes) self.toolbar.addAction(self.actionBookmark) self.connect(self.actionBookmark, SIGNAL("triggered()"), self.bookmark) menutag = tagMenu(self, self.mainwindow) self.tags.setMenu(menutag) self.toolbar.addWidget(self.tags) if self.mode == ADVANCED: self.toolbar.addWidget(self.search) self.connect(self.search, SIGNAL("clicked(bool)"), self.activateSearchPan) else: self.search.setVisible(False) self.toolbar.addWidget(self.filter) self.connect(self.filter, SIGNAL("clicked(bool)"), self.viewFilter) self.mainlayout.addWidget(self.toolbar, 0) def viewFilter(self): if self.filter.isChecked(): self.infostack.setCurrentWidget(self.filterwidget) self.viewpan.setCurrentWidget(self.filterview) self.filterwidget.resetFilter() m = self.currentView().model # if self.filter.isChecked(): self.filterview.model.setDefaultAttributes() self.filterview.model.setSelectedAttributes(m.selectedAttributes()) self.infostack.show() else: self.infostack.setCurrentWidget(self.filterwidget) self.viewpan.setCurrentWidget(self.currentView()) self.infostack.hide() def factorminus(self): value = self.factorSlider.value() - 1 if value >= 1: self.factorSlider.setValue(value) self.refreshIconSize(value) def factorplus(self): value = self.factorSlider.value() + 1 if value <= 4: self.factorSlider.setValue(value) self.refreshIconSize(value) def refreshIconSize(self, value): for view in self.views: view.refreshIconSize(value) def createViewPan(self): self.viewstack = QWidget() self.viewlayout = QVBoxLayout() self.viewlayout.setSpacing(0) self.viewlayout.setMargin(0) self.viewpan = QStackedWidget() self.infostack = QStackedWidget() self.filterwidget = FilterWidget(self) self.infostack.addWidget(self.filterwidget) self.infostack.hide() self.viewlayout.addWidget(self.infostack, 0) self.viewlayout.addWidget(self.viewpan, 90) self.viewstack.setLayout(self.viewlayout) def createNodeWidget(self, selection, tabmode=False, filtermode=False): return NodeWidget(selection, tabmode, filtermode) def createViews(self): self.views = [] self.splitter = QSplitter(self) self.browserview = self.createNodeWidget(self.selection) self.connect(self.browserview, SIGNAL("nodePressed"), self.nodePressed) # append self.views.append(self.browserview) self.viewpan.addWidget(self.browserview) self.leftpan = QStackedWidget() if self.mode == ADVANCED: # Tree view self.treeview = NodeTreeView(self) self.treemodel = TreeModel(self, self.selection) self.treeview.setModel(self.treemodel) self.leftpan.addWidget(self.treeview) self.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.nodetreeclicked) self.navigation.connect(self.browserview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.navigation.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.navigation.pathChanged) # Search view self.searchview = self.createNodeWidget(self.selection,tabmode=True) self.connect(self.searchview, SIGNAL("nodePressed"), self.nodePressed) self.views.append(self.searchview) self.viewpan.addWidget(self.searchview) # Filter view self.filterview = self.createNodeWidget(self.selection, filtermode=True) self.connect(self.filterview, SIGNAL("enterFilter"), self.enterFilter) self.connect(self.filterview, SIGNAL("nodePressed"), self.nodePressed) if self.mode == ADVANCED: self.navigation.connect(self.filterview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.views.append(self.filterview) self.viewpan.addWidget(self.filterview) if self.mode == ADVANCED: self.searchwidget = SearchPanel(self, self.searchview) self.leftpan.addWidget(self.searchwidget) self.splitter.addWidget(self.leftpan) self.splitter.addWidget(self.viewstack) self.splitter.addWidget(self.attributes) self.splitter.setStretchFactor(0, 25) self.splitter.setStretchFactor(1, 60) self.splitter.setStretchFactor(2, 15) self.mainlayout.addWidget(self.splitter, 50) def nodePressed(self, node): self.attributes.fill(node) self.mainwindow.emit(SIGNAL("previewUpdate"), node) def enterFilter(self, node): if self.filterwidget.lock.isChecked(): self.browserview.enterDirectory(node) self.filterwidget.quickFilter() else: self.browserview.enterDirectory(node) self.filterwidget.resetFilter() def refreshModels(self): self.model().emit(SIGNAL("layoutChanged()")) if self.mode == ADVANCED: self.treemodel.emit(SIGNAL("layoutChanged()")) def activateSearchPan(self, state): if self.mode == ADVANCED: if state: self.leftpan.setCurrentIndex(SEARCH_PAN) self.navigationtoolbar.setEnabled(False) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.searchview) else: self.viewpan.setCurrentWidget(self.filterview) else: self.leftpan.setCurrentIndex(TREE_VIEW) self.navigationtoolbar.setEnabled(True) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.browserview) else: self.viewpan.setCurrentWidget(self.filterview) self.model().refresh(self.model().currentRow()) else: if state: self.searchwidget = SearchPanel(self, self.searchview) self.leftpan.addWidget(self.searchwidget) self.leftpan.setCurrentWidget(self.searchwidget) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.searchview) else: self.viewpan.setCurrentWidget(self.filterview) self.leftpan.show() else: self.leftpan.removeWidget(self.searchwidget) self.model().refresh(self.model().currentRow()) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.browserview) else: self.viewpan.setCurrentWidget(self.filterview) self.leftpan.hide() self.filterwidget.resetFilter() def applyFilter(self): if self.filter.isChecked(): if self.filterwidget.lock.isChecked(): self.filterwidget.quickFilter() else: self.filterwidget.resetFilter() def nodetreeclicked(self, node, button, rec=False): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) if not rec: self.currentView().model.emit(SIGNAL("changeList"), node.children()) else: res = [] self.recurseNodes(node, res) res.remove(node) self.currentView().model.emit(SIGNAL("changeList"), res) self.currentView().model.refresh(self.model().currentRow()) self.currentView().refreshVisible() self.applyFilter() QApplication.restoreOverrideCursor() def recurseNodes(self, node, res): res.append(node) if node.hasChildren(): childs = node.children() for child in childs: self.recurseNodes(child, res) def viewChanged(self, index): curentview = self.viewpan.currentWidget() curentview.emit(SIGNAL("changeView"), index) def selectAttributes(self): model = self.currentView().model attr = model.availableAttributes() wiz = SelectAttributesWizard(self.currentView().model, model.selectedAttributes(), model.defaultAttributes()) iret = wiz.exec_() if iret == 1: selected = wiz.getSelectedAttributes() model.setSelectedAttributes(selected) if self.filter.isChecked(): self.filterview.model.setSelectedAttributes(selected) def bookmark(self): self.bookManager.launch() def currentView(self): if not self.search.isChecked(): return self.browserview else: return self.searchview def views(self): views = [] views.append(self.browser) views.append(self.search) def models(self): model_list = [] model_list.append(self.browser.model) model_list.append(self.search.model) return model_list def model(self): return self.viewpan.currentWidget().model def changeList(self, nodelist): self.browserview.model.emit(SIGNAL("changeList"), nodelist)
class NodeListWidgets(Ui_BrowserToolBar, QWidget, EventHandler): def __init__(self, parent=None, mode=ADVANCED): EventHandler.__init__(self) super(QWidget, self).__init__(parent) self.setupUi(self) self.type = "filebrowser" self.icon = None self.name = "nodebrowser" self.setObjectName(self.name) #Define browser functions self.mode = mode self.mainwindow = QApplication.instance().mainWindow # Main layout self.mainlayout = QVBoxLayout() self.mainlayout.setSpacing(0) self.mainlayout.setMargin(0) self.createSelection() self.attributes = PropertyTable(self) if mode == ADVANCED: self.createNavigationHeader() self.createToolbar() self.createViewPan() self.createViews() self.setLayout(self.mainlayout) self.VFS = VFS.Get() self.VFS.connection(self) self.connect(self, SIGNAL("refreshList"), self.refreshList) self.bookManager = BookmarkManager(self.model()) def __del__(self): self.VFS.deconnection(self) self.treemodel.VFS.deconnection(self.treemodel) def Event(self, e): """ Add e.value, which is a Variant containing a Node, in the tree (only if it has children or is a directory). """ self.emit(SIGNAL("refreshList"), e) def refreshList(self, e): if e.value != None: if self.mode == ADVANCED: node = e.value.value() if node == None or self.navigation.currentNode == None: return try: parent = node.parent() navnode = self.navigation.currentNode # XXX Identify event type (add node or apply module) if navnode.absolute() == parent.absolute(): child = parent.children() elif navnode.absolute() == parent.parent().absolute(): child = parent.parent().children() else: return self.currentView().model.changeList(child) self.currentView().refreshVisible() except: pass def createSelection(self): self.selection = SelectionManager() self.connect(self.selection, SIGNAL("selectionChanged()"), self.refreshModels) def createNavigationHeader(self): self.header = QSplitter(Qt.Horizontal) self.navigation = NavigationBar(self) self.navigationtoolbar = self.navigation.getPathbar() self.header.addWidget(self.navigationtoolbar) self.header.setStretchFactor(0, 60) self.mainlayout.addWidget(self.header, 0) def createToolbar(self): self.toolbar = QToolBar() self.toolbar.setMaximumHeight(32) self.toolbar.addAction(self.actionFactorMinus) self.connect(self.factorSlider, SIGNAL("valueChanged(int)"), self.refreshIconSize) self.toolbar.addWidget(self.factorSlider) self.toolbar.addAction(self.actionFactorPlus) self.connect(self.actionFactorMinus, SIGNAL("triggered()"), self.factorminus) self.connect(self.actionFactorPlus, SIGNAL("triggered()"), self.factorplus) self.toolbar.addWidget(self.changeView) self.connect(self.changeView, SIGNAL("currentIndexChanged(int)"), self.viewChanged) self.toolbar.addAction(self.actionAttributes) self.connect(self.actionAttributes, SIGNAL("triggered()"), self.selectAttributes) self.toolbar.addAction(self.actionBookmark) self.connect(self.actionBookmark, SIGNAL("triggered()"), self.bookmark) menutag = tagMenu(self, self.mainwindow) self.tags.setMenu(menutag) self.toolbar.addWidget(self.tags) if self.mode == ADVANCED: self.toolbar.addWidget(self.search) self.connect(self.search, SIGNAL("clicked(bool)"), self.activateSearchPan) else: self.search.setVisible(False) self.toolbar.addWidget(self.filter) self.connect(self.filter, SIGNAL("clicked(bool)"), self.viewFilter) self.mainlayout.addWidget(self.toolbar, 0) def viewFilter(self): if self.filter.isChecked(): self.infostack.setCurrentWidget(self.filterwidget) self.viewpan.setCurrentWidget(self.filterview) self.filterwidget.resetFilter() m = self.currentView().model # if self.filter.isChecked(): self.filterview.model.setDefaultAttributes() self.filterview.model.setSelectedAttributes(m.selectedAttributes()) self.infostack.show() else: self.infostack.setCurrentWidget(self.filterwidget) self.viewpan.setCurrentWidget(self.currentView()) self.infostack.hide() def factorminus(self): value = self.factorSlider.value() - 1 if value >= 1: self.factorSlider.setValue(value) self.refreshIconSize(value) def factorplus(self): value = self.factorSlider.value() + 1 if value <= 4: self.factorSlider.setValue(value) self.refreshIconSize(value) def refreshIconSize(self, value): for view in self.views: view.refreshIconSize(value) def createViewPan(self): self.viewstack = QWidget() self.viewlayout = QVBoxLayout() self.viewlayout.setSpacing(0) self.viewlayout.setMargin(0) self.viewpan = QStackedWidget() self.infostack = QStackedWidget() self.filterwidget = FilterWidget(self) self.infostack.addWidget(self.filterwidget) self.infostack.hide() self.viewlayout.addWidget(self.infostack, 0) self.viewlayout.addWidget(self.viewpan, 90) self.viewstack.setLayout(self.viewlayout) def createNodeWidget(self, selection, tabmode=False, filtermode=False): return NodeWidget(selection, tabmode, filtermode) def createViews(self): self.views = [] self.splitter = QSplitter(self) self.browserview = self.createNodeWidget(self.selection) self.connect(self.browserview, SIGNAL("nodePressed"), self.nodePressed) # append self.views.append(self.browserview) self.viewpan.addWidget(self.browserview) self.leftpan = QStackedWidget() if self.mode == ADVANCED: # Tree view self.treeview = NodeTreeView(self) self.treemodel = TreeModel(self, self.selection) self.treeview.setModel(self.treemodel) self.leftpan.addWidget(self.treeview) self.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.nodetreeclicked) self.navigation.connect(self.browserview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.navigation.connect(self.treeview, SIGNAL("nodeTreeClicked"), self.navigation.pathChanged) # Search view self.searchview = self.createNodeWidget(self.selection, tabmode=True) self.connect(self.searchview, SIGNAL("nodePressed"), self.nodePressed) self.views.append(self.searchview) self.viewpan.addWidget(self.searchview) # Filter view self.filterview = self.createNodeWidget(self.selection, filtermode=True) self.connect(self.filterview, SIGNAL("enterFilter"), self.enterFilter) self.connect(self.filterview, SIGNAL("nodePressed"), self.nodePressed) if self.mode == ADVANCED: self.navigation.connect(self.filterview, SIGNAL("pathChanged"), self.navigation.rootpathchanged) self.views.append(self.filterview) self.viewpan.addWidget(self.filterview) if self.mode == ADVANCED: self.searchwidget = SearchPanel(self, self.searchview) self.leftpan.addWidget(self.searchwidget) self.splitter.addWidget(self.leftpan) self.splitter.addWidget(self.viewstack) self.splitter.addWidget(self.attributes) self.splitter.setStretchFactor(0, 25) self.splitter.setStretchFactor(1, 60) self.splitter.setStretchFactor(2, 15) self.mainlayout.addWidget(self.splitter, 50) def nodePressed(self, node): self.attributes.fill(node) self.mainwindow.emit(SIGNAL("previewUpdate"), node) def enterFilter(self, node): if self.filterwidget.lock.isChecked(): self.browserview.enterDirectory(node) self.filterwidget.quickFilter() else: self.browserview.enterDirectory(node) self.filterwidget.resetFilter() def refreshModels(self): self.model().emit(SIGNAL("layoutChanged()")) if self.mode == ADVANCED: self.treemodel.emit(SIGNAL("layoutChanged()")) def activateSearchPan(self, state): if self.mode == ADVANCED: if state: self.leftpan.setCurrentIndex(SEARCH_PAN) self.navigationtoolbar.setEnabled(False) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.searchview) else: self.viewpan.setCurrentWidget(self.filterview) else: self.leftpan.setCurrentIndex(TREE_VIEW) self.navigationtoolbar.setEnabled(True) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.browserview) else: self.viewpan.setCurrentWidget(self.filterview) self.model().refresh(self.model().currentRow()) else: if state: self.searchwidget = SearchPanel(self, self.searchview) self.leftpan.addWidget(self.searchwidget) self.leftpan.setCurrentWidget(self.searchwidget) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.searchview) else: self.viewpan.setCurrentWidget(self.filterview) self.leftpan.show() else: self.leftpan.removeWidget(self.searchwidget) self.model().refresh(self.model().currentRow()) if not self.filter.isChecked(): self.viewpan.setCurrentWidget(self.browserview) else: self.viewpan.setCurrentWidget(self.filterview) self.leftpan.hide() self.filterwidget.resetFilter() def applyFilter(self): if self.filter.isChecked(): if self.filterwidget.lock.isChecked(): self.filterwidget.quickFilter() else: self.filterwidget.resetFilter() def nodetreeclicked(self, node, button, rec=False): QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) if not rec: self.currentView().model.emit(SIGNAL("changeList"), node.children()) else: res = [] self.recurseNodes(node, res) res.remove(node) self.currentView().model.emit(SIGNAL("changeList"), res) self.currentView().model.refresh(self.model().currentRow()) self.currentView().refreshVisible() self.applyFilter() QApplication.restoreOverrideCursor() def recurseNodes(self, node, res): res.append(node) if node.hasChildren(): childs = node.children() for child in childs: self.recurseNodes(child, res) def viewChanged(self, index): curentview = self.viewpan.currentWidget() curentview.emit(SIGNAL("changeView"), index) def selectAttributes(self): model = self.currentView().model attr = model.availableAttributes() wiz = SelectAttributesWizard(self.currentView().model, model.selectedAttributes(), model.defaultAttributes()) iret = wiz.exec_() if iret == 1: selected = wiz.getSelectedAttributes() model.setSelectedAttributes(selected) if self.filter.isChecked(): self.filterview.model.setSelectedAttributes(selected) def bookmark(self): self.bookManager.launch() def currentView(self): if not self.search.isChecked(): return self.browserview else: return self.searchview def views(self): views = [] views.append(self.browser) views.append(self.search) def models(self): model_list = [] model_list.append(self.browser.model) model_list.append(self.search.model) return model_list def model(self): return self.viewpan.currentWidget().model def changeList(self, nodelist): self.browserview.model.emit(SIGNAL("changeList"), nodelist)