Beispiel #1
0
    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())
        self.timelinerThread = None
Beispiel #2
0
  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())
Beispiel #3
0
 def __init__(self, selection, listmodel):
     super(QWidget, self).__init__()
     self.setupUi(self)
     self.processusManager = ProcessusManager()
     self.loader = loader.loader()
     self.lmodules = self.loader.modules
     self.taskmanager = TaskManager()
     self.mainwindow = QApplication.instance().mainWindow
     self.createActions()
     self.checkedSelection = selection
     self.selection = None
     self.model = listmodel
     self.bookManager = BookmarkManager(self.model)
Beispiel #4
0
 def __init__(self, selection, listmodel):
     super(QWidget, self).__init__()
     self.__iconView = False
     self.setupUi(self)
     self.processusManager = ProcessusManager()
     self.loader = loader.loader()
     self.lmodules = self.loader.modules
     self.taskmanager = TaskManager()
     self.mainwindow = QApplication.instance().mainWindow
     self.createActions()
     self.checkedSelection = selection
     self.selection = None
     self.model = listmodel
     self.bookManager = BookmarkManager(self.model)
     #self.document = QtWebKit.QWebView()
     #self.document.loadFinished.connect(self.__print)
     self.__corrupt = base64.b64encode(
         str(QtGui.QImage(":file_broken.png").bits()))
     self.__printer = QtGui.QPrinter(QtGui.QPrinter.ScreenResolution)
     self.__printer.setOutputFormat(QtGui.QPrinter.PdfFormat)
     self.__printer.setPaperSize(QtGui.QPrinter.A4)
     self.__printer.setFullPage(True)
Beispiel #5
0
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)
Beispiel #6
0
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())
        self.timelinerThread = None

    def __del__(self):
        self.VFS.deconnection(self)
        self.treemodel.VFS.deconnection(self.treemodel)

    def update(self):
        self.updateStatus()
        QWidget.update(self)

    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).
    """
        if e.type == 0xde1:
            node = e.value.value()
            self.treemodel.removeNode(node)
            self.browserview.model.removeNode(node)
            self.filterview.model.removeNode(node)
            self.searchview.model.removeNode(node)
            self.timeLineView.model.removeNode(node)
            self.bookManager.removeCategory(node)
        else:
            self.emit(SIGNAL("refreshList"), e)

    def refreshList(self, e):
        if e.value != None and self.mode == ADVANCED:
            node = e.value.value()
            if node == None:
                return
            try:
                self.currentView().model.vfsNotification(node, e.type)
            except:
                pass

    def reportNodes(self):
        ReportNodesAction(self.model())

    def setupUi(self, BrowserToolBar):
        self.actionReport = QAction(self)
        icon = QIcon()
        icon.addPixmap(QPixmap(QString.fromUtf8(":/report")), QIcon.Normal,
                       QIcon.Off)
        self.actionReport.setIcon(icon)
        self.actionReport.setObjectName(QString.fromUtf8("actionReport"))

        Ui_BrowserToolBar.setupUi(self, BrowserToolBar)

    def retranslateUi(self, BrowserToolBar):
        Ui_BrowserToolBar.retranslateUi(self, BrowserToolBar)
        self.actionReport.setText(
            QApplication.translate("BrowserToolBar", "report", None,
                                   QApplication.UnicodeUTF8))
        self.actionReport.setToolTip(
            QApplication.translate("BrowserToolBar", "Add nodes to report",
                                   None, QApplication.UnicodeUTF8))

    def createSelection(self):
        self.selection = SelectionManager()

    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.timeLineButton = QPushButton(QIcon(":clock"), self.tr("Timeline"),
                                          self)
        self.timeLineButton.setCheckable(True)
        self.toolbar.addWidget(self.timeLineButton)
        self.connect(self.timeLineButton, SIGNAL("clicked(bool)"),
                     self.showTimeLine)

        self.exportButton = QPushButton(QIcon(":spreadsheet.png"),
                                        self.tr("Export"), self)
        self.toolbar.addWidget(self.exportButton)
        self.connect(self.exportButton, SIGNAL("clicked(bool)"), self.export)

        self.mainlayout.addWidget(self.toolbar, 0)

        self.toolbar.insertAction(self.actionBookmark, self.actionReport)
        self.connect(self.actionReport, SIGNAL("triggered()"),
                     self.reportNodes)

    def viewFilter(self):
        if self.filter.isChecked():
            self.infostack.setCurrentWidget(self.filterwidget)
            self.viewpan.setCurrentWidget(self.filterview)
            self.filterwidget.resetFilter()
            m = self.currentView().model
            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()
        self.updateStatus()

    def export(self):
        csvDialog = ExportCSVDialog(
            self,
            self.model().list(),
            self.currentView().model.selectedAttributes())
        csvDialog.exec_()
        #csvDialog.export(nodeList)

    def timerlinerFinished(self, timelineNodeList):
        self.timeLineView.updateStatusShowWidgets()
        self.model().updateList(timelineNodeList)
        self.timelinerStopped()

    def timelinerStopped(self):
        self.timelinerProgressTimer.stop()
        self.timelinerProgressTimer = None
        self.timelinerThread.quit()
        self.timelinerThread.wait()
        self.timelinerThread = None

    def askToStopTimeline(self):
        if self.timeliner.isRunning:
            if QMessageBox(
                    QMessageBox.Warning, self.tr("Stop timeline"),
                    self.tr("Do you want to stop the timeline creation ?"),
                    QMessageBox.Yes | QMessageBox.No,
                    self).exec_() == QMessageBox.No:
                self.timeLineButton.setChecked(True)
                return False
            else:
                self.timeLineView.updateStatusShowWidgets()
                self.emit(SIGNAL("timelinerStop"))
        self.model().clearList()
        self.timeliner = None  #call TimeLineNode destructor
        self.timeLineView.updateStatusShowWidgets()
        self.leftpan.show()
        self.timeLineButton.setChecked(False)
        self.filter.setEnabled(True)
        self.infostack.setEnabled(True)
        return True

    def timelinerGetProgress(self):
        self.emit(SIGNAL("timelinerGetProgress"))

    def timelinerUpdateProgress(self, processed, toProcess):
        if self.parent().visibility():
            self.timeLineView.updateStatusProgressBar(processed, toProcess)

    def showTimeLine(self):
        if self.timeLineButton.isChecked():
            self.filter.setEnabled(False)
            self.infostack.setEnabled(False)
            previousModelNodeList = self.model().list()
            self.viewpan.setCurrentWidget(self.timeLineView)
            self.leftpan.hide()
            self.navigationtoolbar.setEnabled(False)
            self.model().clearList()
            if self.timelinerThread is not None:
                print 'Error timelinerThread still exist'
                return
            self.timelinerThread = QThread()
            self.timeliner = Timeliner()
            self.timeliner.moveToThread(self.timelinerThread)
            self.connect(self.timelinerThread, SIGNAL("finished"),
                         self.timeliner.deleteLater)
            self.connect(self, SIGNAL("timelinerLaunch"),
                         self.timeliner.launch)
            self.connect(self, SIGNAL("timelinerStop"), self.timeliner.stop,
                         Qt.DirectConnection)
            self.connect(self, SIGNAL("timelinerGetProgress"),
                         self.timeliner.progress, Qt.DirectConnection)
            self.connect(self.timeliner, SIGNAL("timelinerFinished"),
                         self.timerlinerFinished)
            self.connect(self.timeliner, SIGNAL("timelinerFinished"),
                         self.updateStatus)
            self.connect(self.timeliner, SIGNAL("timelinerStopped"),
                         self.timelinerStopped)
            self.connect(self.timeliner, SIGNAL("timelinerUpdateProgress"),
                         self.timelinerUpdateProgress)
            self.timeLineView.updateStatusShowProgressBar()
            self.timelinerThread.start()
            self.timelinerProgressTimer = QTimer()
            self.timelinerProgressTimer.setSingleShot(False)
            self.timelinerProgressTimer.timeout.connect(
                self.timelinerGetProgress)
            self.timelinerProgressTimer.start(1000)
            self.emit(SIGNAL("timelinerLaunch"), previousModelNodeList)
        else:
            if self.askToStopTimeline() == False:
                return
            if self.search.isChecked():
                self.viewpan.setCurrentWidget(self.searchview)
            else:
                self.viewpan.setCurrentWidget(self.browserview)

    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.model, SIGNAL("layoutChanged()"),
                     self.updateStatus)
        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.connect(self.treemodel, SIGNAL("layoutChanged()"),
                         self.updateStatus)
            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)
        self.connect(self.filterview.model, SIGNAL("layoutChanged()"),
                     self.updateStatus)
        self.connect(self.filterwidget, SIGNAL("finished()"),
                     self.updateStatus)
        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.connect(self.browserview.model, SIGNAL("layoutChanged()"),
                         self.updateStatus)
            self.connect(self.searchwidget, SIGNAL("finished()"),
                         self.updateStatus)
            self.leftpan.addWidget(self.searchwidget)
        # TimeLine view
        self.timeLineView = TimeLineNodeWidget(self.selection)

        self.connect(self.timeLineView.model, SIGNAL("layoutChanged()"),
                     self.updateStatus)
        self.connect(self.timeLineView, SIGNAL("nodePressed"),
                     self.timeLineNodePressed)
        self.views.append(self.timeLineView)
        self.viewpan.addWidget(self.timeLineView)

        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 timeLineNodePressed(self, timeLineNode):
        node = timeLineNode.node()
        self.attributes.fill(node)
        self.mainwindow.emit(SIGNAL("previewUpdate"), node)
        self.emit(SIGNAL("nodePressed"), node)
        self.updateStatus()

    def nodePressed(self, node):
        self.attributes.fill(node)
        self.mainwindow.emit(SIGNAL("previewUpdate"), node)
        self.emit(SIGNAL("nodePressed"), node)
        self.updateStatus()

    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 setCurrentContext(self, rootpath=None, recursive=False, selected=None):
        if rootpath == None:
            rootpath = self.VFS.GetNode('/')
            self.navigation.rootpathchanged(rootpath)
        else:
            self.navigation.rootpathchanged(rootpath)
            self.treeview.expandToNode(rootpath)
        self.currentView().model.changeList(rootpath, recursive, selected)

    def updateStatus(self):
        if self.filter.isChecked():
            self.filterview.updateStatus()
        else:
            self.currentView().updateStatus()

    def activateSearchPan(self, state):
        if self.timeLineButton.isChecked():
            if self.search.isChecked() == False:
                self.search.setChecked(True)
                return
            else:
                if self.askToStopTimeline() == False:
                    self.search.setChecked(False)
                    return
        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()
        self.updateStatus()

    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))
        self.currentView().model.changeList(node, rec)
        #self.currentView().model.refresh(self.model().currentRow())
        self.currentView().refreshVisible()
        self.applyFilter()
        self.updateStatus()
        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 self.timeLineButton.isChecked():
            return self.timeLineView
        elif self.search.isChecked():
            return self.searchview
        else:
            return self.browserview

    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
Beispiel #7
0
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)