当前位置: 首页>>代码示例>>Python>>正文


Python QtWidgets.QFileSystemModel类代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QFileSystemModel的典型用法代码示例。如果您正苦于以下问题:Python QFileSystemModel类的具体用法?Python QFileSystemModel怎么用?Python QFileSystemModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QFileSystemModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_file_tree

 def update_file_tree(self):
     model = QFileSystemModel()
     model.setRootPath(self._root_dir)
     self.localFilesTreeView.setModel(model)
     local_selection_model = self.localFilesTreeView.selectionModel()
     local_selection_model.selectionChanged.connect(self.local_file_selection_changed)
     self.localFilesTreeView.setRootIndex(model.index(self._root_dir))
开发者ID:BetaRavener,项目名称:uPyLoader,代码行数:7,代码来源:main_window.py

示例2: E5DirCompleter

class E5DirCompleter(QCompleter):
    """
    Class implementing a completer for directory names.
    """

    def __init__(self, parent=None, completionMode=QCompleter.PopupCompletion, showHidden=False):
        """
        Constructor
        
        @param parent parent widget of the completer (QWidget)
        @keyparam completionMode completion mode of the
            completer (QCompleter.CompletionMode)
        @keyparam showHidden flag indicating to show hidden entries as well
            (boolean)
        """
        super(E5DirCompleter, self).__init__(parent)
        self.__model = QFileSystemModel(self)
        if showHidden:
            self.__model.setFilter(QDir.Filters(QDir.Drives | QDir.AllDirs | QDir.Hidden))
        else:
            self.__model.setFilter(QDir.Filters(QDir.Drives | QDir.AllDirs))
        self.setModel(self.__model)
        self.setCompletionMode(completionMode)
        if isWindowsPlatform():
            self.setCaseSensitivity(Qt.CaseInsensitive)
        if parent:
            parent.setCompleter(self)
开发者ID:paulmadore,项目名称:Eric-IDE,代码行数:27,代码来源:E5Completers.py

示例3: __init__

    def __init__(self, module_manager):
        super(AssetBrowser, self).__init__()
        self.setupUi(self)

        self.init_module(module_manager)

        self.dir_model = QFileSystemModel()
        self.dir_model.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
        self.dir_model.setReadOnly(False)

        self.dir_view.setModel(self.dir_model)
        self.dir_view.hideColumn(1)
        self.dir_view.hideColumn(2)
        self.dir_view.hideColumn(3)

        self.file_model = QFileSystemModel()
        self.file_model.setFilter(QDir.NoDotAndDotDot | QDir.Files)
        self.file_model.setReadOnly(False)

        self.file_view.setModel(self.file_model)

        self.dock = self.modules_manager.new_docked(self, self.Name, "Asset browser",
                                                    Qt.BottomDockWidgetArea)

        self.modules_manager.main_window.splitDockWidget(self.dock,
                                                         self.modules_manager["asset_view"].dock, Qt.Horizontal)
开发者ID:cyberegoorg,项目名称:cetech,代码行数:26,代码来源:assetbrowser.py

示例4: FileTree

class FileTree(QTreeView):
    def __init__(self):
        super(FileTree, self).__init__()
        self.model = QFileSystemModel()
        self.model.setRootPath('')
        self.setModel(self.model)
        self.setAnimated(False)
        self.setIndentation(20)
        self.setSortingEnabled(True)
开发者ID:dormouse,项目名称:test,代码行数:9,代码来源:main.py

示例5: initRootDir

	def initRootDir(self,indexDir):
		if not indexDir:
			return
		self.indexDir = indexDir
		model = QFileSystemModel()
		model.setRootPath('')
		self.setModel(model)
		self.setAnimated(False)
		self.setIndentation(20)
		self.setSortingEnabled(True)
		self.setRootIndex(model.index(self.indexDir))
		for i in range(1,model.columnCount()):
			self.hideColumn(i)
开发者ID:3qwasd,项目名称:jobs,代码行数:13,代码来源:DirectoryView.py

示例6: E5FileCompleter

class E5FileCompleter(QCompleter):
    """
    Class implementing a completer for file names.
    """
    def __init__(self, parent=None,
                 completionMode=QCompleter.PopupCompletion,
                 showHidden=False):
        """
        Constructor
        
        @param parent parent widget of the completer (QWidget)
        @keyparam completionMode completion mode of the
            completer (QCompleter.CompletionMode)
        @keyparam showHidden flag indicating to show hidden entries as well
            (boolean)
        """
        super(E5FileCompleter, self).__init__(parent)
        self.__model = QFileSystemModel(self)
        if showHidden:
            self.__model.setFilter(
                QDir.Filters(QDir.Dirs | QDir.Files | QDir.Drives |
                             QDir.AllDirs | QDir.Hidden))
        else:
            self.__model.setFilter(QDir.Filters(
                QDir.Dirs | QDir.Files | QDir.Drives | QDir.AllDirs))
        self.__model.directoryLoaded.connect(self.complete)
        self.__model.setRootPath("")
        self.setModel(self.__model)
        self.setCompletionMode(completionMode)
        if isWindowsPlatform():
            self.setCaseSensitivity(Qt.CaseInsensitive)
        if parent:
            parent.setCompleter(self)
    
    def setRootPath(self, path):
        """
        Public method to set the root path of the model.
        
        @param path root path for the model
        @type str
        """
        if not os.path.isdir(path):
            path = os.path.dirname(path)
        self.__model.setRootPath(path)
    
    def rootPath(self):
        """
        Public method to get the root path of the model.
        
        @return root path of the model
        @rtype str
        """
        return self.__model.rootPath()
开发者ID:testmana2,项目名称:test,代码行数:53,代码来源:E5Completers.py

示例7: dropMimeData

    def dropMimeData(self, data, action, row, column, parent):
        # print 'dropMimeData %s %s %s %s' % (data.data('text/uri-list'), action, row, parent)

        # print data.text()
        # print data.formats()
        # print data.data('text/uri-list')
        # print row, "row"
        # print column, "col"
        # print action, "action"
        # print parent, "parent"
        # print parent.data(Qt.DisplayRole),"parent"

        filePath = data.data('text/uri-list').data()[7:]
        # filesFolderPath = filePath  # canonical , os path parent falan

        fileName = os.path.basename(filePath)
        # fileName = ""
        # print type(filePath.data())
        # print fileName

        # os.path.normpath(unicode(self.model().fileInfo(self.selectedIndexes()[0]).absoluteFilePath()))

        # dfolder = self.fileInfo(parent).absoluteFilePath()
        destFinalPath = os.path.normpath("%s/%s" % (self.filePath(parent), fileName))

        # ya da emit.fileMoved filepath move to destFolder+filename
        self.fileDraggedAndMoved.emit("%s -------->   %s" % (filePath, destFinalPath))

        # return True
        return QFileSystemModel.dropMimeData(self, data, action, row, column, parent)
开发者ID:erdinc-me,项目名称:Defter3,代码行数:30,代码来源:treeFsModel.py

示例8: _init_ui

    def _init_ui(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        model = QFileSystemModel(self)
        model.setRootPath('')
        view = QTreeView()
        view.setModel(model)

        view.setAnimated(False)
        view.setIndentation(20)
        view.setSortingEnabled(True)

        layout = QVBoxLayout()
        layout.addWidget(view)
        self.setLayout(layout)
开发者ID:nnaabbcc,项目名称:exercise,代码行数:16,代码来源:25_directory_view_test.py

示例9: __init__

    def __init__(self, path):
        super(NProject, self).__init__()
        project = json_manager.read_ninja_project(path)

        self.path = path
        self._name = project.get('name', '')
        if self._name == '':
            self._name = file_manager.get_basename(path)
        self.project_type = project.get('project-type', '')
        self.description = project.get('description', '')
        if self.description == '':
            self.description = translations.TR_NO_DESCRIPTION
        self.url = project.get('url', '')
        self.license = project.get('license', '')
        self.main_file = project.get('mainFile', '')
        self.pre_exec_script = project.get('preExecScript', '')
        self.post_exec_script = project.get('postExecScript', '')
        self.indentation = project.get('indentation', settings.INDENT)
        self.use_tabs = project.get('use-tabs', settings.USE_TABS)
        self.extensions = project.get('supported-extensions',
            settings.SUPPORTED_EXTENSIONS)
        self.python_exec = project.get('pythonExec', settings.PYTHON_EXEC)
        self.python_path = project.get('PYTHONPATH', '')
        self.additional_builtins = project.get('additional_builtins', [])
        self.program_params = project.get('programParams', '')
        self.venv = project.get('venv', '')
        self.related_projects = project.get('relatedProjects', [])
        self.added_to_console = False
        self.is_current = False
        #Model is a QFileSystemModel to be set on runtime
        self.__model = QFileSystemModel()
        self.__model.setRootPath(path)
开发者ID:Salmista-94,项目名称:Ninja_3.0_PyQt5,代码行数:32,代码来源:nproject.py

示例10: _iconForPath

    def _iconForPath(self, path):
        """Get icon for file or directory path. Uses QFileSystemModel
        """
        if self._model is None:
            self._model = QFileSystemModel()

        index = self._model.index(path)
        return self._model.data(index, Qt.DecorationRole)
开发者ID:freason,项目名称:enki,代码行数:8,代码来源:pathcompleter.py

示例11: __init__

    def __init__(self):
        super(AssetBrowser, self).__init__()
        self.setupUi(self)

        self.dir_model = QFileSystemModel()
        self.dir_model.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
        self.dir_model.setReadOnly(False)

        self.dir_view.setModel(self.dir_model)
        self.dir_view.hideColumn(1)
        self.dir_view.hideColumn(2)
        self.dir_view.hideColumn(3)

        self.file_model = QFileSystemModel()
        self.file_model.setFilter(QDir.NoDotAndDotDot | QDir.Files)
        self.file_model.setReadOnly(False)

        self.file_view.setModel(self.file_model)
开发者ID:gitter-badger,项目名称:cetech,代码行数:18,代码来源:assetbrowser.py

示例12: load_dir

    def load_dir(self, dir_path):
        if dir_path == self.dir_path:
            return

        self.dir_path = dir_path

        model = QFileSystemModel()
        model.setRootPath(dir_path)
        self.setModel(model)

        index_root = model.index(model.rootPath())
        self.setRootIndex(index_root)

        # hide unwanted info
        self.hideColumn(1)
        self.hideColumn(2)
        self.hideColumn(3)
        self.setHeaderHidden(True)
开发者ID:dormouse,项目名称:laketai,代码行数:18,代码来源:run.py

示例13: ComplexDialog

class ComplexDialog(QDialog, Ui_ComplexForm):

	def __init__(self, parent=None):
		super(ComplexDialog, self).__init__(parent)
		self.setupUi(self)
		self.file_model = QFileSystemModel()
		self.bundle_model = QStringListModel()
		bundle_lists = []
		self.bundle_model.setStringList(bundle_lists)

		root = self.file_model.setRootPath("/Volumes")



		self.columnView_files.setModel(self.file_model)
		self.columnView_files.setRootIndex(root)
		self.listView_files.setModel(self.bundle_model)

		# connect the buttons
		self.pushButton_add_file.clicked.connect(self._add_to_bundle)
		self.pushButton_remove_file.clicked.connect(self._remove_from_bundle)
		self.pushButton_cancle.clicked.connect(self.close_window)
		self.pushButton_add_object.clicked.connect(self.return_bundle)



	def _add_to_bundle(self):
		selection = self.columnView_files.selectedIndexes()
		files = self.bundle_model.stringList()
		model = self.columnView_files.model()
		for index in selection:
			# path = os.path.join()
			if model.isDir(index):
				continue
			newfile = model.filePath(index)
			files.append(newfile)
		self.bundle_model.setStringList(files)
			# self.bundle_model.inser

	def _remove_from_bundle(self):
		selection = self.listView_files.selectedIndexes()
		model = self.listView_files.model()
		for index in selection:
			row = index.row()
			model.removeRows(row, 1)

	def return_bundle(self):
		self.close_window()

	@property
	def bundle(self):
		return self.bundle_model.stringList()

	def close_window(self):
		self.close()
开发者ID:cavpp,项目名称:image_rename_and_convert,代码行数:55,代码来源:complex_gui.py

示例14: __init__

    def __init__(self):
        super(FileSystemOpener, self).__init__()
        hbox = QHBoxLayout(self)
        hbox.setContentsMargins(0, 0, 0, 0)
        self.btnClose = QPushButton(
            self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self.completer = QCompleter(self)
        self.pathLine = ui_tools.LineEditTabCompleter(self.completer)
        fileModel = QFileSystemModel(self.completer)
        fileModel.setRootPath("")
        self.completer.setModel(fileModel)
        self.pathLine.setCompleter(self.completer)
        self.btnOpen = QPushButton(
            self.style().standardIcon(QStyle.SP_ArrowRight), 'Open!')
        hbox.addWidget(self.btnClose)
        hbox.addWidget(QLabel(_translate("FileSystemOpener", "Path:")))
        hbox.addWidget(self.pathLine)
        hbox.addWidget(self.btnOpen)

        self.pathLine.returnPressed.connect(self._open_file)
        self.btnOpen.clicked['bool'].connect(self._open_file)
开发者ID:Salmista-94,项目名称:Ninja_PyQt5,代码行数:21,代码来源:status_bar.py

示例15: LocalPathView

class LocalPathView(QTreeView):
    def __init__ (self):
        super(LocalPathView, self).__init__()
        self._model = QFileSystemModel()
        self._model.setFilter(QDir.Dirs | QDir.Drives | QDir.NoDotAndDotDot | QDir.AllDirs)
        self._model.setRootPath('')
        self.setModel(self._model )

        self.hideColumn(1); # removing Size Column
        self.hideColumn(2); # removing Type Column
        self.setAnimated(False)
        self.setSortingEnabled(True)
        self.header().setSortIndicator(0, Qt.AscendingOrder)

        width = self.size().width() >> 1
        self.setColumnWidth(0, width*0.7)
        self.setColumnWidth(1, width*0.3)

        index = self._model.index(QDir.currentPath())
        self.selectionModel().setCurrentIndex(index, QItemSelectionModel.Select | QItemSelectionModel.Rows)
        self.expand(index)
        self.scrollTo(index)

    @property
    def selectedDir(self):
        return self._model.filePath(self.selectionModel().selectedIndexes()[0])
开发者ID:imelentsov,项目名称:amrecover,代码行数:26,代码来源:amrecover.py


注:本文中的PyQt5.QtWidgets.QFileSystemModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。