kio Library API Documentation

kfiledialog.h

00001 // -*- c++ -*-
00002 /* This file is part of the KDE libraries
00003     Copyright (C) 1997, 1998 Richard Moore <rich@kde.org>
00004                   1998 Stephan Kulow <coolo@kde.org>
00005                   1998 Daniel Grana <grana@ie.iwi.unibe.ch>
00006                   2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
00007                   2001 Frerich Raabe <raabe@kde.org>
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Library General Public
00011     License as published by the Free Software Foundation; either
00012     version 2 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Library General Public License for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with this library; see the file COPYING.LIB.  If not, write to
00021     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022     Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #ifndef __KFILEDIALOG_H__
00026 #define __KFILEDIALOG_H__
00027 
00028 #include <qstring.h>
00029 
00030 #include <kdialogbase.h>
00031 
00032 #include <kfile.h>
00033 #include <kurl.h>
00034 #include <kmimetype.h>
00035 #include <kio/jobclasses.h>
00036 
00037 class QCheckBox;
00038 class QHBoxLayout;
00039 class QGridLayout;
00040 class QLabel;
00041 class QPopupMenu;
00042 class QVBoxLayout;
00043 
00044 class KActionCollection;
00045 class KDirOperator;
00046 class KURLBar;
00047 class KURLComboBox;
00048 class KFileFilterCombo;
00049 class KFileView;
00050 class KFileItem;
00051 class KPushButton;
00052 class KToolBar;
00053 class KPreviewWidgetBase;
00054 
00055 struct KFileDialogPrivate;
00056 
00078 class KFileDialog : public KDialogBase
00079 {
00080     Q_OBJECT
00081 
00082 public:
00083 
00095     enum OperationMode { Other = 0, Opening, Saving };
00096 
00117     KFileDialog(const QString& startDir, const QString& filter,
00118         QWidget *parent, const char *name,
00119         bool modal);
00120 
00157     KFileDialog(const QString& startDir, const QString& filter,
00158         QWidget *parent, const char *name,
00159         bool modal, QWidget* widget);
00160 
00161 
00165     ~KFileDialog();
00166 
00170     KURL selectedURL() const;
00171 
00175     KURL::List selectedURLs() const;
00176 
00180     KURL baseURL() const;
00181 
00186     QString selectedFile() const;
00187 
00191     QStringList selectedFiles() const;
00192 
00200     void setURL(const KURL &url, bool clearforward = true);
00201 
00207     void setSelection(const QString& name);
00208 
00226     void setOperationMode( KFileDialog::OperationMode );
00227 
00235     OperationMode operationMode() const;
00236 
00248     void setKeepLocation( bool keep );
00249 
00254     bool keepsLocation() const;
00255 
00290     void setFilter(const QString& filter);
00291 
00299     QString currentFilter() const;
00300 
00311     void setFilterMimeType(const QString &label, const KMimeType::List &types, const KMimeType::Ptr &defaultType) KDE_DEPRECATED;
00312 
00321     KMimeType::Ptr currentFilterMimeType();
00322 
00334     void setMimeFilter( const QStringList& types,
00335                         const QString& defaultType = QString::null );
00336 
00345     QString currentMimeFilter() const;
00346 
00350     void clearFilter();
00351 
00366     void setPreviewWidget(const QWidget *w) KDE_DEPRECATED;
00367 
00379    void setPreviewWidget(const KPreviewWidgetBase *w);
00380 
00406     static QString getOpenFileName(const QString& startDir= QString::null,
00407                    const QString& filter= QString::null,
00408                    QWidget *parent= 0,
00409                    const QString& caption = QString::null);
00410 
00411 
00412 
00438     static QStringList getOpenFileNames(const QString& startDir= QString::null,
00439                     const QString& filter= QString::null,
00440                     QWidget *parent = 0,
00441                     const QString& caption= QString::null);
00442 
00443 
00444 
00470     static KURL getOpenURL(const QString& startDir = QString::null,
00471                const QString& filter= QString::null,
00472                QWidget *parent= 0,
00473                const QString& caption = QString::null);
00474 
00475 
00476 
00502     static KURL::List getOpenURLs(const QString& startDir= QString::null,
00503                   const QString& filter= QString::null,
00504                   QWidget *parent = 0,
00505                   const QString& caption= QString::null);
00506 
00507 
00508 
00536     static QString getSaveFileName(const QString& startDir= QString::null,
00537                    const QString& filter= QString::null,
00538                    QWidget *parent= 0,
00539                    const QString& caption = QString::null);
00540 
00568     static KURL getSaveURL(const QString& startDir= QString::null,
00569                const QString& filter= QString::null,
00570                QWidget *parent= 0,
00571                const QString& caption = QString::null);
00572 
00573 
00592     static QString getExistingDirectory(const QString & startDir = QString::null,
00593                     QWidget * parent = 0,
00594                     const QString& caption= QString::null);
00595 
00618     static KURL getExistingURL(const QString & startDir = QString::null,
00619                                   QWidget * parent = 0,
00620                                   const QString& caption= QString::null);
00639     static KURL getImageOpenURL( const QString& startDir = QString::null,
00640                  QWidget *parent = 0,
00641                  const QString& caption = QString::null );
00642     virtual void show();
00643 
00647     void setMode( KFile::Mode m );
00648 
00670     void setMode( unsigned int m );
00671 
00676     KFile::Mode mode() const;
00677 
00685     void setLocationLabel(const QString& text);
00686 
00699     KToolBar *toolBar() const { return toolbar; }
00700 
00705     KPushButton *okButton() const;
00706 
00711     KPushButton *cancelButton() const;
00712 
00728     KURLBar *speedBar();
00729 
00734     KActionCollection *actionCollection() const;
00735 
00740     int pathComboIndex();
00741 
00754     static KURL getStartURL( const QString& startDir, QString& recentDirClass );
00755 
00760     static void setStartDir( const KURL& directory );
00761 
00762 signals:
00770     void fileSelected(const QString&);
00771 
00775     void fileHighlighted(const QString&);
00776 
00785     void selectionChanged();
00786 
00797     void filterChanged( const QString& filter );
00798 
00799 protected:
00800     KToolBar *toolbar;
00801 
00802     static KURL *lastDirectory;
00803 
00804     KURLComboBox *locationEdit;
00805 
00806     KFileFilterCombo *filterWidget;
00807 
00811     virtual void keyPressEvent( QKeyEvent *e );
00812 
00817     void init(const QString& startDir, const QString& filter, QWidget* widget);
00818 
00823     virtual void initGUI();
00824 
00829     void multiSelectionChanged();
00830 
00834     virtual void readConfig( KConfig *, const QString& group = QString::null );
00835 
00839     virtual void writeConfig( KConfig *, const QString& group = QString::null );
00840 
00844     virtual void readRecentFiles( KConfig * );
00845 
00849     virtual void saveRecentFiles( KConfig * );
00850 
00857     KURL::List tokenize(const QString& line) const;
00858 
00863     KURL getCompleteURL(const QString&);
00864 
00871     QString currentFilterExtension();
00872 
00881     void updateAutoSelectExtension();
00882 
00883 
00884 protected slots:
00885     void urlEntered( const KURL& );
00886     void enterURL( const KURL& url );
00887     void enterURL( const QString& url );
00888     void locationActivated( const QString& url );
00889 
00893     // ### remove in KDE4
00894     void toolbarCallback(int);
00898     // ### remove in KDE4
00899     void pathComboChanged( const QString& );
00903     // ### remove in KDE4
00904     void dirCompletion( const QString& );
00905 
00906     void slotFilterChanged();
00907     void fileHighlighted(const KFileItem *i);
00908     void fileSelected(const KFileItem *i);
00909     void slotStatResult(KIO::Job* job);
00910     void slotLoadingFinished();
00911 
00912     void fileCompletion( const QString& );
00916     void toggleSpeedbar( bool );
00917 
00921     virtual void updateStatusLine(int dirs, int files);
00922 
00923     virtual void slotOk();
00924     virtual void accept();
00925     virtual void slotCancel();
00926 
00927     void slotAutoSelectExtClicked();
00928     void addToRecentDocuments();
00929     void initSpeedbar();
00930 
00931 private slots:
00932     void slotLocationChanged( const QString& text );
00933 
00934 private:
00935     KFileDialog(const KFileDialog&);
00936     KFileDialog operator=(const KFileDialog&);
00937 
00938     void setLocationText( const QString& text );
00939     void updateLocationWhatsThis();
00940 
00941     void appendExtension(KURL &url);
00942     void updateLocationEditExtension(const QString &);
00943 
00944     static void initStatic();
00945 
00946 protected:
00947     KDirOperator *ops;
00948     bool autoDirectoryFollowing;
00949 
00950     KURL::List& parseSelectedURLs() const;
00951 
00952 protected:
00953     virtual void virtual_hook( int id, void* data );
00954 private:
00955     KFileDialogPrivate *d;
00956 };
00957 
00958 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 3 19:23:40 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003