Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QDIRMODEL_H
00043 #define QDIRMODEL_H
00044
00045 #include <QtCore/qabstractitemmodel.h>
00046 #include <QtCore/qdir.h>
00047 #include <QtGui/qfileiconprovider.h>
00048
00049 QT_BEGIN_HEADER
00050
00051 QT_BEGIN_NAMESPACE
00052
00053 QT_MODULE(Gui)
00054
00055 #ifndef QT_NO_DIRMODEL
00056
00057 class QDirModelPrivate;
00058
00059 class Q_GUI_EXPORT QDirModel : public QAbstractItemModel
00060 {
00061 Q_OBJECT
00062 Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks)
00063 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
00064 Q_PROPERTY(bool lazyChildCount READ lazyChildCount WRITE setLazyChildCount)
00065
00066 public:
00067 enum Roles {
00068 FileIconRole = Qt::DecorationRole,
00069 FilePathRole = Qt::UserRole + 1,
00070 FileNameRole
00071 };
00072
00073 QDirModel(const QStringList &nameFilters, QDir::Filters filters,
00074 QDir::SortFlags sort, QObject *parent = 0);
00075 explicit QDirModel(QObject *parent = 0);
00076 ~QDirModel();
00077
00078 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00079 QModelIndex parent(const QModelIndex &child) const;
00080
00081 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00082 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00083
00084 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00085 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00086
00087 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00088
00089 bool hasChildren(const QModelIndex &index = QModelIndex()) const;
00090 Qt::ItemFlags flags(const QModelIndex &index) const;
00091
00092 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
00093
00094 QStringList mimeTypes() const;
00095 QMimeData *mimeData(const QModelIndexList &indexes) const;
00096 bool dropMimeData(const QMimeData *data, Qt::DropAction action,
00097 int row, int column, const QModelIndex &parent);
00098 Qt::DropActions supportedDropActions() const;
00099
00100
00101
00102 void setIconProvider(QFileIconProvider *provider);
00103 QFileIconProvider *iconProvider() const;
00104
00105 void setNameFilters(const QStringList &filters);
00106 QStringList nameFilters() const;
00107
00108 void setFilter(QDir::Filters filters);
00109 QDir::Filters filter() const;
00110
00111 void setSorting(QDir::SortFlags sort);
00112 QDir::SortFlags sorting() const;
00113
00114 void setResolveSymlinks(bool enable);
00115 bool resolveSymlinks() const;
00116
00117 void setReadOnly(bool enable);
00118 bool isReadOnly() const;
00119
00120 void setLazyChildCount(bool enable);
00121 bool lazyChildCount() const;
00122
00123 QModelIndex index(const QString &path, int column = 0) const;
00124
00125 bool isDir(const QModelIndex &index) const;
00126 QModelIndex mkdir(const QModelIndex &parent, const QString &name);
00127 bool rmdir(const QModelIndex &index);
00128 bool remove(const QModelIndex &index);
00129
00130 QString filePath(const QModelIndex &index) const;
00131 QString fileName(const QModelIndex &index) const;
00132 QIcon fileIcon(const QModelIndex &index) const;
00133 QFileInfo fileInfo(const QModelIndex &index) const;
00134
00135 #ifdef Q_NO_USING_KEYWORD
00136 inline QObject *parent() const { return QObject::parent(); }
00137 #else
00138 using QObject::parent;
00139 #endif
00140
00141 public Q_SLOTS:
00142 void refresh(const QModelIndex &parent = QModelIndex());
00143
00144 protected:
00145 QDirModel(QDirModelPrivate &, QObject *parent = 0);
00146 friend class QFileDialogPrivate;
00147
00148 private:
00149 Q_DECLARE_PRIVATE(QDirModel)
00150 Q_DISABLE_COPY(QDirModel)
00151 Q_PRIVATE_SLOT(d_func(), void _q_refresh())
00152 };
00153
00154 #endif // QT_NO_DIRMODEL
00155
00156 QT_END_NAMESPACE
00157
00158 QT_END_HEADER
00159
00160 #endif // QDIRMODEL_H