1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Qt3Support module of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef Q3FILEDIALOG_H
43 #define Q3FILEDIALOG_H
45 #include <QtCore/qdir.h>
46 #include <QtGui/qdialog.h>
47 #include <Qt3Support/q3urloperator.h>
48 #include <Qt3Support/q3valuelist.h>
54 QT_MODULE(Qt3SupportLight
)
56 class QAbstractButton
;
62 class Q3NetworkOperation
;
66 class Q3FileDialogPrivate
;
67 class Q3FileDialogQFileListView
;
70 #ifndef QT_NO_FILEDIALOG
72 #ifndef QT_MAC_USE_COCOA
74 class Q_COMPAT_EXPORT Q3FileIconProvider
: public QObject
78 Q3FileIconProvider(QObject
* parent
= 0, const char* name
= 0);
79 virtual const QPixmap
* pixmap(const QFileInfo
&);
82 Q_DISABLE_COPY(Q3FileIconProvider
)
85 class Q_COMPAT_EXPORT Q3FilePreview
89 virtual ~Q3FilePreview() {}
90 virtual void previewUrl(const Q3Url
&url
) = 0;
94 class Q_COMPAT_EXPORT Q3FileDialog
: public QDialog
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
)
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);
117 // recommended static functions
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(),
133 const char* name
= 0,
134 const QString
&caption
= QString(),
136 bool resolveSymlinks
= true);
137 static QStringList
getOpenFileNames(const QString
&filter
= QString(),
138 const QString
&dir
= QString(),
140 const char* name
= 0,
141 const QString
&caption
= QString(),
142 QString
*selectedFilter
= 0,
143 bool resolveSymlinks
= true);
145 // other static functions
147 static void setIconProvider(Q3FileIconProvider
*);
148 static Q3FileIconProvider
* iconProvider();
150 // non-static function for special needs
152 QString
selectedFile() const;
153 QString
selectedFilter() const;
154 virtual void setSelectedFilter(const QString
&);
155 virtual void setSelectedFilter(int);
157 void setSelection(const QString
&);
159 void selectAll(bool b
);
161 QStringList
selectedFiles() const;
163 QString
dirPath() const;
165 void setDir(const QDir
&);
166 const QDir
*dir() const;
168 void setShowHiddenFiles(bool s
);
169 bool showHiddenFiles() const;
174 enum Mode
{ AnyFile
, ExistingFile
, Directory
, ExistingFiles
, DirectoryOnly
};
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;
185 bool eventFilter(QObject
*, QEvent
*);
187 bool isInfoPreviewEnabled() const;
188 bool isContentsPreviewEnabled() const;
189 void setInfoPreviewEnabled(bool);
190 void setContentsPreviewEnabled(bool);
192 void setInfoPreview(QWidget
*w
, Q3FilePreview
*preview
);
193 void setContentsPreview(QWidget
*w
, Q3FilePreview
*preview
);
197 void addFilter(const QString
&filter
);
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
&);
209 void resizeEvent(QResizeEvent
*);
210 void keyPressEvent(QKeyEvent
*);
212 void addWidgets(QLabel
*, QWidget
*, QPushButton
*);
213 void addToolButton(QAbstractButton
*b
, bool separator
= false);
214 void addLeftWidget(QWidget
*w
);
215 void addRightWidget(QWidget
*w
);
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
&);
225 void detailViewSelectionChanged();
226 void listBoxSelectionChanged();
227 void changeMode(int);
228 void fileNameEditReturnPressed();
230 void removeProgressDia();
232 void fileSelected(int);
233 void fileHighlighted(int);
234 void dirSelected(int);
235 void pathSelected(int);
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();
246 void filterClicked(); // not used
247 void cancelClicked();
250 void newFolderClicked();
252 void fixupNameEdit();
254 void doMimeTypeLookup();
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
*);
268 Q_DISABLE_COPY(Q3FileDialog
)
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
);
293 friend class Q3FileDialogQFileListView
;
294 friend class QFileListBox
;
296 Q3FileDialogPrivate
*d
;
297 Q3FileDialogQFileListView
*files
;
299 QLineEdit
*nameEdit
; // also filter
301 QPushButton
*cancelB
;
303 #if defined(Q_WS_WIN)
304 static QString
winGetOpenFileName(const QString
&initialSelection
,
305 const QString
&filter
,
306 QString
* workingDirectory
,
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
,
315 const char* name
= 0,
316 const QString
& caption
= QString(),
317 QString
* selectedFilter
= 0);
318 static QStringList
winGetOpenFileNames(const QString
&filter
,
319 QString
* workingDirectory
,
321 const char* name
= 0,
322 const QString
& caption
= QString(),
323 QString
* selectedFilter
= 0);
324 static QString
winGetExistingDirectory(const QString
&initialDirectory
,
326 const char* name
= 0,
327 const QString
& caption
= QString());
328 static QString
resolveLinkFile(const QString
& linkfile
);
329 int old_qt_ntfs_permission_lookup
;
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);
342 #endif // QT_MAC_USE_COCOA
344 #endif // QT_NO_FILEDIALOG
350 #endif // Q3FILEDIALOG_H