1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the item views module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
32
#include <QtCore/qabstractitemmodel.h>
33
#include <QtCore/qdir.h>
34
#include <QtCore/qfileinfo.h>
35
#include <QtGui/qicon.h>
37
class QDirModelPrivate;
38
class QFileIconProviderPrivate;
40
class Q_GUI_EXPORT QFileIconProvider
44
virtual ~QFileIconProvider();
45
enum IconType { Computer, Desktop, Trashcan, Network, Drive, Folder, File };
46
virtual QIcon icon(IconType type) const;
47
virtual QIcon icon(const QFileInfo &info) const;
48
virtual QString type(const QFileInfo &info) const;
51
Q_DECLARE_PRIVATE(QFileIconProvider)
52
QFileIconProviderPrivate *d_ptr;
55
class Q_GUI_EXPORT QDirModel : public QAbstractItemModel
58
Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks)
59
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
60
Q_PROPERTY(bool lazyChildCount READ lazyChildCount WRITE setLazyChildCount)
64
FileIconRole = Qt::DecorationRole,
65
FilePathRole = Qt::UserRole + 1,
69
QDirModel(const QStringList &nameFilters, QDir::Filters filters,
70
QDir::SortFlags sort, QObject *parent = 0);
71
explicit QDirModel(QObject *parent = 0);
74
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
75
QModelIndex parent(const QModelIndex &child) const;
77
int rowCount(const QModelIndex &parent) const;
78
int columnCount(const QModelIndex &parent) const;
80
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
81
bool setData(const QModelIndex &index, const QVariant &value, int role);
83
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
85
bool hasChildren(const QModelIndex &index) const;
86
Qt::ItemFlags flags(const QModelIndex &index) const;
88
void sort(int column, Qt::SortOrder order);
90
QStringList mimeTypes() const;
91
QMimeData *mimeData(const QModelIndexList &indexes) const;
92
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
93
int row, int column, const QModelIndex &parent);
94
Qt::DropActions supportedDropActions() const;
96
// QDirModel specific API
98
void setIconProvider(QFileIconProvider *provider);
99
QFileIconProvider *iconProvider() const;
101
void setNameFilters(const QStringList &filters);
102
QStringList nameFilters() const;
104
void setFilter(QDir::Filters filters);
105
QDir::Filters filter() const;
107
void setSorting(QDir::SortFlags sort);
108
QDir::SortFlags sorting() const;
110
void setResolveSymlinks(bool enable);
111
bool resolveSymlinks() const;
113
void setReadOnly(bool enable);
114
bool isReadOnly() const;
116
void setLazyChildCount(bool enable);
117
bool lazyChildCount() const;
119
void refresh(const QModelIndex &parent = QModelIndex());
120
QModelIndex index(const QString &path, int column = 0) const;
122
bool isDir(const QModelIndex &index) const;
123
QModelIndex mkdir(const QModelIndex &parent, const QString &name);
124
bool rmdir(const QModelIndex &index);
125
bool remove(const QModelIndex &index);
127
QString filePath(const QModelIndex &index) const;
128
QString fileName(const QModelIndex &index) const;
129
QIcon fileIcon(const QModelIndex &index) const;
130
QFileInfo fileInfo(const QModelIndex &index) const;
133
QDirModel(QDirModelPrivate &, QObject *parent = 0);
136
Q_DECLARE_PRIVATE(QDirModel)
137
Q_DISABLE_COPY(QDirModel)
140
#endif // QDIRMODEL_H