Пример #1
0
    def _initFileExplorer(self, base_dir=None):
        """
        Create the File explorer object based on the QFileSystemModel widget.
        """

        model = QtWidgets.QFileSystemModel()
        rootp = ''
        if base_dir:
            rootp = base_dir
        elif self.case_dir:
            rootp = self.case_dir

        model.setRootPath(rootp)

        tree = QtWidgets.QTreeView(None)

        tree.setModel(model)
        tree.setSortingEnabled(True)
        tree.setWindowTitle('Explorer')
        tree.setRootIndex(model.index(rootp))

        # Hide unnecessary columns
        nc = tree.header().count()
        for i in range(1, nc):
            tree.hideColumn(i)

        # Right click menu
        tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        tree.customContextMenuRequested.connect(self.explorerContextMenu)

        # Double click
        tree.doubleClicked.connect(self._explorerDoubleClick)

        return tree
Пример #2
0
    def _initFileExplorer(self):
        """
        Create the File explorer object based on the QFileSystemModel widget.
        """

        if self.dir_type == 'SHARE':
            name = 'Reference'
        elif self.dir_type in ('SRC', 'DATA'):
            name = 'User files'
        else:
            name = 'Name'

        model = FileSystemModel(name)
        if self.root_dir:
            model.setRootPath(self.root_dir)

        tree = QtWidgets.QTreeView(None)

        tree.setModel(model)
        tree.setSortingEnabled(True)
        tree.setWindowTitle('Explorer')
        if self.root_dir:
            tree.setRootIndex(model.index(self.root_dir))

        # Hide unnecessary columns
        nc = tree.header().count()

        for i in range(1, nc):
            tree.hideColumn(i)

        # Right click menu
        tree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        tree.customContextMenuRequested.connect(self.explorerContextMenu)

        # Double click
        tree.doubleClicked.connect(self._explorerDoubleClick)

        return tree