source: trunk/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h@ 875

Last change on this file since 875 was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 4.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the examples of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDECLARATIVEFOLDERLISTMODEL_H
43#define QDECLARATIVEFOLDERLISTMODEL_H
44
45#include <qdeclarative.h>
46#include <QStringList>
47#include <QUrl>
48#include <QAbstractListModel>
49
50#ifndef QT_NO_DIRMODEL
51
52QT_BEGIN_HEADER
53
54QT_BEGIN_NAMESPACE
55
56QT_MODULE(Declarative)
57
58class QDeclarativeContext;
59class QModelIndex;
60
61class QDeclarativeFolderListModelPrivate;
62
63//![class begin]
64class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarativeParserStatus
65{
66 Q_OBJECT
67 Q_INTERFACES(QDeclarativeParserStatus)
68//![class begin]
69
70//![class props]
71 Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged)
72 Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged)
73 Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
74 Q_PROPERTY(SortField sortField READ sortField WRITE setSortField)
75 Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed)
76 Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs)
77 Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot)
78 Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable)
79 Q_PROPERTY(int count READ count)
80//![class props]
81
82//![abslistmodel]
83public:
84 QDeclarativeFolderListModel(QObject *parent = 0);
85 ~QDeclarativeFolderListModel();
86
87 enum Roles { FileNameRole = Qt::UserRole+1, FilePathRole = Qt::UserRole+2 };
88
89 int rowCount(const QModelIndex &parent) const;
90 QVariant data(const QModelIndex &index, int role) const;
91//![abslistmodel]
92
93//![count]
94 int count() const { return rowCount(QModelIndex()); }
95//![count]
96
97//![prop funcs]
98 QUrl folder() const;
99 void setFolder(const QUrl &folder);
100
101 QUrl parentFolder() const;
102
103 QStringList nameFilters() const;
104 void setNameFilters(const QStringList &filters);
105
106 enum SortField { Unsorted, Name, Time, Size, Type };
107 SortField sortField() const;
108 void setSortField(SortField field);
109 Q_ENUMS(SortField)
110
111 bool sortReversed() const;
112 void setSortReversed(bool rev);
113
114 bool showDirs() const;
115 void setShowDirs(bool);
116 bool showDotAndDotDot() const;
117 void setShowDotAndDotDot(bool);
118 bool showOnlyReadable() const;
119 void setShowOnlyReadable(bool);
120//![prop funcs]
121
122//![isfolder]
123 Q_INVOKABLE bool isFolder(int index) const;
124//![isfolder]
125
126//![parserstatus]
127 virtual void classBegin();
128 virtual void componentComplete();
129//![parserstatus]
130
131//![notifier]
132Q_SIGNALS:
133 void folderChanged();
134//![notifier]
135
136//![class end]
137private Q_SLOTS:
138 void refresh();
139 void inserted(const QModelIndex &index, int start, int end);
140 void removed(const QModelIndex &index, int start, int end);
141 void handleDataChanged(const QModelIndex &start, const QModelIndex &end);
142
143private:
144 Q_DISABLE_COPY(QDeclarativeFolderListModel)
145 QDeclarativeFolderListModelPrivate *d;
146};
147//![class end]
148
149QT_END_NAMESPACE
150
151//![qml decl]
152QML_DECLARE_TYPE(QDeclarativeFolderListModel)
153//![qml decl]
154
155QT_END_HEADER
156
157#endif // QT_NO_DIRMODEL
158
159#endif // QDECLARATIVEFOLDERLISTMODEL_H
Note: See TracBrowser for help on using the repository browser.