1 /////////////////////////////////////////////////////////////////////////////
3 // File : qfiledialogP.h
4 // Description : the patch for Qt's QFileDialog class (qfiledialog.h)
5 /////////////////////////////////////////////////////////////////////////////
7 /****************************************************************************
10 ** Definition of QFileDialog class
14 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
16 ** This file is part of the dialogs module of the Qt GUI Toolkit.
18 ** This file may be distributed under the terms of the Q Public License
19 ** as defined by Trolltech AS of Norway and appearing in the file
20 ** LICENSE.QPL included in the packaging of this file.
22 ** This file may be distributed and/or modified under the terms of the
23 ** GNU General Public License version 2 as published by the Free Software
24 ** Foundation and appearing in the file LICENSE.GPL included in the
25 ** packaging of this file.
27 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
28 ** licenses may use this file in accordance with the Qt Commercial License
29 ** Agreement provided with the Software.
31 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
34 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
35 ** information about Qt Commercial License Agreements.
36 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
37 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
39 ** Contact info@trolltech.com if any conditions of this licensing are
42 **********************************************************************/
44 #ifndef QFILEDIALOGP_H
45 #define QFILEDIALOGP_H
53 class QNetworkOperation;
58 class QFileDialogPrivate;
59 class QFileDialogQFileListView;
64 #include "qurloperator.h"
67 #include "qlistview.h"
68 #include "qlineedit.h"
71 #ifndef QT_NO_FILEDIALOG
73 class Q_EXPORT QFileIconProviderP : public QObject
77 QFileIconProviderP( QObject * parent = 0, const char* name = 0 );
78 virtual const QPixmap * pixmap( const QFileInfo & );
80 private: // Disabled copy constructor and operator=
81 #if defined(Q_DISABLE_COPY)
82 QFileIconProviderP( const QFileIconProviderP & );
83 QFileIconProviderP& operator=( const QFileIconProviderP & );
87 class Q_EXPORT QFilePreviewP
91 virtual void previewUrl( const QUrl &url ) = 0;
95 class Q_EXPORT QFileDialogP : public QDialog
98 Q_ENUMS( Mode ViewMode PreviewMode )
99 // ##### Why are this read-only properties ?
100 Q_PROPERTY( QString selectedFile READ selectedFile )
101 Q_PROPERTY( QString selectedFilter READ selectedFilter )
102 Q_PROPERTY( QStringList selectedFiles READ selectedFiles )
103 // #### Should not we be able to set the path ?
104 Q_PROPERTY( QString dirPath READ dirPath )
105 Q_PROPERTY( bool showHiddenFiles READ showHiddenFiles WRITE setShowHiddenFiles )
106 Q_PROPERTY( Mode mode READ mode WRITE setMode )
107 Q_PROPERTY( ViewMode viewMode READ viewMode WRITE setViewMode )
108 Q_PROPERTY( PreviewMode previewMode READ previewMode WRITE setPreviewMode )
109 Q_PROPERTY( bool infoPreview READ isInfoPreviewEnabled WRITE setInfoPreviewEnabled )
110 Q_PROPERTY( bool contentsPreview READ isContentsPreviewEnabled WRITE setContentsPreviewEnabled )
113 QFileDialogP( const QString& dirName, const QString& filter = QString::null,
114 QWidget* parent=0, const char* name=0, bool modal = FALSE );
115 QFileDialogP( QWidget* parent=0, const char* name=0, bool modal = FALSE );
118 // recommended static functions
120 static QString getOpenFileName( const QString &initially = QString::null,
121 const QString &filter = QString::null,
122 QWidget *parent = 0, const char* name = 0,
123 const QString &caption = QString::null,
124 QString *selectedFilter = 0,
125 bool resolveSymlinks = TRUE);
126 static QString getSaveFileName( const QString &initially = QString::null,
127 const QString &filter = QString::null,
128 QWidget *parent = 0, const char* name = 0,
129 const QString &caption = QString::null,
130 QString *selectedFilter = 0,
131 bool resolveSymlinks = TRUE);
132 static QString getExistingDirectory( const QString &dir = QString::null,
134 const char* name = 0,
135 const QString &caption = QString::null,
137 bool resolveSymlinks = TRUE);
138 static QStringList getOpenFileNames( const QString &filter= QString::null,
139 const QString &dir = QString::null,
141 const char* name = 0,
142 const QString &caption = QString::null,
143 QString *selectedFilter = 0,
144 bool resolveSymlinks = TRUE);
146 // other static functions
148 static void setIconProvider( QFileIconProviderP * );
149 static QFileIconProviderP* iconProvider();
151 // non-static function for special needs
153 QString selectedFile() const;
154 QString selectedFilter() const;
155 virtual void setSelectedFilter( const QString& );
156 virtual void setSelectedFilter( int );
158 void setSelection( const QString &);
160 void selectAll( bool b );
162 QStringList selectedFiles() const;
164 QString dirPath() const;
166 void setDir( const QDir & );
167 const QDir *dir() const;
169 void setShowHiddenFiles( bool s );
170 bool showHiddenFiles() const;
175 enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
176 void setMode( Mode );
179 enum ViewMode { Detail, List };
180 enum PreviewMode { NoPreview, Contents, Info };
181 void setViewMode( ViewMode m );
182 ViewMode viewMode() const;
183 void setPreviewMode( PreviewMode m );
184 PreviewMode previewMode() const;
186 bool eventFilter( QObject *, QEvent * );
188 bool isInfoPreviewEnabled() const;
189 bool isContentsPreviewEnabled() const;
190 void setInfoPreviewEnabled( bool );
191 void setContentsPreviewEnabled( bool );
193 void setInfoPreview( QWidget *w, QFilePreviewP *preview );
194 void setContentsPreview( QWidget *w, QFilePreviewP *preview );
198 void addFilter( const QString &filter );
202 void setDir( const QString& );
203 void setUrl( const QUrlOperator &url );
204 void setFilter( const QString& );
205 void setFilters( const QString& );
206 void setFilters( const char ** );
207 void setFilters( const QStringList& );
210 void resizeEvent( QResizeEvent * );
211 void keyPressEvent( QKeyEvent * );
213 void addWidgets( QLabel *, QWidget *, QPushButton * );
214 void addToolButton( QButton *b, bool separator = FALSE );
215 void addLeftWidget( QWidget *w );
216 void addRightWidget( QWidget *w );
219 void fileHighlighted( const QString& );
220 void fileSelected( const QString& );
221 void filesSelected( const QStringList& );
222 void dirEntered( const QString& );
223 void filterSelected( const QString& );
226 void detailViewSelectionChanged();
227 void listBoxSelectionChanged();
228 void changeMode( int );
229 void fileNameEditReturnPressed();
231 void removeProgressDia();
233 void fileSelected( int );
234 void fileHighlighted( int );
235 void dirSelected( int );
236 void pathSelected( int );
238 void updateFileNameEdit( QListViewItem *);
239 void selectDirectoryOrFile( QListViewItem * );
240 void popupContextMenu( QListViewItem *, const QPoint &, int );
241 void popupContextMenu( QListBoxItem *, const QPoint & );
242 void updateFileNameEdit( QListBoxItem *);
243 void selectDirectoryOrFile( QListBoxItem * );
244 void fileNameEditDone();
247 void filterClicked(); // not used
248 void cancelClicked();
251 void newFolderClicked();
253 void fixupNameEdit();
255 void doMimeTypeLookup();
257 void updateGeometries();
258 void modeButtonsDestroyed();
259 void urlStart( QNetworkOperation *op );
260 void urlFinished( QNetworkOperation *op );
261 void dataTransferProgress( int bytesDone, int bytesTotal, QNetworkOperation * );
262 void insertEntry( const QValueList<QUrlInfo> &fi, QNetworkOperation *op );
263 void removeEntry( QNetworkOperation * );
264 void createdDirectory( const QUrlInfo &info, QNetworkOperation * );
265 void itemChanged( QNetworkOperation * );
284 bool trySetSelection( bool isDir, const QUrlOperator &, bool );
285 void deleteFile( const QString &filename );
286 void popupContextMenu( const QString &filename, bool withSort,
287 PopupAction &action, const QPoint &p );
289 QDir reserved; // was cwd
292 friend class QFileDialogQFileListView;
293 friend class QFileListBox;
295 QFileDialogPrivate *d;
296 QFileDialogQFileListView *files;
298 QLineEdit *nameEdit; // also filter
300 QPushButton *cancelB;
302 #if defined(Q_WS_WIN)
303 static QString winGetOpenFileName( const QString &initialSelection,
304 const QString &filter,
305 QString* workingDirectory,
307 const char* name = 0,
308 const QString& caption = QString::null,
309 QString* selectedFilter = 0 );
310 static QString winGetSaveFileName( const QString &initialSelection,
311 const QString &filter,
312 QString* workingDirectory,
314 const char* name = 0,
315 const QString& caption = QString::null,
316 QString* selectedFilter = 0 );
317 static QStringList winGetOpenFileNames( const QString &filter,
318 QString* workingDirectory,
320 const char* name = 0,
321 const QString& caption = QString::null,
322 QString* selectedFilter = 0 );
323 static QString winGetExistingDirectory( const QString &initialDirectory,
325 const char* name = 0,
326 const QString& caption = QString::null);
327 static QString resolveLinkFile( const QString& linkfile );
329 #if defined(Q_WS_MACX) || defined(Q_WS_MAC9)
330 static QString macGetSaveFileName( const QString &, const QString &,
331 QString *, QWidget *, const char*,
333 static QStringList macGetOpenFileNames( const QString &, QString*,
334 QWidget *, const char *,
335 const QString&, bool = TRUE,
340 private: // Disabled copy constructor and operator=
341 #if defined(Q_DISABLE_COPY)
342 QFileDialogP( const QFileDialogP & );
343 QFileDialogP &operator=( const QFileDialogP & );
347 /******************************************************************
349 * Definitions of view classes
351 ******************************************************************/
353 class QRenameEdit : public QLineEdit
358 QRenameEdit( QWidget *parent )
359 : QLineEdit( parent, "qt_rename_edit" )
363 void keyPressEvent( QKeyEvent *e );
364 void focusOutEvent( QFocusEvent *e );
367 void escapePressed();
371 class QFileListBox : public QListBox
373 friend class QFileDialogP;
378 QFileListBox( QWidget *parent, QFileDialogP *d );
382 void startRename( bool check = TRUE );
383 void viewportMousePressEvent( QMouseEvent *e );
384 void viewportMouseReleaseEvent( QMouseEvent *e );
385 void viewportMouseDoubleClickEvent( QMouseEvent *e );
386 void viewportMouseMoveEvent( QMouseEvent *e );
387 #ifndef QT_NO_DRAGANDDROP
388 void viewportDragEnterEvent( QDragEnterEvent *e );
389 void viewportDragMoveEvent( QDragMoveEvent *e );
390 void viewportDragLeaveEvent( QDragLeaveEvent *e );
391 void viewportDropEvent( QDropEvent *e );
392 bool acceptDrop( const QPoint &pnt, QWidget *source );
393 void setCurrentDropItem( const QPoint &pnt );
395 void keyPressEvent( QKeyEvent *e );
400 void doubleClickTimeout();
401 void changeDirDuringDrag();
402 void dragObjDestroyed();
403 void contentsMoved( int, int );
407 QFileDialogP *filedialog;
410 QListBoxItem *renameItem, *dragItem;
411 QPoint pressPos, oldDragPos;
414 QString startDragDir;
415 QListBoxItem *currDropItem;
416 QTimer *changeDirTimer;
417 bool firstMousePressEvent;
418 QUrlOperator startDragUrl;
423 class QFileDialogQFileListView : public QListView
428 QFileDialogQFileListView( QWidget *parent, QFileDialogP *d );
431 void startRename( bool check = TRUE );
432 void setSorting( int column, bool increasing = TRUE );
436 QListViewItem *renameItem;
439 void viewportMousePressEvent( QMouseEvent *e );
440 void viewportMouseDoubleClickEvent( QMouseEvent *e );
441 void keyPressEvent( QKeyEvent *e );
442 void viewportMouseReleaseEvent( QMouseEvent *e );
443 void viewportMouseMoveEvent( QMouseEvent *e );
444 #ifndef QT_NO_DRAGANDDROP
445 void viewportDragEnterEvent( QDragEnterEvent *e );
446 void viewportDragMoveEvent( QDragMoveEvent *e );
447 void viewportDragLeaveEvent( QDragLeaveEvent *e );
448 void viewportDropEvent( QDropEvent *e );
449 bool acceptDrop( const QPoint &pnt, QWidget *source );
450 void setCurrentDropItem( const QPoint &pnt );
456 void changeSortColumn2( int column );
457 void doubleClickTimeout();
458 void changeDirDuringDrag();
459 void dragObjDestroyed();
460 void contentsMoved( int, int );
463 QFileDialogP *filedialog;
465 QPoint pressPos, oldDragPos;
468 QString startDragDir;
469 QListViewItem *currDropItem, *dragItem;
470 QTimer *changeDirTimer;
471 bool firstMousePressEvent;
474 QUrlOperator startDragUrl;
478 /****************************************************************************
480 * Classes for copy progress dialog
482 ****************************************************************************/
484 class QFDProgressAnimation : public QWidget
489 QFDProgressAnimation( QWidget *parent );
496 void paintEvent( QPaintEvent *e );
504 class QFDProgressDialog : public QDialog
509 QFDProgressDialog( QWidget *parent, const QString &fn, int steps );
511 void setReadProgress( int p );
512 void setWriteProgress( int p );
513 void setWriteLabel( const QString &s );
519 QProgressBar *readBar;
520 QProgressBar *writeBar;
522 QFDProgressAnimation *animation;
528 #endif // QFILEDIALOG_H