|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.core.QAbstractItemModel
com.trolltech.qt.gui.QFileSystemModel
public class QFileSystemModel
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.
Nested Class Summary | |
---|---|
static class |
QFileSystemModel.Roles
|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Field Summary | |
---|---|
QSignalEmitter.Signal3 |
fileRenamed
This signal is emitted whenever a file with the oldName is successfully renamed to newName. |
QSignalEmitter.Signal1 |
rootPathChanged
This signal is emitted whenever the root path has been changed to a newPath. |
Fields inherited from class com.trolltech.qt.core.QAbstractItemModel |
---|
dataChanged, headerDataChanged, layoutAboutToBeChanged, layoutChanged |
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(QModelIndex index)
Returns the icon for the item stored in the model under the given index. |
QFileInfo |
fileInfo(QModelIndex index)
Returns the QFileInfo for the item stored in the model under the given index. |
java.lang.String |
fileName(QModelIndex index)
Returns the file name for the item stored in the model under the given index. |
java.lang.String |
filePath(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. |
static QFileSystemModel |
fromNativePointer(QNativePointer nativePointer)
|
QFileIconProvider |
iconProvider()
Returns the file icon provider for this directory model. |
QModelIndex |
index(java.lang.String path)
Returns the model item index for the given path and column. |
QModelIndex |
index(java.lang.String path,
int column)
Returns the model item index for the given path and column. |
boolean |
isDir(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(QModelIndex index)
Returns the date and time when index was last modified. |
QModelIndex |
mkdir(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(QModelIndex index)
Returns the complete OR-ed together combination of QFile::Permission for the index. |
boolean |
remove(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(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. |
QModelIndex |
setRootPath(java.lang.String path)
Sets the directory that is being watched by the model to newPath. |
long |
size(QModelIndex index)
Returns the size in bytes of index. |
java.lang.String |
type(QModelIndex index)
Returns the type of file index such as "Directory" or "JPEG file". |
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 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 |
---|
public final QSignalEmitter.Signal3 fileRenamed
public final QSignalEmitter.Signal1 rootPathChanged
Constructor Detail |
---|
public QFileSystemModel()
public QFileSystemModel(QObject parent)
Method Detail |
---|
public final QIcon fileIcon(QModelIndex index)
public final QFileInfo fileInfo(QModelIndex index)
QFileInfo
for the item stored in the model under the given index.
public final java.lang.String fileName(QModelIndex index)
public final java.lang.String filePath(QModelIndex index)
public final QDir.Filters filter()
setFilter()
, and QDir::Filters.
public final QFileIconProvider iconProvider()
setIconProvider()
.
public final QModelIndex index(java.lang.String path)
public final QModelIndex index(java.lang.String path, int column)
public final boolean isDir(QModelIndex index)
public final boolean isReadOnly()
This property is true by default
public final QDateTime lastModified(QModelIndex index)
public final QModelIndex mkdir(QModelIndex parent, java.lang.String name)
public final java.lang.Object myComputer()
Qt::ItemDataRole
.
public final java.lang.Object myComputer(int role)
Qt::ItemDataRole
.
public final boolean nameFilterDisables()
public final java.util.List nameFilters()
setNameFilters()
.
public final QFile.Permissions permissions(QModelIndex index)
QFile::Permission
for the index.
public final boolean remove(QModelIndex index)
Warning: This function deletes files from the file system; it does not move them to a location where they can be recovered.
rmdir()
.
public final boolean resolveSymlinks()
public final boolean rmdir(QModelIndex index)
Warning: This function deletes directories from the file system; it does not move them to a location where they can be recovered.
remove()
.
public final QDir rootDirectory()
rootPath()
.
public final java.lang.String rootPath()
setRootPath()
, and rootDirectory()
.
public final void setFilter(QDir.Filter[] 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.
filter()
, and QDir::Filters.
public final void setFilter(QDir.Filters 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.
filter()
, and QDir::Filters.
public final void setIconProvider(QFileIconProvider provider)
iconProvider()
.
public final void setNameFilterDisables(boolean enable)
public final void setNameFilters(java.util.List filters)
nameFilters()
.
public final void setReadOnly(boolean enable)
This property is true by default
public final void setResolveSymlinks(boolean enable)
public final QModelIndex setRootPath(java.lang.String path)
rootPath()
.
public final long size(QModelIndex index)
public final java.lang.String type(QModelIndex index)
public static QFileSystemModel fromNativePointer(QNativePointer nativePointer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |