1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the Qt 3 compatibility classes 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
****************************************************************************/
29
#ifndef Q3FILEDIALOG_H
30
#define Q3FILEDIALOG_H
32
class QAbstractButton;
38
class Q3NetworkOperation;
42
class Q3FileDialogPrivate;
43
class Q3FileDialogQFileListView;
45
#include "QtCore/qdir.h"
46
#include "QtGui/qdialog.h"
47
#include "Qt3Support/q3urloperator.h"
48
#include "Qt3Support/q3valuelist.h"
49
#include "QtNetwork/qurlinfo.h"
51
#ifndef QT_NO_FILEDIALOG
53
class Q_COMPAT_EXPORT Q3FileIconProvider : public QObject
57
Q3FileIconProvider(QObject * parent = 0, const char* name = 0);
58
virtual const QPixmap * pixmap(const QFileInfo &);
61
Q_DISABLE_COPY(Q3FileIconProvider)
64
class Q_COMPAT_EXPORT Q3FilePreview
68
virtual ~Q3FilePreview() {}
69
virtual void previewUrl(const Q3Url &url) = 0;
73
class Q_COMPAT_EXPORT Q3FileDialog : public QDialog
76
Q_ENUMS(Mode ViewMode PreviewMode)
77
// ##### Why are this read-only properties ?
78
Q_PROPERTY(QString selectedFile READ selectedFile)
79
Q_PROPERTY(QString selectedFilter READ selectedFilter)
80
Q_PROPERTY(QStringList selectedFiles READ selectedFiles)
81
// #### Should not we be able to set the path ?
82
Q_PROPERTY(QString dirPath READ dirPath)
83
Q_PROPERTY(bool showHiddenFiles READ showHiddenFiles WRITE setShowHiddenFiles)
84
Q_PROPERTY(Mode mode READ mode WRITE setMode)
85
Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
86
Q_PROPERTY(PreviewMode previewMode READ previewMode WRITE setPreviewMode)
87
Q_PROPERTY(bool infoPreview READ isInfoPreviewEnabled WRITE setInfoPreviewEnabled)
88
Q_PROPERTY(bool contentsPreview READ isContentsPreviewEnabled WRITE setContentsPreviewEnabled)
91
Q3FileDialog(const QString& dirName, const QString& filter = QString(),
92
QWidget* parent=0, const char* name=0, bool modal = false);
93
Q3FileDialog(QWidget* parent=0, const char* name=0, bool modal = false);
96
// recommended static functions
98
static QString getOpenFileName(const QString &initially = QString(),
99
const QString &filter = QString(),
100
QWidget *parent = 0, const char* name = 0,
101
const QString &caption = QString(),
102
QString *selectedFilter = 0,
103
bool resolveSymlinks = true);
104
static QString getSaveFileName(const QString &initially = QString(),
105
const QString &filter = QString(),
106
QWidget *parent = 0, const char* name = 0,
107
const QString &caption = QString(),
108
QString *selectedFilter = 0,
109
bool resolveSymlinks = true);
110
static QString getExistingDirectory(const QString &dir = QString(),
112
const char* name = 0,
113
const QString &caption = QString(),
115
bool resolveSymlinks = true);
116
static QStringList getOpenFileNames(const QString &filter= QString(),
117
const QString &dir = QString(),
119
const char* name = 0,
120
const QString &caption = QString(),
121
QString *selectedFilter = 0,
122
bool resolveSymlinks = true);
124
// other static functions
126
static void setIconProvider(Q3FileIconProvider *);
127
static Q3FileIconProvider * iconProvider();
129
// non-static function for special needs
131
QString selectedFile() const;
132
QString selectedFilter() const;
133
virtual void setSelectedFilter(const QString&);
134
virtual void setSelectedFilter(int);
136
void setSelection(const QString &);
138
void selectAll(bool b);
140
QStringList selectedFiles() const;
142
QString dirPath() const;
144
void setDir(const QDir &);
145
const QDir *dir() const;
147
void setShowHiddenFiles(bool s);
148
bool showHiddenFiles() const;
153
enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
157
enum ViewMode { Detail, List };
158
enum PreviewMode { NoPreview, Contents, Info };
159
void setViewMode(ViewMode m);
160
ViewMode viewMode() const;
161
void setPreviewMode(PreviewMode m);
162
PreviewMode previewMode() const;
164
bool eventFilter(QObject *, QEvent *);
166
bool isInfoPreviewEnabled() const;
167
bool isContentsPreviewEnabled() const;
168
void setInfoPreviewEnabled(bool);
169
void setContentsPreviewEnabled(bool);
171
void setInfoPreview(QWidget *w, Q3FilePreview *preview);
172
void setContentsPreview(QWidget *w, Q3FilePreview *preview);
176
void addFilter(const QString &filter);
180
void setDir(const QString&);
181
void setUrl(const Q3UrlOperator &url);
182
void setFilter(const QString&);
183
void setFilters(const QString&);
184
void setFilters(const char **);
185
void setFilters(const QStringList&);
188
void resizeEvent(QResizeEvent *);
189
void keyPressEvent(QKeyEvent *);
191
void addWidgets(QLabel *, QWidget *, QPushButton *);
192
void addToolButton(QAbstractButton *b, bool separator = false);
193
void addLeftWidget(QWidget *w);
194
void addRightWidget(QWidget *w);
197
void fileHighlighted(const QString&);
198
void fileSelected(const QString&);
199
void filesSelected(const QStringList&);
200
void dirEntered(const QString&);
201
void filterSelected(const QString&);
204
void detailViewSelectionChanged();
205
void listBoxSelectionChanged();
206
void changeMode(int);
207
void fileNameEditReturnPressed();
209
void removeProgressDia();
211
void fileSelected(int);
212
void fileHighlighted(int);
213
void dirSelected(int);
214
void pathSelected(int);
216
void updateFileNameEdit(Q3ListViewItem *);
217
void selectDirectoryOrFile(Q3ListViewItem *);
218
void popupContextMenu(Q3ListViewItem *, const QPoint &, int);
219
void popupContextMenu(Q3ListBoxItem *, const QPoint &);
220
void updateFileNameEdit(Q3ListBoxItem *);
221
void selectDirectoryOrFile(Q3ListBoxItem *);
222
void fileNameEditDone();
225
void filterClicked(); // not used
226
void cancelClicked();
229
void newFolderClicked();
231
void fixupNameEdit();
233
void doMimeTypeLookup();
235
void updateGeometries();
236
void modeButtonsDestroyed();
237
void urlStart(Q3NetworkOperation *op);
238
void urlFinished(Q3NetworkOperation *op);
239
void dataTransferProgress(int bytesDone, int bytesTotal, Q3NetworkOperation *);
240
void insertEntry(const Q3ValueList<QUrlInfo> &fi, Q3NetworkOperation *op);
241
void removeEntry(Q3NetworkOperation *);
242
void createdDirectory(const QUrlInfo &info, Q3NetworkOperation *);
243
void itemChanged(Q3NetworkOperation *);
247
Q_DISABLE_COPY(Q3FileDialog)
264
bool trySetSelection(bool isDir, const Q3UrlOperator &, bool);
265
void deleteFile(const QString &filename);
266
void popupContextMenu(const QString &filename, bool withSort,
267
PopupAction &action, const QPoint &p);
268
void updatePreviews(const Q3Url &u);
272
friend class Q3FileDialogQFileListView;
273
friend class QFileListBox;
275
Q3FileDialogPrivate *d;
276
Q3FileDialogQFileListView *files;
278
QLineEdit *nameEdit; // also filter
280
QPushButton *cancelB;
282
#if defined(Q_WS_WIN)
283
static QString winGetOpenFileName(const QString &initialSelection,
284
const QString &filter,
285
QString* workingDirectory,
287
const char* name = 0,
288
const QString& caption = QString(),
289
QString* selectedFilter = 0);
290
static QString winGetSaveFileName(const QString &initialSelection,
291
const QString &filter,
292
QString* workingDirectory,
294
const char* name = 0,
295
const QString& caption = QString(),
296
QString* selectedFilter = 0);
297
static QStringList winGetOpenFileNames(const QString &filter,
298
QString* workingDirectory,
300
const char* name = 0,
301
const QString& caption = QString(),
302
QString* selectedFilter = 0);
303
static QString winGetExistingDirectory(const QString &initialDirectory,
305
const char* name = 0,
306
const QString& caption = QString());
307
static QString resolveLinkFile(const QString& linkfile);
308
int old_qt_ntfs_permission_lookup;
310
#if defined(Q_WS_MAC)
311
static QString macGetSaveFileName(const QString &, const QString &,
312
QString *, QWidget *, const char*,
313
const QString&, QString *);
314
static QStringList macGetOpenFileNames(const QString &, QString*,
315
QWidget *, const char *,
316
const QString&, QString *,
317
bool = true, bool = false);
323
#endif // Q3FILEDIALOG_H