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


Python QtGui.QFileSystemModel类代码示例

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


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

示例1: Explorador

class Explorador(custom_dock.CustomDock):

    def __init__(self, parent=None):
        custom_dock.CustomDock.__init__(self)
        self.explorador = QTreeView()
        self.setWidget(self.explorador)
        self.explorador.header().setHidden(True)
        self.explorador.setAnimated(True)

        # Modelo
        self.modelo = QFileSystemModel(self.explorador)
        path = QDir.toNativeSeparators(QDir.homePath())
        self.modelo.setRootPath(path)
        self.explorador.setModel(self.modelo)
        self.modelo.setNameFilters(["*.c", "*.h", "*.s"])
        self.explorador.setRootIndex(QModelIndex(self.modelo.index(path)))
        self.modelo.setNameFilterDisables(False)

        # Se ocultan algunas columnas
        self.explorador.hideColumn(1)
        self.explorador.hideColumn(2)
        self.explorador.hideColumn(3)

        # Conexion
        self.explorador.doubleClicked.connect(self._abrir_archivo)

        EDIS.cargar_lateral("explorador", self)

    def _abrir_archivo(self, i):
        if not self.modelo.isDir(i):
            indice = self.modelo.index(i.row(), 0, i.parent())
            archivo = self.modelo.filePath(indice)
            principal = EDIS.componente("principal")
            principal.abrir_archivo(archivo)
开发者ID:ekimdev,项目名称:edis,代码行数:34,代码来源:explorador.py

示例2: E4DirCompleter

class E4DirCompleter(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)
        """
        QCompleter.__init__(self, 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:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:29,代码来源:E4Completers.py

示例3: Explorer

class Explorer(QTreeView):

    def __init__(self, parent=None):
        QTreeView.__init__(self)
        self.header().setHidden(True)
        self.setAnimated(True)

        # Modelo
        self.model = QFileSystemModel(self)
        path = QDir.toNativeSeparators(QDir.homePath())
        self.model.setRootPath(path)
        self.setModel(self.model)
        self.model.setNameFilters(["*.c", "*.h", "*.s"])
        self.setRootIndex(QModelIndex(self.model.index(path)))
        self.model.setNameFilterDisables(False)

        # Se ocultan algunas columnas
        self.hideColumn(1)
        self.hideColumn(2)
        self.hideColumn(3)

        # Conexion
        self.doubleClicked.connect(self._open_file)

        Edis.load_lateral("explorer", self)

    def _open_file(self, i):
        if not self.model.isDir(i):
            indice = self.model.index(i.row(), 0, i.parent())
            archivo = self.model.filePath(indice)
            principal = Edis.get_component("principal")
            principal.open_file(archivo)
开发者ID:centaurialpha,项目名称:edis,代码行数:32,代码来源:explorer.py

示例4: DockFileSystem

class DockFileSystem(QDockWidget):

	left = Qt.LeftDockWidgetArea
	right = Qt.RightDockWidgetArea

	def __init__(self, parent = None):
		QDockWidget.__init__(self, "File System Tree View", parent)
		self.setObjectName("FileNavigatorDock")

		self.fsm = QFileSystemModel(self)
		tv = QTreeView(self)
		tv.showColumn(1)
		self.fsm.setRootPath(self.parent().workdir)
		tv.setModel(self.fsm)

		self.setAllowedAreas( self.left | self.right )
		self.setGeometry(0,0,400,1000)

		pb = QPushButton("...",self)
		pb.clicked.connect(self.changeWorkdir)
		self.le = QLineEdit(self)
		self.le.setText(self.parent().workdir)

		dockbox = QWidget(self)
		hl = QHBoxLayout(dockbox)
		hl.addWidget(self.le)
		hl.addWidget(pb)
		hll=QWidget(self)
		hll.setLayout(hl)
		vl = QVBoxLayout(dockbox)
		dockbox.setLayout(vl)
		vl.addWidget(hll)
		vl.addWidget(tv)
		self.setWidget(dockbox)

		self.adjustSize()

		self.parent().say("Vista del sistema de ficheros creada")

	@pyqtSlot()
	def changeWorkdir(self):
		dialog=QFileDialog(self,"Elige directorio de trabajo",self.parent().workdir)
		dialog.setFileMode(QFileDialog.Directory)
		dialog.setAcceptMode(QFileDialog.AcceptOpen)
		if dialog.exec_():
			fichero = dialog.selectedFiles().first().toLocal8Bit().data()
			self.parent().workdir = fichero
			self.le.setText(fichero)
			self.fsm.setRootPath(self.parent().workdir)
开发者ID:LJavierG,项目名称:thesis-cyphers-block-construction,代码行数:49,代码来源:docks.py

示例5: __init__

	def __init__(self, parent = None):
		QDockWidget.__init__(self, "File System Tree View", parent)
		self.setObjectName("FileNavigatorDock")

		self.fsm = QFileSystemModel(self)
		tv = QTreeView(self)
		tv.showColumn(1)
		self.fsm.setRootPath(self.parent().workdir)
		tv.setModel(self.fsm)

		self.setAllowedAreas( self.left | self.right )
		self.setGeometry(0,0,400,1000)

		pb = QPushButton("...",self)
		pb.clicked.connect(self.changeWorkdir)
		self.le = QLineEdit(self)
		self.le.setText(self.parent().workdir)

		dockbox = QWidget(self)
		hl = QHBoxLayout(dockbox)
		hl.addWidget(self.le)
		hl.addWidget(pb)
		hll=QWidget(self)
		hll.setLayout(hl)
		vl = QVBoxLayout(dockbox)
		dockbox.setLayout(vl)
		vl.addWidget(hll)
		vl.addWidget(tv)
		self.setWidget(dockbox)

		self.adjustSize()

		self.parent().say("Vista del sistema de ficheros creada")
开发者ID:LJavierG,项目名称:thesis-cyphers-block-construction,代码行数:33,代码来源:docks.py

示例6: __init__

    def __init__(self, parent=None):
        custom_dock.CustomDock.__init__(self)
        self.explorador = QTreeView()
        self.setWidget(self.explorador)
        self.explorador.header().setHidden(True)
        self.explorador.setAnimated(True)

        # Modelo
        self.modelo = QFileSystemModel(self.explorador)
        path = QDir.toNativeSeparators(QDir.homePath())
        self.modelo.setRootPath(path)
        self.explorador.setModel(self.modelo)
        self.modelo.setNameFilters(["*.c", "*.h", "*.s"])
        self.explorador.setRootIndex(QModelIndex(self.modelo.index(path)))
        self.modelo.setNameFilterDisables(False)

        # Se ocultan algunas columnas
        self.explorador.hideColumn(1)
        self.explorador.hideColumn(2)
        self.explorador.hideColumn(3)

        # Conexion
        self.explorador.doubleClicked.connect(self._abrir_archivo)

        EDIS.cargar_lateral("explorador", self)
开发者ID:ekimdev,项目名称:edis,代码行数:25,代码来源:explorador.py

示例7: _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:daffodil,项目名称:enki,代码行数:8,代码来源:pathcompleter.py

示例8: __init__

 def __init__(self, parent=None):
     QLineEdit.__init__(self, parent)
     self.fsmodel = QFileSystemModel()
     self.fsmodel.setRootPath("")
     self.completer = QCompleter()
     self.completer.setModel(self.fsmodel)
     self.setCompleter(self.completer)
     self.fsmodel.setFilter(QDir.Drives | QDir.AllDirs | QDir.Hidden |
                            QDir.NoDotAndDotDot)
开发者ID:pombredanne,项目名称:mozregression,代码行数:9,代码来源:utils.py

示例9: __init__

    def __init__(self):
        QWidget.__init__(self)
        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(self.tr("Path:")))
        hbox.addWidget(self.pathLine)
        hbox.addWidget(self.btnOpen)

        self.connect(self.pathLine, SIGNAL("returnPressed()"), self._open_file)
        self.connect(self.btnOpen, SIGNAL("clicked()"), self._open_file)
开发者ID:beuno,项目名称:ninja-ide,代码行数:19,代码来源:status_bar.py

示例10: __init__

 def __init__(self, parent=None):
   """Constructor."""
   super(LayerLoaderDialog, self).__init__(parent)
   self.setupUi(self)
   self.completer = QCompleter(self)
   self.fsmodel = QFileSystemModel(self.completer)
   self.fsmodel.setNameFilters(['*.qlf'])
   self.completer.setModel(self.fsmodel)
   self.filename.setCompleter(self.completer)
   self.searchdir.clicked.connect(self.opensearchform)
开发者ID:m-kuhn,项目名称:LayerSaver,代码行数:10,代码来源:layer_loader_dialog.py

示例11: update_dirmodel

 def update_dirmodel(self, path):
     dirmodel = QFileSystemModel()
     dirmodel.setFilter(QDir.NoDotAndDotDot | QDir.AllEntries)
     filefilter = ["*.zip"]
     dirmodel.setNameFilters(filefilter)
     dirmodel.sort(0, Qt.AscendingOrder)
     self.file_treeView.setModel(dirmodel)
     self.file_treeView.header().setResizeMode(3)
     self.file_treeView.model().setRootPath(path)
     self.file_treeView.setRootIndex(self.file_treeView.model().index(path))
开发者ID:cbig,项目名称:gedagui,代码行数:10,代码来源:gui.py

示例12: AttachmentView

class AttachmentView(QListView):
    """ A dockWidget displaying attachments of the current note.
    """

    def __init__(self, parent=None):
        super(AttachmentView, self).__init__(parent)
        self.parent = parent
        self.settings = parent.settings

        self.model = QFileSystemModel()
        self.model.setFilter(QDir.Files)
        self.model.setRootPath(self.settings.attachmentPath)
        self.setModel(self.model)

        # self.setRootIndex(self.model.index(self.settings.attachmentPath))
        self.setViewMode(QListView.IconMode)
        self.setUniformItemSizes(True)
        self.setResizeMode(QListView.Adjust)
        self.setItemDelegate(AttachmentItemDelegate(self))
        self.clicked.connect(self.click)

    def contextMenuEvent(self, event):
        menu = QMenu()
        indice = self.selectedIndexes()
        if len(indice):
            menu.addAction("Insert into note", self.insert)
            menu.addAction("Delete", self.delete)
        else:
            pass
        menu.exec_(event.globalPos())

    def mousePressEvent(self, event):
        """ Trigger click() when an item is pressed.
        """
        self.clearSelection()
        QListView.mousePressEvent(self, event)

    def mouseReleaseEvent(self, event):
        """ Trigger click() when an item is pressed.
        """
        self.clearSelection()
        QListView.mouseReleaseEvent(self, event)

    def insert(self):
        indice = self.selectedIndexes()
        for i in indice:
            filePath = self.model.filePath(i)
            filePath = filePath.replace(self.settings.notebookPath, "..")
            fileName = os.path.basename(filePath)
            text = "![%s](%s)" % (fileName, filePath)
            self.parent.notesEdit.insertPlainText(text)

    def delete(self):
        indice = self.selectedIndexes()
        for i in indice:
            filePath = self.model.filePath(i)
            QFile(filePath).remove()

    def click(self, index):
        self.setCurrentIndex(index)
开发者ID:mjnaderi,项目名称:mikidown,代码行数:60,代码来源:attachment.py

示例13: LayerLoaderDialog

class LayerLoaderDialog(QDialog, FORM_CLASS):
  def __init__(self, parent=None):
    """Constructor."""
    super(LayerLoaderDialog, self).__init__(parent)
    self.setupUi(self)
    self.completer = QCompleter(self)
    self.fsmodel = QFileSystemModel(self.completer)
    self.fsmodel.setNameFilters(['*.qlf'])
    self.completer.setModel(self.fsmodel)
    self.filename.setCompleter(self.completer)
    self.searchdir.clicked.connect(self.opensearchform)

  def opensearchform(self):
    dn = QFileDialog.getOpenFileName(self, self.tr('Choose target directory for layers'), self.filename.text(), '*.qlf' )
    if dn:
      self.filename.setText(dn)

  def set_target_directory(self, dn):
    self.filename.setText(dn)

  def layer(self):
    return self.filename.text()
开发者ID:m-kuhn,项目名称:LayerSaver,代码行数:22,代码来源:layer_loader_dialog.py

示例14: open_project

 def open_project(self, project):
     project_path = project.path
     qfsm = None  # Should end up having a QFileSystemModel
     if project_path not in self.__projects:
         qfsm = QFileSystemModel()
         project.model = qfsm
         qfsm.setRootPath(project_path)
         qfsm.setFilter(QDir.AllDirs | QDir.Files | QDir.NoDotAndDotDot)
         # If set to true items that dont match are displayed disabled
         qfsm.setNameFilterDisables(False)
         pext = ["*{0}".format(x) for x in project.extensions]
         logger.debug(pext)
         qfsm.setNameFilters(pext)
         self.__projects[project_path] = project
         self.__check_files_for(project_path)
         self.emit(SIGNAL("projectOpened(PyQt_PyObject)"), project)
     else:
         qfsm = self.__projects[project_path]
     return qfsm
开发者ID:cags84,项目名称:ninja-ide,代码行数:19,代码来源:nfilesystem.py

示例15: __init__

    def __init__(self, *args):
        super(FileBrowser, self).__init__(*args)

        layout = QVBoxLayout()
        model = QFileSystemModel()

        filters = ["*.jpg", "*.JPG", "*.jpeg", "*.JPEG","*.png","*.PNG"]
        model.setNameFilters(filters)
        
        self.directoryTree = QTreeView()
	self.directoryTree.setModel(model)
        self.directoryTree.currentChanged = self.currentChanged
        self.directoryTree.setSortingEnabled(True)
        self.directoryTree.sortByColumn(0, Qt.AscendingOrder)

        self.fileList = QListWidget()

        layout.addWidget(self.directoryTree)
        self.setLayout(layout)
        
        
        root = model.setRootPath(QDir.homePath())
        self.directoryTree.setRootIndex(root)
开发者ID:aladagemre,项目名称:teleskop,代码行数:23,代码来源:filebrowser.py


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