|
|||||||||
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.QDirModel
public class QDirModel
The QDirModel
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 filer.
QDirModel
keeps a cache with file information. The cache needs to be updated with refresh()
.
A directory model that displays the contents of a default directory is usually constructed with a parent object:
QDirModel model = new QDirModel();A tree view can be used to display the contents of the model
QTreeView tree = new QTreeView(splitter); tree.setModel(model);and the contents of a particular directory can be displayed by setting the tree view's root index:
tree.setRootIndex(model.index(QDir.currentPath()));The view's root index can be used to control how much of a hierarchical model is displayed.
QDirModel
provides a convenience function that returns a suitable model index for a path to a directory within the model. QDirModel
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()
and isDir()
functions provide information about the underlying files and directories related to items in the model.
Directories can be created and removed using mkdir()
, rmdir()
, and the model will be automatically updated to take the changes into account.
Note:QDirModel
requires an instance of a GUI application.
nameFilters()
, setFilter()
, filter()
, QListView
, QTreeView
, Dir View Example, and Model Classes.
Nested Class Summary | |
---|---|
static class |
QDirModel.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 |
---|
Fields inherited from class com.trolltech.qt.core.QAbstractItemModel |
---|
dataChanged, headerDataChanged, layoutAboutToBeChanged, layoutChanged |
Constructor Summary | |
---|---|
QDirModel()
Constructs a directory model with the given parent. |
|
QDirModel(java.util.List nameFilters,
QDir.Filters filters,
QDir.SortFlags sort)
Constructs a new directory model with the given parent. |
|
QDirModel(java.util.List nameFilters,
QDir.Filters filters,
QDir.SortFlags sort,
QObject parent)
Constructs a new directory model with the given parent. |
|
QDirModel(QObject parent)
Constructs a directory model with the given parent. |
Method Summary | |
---|---|
QIcon |
fileIcon(QModelIndex index)
Returns the icons for the item stored in the model under the given index. |
QFileInfo |
fileInfo(QModelIndex index)
Returns the file information for the specified model index. |
java.lang.String |
fileName(QModelIndex index)
Returns the name of the item stored in the model under the index given. |
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 QDirModel |
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. |
QModelIndex |
index(java.lang.String path,
int column)
Returns the model item index for the given path. |
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. |
boolean |
lazyChildCount()
This property holds Whether the directory model optimizes the hasChildren function to only check if the item is a directory. |
QModelIndex |
mkdir(QModelIndex parent,
java.lang.String name)
Create a directory with the name in the parent model item. |
java.util.List |
nameFilters()
Returns a list of filters applied to the names in the model. |
void |
refresh()
QDirModel caches file information. |
void |
refresh(QModelIndex parent)
QDirModel caches file information. |
boolean |
remove(QModelIndex index)
Removes the model item index from the directory 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 directory model and deletes the corresponding directory from the file system, returning true if successful. |
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 |
setLazyChildCount(boolean enable)
This property holds Whether the directory model optimizes the hasChildren function to only check if the item is a directory. |
void |
setNameFilters(java.util.List filters)
Sets the name filters for the directory model. |
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. |
void |
setSorting(QDir.SortFlag[] sort)
Sets the directory model's sorting order to that specified by sort. |
void |
setSorting(QDir.SortFlags sort)
Sets the directory model's sorting order to that specified by sort. |
QDir.SortFlags |
sorting()
Returns the sorting method used for the directory model. |
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 |
Constructor Detail |
---|
public QDirModel()
public QDirModel(QObject parent)
public QDirModel(java.util.List nameFilters, QDir.Filters filters, QDir.SortFlags sort)
public QDirModel(java.util.List nameFilters, QDir.Filters filters, QDir.SortFlags sort, QObject parent)
Method Detail |
---|
public final QIcon fileIcon(QModelIndex index)
public final QFileInfo fileInfo(QModelIndex index)
Note: If the model index represents a symbolic link in the underlying filing system, the file information returned will contain information about the symbolic link itself, regardless of whether resolveSymlinks
is enabled or not.
QFileInfo::symLinkTarget()
.
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 boolean lazyChildCount()
hasChildren
function to only check if the item is a directory. If this property is set to false, the directory model will make sure that a directory actually containes any files before reporting that it has children. Otherwise the directory model will report that an item has children if the item is a directory. This property is false by default
public final QModelIndex mkdir(QModelIndex parent, java.lang.String name)
public final java.util.List nameFilters()
setNameFilters()
.
public final void refresh()
QDirModel
caches file information. This function updates the cache. The parent parameter is the directory from which the model is updated; the default value will update the model from root directory of the file system (the entire model).
public final void refresh(QModelIndex parent)
QDirModel
caches file information. This function updates the cache. The parent parameter is the directory from which the model is updated; the default value will update the model from root directory of the file system (the entire model).
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 void setFilter(QDir.Filter[] filters)
Note that the filter you set should always include the QDir::AllDirs
enum value, otherwise QDirModel
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 QDirModel
won't be able to read the directory structure.
filter()
, and QDir::Filters.
public final void setIconProvider(QFileIconProvider provider)
iconProvider()
.
public final void setLazyChildCount(boolean enable)
hasChildren
function to only check if the item is a directory. If this property is set to false, the directory model will make sure that a directory actually containes any files before reporting that it has children. Otherwise the directory model will report that an item has children if the item is a directory. This property is false by default
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 void setSorting(QDir.SortFlag[] sort)
sorting()
, and QDir::SortFlags.
public final void setSorting(QDir.SortFlags sort)
sorting()
, and QDir::SortFlags.
public final QDir.SortFlags sorting()
setSorting()
, and QDir::SortFlags.
public static QDirModel fromNativePointer(QNativePointer nativePointer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |