QDirModel Class Reference

[QtGui module]

该QDirModel类提供了在本地文件系统的数据模型。More…

继承QAbstractItemModel

Types

  • enum Roles { FileIconRole, FilePathRole, FileNameRole }

Methods

  • __init__ (self, QStringList nameFilters, QDir.Filters filters, QDir.SortFlags sort, QObject parent = None)
  • __init__ (self, QObject parent = None)
  • int columnCount (self, QModelIndex parent = QModelIndex())
  • QVariant data (self, QModelIndex index, int role = Qt.DisplayRole)
  • bool dropMimeData (self, QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent)
  • QIcon fileIcon (self, QModelIndex index)
  • QFileInfo fileInfo (self, QModelIndex index)
  • QString fileName (self, QModelIndex index)
  • QString filePath (self, QModelIndex index)
  • QDir.Filters filter (self)
  • Qt.ItemFlags flags (self, QModelIndex index)
  • bool hasChildren (self, QModelIndex parent = QModelIndex())
  • QVariant headerData (self, int section, Qt.Orientation orientation, int role = Qt.DisplayRole)
  • QFileIconProvider iconProvider (self)
  • QModelIndex index (self, int row, int column, QModelIndex parent = QModelIndex())
  • QModelIndex index (self, QString path, int column = 0)
  • bool isDir (self, QModelIndex index)
  • bool isReadOnly (self)
  • bool lazyChildCount (self)
  • QMimeData mimeData (self, list-of-QModelIndex indexes)
  • QStringList mimeTypes (self)
  • QModelIndex mkdir (self, QModelIndex parent, QString name)
  • QStringList nameFilters (self)
  • QModelIndex parent (self, QModelIndex child)
  • QObject parent (self)
  • refresh (self, QModelIndex parent = QModelIndex())
  • bool remove (self, QModelIndex index)
  • bool resolveSymlinks (self)
  • bool rmdir (self, QModelIndex index)
  • int rowCount (self, QModelIndex parent = QModelIndex())
  • bool setData (self, QModelIndex index, QVariant value, int role = Qt.EditRole)
  • setFilter (self, QDir.Filters filters)
  • setIconProvider (self, QFileIconProvider provider)
  • setLazyChildCount (self, bool enable)
  • setNameFilters (self, QStringList filters)
  • setReadOnly (self, bool enable)
  • setResolveSymlinks (self, bool enable)
  • setSorting (self, QDir.SortFlags sort)
  • sort (self, int column, Qt.SortOrder order = Qt.AscendingOrder)
  • QDir.SortFlags sorting (self)
  • Qt.DropActions supportedDropActions (self)

Detailed Description

该QDirModel类提供了在本地文件系统的数据模型。

QDirModel的使用是不推荐了。该QFileSystemModel类是一个更高性能的替代方案。

这个类提供了访问本地文件系统,提供了功能重命名和删除文件和目录,并创建新的目录。在最简单的情况下,它可以用于与合适的显示部件作为一个浏览器或者文件管理器的一部分。

QDirModel保持与文件信息的高速缓存。缓存需要与被更新refresh( ) 。

QDirModel可以使用所提供的标准接口来访问QAbstractItemModel的,但它也提供了一些方便的功能所特有的一个目录模型。该fileInfo()和isDir( )函数提供了有关与模型中的项目相关的文件和目录信息。

目录中可以创建和删除使用mkdir( )rmdir( ) ,模型会自动更新,以变化考虑在内。

Note:QDirModel需要一个GUI应用程序的一个实例。


Type Documentation

  1. QDirModel.Roles
Constant Value
QDirModel.FileIconRole Qt.DecorationRole
QDirModel.FilePathRole Qt.UserRole + 1
QDirModel.FileNameRole

Method Documentation

  1. QDirModel.__init__ (self, QStringList nameFilters, QDir.Filters filters, QDir.SortFlags sort, QObject parent = None)

parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。

构造一个新的目录模式与给定parent。只有那些匹配的文件nameFiltersfilters被包括在模型中。排序顺序是由给定sort标志。

  1. QDirModel.__init__ (self, QObject parent = None)

parent的说法,如果不是没有,原因self通过Qt的,而不是PyQt的拥有。

构造一个目录模式与给定parent

  1. int QDirModel.columnCount (self, QModelIndex parent = QModelIndex())

从重新实现QAbstractItemModel.columnCount( ) 。

返回列中的数parent模型项目。

  1. QVariant QDirModel.data (self, QModelIndex index, int role = Qt.DisplayRole)

从重新实现QAbstractItemModel.data( ) 。

返回的数据为模型项目index用给定的role

See also setData( ) 。

  1. bool QDirModel.dropMimeData (self, QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent)

从重新实现QAbstractItemModel.dropMimeData( ) 。

处理data通过拖放操作,与给定的供给结束action过在由指定的模型中的行rowcolumn以及由parent索引。

See also supportedDropActions( ) 。

  1. QIcon QDirModel.fileIcon (self, QModelIndex index)

[

返回根据给定的存储在模型中的图标的项index

](qicon.html)

  1. QFileInfo QDirModel.fileInfo (self, QModelIndex index)

[

返回文件信息指定模型index

]($docs-qfileinfo.html)

Note:如果模型指数代表了底层的文件系统的符号链接时,返回的文件信息,将包含有关符号链接本身的信息,而不管是否resolveSymlinks启用与否。

See also QFileInfo.symLinkTarget( ) 。

  1. QString QDirModel.fileName (self, QModelIndex index)

返回根据存储在模型中的项的名称index给出。

  1. QString QDirModel.filePath (self, QModelIndex index)

返回根据存储在模型中的项的路径index给出。

  1. QDir.Filters QDirModel.filter (self)

[

返回过滤器规格为目录模式。

]($docs-index.htm)

See also setFilter()和QDir.Filters

  1. Qt.ItemFlags QDirModel.flags (self, QModelIndex index)

从重新实现QAbstractItemModel.flags( ) 。

返回项标志为给定的index在模型中。

See also Qt.ItemFlags

  1. bool QDirModel.hasChildren (self, QModelIndex parent = QModelIndex())

从重新实现QAbstractItemModel.hasChildren( ) 。

返回True如果parent模型项目有孩子,否则返回False 。

  1. QVariant QDirModel.headerData (self, int section, Qt.Orientation orientation, int role = Qt.DisplayRole)

从重新实现QAbstractItemModel.headerData( ) 。

返回下指定存储的数据role为指定的section与给定的标头orientation

  1. QFileIconProvider QDirModel.iconProvider (self)

[

返回文件的图标提供商此目录的模式。

]($docs-qfileiconprovider.html)

See also setIconProvider( ) 。

  1. QModelIndex QDirModel.index (self, int row, int column, QModelIndex parent = QModelIndex())

从重新实现QAbstractItemModel.index( ) 。

返回在模型项目索引项parent用给定的rowcolumn

  1. QModelIndex QDirModel.index (self, QString path, int column = 0)

[

这是一个重载函数。

返回模型项指数为给定的path

  1. bool QDirModel.isDir (self, QModelIndex index)

返回True如果模型项目index表示一个目录,否则返回False 。

  1. bool QDirModel.isReadOnly (self)
  1. bool QDirModel.lazyChildCount (self)

]($docs-qmodelindex.html)

  1. QMimeData QDirModel.mimeData (self, list-of-QModelIndex indexes)

[

QMimeData结果

]($docs-qmimedata.html)

从重新实现QAbstractItemModel.mimeData( ) 。

返回一个对象,该对象包含指定的序列化描述indexes。用于描述对应于该索引的项的格式是从所获得的mimeTypes()函数。

如果索引的列表为空,则返回0 ,而不是一个序列化的空单。

  1. QStringList QDirModel.mimeTypes (self)

从重新实现QAbstractItemModel.mimeTypes( ) 。

返回可用于描述在模型中的项列表的MIME类型的列表。

  1. QModelIndex QDirModel.mkdir (self, QModelIndex parent, QString name)

[

创建具有一个目录nameparent模型项目。

  1. QStringList QDirModel.nameFilters (self)

返回应用到该模型中的名称的过滤器列表。

]($docs-qmodelindex.html)

See also setNameFilters( ) 。

  1. QModelIndex QDirModel.parent (self, QModelIndex child)

从重新实现QAbstractItemModel.parent( ) 。

返回给定的父child模型项目。

  1. QObject QDirModel.parent (self)

[

  1. QDirModel.refresh (self, QModelIndex parent = QModelIndex())

](qobject.html)

QDirModel缓存文件信息。这个函数更新缓存。该parent参数是从该模型被更新的目录中,默认值将更新从文件系统(整个模型)的根目录中的模型。

  1. bool QDirModel.remove (self, QModelIndex index)

删除模型项目index从目录模型和deletes the corresponding file from the file system,返回True,如果成功的。如果该项目不能被删除,则返回False。

Warning:此函数删除从文件系统中的文件,它not它们移动到那里他们可以恢复的位置。

See also rmdir( ) 。

  1. bool QDirModel.resolveSymlinks (self)
  1. bool QDirModel.rmdir (self, QModelIndex index)

删除对应的模型项目的目录index在目录中的模型和deletes the corresponding directory from the file system,返回True,如果成功的。如果目录不能被删除,则返回False。

Warning:此函数删除目录的文件系统;它not它们移动到那里他们可以恢复的位置。

See also remove( ) 。

  1. int QDirModel.rowCount (self, QModelIndex parent = QModelIndex())

从重新实现QAbstractItemModel.rowCount( ) 。

返回行的数目parent模型项目。

  1. bool QDirModel.setData (self, QModelIndex index, QVariant value, int role = Qt.EditRole)

从重新实现QAbstractItemModel.setData( ) 。

设置数据模型项目index用给定的role由所引用的数据value。成功返回True ,否则返回False 。

See also data()和Qt.ItemDataRole

  1. QDirModel.setFilter (self, QDir.Filters filters)

设置目录型号的过滤器,通过指定filters

请注意,您设置的过滤器应始终包含QDir.AllDirs枚举值,否则QDirModel将无法读取的目录结构。

See also filter()和QDir.Filters

  1. QDirModel.setIconProvider (self, QFileIconProvider provider)

设置provider文件图标的目录模式。

See also iconProvider( ) 。

  1. QDirModel.setLazyChildCount (self, bool enable)
  1. QDirModel.setNameFilters (self, QStringList filters)

设置名称filters该目录模型。

See also nameFilters( ) 。

  1. QDirModel.setReadOnly (self, bool enable)
  1. QDirModel.setResolveSymlinks (self, bool enable)
  1. QDirModel.setSorting (self, QDir.SortFlags sort)

设置目录模式的排序顺序,通过指定sort

See also sorting()和QDir.SortFlags

  1. QDirModel.sort (self, int column, Qt.SortOrder order = Qt.AscendingOrder)

从重新实现QAbstractItemModel.sort( ) 。

排序的模型项目column使用order给出。该命令是在定义的值Qt.SortOrder

  1. QDir.SortFlags QDirModel.sorting (self)

[

返回用于目录模型的排序方法。

]($docs-index.htm)

See also setSorting()和QDir.SortFlags

  1. Qt.DropActions QDirModel.supportedDropActions (self)

从重新实现QAbstractItemModel.supportedDropActions( ) 。

返回此模型所支持的放置动作。

See also Qt.DropActions