Qt 4.8
|
The QDirModel class provides a data model for the local filesystem. More...
#include <qdirmodel.h>
Public Types | |
enum | Roles { FileIconRole = Qt::DecorationRole, FilePathRole = Qt::UserRole + 1, FileNameRole } |
Public Slots | |
void | refresh (const QModelIndex &parent=QModelIndex()) |
QDirModel caches file information. More... | |
Public Slots inherited from QAbstractItemModel | |
virtual void | revert () |
Lets the model know that it should discard cached information. More... | |
virtual bool | submit () |
Lets the model know that it should submit cached information to permanent storage. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Public Functions | |
int | columnCount (const QModelIndex &parent=QModelIndex()) const |
Returns the number of columns in the parent model item. More... | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
Returns the data for the model item index with the given role. More... | |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
Handles the data supplied by a drag and drop operation that ended with the given action over the row in the model specified by the row and column and by the parent index. More... | |
QIcon | fileIcon (const QModelIndex &index) const |
Returns the icons for the item stored in the model under the given index. More... | |
QFileInfo | fileInfo (const QModelIndex &index) const |
Returns the file information for the specified model index. More... | |
QString | fileName (const QModelIndex &index) const |
Returns the name of the item stored in the model under the index given. More... | |
QString | filePath (const QModelIndex &index) const |
Returns the path of the item stored in the model under the index given. More... | |
QDir::Filters | filter () const |
Returns the filter specification for the directory model. More... | |
Qt::ItemFlags | flags (const QModelIndex &index) const |
Returns the item flags for the given index in the model. More... | |
bool | hasChildren (const QModelIndex &index=QModelIndex()) const |
Returns true if the parent model item has children; otherwise returns false. More... | |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
Returns the data stored under the given role for the specified section of the header with the given orientation. More... | |
QFileIconProvider * | iconProvider () const |
Returns the file icon provider for this directory model. More... | |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
Returns the model item index for the item in the parent with the given row and column. More... | |
QModelIndex | index (const QString &path, int column=0) const |
Returns the model item index for the given path. More... | |
bool | isDir (const QModelIndex &index) const |
Returns true if the model item index represents a directory; otherwise returns false. More... | |
bool | isReadOnly () const |
bool | lazyChildCount () const |
QMimeData * | mimeData (const QModelIndexList &indexes) const |
Returns an object that contains a serialized description of the specified indexes. More... | |
QStringList | mimeTypes () const |
Returns a list of MIME types that can be used to describe a list of items in the model. More... | |
QModelIndex | mkdir (const QModelIndex &parent, const QString &name) |
Create a directory with the name in the parent model item. More... | |
QStringList | nameFilters () const |
Returns a list of filters applied to the names in the model. More... | |
QModelIndex | parent (const QModelIndex &child) const |
Return the parent of the given child model item. More... | |
QDirModel (const QStringList &nameFilters, QDir::Filters filters, QDir::SortFlags sort, QObject *parent=0) | |
Constructs a new directory model with the given parent. More... | |
QDirModel (QObject *parent=0) | |
Constructs a directory model with the given parent. More... | |
bool | remove (const QModelIndex &index) |
Removes the model item index from the directory model and deletes the corresponding file from the file system, returning true if successful. More... | |
bool | resolveSymlinks () const |
bool | rmdir (const 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. More... | |
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
Returns the number of rows in the parent model item. More... | |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
Sets the data for the model item index with the given role to the data referenced by the value. More... | |
void | setFilter (QDir::Filters filters) |
Sets the directory model's filter to that specified by filters. More... | |
void | setIconProvider (QFileIconProvider *provider) |
Sets the provider of file icons for the directory model. More... | |
void | setLazyChildCount (bool enable) |
void | setNameFilters (const QStringList &filters) |
Sets the name filters for the directory model. More... | |
void | setReadOnly (bool enable) |
void | setResolveSymlinks (bool enable) |
void | setSorting (QDir::SortFlags sort) |
Sets the directory model's sorting order to that specified by sort. More... | |
void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) |
Sort the model items in the column using the order given. More... | |
QDir::SortFlags | sorting () const |
Returns the sorting method used for the directory model. More... | |
Qt::DropActions | supportedDropActions () const |
Returns the drop actions supported by this model. More... | |
~QDirModel () | |
Destroys this directory model. More... | |
Public Functions inherited from QAbstractItemModel | |
virtual QModelIndex | buddy (const QModelIndex &index) const |
Returns a model index for the buddy of the item represented by index. More... | |
virtual bool | canFetchMore (const QModelIndex &parent) const |
Returns true if there is more data available for parent; otherwise returns false. More... | |
virtual void | fetchMore (const QModelIndex &parent) |
Fetches any available data for the items with the parent specified by the parent index. More... | |
bool | hasIndex (int row, int column, const QModelIndex &parent=QModelIndex()) const |
Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false. More... | |
bool | insertColumn (int column, const QModelIndex &parent=QModelIndex()) |
Inserts a single column before the given column in the child items of the parent specified. More... | |
virtual bool | insertColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, inserts count new columns into the model before the given column. More... | |
bool | insertRow (int row, const QModelIndex &parent=QModelIndex()) |
Inserts a single row before the given row in the child items of the parent specified. More... | |
virtual bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, inserts count rows into the model before the given row. More... | |
virtual QMap< int, QVariant > | itemData (const QModelIndex &index) const |
Returns a map with values for all predefined roles in the model for the item at the given index. More... | |
virtual QModelIndexList | match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const |
Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value. More... | |
QAbstractItemModel (QObject *parent=0) | |
Constructs an abstract item model with the given parent. More... | |
bool | removeColumn (int column, const QModelIndex &parent=QModelIndex()) |
Removes the given column from the child items of the parent specified. More... | |
virtual bool | removeColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, removes count columns starting with the given column under parent parent from the model. More... | |
bool | removeRow (int row, const QModelIndex &parent=QModelIndex()) |
Removes the given row from the child items of the parent specified. More... | |
virtual bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
On models that support this, removes count rows starting with the given row under parent parent from the model. More... | |
const QHash< int, QByteArray > & | roleNames () const |
Returns the model's role names. More... | |
virtual bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) |
Sets the data for the given role and section in the header with the specified orientation to the value supplied. More... | |
virtual bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) |
Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole. More... | |
void | setSupportedDragActions (Qt::DropActions) |
Sets the supported drag actions for the items in the model. More... | |
QModelIndex | sibling (int row, int column, const QModelIndex &idx) const |
Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no sibling at that location. More... | |
virtual QSize | span (const QModelIndex &index) const |
Returns the row and column span of the item represented by index. More... | |
Qt::DropActions | supportedDragActions () const |
Returns the actions supported by the data in this model. More... | |
virtual | ~QAbstractItemModel () |
Destroys the abstract item model. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Functions | |
QDirModel (QDirModelPrivate &, QObject *parent=0) | |
Protected Functions inherited from QAbstractItemModel | |
void | beginInsertColumns (const QModelIndex &parent, int first, int last) |
Begins a column insertion operation. More... | |
void | beginInsertRows (const QModelIndex &parent, int first, int last) |
Begins a row insertion operation. More... | |
bool | beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn) |
Begins a column move operation. More... | |
bool | beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow) |
Begins a row move operation. More... | |
void | beginRemoveColumns (const QModelIndex &parent, int first, int last) |
Begins a column removal operation. More... | |
void | beginRemoveRows (const QModelIndex &parent, int first, int last) |
Begins a row removal operation. More... | |
void | beginResetModel () |
Begins a model reset operation. More... | |
void | changePersistentIndex (const QModelIndex &from, const QModelIndex &to) |
Changes the QPersistentModelIndex that is equal to the given from model index to the given to model index. More... | |
void | changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to) |
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list. More... | |
QModelIndex | createIndex (int row, int column, void *data=0) const |
Creates a model index for the given row and column with the internal pointer ptr. More... | |
QModelIndex | createIndex (int row, int column, int id) const |
Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. More... | |
QModelIndex | createIndex (int row, int column, quint32 id) const |
Creates a model index for the given row and column with the internal identifier, id. More... | |
bool | decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream) |
void | encodeData (const QModelIndexList &indexes, QDataStream &stream) const |
void | endInsertColumns () |
Ends a column insertion operation. More... | |
void | endInsertRows () |
Ends a row insertion operation. More... | |
void | endMoveColumns () |
Ends a column move operation. More... | |
void | endMoveRows () |
Ends a row move operation. More... | |
void | endRemoveColumns () |
Ends a column removal operation. More... | |
void | endRemoveRows () |
Ends a row removal operation. More... | |
void | endResetModel () |
Completes a model reset operation. More... | |
QModelIndexList | persistentIndexList () const |
Returns the list of indexes stored as persistent indexes in the model. More... | |
QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0) | |
void | reset () |
Resets the model to its original state in any attached views. More... | |
void | setRoleNames (const QHash< int, QByteArray > &roleNames) |
Sets the model's role names to roleNames. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Properties | |
bool | lazyChildCount |
Whether the directory model optimizes the hasChildren function to only check if the item is a directory. More... | |
bool | readOnly |
Whether the directory model allows writing to the file system. More... | |
bool | resolveSymlinks |
Whether the directory model should resolve symbolic links. More... | |
Friends | |
class | QFileDialogPrivate |
Additional Inherited Members | |
Signals inherited from QAbstractItemModel | |
void | columnsAboutToBeInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted just before columns are inserted into the model. More... | |
void | columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) |
This signal is emitted just before columns are moved within the model. More... | |
void | columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted just before columns are removed from the model. More... | |
void | columnsInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted after columns have been inserted into the model. More... | |
void | columnsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column) |
This signal is emitted after columns have been moved within the model. More... | |
void | columnsRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted after columns have been removed from the model. More... | |
void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
This signal is emitted whenever the data in an existing item changes. More... | |
void | headerDataChanged (Qt::Orientation orientation, int first, int last) |
This signal is emitted whenever a header is changed. More... | |
void | layoutAboutToBeChanged () |
This signal is emitted just before the layout of a model is changed. More... | |
void | layoutChanged () |
This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. More... | |
void | modelAboutToBeReset () |
This signal is emitted when reset() is called, before the model's internal state (e. More... | |
void | modelReset () |
This signal is emitted when reset() is called, after the model's internal state (e. More... | |
void | rowsAboutToBeInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted just before rows are inserted into the model. More... | |
void | rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) |
This signal is emitted just before rows are moved within the model. More... | |
void | rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted just before rows are removed from the model. More... | |
void | rowsInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted after rows have been inserted into the model. More... | |
void | rowsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row) |
This signal is emitted after rows have been moved within the model. More... | |
void | rowsRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted after rows have been removed from the model. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Slots inherited from QAbstractItemModel | |
void | resetInternalData () |
This slot is called just after the internal data of a model is cleared while it is being reset. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QDirModel class provides a data model for the local filesystem.
The usage of QDirModel is not recommended anymore. The QFileSystemModel class is a more performant alternative.
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().
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.
Definition at line 59 of file qdirmodel.h.
enum QDirModel::Roles |
Enumerator | |
---|---|
FileIconRole | |
FilePathRole | |
FileNameRole |
Definition at line 67 of file qdirmodel.h.
QDirModel::QDirModel | ( | const QStringList & | nameFilters, |
QDir::Filters | filters, | ||
QDir::SortFlags | sort, | ||
QObject * | parent = 0 |
||
) |
Constructs a new directory model with the given parent.
Only those files matching the nameFilters and the filters are included in the model. The sort order is given by the sort flags.
Definition at line 229 of file qdirmodel.cpp.
|
explicit |
Constructs a directory model with the given parent.
Definition at line 249 of file qdirmodel.cpp.
QDirModel::~QDirModel | ( | ) |
|
protected |
Definition at line 259 of file qdirmodel.cpp.
|
virtual |
Returns the number of columns in the parent model item.
Implements QAbstractItemModel.
Definition at line 355 of file qdirmodel.cpp.
Referenced by index().
|
virtual |
Returns the data for the model item index with the given role.
Implements QAbstractItemModel.
Definition at line 365 of file qdirmodel.cpp.
Referenced by QDeclarativeFolderListModel::data(), mimeData(), QDirModelPrivate::restorePersistentIndexes(), and QDirModelPrivate::savePersistentIndexes().
|
virtual |
Handles the data supplied by a drag and drop operation that ended with the given action over the row in the model specified by the row and column and by the parent index.
Reimplemented from QAbstractItemModel.
Definition at line 574 of file qdirmodel.cpp.
QIcon QDirModel::fileIcon | ( | const QModelIndex & | index | ) | const |
Returns the icons for the item stored in the model under the given index.
Definition at line 1139 of file qdirmodel.cpp.
Referenced by data().
QFileInfo QDirModel::fileInfo | ( | const QModelIndex & | index | ) | const |
Returns the file information for the specified model 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.
Definition at line 1161 of file qdirmodel.cpp.
Referenced by fileName(), filePath(), and flags().
QString QDirModel::fileName | ( | const QModelIndex & | index | ) | const |
Returns the name of the item stored in the model under the index given.
Definition at line 1121 of file qdirmodel.cpp.
Referenced by data(), and dropMimeData().
QString QDirModel::filePath | ( | const QModelIndex & | index | ) | const |
Returns the path of the item stored in the model under the index given.
Definition at line 1103 of file qdirmodel.cpp.
Referenced by data(), dropMimeData(), and mimeData().
QDir::Filters QDirModel::filter | ( | ) | const |
Returns the filter specification for the directory model.
Definition at line 712 of file qdirmodel.cpp.
Referenced by QDeclarativeFolderListModel::handleDataChanged(), QDeclarativeFolderListModel::setShowDirs(), QDeclarativeFolderListModel::setShowDotAndDotDot(), and QDeclarativeFolderListModel::setShowOnlyReadable().
|
virtual |
Returns the item flags for the given index in the model.
Reimplemented from QAbstractItemModel.
Definition at line 486 of file qdirmodel.cpp.
Referenced by setData().
|
virtual |
Returns true if the parent model item has children; otherwise returns false.
Reimplemented from QAbstractItemModel.
Definition at line 465 of file qdirmodel.cpp.
|
virtual |
Returns the data stored under the given role for the specified section of the header with the given orientation.
Reimplemented from QAbstractItemModel.
Definition at line 435 of file qdirmodel.cpp.
QFileIconProvider * QDirModel::iconProvider | ( | ) | const |
Returns the file icon provider for this directory model.
Definition at line 653 of file qdirmodel.cpp.
Referenced by QDirModelPrivate::type().
|
virtual |
Returns the model item index for the item in the parent with the given row and column.
Implements QAbstractItemModel.
Definition at line 281 of file qdirmodel.cpp.
Referenced by QDeclarativeFolderListModel::data(), dropMimeData(), index(), QDeclarativeFolderListModel::isFolder(), mkdir(), QDeclarativeFolderListModel::refresh(), QDirModelPrivate::savePersistentIndexes(), and QDeclarativeFolderListModel::setFolder().
QModelIndex QDirModel::index | ( | const QString & | path, |
int | column = 0 |
||
) | const |
Returns the model item index for the given path.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 863 of file qdirmodel.cpp.
bool QDirModel::isDir | ( | const QModelIndex & | index | ) | const |
Returns true if the model item index represents a directory; otherwise returns false.
Definition at line 986 of file qdirmodel.cpp.
Referenced by index(), QDeclarativeFolderListModel::isFolder(), QDirModelPrivate::node(), and QDeclarativeFolderListModel::setFolder().
bool QDirModel::isReadOnly | ( | ) | const |
Definition at line 788 of file qdirmodel.cpp.
Referenced by dropMimeData(), mkdir(), remove(), and rmdir().
bool QDirModel::lazyChildCount | ( | ) | const |
Referenced by setLazyChildCount().
|
virtual |
Returns an object that contains a serialized description of the specified indexes.
The format used to describe the items corresponding to the indexes is obtained from the mimeTypes() function.
If the list of indexes is empty, 0 is returned rather than a serialized empty list.
Reimplemented from QAbstractItemModel.
Definition at line 554 of file qdirmodel.cpp.
|
virtual |
Returns a list of MIME types that can be used to describe a list of items in the model.
Reimplemented from QAbstractItemModel.
Definition at line 540 of file qdirmodel.cpp.
QModelIndex QDirModel::mkdir | ( | const QModelIndex & | parent, |
const QString & | name | ||
) |
Create a directory with the name in the parent model item.
Definition at line 998 of file qdirmodel.cpp.
QStringList QDirModel::nameFilters | ( | ) | const |
Returns a list of filters applied to the names in the model.
Definition at line 679 of file qdirmodel.cpp.
Referenced by QDirModelPrivate::children(), QDirModelPrivate::entryInfoList(), QDirModelPrivate::entryList(), QDirModelPrivate::init(), and QDirModel().
|
virtual |
Return the parent of the given child model item.
Implements QAbstractItemModel.
Definition at line 305 of file qdirmodel.cpp.
|
slot |
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).
Definition at line 829 of file qdirmodel.cpp.
Referenced by dropMimeData(), mkdir(), remove(), rmdir(), setFilter(), setNameFilters(), and setSorting().
bool QDirModel::remove | ( | const QModelIndex & | index | ) |
Removes the model item index from the directory model and deletes the corresponding file from the file system, returning true if successful.
If the item cannot be removed, false is returned.
Definition at line 1075 of file qdirmodel.cpp.
bool QDirModel::resolveSymlinks | ( | ) | const |
Referenced by QDirModelPrivate::children(), and setResolveSymlinks().
bool QDirModel::rmdir | ( | const 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.
If the directory cannot be removed, false is returned.
Definition at line 1040 of file qdirmodel.cpp.
|
virtual |
Returns the number of rows in the parent model item.
Implements QAbstractItemModel.
Definition at line 331 of file qdirmodel.cpp.
Referenced by hasChildren(), QDeclarativeFolderListModel::inserted(), QDeclarativeFolderListModel::refresh(), and QDeclarativeFolderListModel::removed().
|
virtual |
Sets the data for the model item index with the given role to the data referenced by the value.
Returns true if successful; otherwise returns false.
Reimplemented from QAbstractItemModel.
Definition at line 406 of file qdirmodel.cpp.
void QDirModel::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 QDirModel won't be able to read the directory structure.
Definition at line 694 of file qdirmodel.cpp.
Referenced by QDeclarativeFolderListModel::QDeclarativeFolderListModel(), QDeclarativeFolderListModel::setShowDirs(), QDeclarativeFolderListModel::setShowDotAndDotDot(), and QDeclarativeFolderListModel::setShowOnlyReadable().
void QDirModel::setIconProvider | ( | QFileIconProvider * | provider | ) |
Sets the provider of file icons for the directory model.
Definition at line 643 of file qdirmodel.cpp.
void QDirModel::setLazyChildCount | ( | bool | enable | ) |
Definition at line 810 of file qdirmodel.cpp.
void QDirModel::setNameFilters | ( | const QStringList & | filters | ) |
Sets the name filters for the directory model.
Definition at line 663 of file qdirmodel.cpp.
Referenced by QDeclarativeFolderListModel::setNameFilters().
void QDirModel::setReadOnly | ( | bool | enable | ) |
Definition at line 782 of file qdirmodel.cpp.
void QDirModel::setResolveSymlinks | ( | bool | enable | ) |
Definition at line 757 of file qdirmodel.cpp.
void QDirModel::setSorting | ( | QDir::SortFlags | sort | ) |
Sets the directory model's sorting order to that specified by sort.
Definition at line 724 of file qdirmodel.cpp.
Referenced by sort(), and QDeclarativeFolderListModelPrivate::updateSorting().
|
virtual |
Sort the model items in the column using the order given.
The order is a value defined in Qt::SortOrder .
Reimplemented from QAbstractItemModel.
Definition at line 509 of file qdirmodel.cpp.
Referenced by QDirModelPrivate::entryInfoList(), QDirModelPrivate::entryList(), QDirModelPrivate::init(), QDirModel(), and setSorting().
QDir::SortFlags QDirModel::sorting | ( | ) | const |
Returns the sorting method used for the directory model.
Definition at line 741 of file qdirmodel.cpp.
|
virtual |
Returns the drop actions supported by this model.
Reimplemented from QAbstractItemModel.
Definition at line 633 of file qdirmodel.cpp.
|
friend |
Definition at line 146 of file qdirmodel.h.
|
private |
Whether the directory model optimizes the 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
Definition at line 64 of file qdirmodel.h.
|
private |
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
Definition at line 63 of file qdirmodel.h.
|
private |
Whether the directory model should resolve symbolic links.
This is only relevant on operating systems that support symbolic links.
Definition at line 62 of file qdirmodel.h.