1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module 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 qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QFILEDIALOG_H
|
---|
43 | #define QFILEDIALOG_H
|
---|
44 |
|
---|
45 | #include <QtCore/qdir.h>
|
---|
46 | #include <QtCore/qstring.h>
|
---|
47 | #include <QtGui/qdialog.h>
|
---|
48 |
|
---|
49 | QT_BEGIN_HEADER
|
---|
50 |
|
---|
51 | QT_BEGIN_NAMESPACE
|
---|
52 |
|
---|
53 | QT_MODULE(Gui)
|
---|
54 |
|
---|
55 | #ifndef QT_NO_FILEDIALOG
|
---|
56 |
|
---|
57 | class QModelIndex;
|
---|
58 | class QItemSelection;
|
---|
59 | struct QFileDialogArgs;
|
---|
60 | class QFileIconProvider;
|
---|
61 | class QFileDialogPrivate;
|
---|
62 | class QAbstractItemDelegate;
|
---|
63 | class QAbstractProxyModel;
|
---|
64 | class QUrl;
|
---|
65 |
|
---|
66 | class Q_GUI_EXPORT QFileDialog : public QDialog
|
---|
67 | {
|
---|
68 | Q_OBJECT
|
---|
69 | Q_ENUMS(ViewMode FileMode AcceptMode Option)
|
---|
70 | Q_FLAGS(Options)
|
---|
71 | Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
|
---|
72 | Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode)
|
---|
73 | Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode)
|
---|
74 | Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE false)
|
---|
75 | Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks DESIGNABLE false)
|
---|
76 | Q_PROPERTY(bool confirmOverwrite READ confirmOverwrite WRITE setConfirmOverwrite DESIGNABLE false)
|
---|
77 | Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix)
|
---|
78 | Q_PROPERTY(bool nameFilterDetailsVisible READ isNameFilterDetailsVisible
|
---|
79 | WRITE setNameFilterDetailsVisible DESIGNABLE false)
|
---|
80 | Q_PROPERTY(Options options READ options WRITE setOptions)
|
---|
81 |
|
---|
82 | public:
|
---|
83 | enum ViewMode { Detail, List };
|
---|
84 | enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
|
---|
85 | enum AcceptMode { AcceptOpen, AcceptSave };
|
---|
86 | enum DialogLabel { LookIn, FileName, FileType, Accept, Reject };
|
---|
87 |
|
---|
88 | // ### Rename to FileDialogOption and FileDialogOptions for Qt 5.0
|
---|
89 | enum Option
|
---|
90 | {
|
---|
91 | ShowDirsOnly = 0x00000001,
|
---|
92 | DontResolveSymlinks = 0x00000002,
|
---|
93 | DontConfirmOverwrite = 0x00000004,
|
---|
94 | DontUseSheet = 0x00000008,
|
---|
95 | DontUseNativeDialog = 0x00000010,
|
---|
96 | ReadOnly = 0x00000020,
|
---|
97 | HideNameFilterDetails = 0x00000040
|
---|
98 | };
|
---|
99 | Q_DECLARE_FLAGS(Options, Option)
|
---|
100 |
|
---|
101 | QFileDialog(QWidget *parent, Qt::WindowFlags f);
|
---|
102 | explicit QFileDialog(QWidget *parent = 0,
|
---|
103 | const QString &caption = QString(),
|
---|
104 | const QString &directory = QString(),
|
---|
105 | const QString &filter = QString());
|
---|
106 | ~QFileDialog();
|
---|
107 |
|
---|
108 | void setDirectory(const QString &directory);
|
---|
109 | inline void setDirectory(const QDir &directory);
|
---|
110 | QDir directory() const;
|
---|
111 |
|
---|
112 | void selectFile(const QString &filename);
|
---|
113 | QStringList selectedFiles() const;
|
---|
114 |
|
---|
115 | #ifdef QT_DEPRECATED
|
---|
116 | QT_DEPRECATED void setFilter(const QString &filter);
|
---|
117 | QT_DEPRECATED void setFilters(const QStringList &filters);
|
---|
118 | QT_DEPRECATED QStringList filters() const;
|
---|
119 | QT_DEPRECATED void selectFilter(const QString &filter);
|
---|
120 | QT_DEPRECATED QString selectedFilter() const;
|
---|
121 | #endif
|
---|
122 | void setNameFilterDetailsVisible(bool enabled);
|
---|
123 | bool isNameFilterDetailsVisible() const;
|
---|
124 |
|
---|
125 | void setNameFilter(const QString &filter);
|
---|
126 | void setNameFilters(const QStringList &filters);
|
---|
127 | QStringList nameFilters() const;
|
---|
128 | void selectNameFilter(const QString &filter);
|
---|
129 | QString selectedNameFilter() const;
|
---|
130 |
|
---|
131 | QDir::Filters filter() const;
|
---|
132 | void setFilter(QDir::Filters filters);
|
---|
133 |
|
---|
134 | void setViewMode(ViewMode mode);
|
---|
135 | ViewMode viewMode() const;
|
---|
136 |
|
---|
137 | void setFileMode(FileMode mode);
|
---|
138 | FileMode fileMode() const;
|
---|
139 |
|
---|
140 | void setAcceptMode(AcceptMode mode);
|
---|
141 | AcceptMode acceptMode() const;
|
---|
142 |
|
---|
143 | void setReadOnly(bool enabled);
|
---|
144 | bool isReadOnly() const;
|
---|
145 |
|
---|
146 | void setResolveSymlinks(bool enabled);
|
---|
147 | bool resolveSymlinks() const;
|
---|
148 |
|
---|
149 | void setSidebarUrls(const QList<QUrl> &urls);
|
---|
150 | QList<QUrl> sidebarUrls() const;
|
---|
151 |
|
---|
152 | QByteArray saveState() const;
|
---|
153 | bool restoreState(const QByteArray &state);
|
---|
154 |
|
---|
155 | void setConfirmOverwrite(bool enabled);
|
---|
156 | bool confirmOverwrite() const;
|
---|
157 |
|
---|
158 | void setDefaultSuffix(const QString &suffix);
|
---|
159 | QString defaultSuffix() const;
|
---|
160 |
|
---|
161 | void setHistory(const QStringList &paths);
|
---|
162 | QStringList history() const;
|
---|
163 |
|
---|
164 | void setItemDelegate(QAbstractItemDelegate *delegate);
|
---|
165 | QAbstractItemDelegate *itemDelegate() const;
|
---|
166 |
|
---|
167 | void setIconProvider(QFileIconProvider *provider);
|
---|
168 | QFileIconProvider *iconProvider() const;
|
---|
169 |
|
---|
170 | void setLabelText(DialogLabel label, const QString &text);
|
---|
171 | QString labelText(DialogLabel label) const;
|
---|
172 |
|
---|
173 | #ifndef QT_NO_PROXYMODEL
|
---|
174 | void setProxyModel(QAbstractProxyModel *model);
|
---|
175 | QAbstractProxyModel *proxyModel() const;
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | void setOption(Option option, bool on = true);
|
---|
179 | bool testOption(Option option) const;
|
---|
180 | void setOptions(Options options);
|
---|
181 | Options options() const;
|
---|
182 |
|
---|
183 | #ifdef Q_NO_USING_KEYWORD
|
---|
184 | #ifndef Q_QDOC
|
---|
185 | void open() { QDialog::open(); }
|
---|
186 | #endif
|
---|
187 | #else
|
---|
188 | using QDialog::open;
|
---|
189 | #endif
|
---|
190 | void open(QObject *receiver, const char *member);
|
---|
191 | void setVisible(bool visible);
|
---|
192 |
|
---|
193 | Q_SIGNALS:
|
---|
194 | void fileSelected(const QString &file);
|
---|
195 | void filesSelected(const QStringList &files);
|
---|
196 | void currentChanged(const QString &path);
|
---|
197 | void directoryEntered(const QString &directory);
|
---|
198 | void filterSelected(const QString &filter);
|
---|
199 |
|
---|
200 | public:
|
---|
201 | #ifdef QT3_SUPPORT
|
---|
202 | typedef FileMode Mode;
|
---|
203 | inline QT3_SUPPORT void setMode(FileMode m) { setFileMode(m); }
|
---|
204 | inline QT3_SUPPORT FileMode mode() const { return fileMode(); }
|
---|
205 | inline QT3_SUPPORT void setDir(const QString &directory) { setDirectory(directory); }
|
---|
206 | inline QT3_SUPPORT void setDir( const QDir &directory ) { setDirectory(directory); }
|
---|
207 | QT3_SUPPORT QString selectedFile() const;
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | static QString getOpenFileName(QWidget *parent = 0,
|
---|
211 | const QString &caption = QString(),
|
---|
212 | const QString &dir = QString(),
|
---|
213 | const QString &filter = QString(),
|
---|
214 | QString *selectedFilter = 0,
|
---|
215 | Options options = 0);
|
---|
216 |
|
---|
217 | static QString getSaveFileName(QWidget *parent = 0,
|
---|
218 | const QString &caption = QString(),
|
---|
219 | const QString &dir = QString(),
|
---|
220 | const QString &filter = QString(),
|
---|
221 | QString *selectedFilter = 0,
|
---|
222 | Options options = 0);
|
---|
223 |
|
---|
224 | static QString getExistingDirectory(QWidget *parent = 0,
|
---|
225 | const QString &caption = QString(),
|
---|
226 | const QString &dir = QString(),
|
---|
227 | Options options = ShowDirsOnly);
|
---|
228 |
|
---|
229 | static QStringList getOpenFileNames(QWidget *parent = 0,
|
---|
230 | const QString &caption = QString(),
|
---|
231 | const QString &dir = QString(),
|
---|
232 | const QString &filter = QString(),
|
---|
233 | QString *selectedFilter = 0,
|
---|
234 | Options options = 0);
|
---|
235 |
|
---|
236 | #ifdef QT3_SUPPORT
|
---|
237 | inline static QString QT3_SUPPORT getOpenFileName(const QString &dir,
|
---|
238 | const QString &filter = QString(),
|
---|
239 | QWidget *parent = 0, const char* name = 0,
|
---|
240 | const QString &caption = QString(),
|
---|
241 | QString *selectedFilter = 0,
|
---|
242 | bool resolveSymlinks = true)
|
---|
243 | { Q_UNUSED(name);
|
---|
244 | return getOpenFileName(parent, caption, dir, filter, selectedFilter,
|
---|
245 | resolveSymlinks ? Option(0) : DontResolveSymlinks); }
|
---|
246 |
|
---|
247 | inline static QString QT3_SUPPORT getSaveFileName(const QString &dir,
|
---|
248 | const QString &filter = QString(),
|
---|
249 | QWidget *parent = 0, const char* name = 0,
|
---|
250 | const QString &caption = QString(),
|
---|
251 | QString *selectedFilter = 0,
|
---|
252 | bool resolveSymlinks = true)
|
---|
253 | { Q_UNUSED(name);
|
---|
254 | return getSaveFileName(parent, caption, dir, filter, selectedFilter,
|
---|
255 | resolveSymlinks ? Option(0) : DontResolveSymlinks); }
|
---|
256 |
|
---|
257 | inline static QString QT3_SUPPORT getExistingDirectory(const QString &dir,
|
---|
258 | QWidget *parent = 0,
|
---|
259 | const char* name = 0,
|
---|
260 | const QString &caption = QString(),
|
---|
261 | bool dirOnly = true,
|
---|
262 | bool resolveSymlinks = true)
|
---|
263 | { Q_UNUSED(name);
|
---|
264 | return getExistingDirectory(parent, caption, dir,
|
---|
265 | Options((resolveSymlinks ? Option(0) : DontResolveSymlinks)
|
---|
266 | | (dirOnly ? ShowDirsOnly : Option(0)))); }
|
---|
267 |
|
---|
268 | inline static QStringList QT3_SUPPORT getOpenFileNames(const QString &filter,
|
---|
269 | const QString &dir = QString(),
|
---|
270 | QWidget *parent = 0,
|
---|
271 | const char* name = 0,
|
---|
272 | const QString &caption = QString(),
|
---|
273 | QString *selectedFilter = 0,
|
---|
274 | bool resolveSymlinks = true)
|
---|
275 | { Q_UNUSED(name);
|
---|
276 | return getOpenFileNames(parent, caption, dir, filter, selectedFilter,
|
---|
277 | resolveSymlinks ? Option(0) : DontResolveSymlinks); }
|
---|
278 | #endif // QT3_SUPPORT
|
---|
279 |
|
---|
280 | protected:
|
---|
281 | QFileDialog(const QFileDialogArgs &args);
|
---|
282 | void done(int result);
|
---|
283 | void accept();
|
---|
284 | void changeEvent(QEvent *e);
|
---|
285 |
|
---|
286 | private:
|
---|
287 | Q_DECLARE_PRIVATE(QFileDialog)
|
---|
288 | Q_DISABLE_COPY(QFileDialog)
|
---|
289 |
|
---|
290 | Q_PRIVATE_SLOT(d_func(), void _q_pathChanged(const QString &))
|
---|
291 |
|
---|
292 | Q_PRIVATE_SLOT(d_func(), void _q_navigateBackward())
|
---|
293 | Q_PRIVATE_SLOT(d_func(), void _q_navigateForward())
|
---|
294 | Q_PRIVATE_SLOT(d_func(), void _q_navigateToParent())
|
---|
295 | Q_PRIVATE_SLOT(d_func(), void _q_createDirectory())
|
---|
296 | Q_PRIVATE_SLOT(d_func(), void _q_showListView())
|
---|
297 | Q_PRIVATE_SLOT(d_func(), void _q_showDetailsView())
|
---|
298 | Q_PRIVATE_SLOT(d_func(), void _q_showContextMenu(const QPoint &))
|
---|
299 | Q_PRIVATE_SLOT(d_func(), void _q_renameCurrent())
|
---|
300 | Q_PRIVATE_SLOT(d_func(), void _q_deleteCurrent())
|
---|
301 | Q_PRIVATE_SLOT(d_func(), void _q_showHidden())
|
---|
302 | Q_PRIVATE_SLOT(d_func(), void _q_updateOkButton())
|
---|
303 | Q_PRIVATE_SLOT(d_func(), void _q_currentChanged(const QModelIndex &index))
|
---|
304 | Q_PRIVATE_SLOT(d_func(), void _q_enterDirectory(const QModelIndex &index))
|
---|
305 | Q_PRIVATE_SLOT(d_func(), void _q_goToDirectory(const QString &path))
|
---|
306 | Q_PRIVATE_SLOT(d_func(), void _q_useNameFilter(int index))
|
---|
307 | Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
|
---|
308 | Q_PRIVATE_SLOT(d_func(), void _q_goToUrl(const QUrl &url))
|
---|
309 | Q_PRIVATE_SLOT(d_func(), void _q_goHome())
|
---|
310 | Q_PRIVATE_SLOT(d_func(), void _q_showHeader(QAction *))
|
---|
311 | Q_PRIVATE_SLOT(d_func(), void _q_autoCompleteFileName(const QString &text))
|
---|
312 | Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex & parent))
|
---|
313 | Q_PRIVATE_SLOT(d_func(), void _q_fileRenamed(const QString &path,
|
---|
314 | const QString oldName, const QString newName))
|
---|
315 | #if defined(Q_WS_MAC)
|
---|
316 | Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
|
---|
317 | #endif
|
---|
318 | };
|
---|
319 |
|
---|
320 | inline void QFileDialog::setDirectory(const QDir &adirectory)
|
---|
321 | { setDirectory(adirectory.absolutePath()); }
|
---|
322 |
|
---|
323 | Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDialog::Options)
|
---|
324 |
|
---|
325 | #endif // QT_NO_FILEDIALOG
|
---|
326 |
|
---|
327 | QT_END_NAMESPACE
|
---|
328 |
|
---|
329 | QT_END_HEADER
|
---|
330 |
|
---|
331 | #endif // QFILEDIALOG_H
|
---|