KFileDialog Class Reference
Provides a user (and developer) friendly way to select files and directories. A file selection dialog. More...
#include <kfiledialog.h>
Inheritance diagram for KFileDialog:


Public Types | |
| enum | OperationMode { Other = 0, Opening, Saving } |
Signals | |
| void | fileSelected (const QString &) |
| void | fileHighlighted (const QString &) |
| void | selectionChanged () |
| void | filterChanged (const QString &filter) |
Public Member Functions | |
| KFileDialog (const QString &startDir, const QString &filter, QWidget *parent, const char *name, bool modal) | |
| KFileDialog (const QString &startDir, const QString &filter, QWidget *parent, const char *name, bool modal, QWidget *widget) | |
| ~KFileDialog () | |
| KURL | selectedURL () const |
| KURL::List | selectedURLs () const |
| KURL | baseURL () const |
| QString | selectedFile () const |
| QStringList | selectedFiles () const |
| void | setURL (const KURL &url, bool clearforward=true) |
| void | setSelection (const QString &name) |
| void | setOperationMode (KFileDialog::OperationMode) |
| OperationMode | operationMode () const |
| void | setKeepLocation (bool keep) |
| bool | keepsLocation () const |
| void | setFilter (const QString &filter) |
| QString | currentFilter () const |
| void | setFilterMimeType (const QString &label, const KMimeType::List &types, const KMimeType::Ptr &defaultType) KDE_DEPRECATED |
| KMimeType::Ptr | currentFilterMimeType () |
| void | setMimeFilter (const QStringList &types, const QString &defaultType=QString::null) |
| QString | currentMimeFilter () const |
| void | clearFilter () |
| void | setPreviewWidget (const QWidget *w) KDE_DEPRECATED |
| void | setPreviewWidget (const KPreviewWidgetBase *w) |
| virtual void | show () |
| void | setMode (KFile::Mode m) |
| void | setMode (unsigned int m) |
| KFile::Mode | mode () const |
| void | setLocationLabel (const QString &text) |
| KToolBar * | toolBar () const |
| KPushButton * | okButton () const |
| KPushButton * | cancelButton () const |
| KURLBar * | speedBar () |
| KActionCollection * | actionCollection () const |
| int | pathComboIndex () |
Static Public Member Functions | |
| static QString | getOpenFileName (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static QString | getOpenFileNameWId (const QString &startDir, const QString &filter, WId parent_id, const QString &caption) |
| static QStringList | getOpenFileNames (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static KURL | getOpenURL (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static KURL::List | getOpenURLs (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static QString | getSaveFileName (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static QString | getSaveFileNameWId (const QString &dir, const QString &filter, WId parent_id, const QString &caption) |
| static KURL | getSaveURL (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static QString | getExistingDirectory (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static KURL | getExistingURL (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static KURL | getImageOpenURL (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null) |
| static KURL | getStartURL (const QString &startDir, QString &recentDirClass) |
| static void | setStartDir (const KURL &directory) |
Protected Slots | |
| void | urlEntered (const KURL &) |
| void | enterURL (const KURL &url) |
| void | enterURL (const QString &url) |
| void | locationActivated (const QString &url) |
| void | toolbarCallback (int) |
| void | pathComboChanged (const QString &) |
| void | dirCompletion (const QString &) |
| void | slotFilterChanged () |
| void | fileHighlighted (const KFileItem *i) |
| void | fileSelected (const KFileItem *i) |
| void | slotStatResult (KIO::Job *job) |
| void | slotLoadingFinished () |
| void | fileCompletion (const QString &) |
| void | toggleSpeedbar (bool) |
| void | toggleBookmarks (bool show) |
| virtual void | updateStatusLine (int dirs, int files) |
| virtual void | slotOk () |
| virtual void | accept () |
| virtual void | slotCancel () |
| void | slotAutoSelectExtClicked () |
| void | addToRecentDocuments () |
| void | initSpeedbar () |
Protected Member Functions | |
| virtual void | keyPressEvent (QKeyEvent *e) |
| void | init (const QString &startDir, const QString &filter, QWidget *widget) |
| virtual void | initGUI () |
| void | multiSelectionChanged () |
| virtual void | readConfig (KConfig *, const QString &group=QString::null) |
| virtual void | writeConfig (KConfig *, const QString &group=QString::null) |
| virtual void | readRecentFiles (KConfig *) |
| virtual void | saveRecentFiles (KConfig *) |
| KURL::List | tokenize (const QString &line) const |
| KURL | getCompleteURL (const QString &) |
| QString | currentFilterExtension () |
| void | updateAutoSelectExtension () |
| KURL::List & | parseSelectedURLs () const |
| virtual void | virtual_hook (int id, void *data) |
Protected Attributes | |
| KToolBar * | toolbar |
| KURLComboBox * | locationEdit |
| KFileFilterCombo * | filterWidget |
| KDirOperator * | ops |
| bool | autoDirectoryFollowing |
Static Protected Attributes | |
| static KURL * | lastDirectory |
Detailed Description
Provides a user (and developer) friendly way to select files and directories. A file selection dialog.The widget can be used as a drop in replacement for the QFileDialog widget, but has greater functionality and a nicer GUI.
You will usually want to use one of the static methods getOpenFileName(), getSaveFileName(), getOpenURL() or for multiple files getOpenFileNames() or getOpenURLs().
The dialog has been designed to allow applications to customise it by subclassing. It uses geometry management to ensure that subclasses can easily add children that will be incorporated into the layout.
KDE File Dialog
- Author:
- Richard J. Moore <rich@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org>
Definition at line 77 of file kfiledialog.h.
Member Enumeration Documentation
|
|
Defines some default behavior of the filedialog.
E.g. in mode
Definition at line 94 of file kfiledialog.h. |
Constructor & Destructor Documentation
|
||||||||||||||||||||||||
|
Constructs a file dialog.
Definition at line 168 of file kfiledialog.cpp. References init(). |
|
||||||||||||||||||||||||||||
|
Constructs a file dialog. The parameters here are identical to the first constructor except for the addition of a QWidget parameter. Historical note: The original version of KFileDialog did not have this extra parameter. It was added later, and, in order to maintain binary compatibility, it was placed in a new constructor instead of added to the original one.
Definition at line 175 of file kfiledialog.cpp. References init(). |
|
|
Destructs the file dialog.
Definition at line 183 of file kfiledialog.cpp. References KGlobal::config(), and KConfigBase::sync(). |
Member Function Documentation
|
|
Definition at line 1426 of file kfiledialog.cpp. References QDialog::result(), and KURL::url(). Referenced by getOpenURL(), getSaveURL(), and KURLRequester::slotOpenDialog(). |
|
|
Definition at line 1434 of file kfiledialog.cpp. References QValueList::append(), KDirOperator::mode(), and QDialog::result(). Referenced by getOpenURLs(). |
|
|
Definition at line 1566 of file kfiledialog.cpp. References KDirOperator::url(). |
|
|
Returns the full path of the selected file in the local filesystem. (Local files only) Definition at line 1527 of file kfiledialog.cpp. References QDialog::result(), and KMessageBox::sorry(). Referenced by getOpenFileName(), getOpenFileNameWId(), getSaveFileName(), and getSaveFileNameWId(). |
|
|
Returns a list of all selected local files.
Definition at line 1542 of file kfiledialog.cpp. References QValueList::begin(), QValueList::end(), KDirOperator::mode(), and QDialog::result(). Referenced by getOpenFileNames(). |
|
||||||||||||
|
Sets the directory to view.
Definition at line 1143 of file kfiledialog.cpp. References KDirOperator::setURL(). Referenced by setSelection(). |
|
|
Sets the file name to preselect to This takes absolute URLs and relative file names. Definition at line 1204 of file kfiledialog.cpp. References endl(), QFile::exists(), QString::findRev(), getCompleteURL(), KFileItem::isDir(), KURL::isLocalFile(), KURL::isValid(), kdDebug(), kdWarning(), QComboBox::lineEdit(), KURL::path(), KURL::setFileName(), KURL::setQuery(), setURL(), KDirOperator::url(), and KURL::url(). Referenced by getSaveFileName(), getSaveFileNameWId(), getSaveURL(), init(), and KURLRequester::slotOpenDialog(). |
|
|
Sets the operational mode of the filedialog to This will set some flags that are specific to loading or saving files. E.g. setKeepLocation() makes mostly sense for a save-as dialog. So setOperationMode( KFileDialog::Saving ); sets setKeepLocation for example.
The mode
The default mode is Call this method right after instantiating KFileDialog.
Definition at line 1810 of file kfiledialog.cpp. References updateAutoSelectExtension(). Referenced by getOpenFileName(), getOpenFileNames(), getOpenFileNameWId(), getOpenURL(), getOpenURLs(), getSaveFileName(), getSaveFileNameWId(), getSaveURL(), and KEncodingFileDialog::KEncodingFileDialog(). |
|
|
Definition at line 1825 of file kfiledialog.cpp. Referenced by updateAutoSelectExtension(). |
|
|
Sets whether the filename/url should be kept when changing directories. This is for example useful when having a predefined filename where the full path for that file is searched. This is implicitly set when operationMode() is KFileDialog::Saving getSaveFileName() and getSaveURL() set this to true by default, so that you can type in the filename and change the directory without having to type the name again. Definition at line 1800 of file kfiledialog.cpp. |
|
|
Definition at line 1805 of file kfiledialog.cpp. |
|
|
Sets the filter to be used to
You can set more filters for the user to select separated by '
kfile->setFilter("*.cpp|C++ Source Files\n*.h|Header files"); kfile->setFilter("*.cpp"); kfile->setFilter("*.cpp|Sources (*.cpp)"); kfile->setFilter("*.cpp|" + i18n("Sources (*.cpp)")); kfile->setFilter("*.cpp *.cc *.C|C++ Source Files\n*.h *.H|Header files"); Note: The text to display is not parsed in any way. So, if you want to show the suffix to select by a specific filter, you must repeat it. If the filter contains an unescaped '/', a mimetype-filter is assumed. If you would like a '/' visible in your filter it can be escaped with a '\'. You can specify multiple mimetypes like this (separated with space):
kfile->setFilter( "image/png text/html text/plain" ); kfile->setFilter( "*.cue|CUE\\/BIN Files (*.cue)" );
Definition at line 204 of file kfiledialog.cpp. References KDirOperator::clearFilter(), QWidget::find(), KShortcut::remove(), setMimeFilter(), KDirOperator::setNameFilter(), QStringList::split(), and updateAutoSelectExtension(). Referenced by init(), and KURLRequester::setFilter(). |
|
|
Returns the current filter as entered by the user or one of the predefined set via setFilter().
Definition at line 233 of file kfiledialog.cpp. Referenced by updateAutoSelectExtension(). |
|
||||||||||||||||
|
Sets the filter up to specify the output type.
Definition at line 239 of file kfiledialog.cpp. References QString::append(), and setMimeFilter(). |
|
|
Returns the mimetype for the desired output format. This is only valid if setFilterMimeType() has been called previously.
Definition at line 292 of file kfiledialog.cpp. References currentMimeFilter(), and KMimeType::mimeType(). |
|
||||||||||||
|
Sets the filter up to specify the output type.
Definition at line 253 of file kfiledialog.cpp. References KDirOperator::clearFilter(), KDirOperator::setMimeFilter(), QStringList::split(), and updateAutoSelectExtension(). Referenced by setFilter(), and setFilterMimeType(). |
|
|
The mimetype for the desired output format. This is only valid if setMimeFilter() has been called previously.
Definition at line 281 of file kfiledialog.cpp. Referenced by currentFilterMimeType(). |
|
|
Clears any mime- or namefilter. Does not reload the directory. Definition at line 270 of file kfiledialog.cpp. References KDirOperator::clearFilter(), and updateAutoSelectExtension(). |
|
|
Ownership is transferred to KFileDialog. You need to create the preview-widget with "new", i.e. on the heap. Definition at line 297 of file kfiledialog.cpp. References KDirOperator::clearHistory(), and KDirOperator::setPreviewWidget(). |
|
|
Adds a preview widget and enters the preview mode. In this mode the dialog is split and the right part contains your preview widget. Ownership is transferred to KFileDialog. You need to create the preview-widget with "new", i.e. on the heap.
Definition at line 303 of file kfiledialog.cpp. References KDirOperator::clearHistory(), and KDirOperator::setPreviewWidget(). |
|
||||||||||||||||||||
|
Creates a modal file dialog and return the selected filename or an empty string if none was chosen. Note that with this method the user must select an existing filename.
Definition at line 1298 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), ops, selectedFile(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
||||||||||||||||||||
|
Use this version only if you have no QWidget available as parent widget. This can be the case if the parent widget is a widget in another process or if the parent widget is a non-Qt widget. For example, in a GTK program.
Definition at line 1314 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), QWidget::find(), ops, selectedFile(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
||||||||||||||||||||
|
Creates a modal file dialog and returns the selected filenames or an empty list if none was chosen. Note that with this method the user must select an existing filename.
Definition at line 1338 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), ops, selectedFiles(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
||||||||||||||||||||
|
Creates a modal file dialog and returns the selected URL or an empty string if none was chosen. Note that with this method the user must select an existing URL.
Definition at line 1354 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), ops, selectedURL(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
||||||||||||||||||||
|
Creates a modal file dialog and returns the selected URLs or an empty list if none was chosen. Note that with this method the user must select an existing filename.
Definition at line 1368 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), ops, selectedURLs(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
||||||||||||||||||||
|
Creates a modal file dialog and returns the selected filename or an empty string if none was chosen. Note that with this method the user need not select an existing filename.
Definition at line 1571 of file kfiledialog.cpp. References KRecentDocument::add(), QString::at(), QDialog::exec(), QString::isEmpty(), selectedFile(), KDialog::setCaption(), setOperationMode(), and setSelection(). |
|
||||||||||||||||||||
|
This function accepts the window id of the parent window, instead of QWidget*. It should be used only when necessary.
Definition at line 1592 of file kfiledialog.cpp. References KRecentDocument::add(), QString::at(), QDialog::exec(), QWidget::find(), QString::isEmpty(), selectedFile(), KDialog::setCaption(), setOperationMode(), and setSelection(). |
|
||||||||||||||||||||
|
Creates a modal file dialog and returns the selected filename or an empty string if none was chosen. Note that with this method the user need not select an existing filename.
Definition at line 1621 of file kfiledialog.cpp. References KRecentDocument::add(), QDialog::exec(), KURL::isValid(), selectedURL(), KDialog::setCaption(), setOperationMode(), and setSelection(). |
|
||||||||||||||||
|
Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.
Definition at line 1391 of file kfiledialog.cpp. References QFileDialog::getExistingDirectory(), KURL::isValid(), KURL::path(), and KDirSelectDialog::selectDirectory(). |
|
