QDirModel Class Reference
The QDirModel class provides a data model for the local filesystem. More...
#include <QDirModel>
Inherits QAbstractItemModel.
List of all members.
Writable Properties
- 1 writable property inherited from QObject
Public Functions
- QDirModel ( const QString & path = QString::null, const QStringList & nameFilters = QStringList(), int filter = QDir::DefaultFilter, int sorting = QDir::DefaultSort, QObject * parent = 0 )
- QDirModel ( const QDir & directory, QObject * parent = 0 )
- ~QDirModel ()
- virtual bool canDecode ( QMimeSource * source ) const
- virtual int columnCount ( const QModelIndex & parent ) const
- virtual QVariant data ( const QModelIndex & index, int role = QAbstractItemModel::DisplayRole ) const
- virtual bool decode ( QDropEvent * e, const QModelIndex & parent )
- virtual QDragObject * dragObject ( const QModelIndexList & indices, QWidget * dragSource )
- virtual bool equal ( const QModelIndex & first, const QModelIndex & second ) const
- QFileInfo fileInfo ( const QModelIndex & index ) const
- QDir::FilterSpec filter () const
- virtual bool hasChildren ( const QModelIndex & parent ) const
- QFileIconProvider * iconProvider () const
- QIconSet icons ( const QModelIndex & index ) const
- virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex(), QModelIndex::Type type = QModelIndex::View ) const
- QModelIndex index ( const QString & path ) const
- bool isDir ( const QModelIndex & index ) const
- virtual bool isDragEnabled ( const QModelIndex & index ) const
- virtual bool isDropEnabled ( const QModelIndex & index ) const
- virtual bool isEditable ( const QModelIndex & index ) const
- virtual bool isSortable () const
- virtual bool lessThan ( const QModelIndex & first, const QModelIndex & second ) const
- QModelIndex mkdir ( const QModelIndex & parent, const QString & name )
- QString name ( const QModelIndex & index ) const
- QStringList nameFilters () const
- virtual QModelIndex parent ( const QModelIndex & child ) const
- QString path ( const QModelIndex & index ) const
- void refresh ( const QModelIndex & parent = QModelIndex() )
- bool remove ( const QModelIndex & index )
- bool rmdir ( const QModelIndex & index )
- virtual int rowCount ( const QModelIndex & parent ) const
- virtual bool setData ( const QModelIndex & index, int role, const QVariant & value )
- void setFilter ( int spec )
- void setIconProvider ( QFileIconProvider * provider )
- void setNameFilters ( const QStringList & filters )
- void setSorting ( int spec )
- virtual void sort ( int column, Qt::SortOrder order )
- QDir::SortSpec sorting () const
Public Slots
- 1 public slot inherited from QObject
Signals
Static Public Members
- 4 static public members inherited from QObject
Protected Functions
Detailed Description
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.
See also Model/View Programming.
Member Function Documentation
QDirModel::QDirModel ( const QString & path = QString::null, const QStringList & nameFilters = QStringList(), int filter = QDir::DefaultFilter, int sorting = QDir::DefaultSort, QObject * parent = 0 )
Constructs a new directory model with the given parent. The model initially contains information about the directory specified by path. Only those files matching the nameFilters and the filter are included in the model. The sort order is given by sorting.
QDirModel::QDirModel ( const QDir & directory, QObject * parent = 0 )
Constructs a directory model of the directory with a parent object.
QDirModel::~QDirModel ()
Destroys this directory model.
bool QDirModel::canDecode ( QMimeSource * source ) const [virtual]
Returns true if the directory model can decode the source information; otherwise returns false.
Reimplemented from QAbstractItemModel.
int QDirModel::columnCount ( const QModelIndex & parent ) const [virtual]
Returns the number of columns in the parent model item.
Reimplemented from QAbstractItemModel.
QVariant QDirModel::data ( const QModelIndex & index, int role = QAbstractItemModel::DisplayRole ) const [virtual]
Returns the data for the model item index with the given role.
Reimplemented from QAbstractItemModel.
bool QDirModel::decode ( QDropEvent * e, const QModelIndex & parent ) [virtual]
Returns true if this directory model (whose parent is parent), can decode drop event e.
Reimplemented from QAbstractItemModel.
QDragObject * QDirModel::dragObject ( const QModelIndexList & indices, QWidget * dragSource ) [virtual]
Returns the drag object for the list of model item indices originally dragged from the dragSource widget.
Reimplemented from QAbstractItemModel.
bool QDirModel::equal ( const QModelIndex & first, const QModelIndex & second ) const [virtual]
Returns true if the first model index is equal to the second index given.
Reimplemented from QAbstractItemModel.
QFileInfo QDirModel::fileInfo ( const QModelIndex & index ) const
Returns the file information for the model item index.
QDir::FilterSpec QDirModel::filter () const
Returns the filter specification for the directory model.
See also QDir::FilterSpec.
bool QDirModel::hasChildren ( const QModelIndex & parent ) const [virtual]
Returns true if the parent model item has children; otherwise returns false.
Reimplemented from QAbstractItemModel.
QFileIconProvider * QDirModel::iconProvider () const
Returns the file icon provider for this directory model.
QIconSet QDirModel::icons ( const QModelIndex & index ) const
Returns the iconset for the item stored in the model under the index given.
QModelIndex QDirModel::index ( int row, int column, const QModelIndex & parent = QModelIndex(), QModelIndex::Type type = QModelIndex::View ) const [virtual]
Returns the model item index for the item in the parent with the given row, column, and type.
The type is a value defined in QModelIndex::Type.
Reimplemented from QAbstractItemModel.
QModelIndex QDirModel::index ( const QString & path ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the model item index for the given path.
bool QDirModel::isDir ( const QModelIndex & index ) const
Returns true if the model item index represents a directory; otherwise returns false.
bool QDirModel::isDragEnabled ( const QModelIndex & index ) const [virtual]
Returns true if the model item index in the directory model can be dragged; otherwise returns false.
Reimplemented from QAbstractItemModel.
bool QDirModel::isDropEnabled ( const QModelIndex & index ) const [virtual]
Returns true if the model item index in the directory model can receive items dropped on it; otherwise returns false.
Reimplemented from QAbstractItemModel.
bool QDirModel::isEditable ( const QModelIndex & index ) const [virtual]
Returns true if the model item index in the directory model is editable; otherwise returns false.
Reimplemented from QAbstractItemModel.
bool QDirModel::isSortable () const [virtual]
Returns true if the items in the directory model can be sorted; otherwise returns false.
Reimplemented from QAbstractItemModel.
bool QDirModel::lessThan ( const QModelIndex & first, const QModelIndex & second ) const [virtual]
Returns true if the first model item is less than the second item given.
Reimplemented from QAbstractItemModel.
QModelIndex QDirModel::mkdir ( const QModelIndex & parent, const QString & name )
Create a directory with the name in the parent model item.
QString QDirModel::name ( const QModelIndex & index ) const
Returns the name of the item stored in the model under the index given.
QStringList QDirModel::nameFilters () const
Returns a list of filters applied to the names in the model.
QModelIndex QDirModel::parent ( const QModelIndex & child ) const [virtual]
Return the parent of the given child model item.
Reimplemented from QAbstractItemModel.
QString QDirModel::path ( const QModelIndex & index ) const
Returns the path of the item stored in the model under the index given.
void QDirModel::refresh ( const QModelIndex & parent = QModelIndex() )
Refreshes (rereads) the children of parent.
bool QDirModel::remove ( const QModelIndex & index )
Removes the model item index from the directory model, returning true if successful. If the item cannot be removed, false is returned.
bool QDirModel::rmdir ( const QModelIndex & index )
Removes the directory corresponding to the model item index in the directory model, returning true if successful. If the directory cannot be removed, false is returned.
int QDirModel::rowCount ( const QModelIndex & parent ) const [virtual]
Returns the number of rows in the parent model item.
Reimplemented from QAbstractItemModel.
bool QDirModel::setData ( const QModelIndex & index, int role, const QVariant & value ) [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.
void QDirModel::setFilter ( int spec )
Sets the directory model's filter to that specified by spec.
See also QDir::FilterSpec.
void QDirModel::setIconProvider ( QFileIconProvider * provider )
Sets the provider of file icons for the directory model.
void QDirModel::setNameFilters ( const QStringList & filters )
Sets the name filters for the directory model.
void QDirModel::setSorting ( int spec )
Sets the directory model's sorting order to that specified by spec.
See also QDir::SortSpec.
void QDirModel::sort ( int column, Qt::SortOrder order ) [virtual]
Sort the model items in the column using the order given. The order is a value defined in Qt::SortOrder.
Reimplemented from QAbstractItemModel.
QDir::SortSpec QDirModel::sorting () const
Returns the sorting method used for the directory model.
See also QDir::SortSpec.