|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 Qt3Support module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef Q3FILEDIALOG_H |
|
43 #define Q3FILEDIALOG_H |
|
44 |
|
45 #include <QtCore/qdir.h> |
|
46 #include <QtGui/qdialog.h> |
|
47 #include <Qt3Support/q3urloperator.h> |
|
48 #include <Qt3Support/q3valuelist.h> |
|
49 |
|
50 QT_BEGIN_HEADER |
|
51 |
|
52 QT_BEGIN_NAMESPACE |
|
53 |
|
54 QT_MODULE(Qt3SupportLight) |
|
55 |
|
56 class QAbstractButton; |
|
57 class QPushButton; |
|
58 class QLabel; |
|
59 class QWidget; |
|
60 class QFileDialog; |
|
61 class QTimer; |
|
62 class Q3NetworkOperation; |
|
63 class QLineEdit; |
|
64 class Q3ListViewItem; |
|
65 class Q3ListBoxItem; |
|
66 class Q3FileDialogPrivate; |
|
67 class Q3FileDialogQFileListView; |
|
68 class QUrlInfo; |
|
69 |
|
70 #ifndef QT_NO_FILEDIALOG |
|
71 |
|
72 #ifndef QT_MAC_USE_COCOA |
|
73 |
|
74 class Q_COMPAT_EXPORT Q3FileIconProvider : public QObject |
|
75 { |
|
76 Q_OBJECT |
|
77 public: |
|
78 Q3FileIconProvider(QObject * parent = 0, const char* name = 0); |
|
79 virtual const QPixmap * pixmap(const QFileInfo &); |
|
80 |
|
81 private: |
|
82 Q_DISABLE_COPY(Q3FileIconProvider) |
|
83 }; |
|
84 |
|
85 class Q_COMPAT_EXPORT Q3FilePreview |
|
86 { |
|
87 public: |
|
88 Q3FilePreview(); |
|
89 virtual ~Q3FilePreview() {} |
|
90 virtual void previewUrl(const Q3Url &url) = 0; |
|
91 |
|
92 }; |
|
93 |
|
94 class Q_COMPAT_EXPORT Q3FileDialog : public QDialog |
|
95 { |
|
96 Q_OBJECT |
|
97 Q_ENUMS(Mode ViewMode PreviewMode) |
|
98 // ##### Why are this read-only properties ? |
|
99 Q_PROPERTY(QString selectedFile READ selectedFile) |
|
100 Q_PROPERTY(QString selectedFilter READ selectedFilter) |
|
101 Q_PROPERTY(QStringList selectedFiles READ selectedFiles) |
|
102 // #### Should not we be able to set the path ? |
|
103 Q_PROPERTY(QString dirPath READ dirPath) |
|
104 Q_PROPERTY(bool showHiddenFiles READ showHiddenFiles WRITE setShowHiddenFiles) |
|
105 Q_PROPERTY(Mode mode READ mode WRITE setMode) |
|
106 Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode) |
|
107 Q_PROPERTY(PreviewMode previewMode READ previewMode WRITE setPreviewMode) |
|
108 Q_PROPERTY(bool infoPreview READ isInfoPreviewEnabled WRITE setInfoPreviewEnabled) |
|
109 Q_PROPERTY(bool contentsPreview READ isContentsPreviewEnabled WRITE setContentsPreviewEnabled) |
|
110 |
|
111 public: |
|
112 Q3FileDialog(const QString& dirName, const QString& filter = QString(), |
|
113 QWidget* parent=0, const char* name=0, bool modal = false); |
|
114 Q3FileDialog(QWidget* parent=0, const char* name=0, bool modal = false); |
|
115 ~Q3FileDialog(); |
|
116 |
|
117 // recommended static functions |
|
118 |
|
119 static QString getOpenFileName(const QString &initially = QString(), |
|
120 const QString &filter = QString(), |
|
121 QWidget *parent = 0, const char* name = 0, |
|
122 const QString &caption = QString(), |
|
123 QString *selectedFilter = 0, |
|
124 bool resolveSymlinks = true); |
|
125 static QString getSaveFileName(const QString &initially = QString(), |
|
126 const QString &filter = QString(), |
|
127 QWidget *parent = 0, const char* name = 0, |
|
128 const QString &caption = QString(), |
|
129 QString *selectedFilter = 0, |
|
130 bool resolveSymlinks = true); |
|
131 static QString getExistingDirectory(const QString &dir = QString(), |
|
132 QWidget *parent = 0, |
|
133 const char* name = 0, |
|
134 const QString &caption = QString(), |
|
135 bool dirOnly = true, |
|
136 bool resolveSymlinks = true); |
|
137 static QStringList getOpenFileNames(const QString &filter= QString(), |
|
138 const QString &dir = QString(), |
|
139 QWidget *parent = 0, |
|
140 const char* name = 0, |
|
141 const QString &caption = QString(), |
|
142 QString *selectedFilter = 0, |
|
143 bool resolveSymlinks = true); |
|
144 |
|
145 // other static functions |
|
146 |
|
147 static void setIconProvider(Q3FileIconProvider *); |
|
148 static Q3FileIconProvider * iconProvider(); |
|
149 |
|
150 // non-static function for special needs |
|
151 |
|
152 QString selectedFile() const; |
|
153 QString selectedFilter() const; |
|
154 virtual void setSelectedFilter(const QString&); |
|
155 virtual void setSelectedFilter(int); |
|
156 |
|
157 void setSelection(const QString &); |
|
158 |
|
159 void selectAll(bool b); |
|
160 |
|
161 QStringList selectedFiles() const; |
|
162 |
|
163 QString dirPath() const; |
|
164 |
|
165 void setDir(const QDir &); |
|
166 const QDir *dir() const; |
|
167 |
|
168 void setShowHiddenFiles(bool s); |
|
169 bool showHiddenFiles() const; |
|
170 |
|
171 void rereadDir(); |
|
172 void resortDir(); |
|
173 |
|
174 enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly }; |
|
175 void setMode(Mode); |
|
176 Mode mode() const; |
|
177 |
|
178 enum ViewMode { Detail, List }; |
|
179 enum PreviewMode { NoPreview, Contents, Info }; |
|
180 void setViewMode(ViewMode m); |
|
181 ViewMode viewMode() const; |
|
182 void setPreviewMode(PreviewMode m); |
|
183 PreviewMode previewMode() const; |
|
184 |
|
185 bool eventFilter(QObject *, QEvent *); |
|
186 |
|
187 bool isInfoPreviewEnabled() const; |
|
188 bool isContentsPreviewEnabled() const; |
|
189 void setInfoPreviewEnabled(bool); |
|
190 void setContentsPreviewEnabled(bool); |
|
191 |
|
192 void setInfoPreview(QWidget *w, Q3FilePreview *preview); |
|
193 void setContentsPreview(QWidget *w, Q3FilePreview *preview); |
|
194 |
|
195 Q3Url url() const; |
|
196 |
|
197 void addFilter(const QString &filter); |
|
198 |
|
199 public Q_SLOTS: |
|
200 void done(int); |
|
201 void setDir(const QString&); |
|
202 void setUrl(const Q3UrlOperator &url); |
|
203 void setFilter(const QString&); |
|
204 void setFilters(const QString&); |
|
205 void setFilters(const char **); |
|
206 void setFilters(const QStringList&); |
|
207 |
|
208 protected: |
|
209 void resizeEvent(QResizeEvent *); |
|
210 void keyPressEvent(QKeyEvent *); |
|
211 |
|
212 void addWidgets(QLabel *, QWidget *, QPushButton *); |
|
213 void addToolButton(QAbstractButton *b, bool separator = false); |
|
214 void addLeftWidget(QWidget *w); |
|
215 void addRightWidget(QWidget *w); |
|
216 |
|
217 Q_SIGNALS: |
|
218 void fileHighlighted(const QString&); |
|
219 void fileSelected(const QString&); |
|
220 void filesSelected(const QStringList&); |
|
221 void dirEntered(const QString&); |
|
222 void filterSelected(const QString&); |
|
223 |
|
224 private Q_SLOTS: |
|
225 void detailViewSelectionChanged(); |
|
226 void listBoxSelectionChanged(); |
|
227 void changeMode(int); |
|
228 void fileNameEditReturnPressed(); |
|
229 void stopCopy(); |
|
230 void removeProgressDia(); |
|
231 |
|
232 void fileSelected(int); |
|
233 void fileHighlighted(int); |
|
234 void dirSelected(int); |
|
235 void pathSelected(int); |
|
236 |
|
237 void updateFileNameEdit(Q3ListViewItem *); |
|
238 void selectDirectoryOrFile(Q3ListViewItem *); |
|
239 void popupContextMenu(Q3ListViewItem *, const QPoint &, int); |
|
240 void popupContextMenu(Q3ListBoxItem *, const QPoint &); |
|
241 void updateFileNameEdit(Q3ListBoxItem *); |
|
242 void selectDirectoryOrFile(Q3ListBoxItem *); |
|
243 void fileNameEditDone(); |
|
244 |
|
245 void okClicked(); |
|
246 void filterClicked(); // not used |
|
247 void cancelClicked(); |
|
248 |
|
249 void cdUpClicked(); |
|
250 void newFolderClicked(); |
|
251 |
|
252 void fixupNameEdit(); |
|
253 |
|
254 void doMimeTypeLookup(); |
|
255 |
|
256 void updateGeometries(); |
|
257 void modeButtonsDestroyed(); |
|
258 void urlStart(Q3NetworkOperation *op); |
|
259 void urlFinished(Q3NetworkOperation *op); |
|
260 void dataTransferProgress(int bytesDone, int bytesTotal, Q3NetworkOperation *); |
|
261 void insertEntry(const Q3ValueList<QUrlInfo> &fi, Q3NetworkOperation *op); |
|
262 void removeEntry(Q3NetworkOperation *); |
|
263 void createdDirectory(const QUrlInfo &info, Q3NetworkOperation *); |
|
264 void itemChanged(Q3NetworkOperation *); |
|
265 void goBack(); |
|
266 |
|
267 private: |
|
268 Q_DISABLE_COPY(Q3FileDialog) |
|
269 |
|
270 enum PopupAction { |
|
271 PA_Open = 0, |
|
272 PA_Delete, |
|
273 PA_Rename, |
|
274 PA_SortName, |
|
275 PA_SortSize, |
|
276 PA_SortType, |
|
277 PA_SortDate, |
|
278 PA_SortUnsorted, |
|
279 PA_Cancel, |
|
280 PA_Reload, |
|
281 PA_Hidden |
|
282 }; |
|
283 |
|
284 void init(); |
|
285 bool trySetSelection(bool isDir, const Q3UrlOperator &, bool); |
|
286 void deleteFile(const QString &filename); |
|
287 void popupContextMenu(const QString &filename, bool withSort, |
|
288 PopupAction &action, const QPoint &p); |
|
289 void updatePreviews(const Q3Url &u); |
|
290 |
|
291 QString fileName; |
|
292 |
|
293 friend class Q3FileDialogQFileListView; |
|
294 friend class QFileListBox; |
|
295 |
|
296 Q3FileDialogPrivate *d; |
|
297 Q3FileDialogQFileListView *files; |
|
298 |
|
299 QLineEdit *nameEdit; // also filter |
|
300 QPushButton *okB; |
|
301 QPushButton *cancelB; |
|
302 |
|
303 #if defined(Q_WS_WIN) |
|
304 static QString winGetOpenFileName(const QString &initialSelection, |
|
305 const QString &filter, |
|
306 QString* workingDirectory, |
|
307 QWidget *parent = 0, |
|
308 const char* name = 0, |
|
309 const QString& caption = QString(), |
|
310 QString* selectedFilter = 0); |
|
311 static QString winGetSaveFileName(const QString &initialSelection, |
|
312 const QString &filter, |
|
313 QString* workingDirectory, |
|
314 QWidget *parent = 0, |
|
315 const char* name = 0, |
|
316 const QString& caption = QString(), |
|
317 QString* selectedFilter = 0); |
|
318 static QStringList winGetOpenFileNames(const QString &filter, |
|
319 QString* workingDirectory, |
|
320 QWidget *parent = 0, |
|
321 const char* name = 0, |
|
322 const QString& caption = QString(), |
|
323 QString* selectedFilter = 0); |
|
324 static QString winGetExistingDirectory(const QString &initialDirectory, |
|
325 QWidget* parent = 0, |
|
326 const char* name = 0, |
|
327 const QString& caption = QString()); |
|
328 static QString resolveLinkFile(const QString& linkfile); |
|
329 int old_qt_ntfs_permission_lookup; |
|
330 #endif |
|
331 #if defined(Q_WS_MAC) |
|
332 static QString macGetSaveFileName(const QString &, const QString &, |
|
333 QString *, QWidget *, const char*, |
|
334 const QString&, QString *); |
|
335 static QStringList macGetOpenFileNames(const QString &, QString*, |
|
336 QWidget *, const char *, |
|
337 const QString&, QString *, |
|
338 bool = true, bool = false); |
|
339 #endif |
|
340 }; |
|
341 |
|
342 #endif // QT_MAC_USE_COCOA |
|
343 |
|
344 #endif // QT_NO_FILEDIALOG |
|
345 |
|
346 QT_END_NAMESPACE |
|
347 |
|
348 QT_END_HEADER |
|
349 |
|
350 #endif // Q3FILEDIALOG_H |