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 KURLComboBox;
00047 class KFileFilterCombo;
00048 class KFileView;
00049 class KFileItem;
00050 class KPushButton;
00051 class KToolBar;
00052 class KPreviewWidgetBase;
00053 
00054 struct KFileDialogPrivate;
00055 
00077 class KFileDialog : public KDialogBase
00078 {
00079     Q_OBJECT
00080 
00081 public:
00093     enum OperationMode { Other = 0, Opening, Saving };
00094 
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 
00164     ~KFileDialog();
00165 
00169     KURL selectedURL() const;
00170 
00174     KURL::List selectedURLs() const;
00175 
00179     KURL baseURL() const;
00180 
00185     QString selectedFile() const;
00186 
00190     QStringList selectedFiles() const;
00191 
00199     void setURL(const KURL &url, bool clearforward = true);
00200 
00206     void setSelection(const QString& name);
00207 
00225     void setOperationMode( KFileDialog::OperationMode );
00226 
00234     OperationMode operationMode() const;
00235 
00247     void setKeepLocation( bool keep );
00248 
00253     bool keepsLocation() const;
00254 
00288     void setFilter(const QString& filter);
00289 
00300     QString currentFilter() const;
00301 
00312     void setFilterMimeType(const QString &label, const KMimeType::List &types, const KMimeType::Ptr &defaultType);
00313 
00322     KMimeType::Ptr currentFilterMimeType();
00323 
00335     void setMimeFilter( const QStringList& types,
00336                         const QString& defaultType = QString::null );
00337 
00346     QString currentMimeFilter() const;
00347 
00351     void clearFilter();
00352 
00367     void setPreviewWidget(const QWidget *w);
00368 
00380    void setPreviewWidget(const KPreviewWidgetBase *w);
00381 
00407     static QString getOpenFileName(const QString& startDir= QString::null,
00408                    const QString& filter= QString::null,
00409                    QWidget *parent= 0,
00410                    const QString& caption = QString::null);
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 
00468     static KURL getOpenURL(const QString& startDir = QString::null,
00469                const QString& filter= QString::null,
00470                QWidget *parent= 0,
00471                const QString& caption = QString::null);
00472 
00473 
00499     static KURL::List getOpenURLs(const QString& startDir= QString::null,
00500                   const QString& filter= QString::null,
00501                   QWidget *parent = 0,
00502                   const QString& caption= QString::null);
00503 
00531     static QString getSaveFileName(const QString& startDir= QString::null,
00532                    const QString& filter= QString::null,
00533                    QWidget *parent= 0,
00534                    const QString& caption = QString::null);
00535 
00563     static KURL getSaveURL(const QString& startDir= QString::null,
00564                const QString& filter= QString::null,
00565                QWidget *parent= 0,
00566                const QString& caption = QString::null);
00585     static QString getExistingDirectory(const QString & startDir = QString::null,
00586                     QWidget * parent = 0,
00587                     const QString& caption= QString::null);
00588 
00611     static KURL getExistingURL(const QString & startDir = QString::null,
00612                                   QWidget * parent = 0,
00613                                   const QString& caption= QString::null);
00632     static KURL getImageOpenURL( const QString& startDir = QString::null,
00633                  QWidget *parent = 0,
00634                  const QString& caption = QString::null );
00638     virtual void show();
00639 
00643     void setMode( KFile::Mode m );
00644 
00666     void setMode( unsigned int m );
00667 
00672     KFile::Mode mode() const;
00673 
00681     void setLocationLabel(const QString& text);
00682 
00695     KToolBar *toolBar() const { return toolbar; }
00696 
00701     KPushButton *okButton() const;
00702 
00707     KPushButton *cancelButton() const;
00708 
00713     KActionCollection *actionCollection() const;
00714 
00719     int pathComboIndex();
00720 
00733     static KURL getStartURL( const QString& startDir, QString& recentDirClass );
00734 
00735 
00736 signals:
00744     void fileSelected(const QString&);
00745 
00749     void fileHighlighted(const QString&);
00750 
00759     void selectionChanged();
00760 
00771     void filterChanged( const QString& filter );
00772 
00773 protected:
00774     KToolBar *toolbar;
00775 
00776     static KURL *lastDirectory;
00777 
00778     KURLComboBox *locationEdit;
00779 
00780     KFileFilterCombo *filterWidget;
00781 
00786     void addDirEntry(KFileItem *entry, bool disableUpdating);
00787 
00792     void init(const QString& startDir, const QString& filter, QWidget* widget);
00793 
00798     virtual void initGUI();
00799 
00804     void multiSelectionChanged();
00805 
00809     virtual void readConfig( KConfig *, const QString& group = QString::null );
00810 
00814     virtual void writeConfig( KConfig *, const QString& group = QString::null );
00815 
00819     virtual void readRecentFiles( KConfig * );
00820 
00824     virtual void saveRecentFiles( KConfig * );
00825 
00832     KURL::List tokenize(const QString& line) const;
00833 
00834 protected slots:
00835     void urlEntered( const KURL& );
00836     void enterURL( const KURL& url );
00837     void enterURL( const QString& url );
00838     void locationActivated( const QString& url );
00839 
00843     void toolbarCallback(int);
00844 
00845     void slotFilterChanged();
00846     void pathComboChanged( const QString& );
00847     void fileHighlighted(const KFileItem *i);
00848     void fileSelected(const KFileItem *i);
00849     void slotStatResult(KIO::Job* job);
00850     void slotLoadingFinished();
00851 
00852     void dirCompletion( const QString& );
00853     void fileCompletion( const QString& );
00857     void toggleSpeedbar( bool );
00858 
00862     virtual void updateStatusLine(int dirs, int files);
00863 
00864     virtual void slotOk();
00865     virtual void accept();
00866     virtual void slotCancel();
00867 
00868     void addToRecentDocuments();
00869     void initSpeedbar();
00870 
00871 private:
00872     KFileDialog(const KFileDialog&);
00873     KFileDialog operator=(const KFileDialog&);
00874     static void initStatic();
00875 
00876 protected:
00877     KDirOperator *ops;
00878     bool autoDirectoryFollowing;
00879 
00880     KURL::List& parseSelectedURLs() const;
00881 
00882 protected:
00883     virtual void virtual_hook( int id, void* data );
00884 private:
00885     KFileDialogPrivate *d;
00886 };
00887 
00888 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:29 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001