Eneboo - Documentación para desarrolladores
src/qt/include/qfiledialog.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qfiledialog.h   3.3.8   edited Jan 11 14:37 $
00003 **
00004 ** Definition of QFileDialog class
00005 **
00006 ** Created : 950428
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the dialogs module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QFILEDIALOG_H
00039 #define QFILEDIALOG_H
00040 
00041 class QPushButton;
00042 class QButton;
00043 class QLabel;
00044 class QWidget;
00045 class QFileDialog;
00046 class QTimer;
00047 class QNetworkOperation;
00048 class QLineEdit;
00049 class QListViewItem;
00050 class QListBoxItem;
00051 class QFileDialogPrivate;
00052 class QFileDialogQFileListView;
00053 
00054 #ifndef QT_H
00055 #include "qdir.h"
00056 #include "qdialog.h"
00057 #include "qurloperator.h"
00058 #include "qurlinfo.h"
00059 #endif // QT_H
00060 
00061 #if __GNUC__ - 0 > 3
00062 #pragma GCC system_header
00063 #endif
00064 
00065 #ifndef QT_NO_FILEDIALOG
00066 
00067 class Q_EXPORT QFileIconProvider : public QObject
00068 {
00069     Q_OBJECT
00070 public:
00071     QFileIconProvider( QObject * parent = 0, const char* name = 0 );
00072     virtual const QPixmap * pixmap( const QFileInfo & );
00073 
00074 private:        // Disabled copy constructor and operator=
00075 #if defined(Q_DISABLE_COPY)
00076     QFileIconProvider( const QFileIconProvider & );
00077     QFileIconProvider& operator=( const QFileIconProvider & );
00078 #endif
00079 };
00080 
00081 class Q_EXPORT QFilePreview
00082 {
00083 public:
00084     QFilePreview();
00085     virtual void previewUrl( const QUrl &url ) = 0;
00086 
00087 };
00088 
00089 class Q_EXPORT QFileDialog : public QDialog
00090 {
00091     Q_OBJECT
00092     Q_ENUMS( Mode ViewMode PreviewMode )
00093     // ##### Why are this read-only properties ?
00094     Q_PROPERTY( QString selectedFile READ selectedFile )
00095     Q_PROPERTY( QString selectedFilter READ selectedFilter )
00096     Q_PROPERTY( QStringList selectedFiles READ selectedFiles )
00097     // #### Should not we be able to set the path ?
00098     Q_PROPERTY( QString dirPath READ dirPath )
00099     Q_PROPERTY( bool showHiddenFiles READ showHiddenFiles WRITE setShowHiddenFiles )
00100     Q_PROPERTY( Mode mode READ mode WRITE setMode )
00101     Q_PROPERTY( ViewMode viewMode READ viewMode WRITE setViewMode )
00102     Q_PROPERTY( PreviewMode previewMode READ previewMode WRITE setPreviewMode )
00103     Q_PROPERTY( bool infoPreview READ isInfoPreviewEnabled WRITE setInfoPreviewEnabled )
00104     Q_PROPERTY( bool contentsPreview READ isContentsPreviewEnabled WRITE setContentsPreviewEnabled )
00105 
00106 public:
00107     QFileDialog( const QString& dirName, const QString& filter = QString::null,
00108                  QWidget* parent=0, const char* name=0, bool modal = FALSE );
00109     QFileDialog( QWidget* parent=0, const char* name=0, bool modal = FALSE );
00110     ~QFileDialog();
00111 
00112     // recommended static functions
00113 
00114     static QString getOpenFileName( const QString &initially = QString::null,
00115                                     const QString &filter = QString::null,
00116                                     QWidget *parent = 0, const char* name = 0,
00117                                     const QString &caption = QString::null,
00118                                     QString *selectedFilter = 0,
00119                                     bool resolveSymlinks = TRUE);
00120     static QString getSaveFileName( const QString &initially = QString::null,
00121                                     const QString &filter = QString::null,
00122                                     QWidget *parent = 0, const char* name = 0,
00123                                     const QString &caption = QString::null,
00124                                     QString *selectedFilter = 0,
00125                                     bool resolveSymlinks = TRUE);
00126     static QString getExistingDirectory( const QString &dir = QString::null,
00127                                          QWidget *parent = 0,
00128                                          const char* name = 0,
00129                                          const QString &caption = QString::null,
00130                                          bool dirOnly = TRUE,
00131                                          bool resolveSymlinks = TRUE);
00132     static QStringList getOpenFileNames( const QString &filter= QString::null,
00133                                          const QString &dir = QString::null,
00134                                          QWidget *parent = 0,
00135                                          const char* name = 0,
00136                                          const QString &caption = QString::null,
00137                                          QString *selectedFilter = 0,
00138                                          bool resolveSymlinks = TRUE);
00139 
00140     // other static functions
00141 
00142     static void setIconProvider( QFileIconProvider * );
00143     static QFileIconProvider * iconProvider();
00144 
00145     // non-static function for special needs
00146 
00147     QString selectedFile() const;
00148     QString selectedFilter() const;
00149     virtual void setSelectedFilter( const QString& );
00150     virtual void setSelectedFilter( int );
00151 
00152     void setSelection( const QString &);
00153 
00154     void selectAll( bool b );
00155 
00156     QStringList selectedFiles() const;
00157 
00158     QString dirPath() const;
00159 
00160     void setDir( const QDir & );
00161     const QDir *dir() const;
00162 
00163     void setShowHiddenFiles( bool s );
00164     bool showHiddenFiles() const;
00165 
00166     void rereadDir();
00167     void resortDir();
00168 
00169     enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
00170     void setMode( Mode );
00171     Mode mode() const;
00172 
00173     enum ViewMode { Detail, List };
00174     enum PreviewMode { NoPreview, Contents, Info };
00175     void setViewMode( ViewMode m );
00176     ViewMode viewMode() const;
00177     void setPreviewMode( PreviewMode m );
00178     PreviewMode previewMode() const;
00179 
00180     bool eventFilter( QObject *, QEvent * );
00181 
00182     bool isInfoPreviewEnabled() const;
00183     bool isContentsPreviewEnabled() const;
00184     void setInfoPreviewEnabled( bool );
00185     void setContentsPreviewEnabled( bool );
00186 
00187     void setInfoPreview( QWidget *w, QFilePreview *preview );
00188     void setContentsPreview( QWidget *w, QFilePreview *preview );
00189 
00190     QUrl url() const;
00191 
00192     void addFilter( const QString &filter );
00193 
00194 public slots:
00195     void done( int );
00196     void setDir( const QString& );
00197     void setUrl( const QUrlOperator &url );
00198     void setFilter( const QString& );
00199     void setFilters( const QString& );
00200     void setFilters( const char ** );
00201     void setFilters( const QStringList& );
00202 
00203 protected:
00204     void resizeEvent( QResizeEvent * );
00205     void keyPressEvent( QKeyEvent * );
00206 
00207     void addWidgets( QLabel *, QWidget *, QPushButton * );
00208     void addToolButton( QButton *b, bool separator = FALSE );
00209     void addLeftWidget( QWidget *w );
00210     void addRightWidget( QWidget *w );
00211 
00212 signals:
00213     void fileHighlighted( const QString& );
00214     void fileSelected( const QString& );
00215     void filesSelected( const QStringList& );
00216     void dirEntered( const QString& );
00217     void filterSelected( const QString& );
00218 
00219 private slots:
00220     void detailViewSelectionChanged();
00221     void listBoxSelectionChanged();
00222     void changeMode( int );
00223     void fileNameEditReturnPressed();
00224     void stopCopy();
00225     void removeProgressDia();
00226 
00227     void fileSelected( int );
00228     void fileHighlighted( int );
00229     void dirSelected( int );
00230     void pathSelected( int );
00231 
00232     void updateFileNameEdit( QListViewItem *);
00233     void selectDirectoryOrFile( QListViewItem * );
00234     void popupContextMenu( QListViewItem *, const QPoint &, int );
00235     void popupContextMenu( QListBoxItem *, const QPoint & );
00236     void updateFileNameEdit( QListBoxItem *);
00237     void selectDirectoryOrFile( QListBoxItem * );
00238     void fileNameEditDone();
00239 
00240     void okClicked();
00241     void filterClicked(); // not used
00242     void cancelClicked();
00243 
00244     void cdUpClicked();
00245     void newFolderClicked();
00246 
00247     void fixupNameEdit();
00248 
00249     void doMimeTypeLookup();
00250 
00251     void updateGeometries();
00252     void modeButtonsDestroyed();
00253     void urlStart( QNetworkOperation *op );
00254     void urlFinished( QNetworkOperation *op );
00255     void dataTransferProgress( int bytesDone, int bytesTotal, QNetworkOperation * );
00256     void insertEntry( const QValueList<QUrlInfo> &fi, QNetworkOperation *op );
00257     void removeEntry( QNetworkOperation * );
00258     void createdDirectory( const QUrlInfo &info, QNetworkOperation * );
00259     void itemChanged( QNetworkOperation * );
00260     void goBack();
00261 
00262 private:
00263     enum PopupAction {
00264         PA_Open = 0,
00265         PA_Delete,
00266         PA_Rename,
00267         PA_SortName,
00268         PA_SortSize,
00269         PA_SortType,
00270         PA_SortDate,
00271         PA_SortUnsorted,
00272         PA_Cancel,
00273         PA_Reload,
00274         PA_Hidden
00275     };
00276 
00277     void init();
00278     bool trySetSelection( bool isDir, const QUrlOperator &, bool );
00279     void deleteFile( const QString &filename );
00280     void popupContextMenu( const QString &filename, bool withSort,
00281                            PopupAction &action, const QPoint &p );
00282     void updatePreviews( const QUrl &u );
00283 
00284     QDir reserved; // was cwd
00285     QString fileName;
00286 
00287     friend class QFileDialogQFileListView;
00288     friend class QFileListBox;
00289 
00290     QFileDialogPrivate *d;
00291     QFileDialogQFileListView  *files;
00292 
00293     QLineEdit  *nameEdit; // also filter
00294     QPushButton *okB;
00295     QPushButton *cancelB;
00296 
00297 #if defined(Q_WS_WIN)
00298     static QString winGetOpenFileName( const QString &initialSelection,
00299                                        const QString &filter,
00300                                        QString* workingDirectory,
00301                                        QWidget *parent = 0,
00302                                        const char* name = 0,
00303                                        const QString& caption = QString::null,
00304                                        QString* selectedFilter = 0 );
00305     static QString winGetSaveFileName( const QString &initialSelection,
00306                                        const QString &filter,
00307                                        QString* workingDirectory,
00308                                        QWidget *parent = 0,
00309                                        const char* name = 0,
00310                                        const QString& caption = QString::null,
00311                                        QString* selectedFilter = 0 );
00312     static QStringList winGetOpenFileNames( const QString &filter,
00313                                             QString* workingDirectory,
00314                                             QWidget *parent = 0,
00315                                             const char* name = 0,
00316                                             const QString& caption = QString::null,
00317                                             QString* selectedFilter = 0 );
00318     static QString winGetExistingDirectory( const QString &initialDirectory,
00319                                             QWidget* parent = 0,
00320                                             const char* name = 0,
00321                                             const QString& caption = QString::null);
00322     static QString resolveLinkFile( const QString& linkfile );
00323 #endif
00324 #if defined(Q_WS_MACX) || defined(Q_WS_MAC9)
00325     static QString macGetSaveFileName( const QString &, const QString &,
00326                                        QString *, QWidget *, const char*,
00327                                        const QString&, QString *);
00328     static QStringList macGetOpenFileNames( const QString &, QString*,
00329                                             QWidget *, const char *,
00330                                             const QString&, QString *,
00331                                             bool = TRUE, bool = FALSE );
00332 #endif
00333 
00334 
00335 private:        // Disabled copy constructor and operator=
00336 #if defined(Q_DISABLE_COPY)
00337     QFileDialog( const QFileDialog & );
00338     QFileDialog &operator=( const QFileDialog & );
00339 #endif
00340 };
00341 
00342 #endif
00343 
00344 #endif // QFILEDIALOG_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'