Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QFileSystemModel

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.core.QAbstractItemModel
                          com.trolltech.qt.gui.QFileSystemModel

All Implemented Interfaces:
  QtJambiInterface

    public class QFileSystemModel

extends QAbstractItemModel

The `QFileSystemModel` class provides a data model for the local filesystem. This class provides access to the local filesystem, providing functions for renaming and removing files and directories, and for creating new directories. In the simplest case, it can be used with a suitable display widget as part of a browser or filter.

`QFileSystemModel` will not fetch any files or directories until setRootPath is called. This will prevent any unnecessary querying on the file system until that point such as listing the drives on Windows.

Unlike the `QDirModel`, `QFileSystemModel` uses a separate thread to populate itself so it will not cause the main thread to hang as the file system is being queried. Calls to `rowCount()` will return 0 until the model populates a directory.

`QFileSystemModel` keeps a cache with file information. The cache is automatically kept up to date using the `QFileSystemWatcher`.

`QFileSystemModel` can be accessed using the standard interface provided by `QAbstractItemModel`, but it also provides some convenience functions that are specific to a directory model. The `fileInfo()`, `isDir()`, name(), and path() functions provide information about the underlying files and directories related to items in the model. Directories can be created and removed using `mkdir()`, `rmdir()`.

Note:`QFileSystemModel` requires an instance of a GUI application.

See also:
  Model Classes.

Nested Class Summary
`static class` | `QFileSystemModel.Roles`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal3` | `fileRenamed` This signal takes 3 generic argument(s).
`QSignalEmitter.Signal1` | `rootPathChanged` This signal takes 1 generic argument(s).

Fields inherited from class com.trolltech.qt.core.QAbstractItemModel
`dataChanged, headerDataChanged, layoutAboutToBeChanged, layoutChanged`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QFileSystemModel()` Constructs a file system model with the given `parent`.
`QFileSystemModel(QObject parent)` Constructs a file system model with the given `parent`.

Method Summary
`QIcon` | `fileIcon(com.trolltech.qt.core.QModelIndex index)` Returns the icon for the item stored in the model under the given `index`.
`QFileInfo` | `fileInfo(com.trolltech.qt.core.QModelIndex index)` Returns the `QFileInfo` for the item stored in the model under the given `index`.
`java.lang.String` | `fileName(com.trolltech.qt.core.QModelIndex index)` Returns the file name for the item stored in the model under the given `index`.
`java.lang.String` | `filePath(com.trolltech.qt.core.QModelIndex index)` Returns the path of the item stored in the model under the `index` given.
`QDir.Filters` | `filter()` Returns the filter specification for the directory model.
`QFileIconProvider` | `iconProvider()` Returns the file icon provider for this directory model.
`com.trolltech.qt.core.QModelIndex` | `index(java.lang.String path)` Returns the model item index for the given `path` and `column`.
`com.trolltech.qt.core.QModelIndex` | `index(java.lang.String path, int column)` Returns the model item index for the given `path` and `column`.
`boolean` | `isDir(com.trolltech.qt.core.QModelIndex index)` Returns true if the model item `index` represents a directory; otherwise returns false.
`boolean` | `isReadOnly()` This property holds Whether the directory model allows writing to the file system.
`QDateTime` | `lastModified(com.trolltech.qt.core.QModelIndex index)` Returns the date and time when `index` was last modified.
`com.trolltech.qt.core.QModelIndex` | `mkdir(com.trolltech.qt.core.QModelIndex parent, java.lang.String name)` Create a directory with the `name` in the `parent` model index.
`java.lang.Object` | `myComputer()` Returns the data stored under the given `role` for the item "My Computer".
`java.lang.Object` | `myComputer(int role)` Returns the data stored under the given `role` for the item "My Computer".
`boolean` | `nameFilterDisables()` This property holds Whether files that don't pass the name filter are hidden or disabled.
`java.util.List` | `nameFilters()` Returns a list of filters applied to the names in the model.
`QFile.Permissions` | `permissions(com.trolltech.qt.core.QModelIndex index)` Returns the complete OR-ed together combination of `QFile::Permission` for the `index`.
`boolean` | `remove(com.trolltech.qt.core.QModelIndex index)` Removes the model item `index` from the file system model and deletes the corresponding file from the file system, returning true if successful.
`boolean` | `resolveSymlinks()` This property holds Whether the directory model should resolve symbolic links.
`boolean` | `rmdir(com.trolltech.qt.core.QModelIndex index)` Removes the directory corresponding to the model item `index` in the file system model and deletes the corresponding directory from the file system, returning true if successful.
`QDir` | `rootDirectory()` The currently set directory
`java.lang.String` | `rootPath()` The currently set root path
`void` | `setFilter(QDir.Filter[] filters)` Sets the directory model's filter to that specified by `filters`.
`void` | `setFilter(QDir.Filters filters)` Sets the directory model's filter to that specified by `filters`.
`void` | `setIconProvider(QFileIconProvider provider)` Sets the `provider` of file icons for the directory model.
`void` | `setNameFilterDisables(boolean enable)` This property holds Whether files that don't pass the name filter are hidden or disabled.
`void` | `setNameFilters(java.util.List filters)` Sets the name `filters` to apply against the existing files.
`void` | `setReadOnly(boolean enable)` This property holds Whether the directory model allows writing to the file system.
`void` | `setResolveSymlinks(boolean enable)` This property holds Whether the directory model should resolve symbolic links.
`com.trolltech.qt.core.QModelIndex` | `setRootPath(java.lang.String path)` Sets the directory that is being watched by the model to `newPath`.
`long` | `size(com.trolltech.qt.core.QModelIndex index)` Returns the size in bytes of `index`.
`java.lang.String` | `type(com.trolltech.qt.core.QModelIndex index)` Returns the type of file `index` such as "Directory" or "JPEG file".

Methods inherited from class com.trolltech.qt.core.QAbstractItemModel
`beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, buddy, canFetchMore, changePersistentIndex, changePersistentIndexList, columnCount, columnCount, createIndex, createIndex, createIndex, data, data, data, data, dropMimeData, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, fetchMore, flags, hasChildren, hasChildren, hasIndex, hasIndex, headerData, headerData, index, index, insertColumn, insertColumn, insertColumns, insertColumns, insertRow, insertRow, insertRows, insertRows, itemData, match, match, match, match, mimeData, mimeTypes, parent, persistentIndexList, removeColumn, removeColumn, removeColumns, removeColumns, removeRow, removeRow, removeRows, removeRows, reset, revert, rowCount, rowCount, setData, setData, setData, setData, setHeaderData, setHeaderData, setItemData, setSupportedDragActions, setSupportedDragActions, sibling, sort, sort, span, submit, supportedDragActions, supportedDropActions`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### fileRenamed

    public final QSignalEmitter.Signal3 fileRenamed

  This signal takes 3 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: path), java.lang.String(named: oldName), java.lang.String(named: newName)>:

  This signal is emitted whenever a file with the `oldName` is successfully renamed to `newName`. The file is located in in the directory `path`.

### rootPathChanged

    public final QSignalEmitter.Signal1 rootPathChanged

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: newPath)>:

  This signal is emitted whenever the root path has been changed to a `newPath`.

Constructor Detail

### QFileSystemModel

    public QFileSystemModel()

  Constructs a file system model with the given `parent`.

### QFileSystemModel

    public QFileSystemModel(QObject parent)

  Constructs a file system model with the given `parent`.

Method Detail

### fileIcon

    public final QIcon fileIcon(com.trolltech.qt.core.QModelIndex index)

  Returns the icon for the item stored in the model under the given `index`.

### fileInfo

    public final QFileInfo fileInfo(com.trolltech.qt.core.QModelIndex index)

  Returns the `QFileInfo` for the item stored in the model under the given `index`.

### fileName

    public final java.lang.String fileName(com.trolltech.qt.core.QModelIndex index)

  Returns the file name for the item stored in the model under the given `index`.

### filePath

    public final java.lang.String filePath(com.trolltech.qt.core.QModelIndex index)

  Returns the path of the item stored in the model under the `index` given.

### filter

    public final QDir.Filters filter()

  Returns the filter specification for the directory model.

See also:
  `setFilter()`, and QDir::Filters.

### iconProvider

    public final QFileIconProvider iconProvider()

  Returns the file icon provider for this directory model.

See also:
  `setIconProvider()`.

### index

    public final com.trolltech.qt.core.QModelIndex index(java.lang.String path)

  Returns the model item index for the given `path` and `column`.

### index

    public final com.trolltech.qt.core.QModelIndex index(java.lang.String path,
                                                         int column)

  Returns the model item index for the given `path` and `column`.

### isDir

    public final boolean isDir(com.trolltech.qt.core.QModelIndex index)

  Returns true if the model item `index` represents a directory; otherwise returns false.

### isReadOnly

    public final boolean isReadOnly()

  This property holds Whether the directory model allows writing to the file system. If this property is set to false, the directory model will allow renaming, copying and deleting of files and directories.

  This property is true by default

### lastModified

    public final QDateTime lastModified(com.trolltech.qt.core.QModelIndex index)

  Returns the date and time when `index` was last modified.

### mkdir

    public final com.trolltech.qt.core.QModelIndex mkdir(com.trolltech.qt.core.QModelIndex parent,
                                                         java.lang.String name)

  Create a directory with the `name` in the `parent` model index.

### myComputer

    public final java.lang.Object myComputer()

  Returns the data stored under the given `role` for the item "My Computer".

See also:
  `Qt::ItemDataRole` .

### myComputer

    public final java.lang.Object myComputer(int role)

  Returns the data stored under the given `role` for the item "My Computer".

See also:
  `Qt::ItemDataRole` .

### nameFilterDisables

    public final boolean nameFilterDisables()

  This property holds Whether files that don't pass the name filter are hidden or disabled. This property is true by default

### nameFilters

    public final java.util.List nameFilters()

  Returns a list of filters applied to the names in the model.

See also:
  `setNameFilters()`.

### permissions

    public final QFile.Permissions permissions(com.trolltech.qt.core.QModelIndex index)

  Returns the complete OR-ed together combination of `QFile::Permission` for the `index`.

### remove

    public final boolean remove(com.trolltech.qt.core.QModelIndex index)

  Removes the model item `index` from the file system model and deletes the corresponding file from the file system, returning true if successful. If the item cannot be removed, false is returned.

  Warning: This function deletes files from the file system; it does not move them to a location where they can be recovered.

See also:
  `rmdir()`.

### resolveSymlinks

    public final boolean resolveSymlinks()

  This property holds Whether the directory model should resolve symbolic links. This is only relevant on operating systems that support symbolic links.

  By default, this property is false.

### rmdir

    public final boolean rmdir(com.trolltech.qt.core.QModelIndex index)

  Removes the directory corresponding to the model item `index` in the file system model and deletes the corresponding directory from the file system, returning true if successful. If the directory cannot be removed, false is returned.

  Warning: This function deletes directories from the file system; it does not move them to a location where they can be recovered.

See also:
  `remove()`.

### rootDirectory

    public final QDir rootDirectory()

  The currently set directory

See also.
  `rootPath()`.

### rootPath

    public final java.lang.String rootPath()

  The currently set root path

See also.
  `setRootPath()`, and `rootDirectory()`.

### setFilter

    public final void setFilter(QDir.Filter[] filters)

  Sets the directory model's filter to that specified by `filters`.

  Note that the filter you set should always include the `QDir::AllDirs` enum value, otherwise `QFileSystemModel` won't be able to read the directory structure.

See also:
  `filter()`, and QDir::Filters.

### setFilter

    public final void setFilter(QDir.Filters filters)

  Sets the directory model's filter to that specified by `filters`.

  Note that the filter you set should always include the `QDir::AllDirs` enum value, otherwise `QFileSystemModel` won't be able to read the directory structure.

See also:
  `filter()`, and QDir::Filters.

### setIconProvider

    public final void setIconProvider(QFileIconProvider provider)

  Sets the `provider` of file icons for the directory model.

See also:
  `iconProvider()`.

### setNameFilterDisables

    public final void setNameFilterDisables(boolean enable)

  This property holds Whether files that don't pass the name filter are hidden or disabled. This property is true by default

### setNameFilters

    public final void setNameFilters(java.util.List filters)

  Sets the name `filters` to apply against the existing files.

See also:
  `nameFilters()`.

### setReadOnly

    public final void setReadOnly(boolean enable)

  This property holds Whether the directory model allows writing to the file system. If this property is set to false, the directory model will allow renaming, copying and deleting of files and directories.

  This property is true by default

### setResolveSymlinks

    public final void setResolveSymlinks(boolean enable)

  This property holds Whether the directory model should resolve symbolic links. This is only relevant on operating systems that support symbolic links.

  By default, this property is false.

### setRootPath

    public final com.trolltech.qt.core.QModelIndex setRootPath(java.lang.String path)

  Sets the directory that is being watched by the model to `newPath`. If the path is changed the model will be reset.

See also:
  `rootPath()`.

### size

    public final long size(com.trolltech.qt.core.QModelIndex index)

  Returns the size in bytes of `index`. If the file does not exist, 0 is returned.

### type

    public final java.lang.String type(com.trolltech.qt.core.QModelIndex index)

  Returns the type of file `index` such as "Directory" or "JPEG file".

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD