kio Library API Documentation

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:

Inheritance graph
[legend]
Collaboration diagram for KFileDialog:

Collaboration graph
[legend]
List of all members.

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)
KToolBartoolBar () const
KPushButtonokButton () const
KPushButtoncancelButton () const
KURLBarspeedBar ()
KActionCollectionactionCollection () const
int pathComboIndex ()

Static Public Member Functions

QString getOpenFileName (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
QStringList getOpenFileNames (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
KURL getOpenURL (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
KURL::List getOpenURLs (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
QString getSaveFileName (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
KURL getSaveURL (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
QString getExistingDirectory (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null)
KURL getExistingURL (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null)
KURL getImageOpenURL (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null)
KURL getStartURL (const QString &startDir, QString &recentDirClass)
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)
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::ListparseSelectedURLs () const
virtual void virtual_hook (int id, void *data)

Protected Attributes

KToolBartoolbar
KURLComboBoxlocationEdit
KFileFilterCombo * filterWidget
KDirOperatorops
bool autoDirectoryFollowing

Static Protected Attributes

KURLlastDirectory

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.

kfiledialog.png

KDE File Dialog

Author:
Richard J. Moore <rich@kde.org>, Carsten Pfeiffer <pfeiffer@kde.org>

Definition at line 78 of file kfiledialog.h.


Member Enumeration Documentation

enum KFileDialog::OperationMode
 

Defines some default behavior of the filedialog.

E.g. in mode Opening and Saving, the selected files/urls will be added to the "recent documents" list. The Saving mode also implies setKeepLocation() being set.

Other means that no default actions are performed.

See also:
setOperationMode

operationMode

Definition at line 95 of file kfiledialog.h.

Referenced by operationMode().


Constructor & Destructor Documentation

KFileDialog::KFileDialog const QString startDir,
const QString filter,
QWidget parent,
const char *  name,
bool  modal
 

Constructs a file dialog.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter A shell glob or a mime-type-filter that specifies which files to display. See setFilter() for details on how to use this argument.

Definition at line 165 of file kfiledialog.cpp.

References init().

KFileDialog::KFileDialog const QString startDir,
const QString filter,
QWidget parent,
const char *  name,
bool  modal,
QWidget widget
 

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.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter A shell glob or a mime-type-filter that specifies which files to display. See setFilter() for details on how to use this argument.
acceptURLs If set to false, the dialog will just accept files on the local filesystem.
widget A widget, or a widget of widgets, for displaying custom data in the dialog. This can be used, for example, to display a check box with the caption "Open as read-only". When creating this widget, you don't need to specify a parent, since the widget's parent will be set automatically by KFileDialog.
Since:
3.1

Definition at line 172 of file kfiledialog.cpp.

References init().

KFileDialog::~KFileDialog  ) 
 

Destructs the file dialog.

Definition at line 180 of file kfiledialog.cpp.

References KGlobal::config(), and KConfigBase::sync().


Member Function Documentation

KURL KFileDialog::selectedURL  )  const
 

Returns:
The selected fully qualified filename.

Definition at line 1399 of file kfiledialog.cpp.

References QDialog::result().

Referenced by getImageOpenURL(), getOpenURL(), KEncodingFileDialog::getOpenURLAndEncoding(), getSaveURL(), KEncodingFileDialog::getSaveURLAndEncoding(), and KURLRequester::slotOpenDialog().

KURL::List KFileDialog::selectedURLs  )  const
 

Returns:
The list of selected URLs.

Definition at line 1407 of file kfiledialog.cpp.

References QValueList< KURL >::append(), KDirOperator::mode(), and QDialog::result().

Referenced by getOpenURLs(), and KEncodingFileDialog::getOpenURLsAndEncoding().

KURL KFileDialog::baseURL  )  const
 

Returns:
the currently shown directory.

Definition at line 1534 of file kfiledialog.cpp.

References KDirOperator::url().

QString KFileDialog::selectedFile  )  const
 

Returns the full path of the selected file in the local filesystem.

(Local files only)

Definition at line 1500 of file kfiledialog.cpp.

References QDialog::result().

Referenced by getOpenFileName(), KEncodingFileDialog::getOpenFileNameAndEncoding(), getSaveFileName(), and KEncodingFileDialog::getSaveFileNameAndEncoding().

QStringList KFileDialog::selectedFiles  )  const
 

Returns a list of all selected local files.

Definition at line 1510 of file kfiledialog.cpp.

References QValueList< KURL >::begin(), QValueList< KURL >::end(), KDirOperator::mode(), and QDialog::result().

Referenced by getOpenFileNames(), and KEncodingFileDialog::getOpenFileNamesAndEncoding().

void KFileDialog::setURL const KURL url,
bool  clearforward = true
 

Sets the directory to view.

Parameters:
url URL to show.
clearforward Indicates whether the forward queue should be cleared.

Definition at line 1149 of file kfiledialog.cpp.

References KDirOperator::setURL().

Referenced by setSelection().

void KFileDialog::setSelection const QString name  ) 
 

Sets the file name to preselect to name.

This takes absolute URLs and relative file names.

Definition at line 1210 of file kfiledialog.cpp.

References QFile::exists(), KURL::fileName(), QString::findRev(), getCompleteURL(), KFileItem::isDir(), QString::isEmpty(), KURL::isLocalFile(), KURL::isValid(), kdDebug(), kdWarning(), QString::left(), QComboBox::lineEdit(), KURL::path(), setURL(), KProtocolInfo::supportsListing(), KDirOperator::url(), and KURL::url().

Referenced by getSaveFileName(), KEncodingFileDialog::getSaveFileNameAndEncoding(), getSaveURL(), KEncodingFileDialog::getSaveURLAndEncoding(), init(), and KURLRequester::slotOpenDialog().

void KFileDialog::setOperationMode KFileDialog::OperationMode   ) 
 

Sets the operational mode of the filedialog to Saving, Opening or Other.

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 Saving, together with a default filter set via setMimeFilter() will make the filter combobox read-only.

The default mode is Opening.

Call this method right after instantiating KFileDialog.

See also:
operationMode

KFileDialog::OperationMode

Definition at line 1740 of file kfiledialog.cpp.

References updateAutoSelectExtension().

Referenced by getImageOpenURL(), getOpenFileName(), getOpenFileNames(), getOpenURL(), getOpenURLs(), getSaveFileName(), getSaveURL(), and KEncodingFileDialog::KEncodingFileDialog().

KFileDialog::OperationMode KFileDialog::operationMode  )  const
 

Returns:
the current operation mode, Opening, Saving or Other. Default is Other.
See also:
operationMode

KFileDialog::OperationMode

Definition at line 1750 of file kfiledialog.cpp.

References OperationMode.

Referenced by updateAutoSelectExtension().

void KFileDialog::setKeepLocation bool  keep  ) 
 

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 1730 of file kfiledialog.cpp.

bool KFileDialog::keepsLocation  )  const
 

Returns:
whether the contents of the location edit are kept when changing directories.

Definition at line 1735 of file kfiledialog.cpp.

void KFileDialog::setFilter const QString filter  ) 
 

Sets the filter to be used to filter.

You can set more filters for the user to select separated by '
'. Every filter entry is defined through namefilter|text to diplay. If no | is found in the expression, just the namefilter is shown. Examples:

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)" );

See also:
filterChanged

setMimeFilter

Definition at line 201 of file kfiledialog.cpp.

References KDirOperator::clearFilter(), QString::find(), setMimeFilter(), KDirOperator::setNameFilter(), QStringList::split(), and updateAutoSelectExtension().

Referenced by KURLRequester::fileDialog(), init(), and KURLRequester::setFilter().

QString KFileDialog::currentFilter  )  const
 

Returns the current filter as entered by the user or one of the predefined set via setFilter().

See also:
setFilter()

filterChanged()

Definition at line 230 of file kfiledialog.cpp.

Referenced by updateAutoSelectExtension().

void KFileDialog::setFilterMimeType const QString label,
const KMimeType::List types,
const KMimeType::Ptr defaultType
 

Sets the filter up to specify the output type.

Parameters:
label the label to use instead of "Filter:"
types a list of mimetypes that can be used as output format
defaultType the default mimetype to use as output format.
Do not use in conjunction with setFilter()

Deprecated:

Definition at line 236 of file kfiledialog.cpp.

References setMimeFilter().

KMimeType::Ptr KFileDialog::currentFilterMimeType  ) 
 

Returns the mimetype for the desired output format.

This is only valid if setFilterMimeType() has been called previously.

See also:
setFilterMimeType()

Definition at line 289 of file kfiledialog.cpp.

References currentMimeFilter(), and KMimeType::mimeType().

void KFileDialog::setMimeFilter const QStringList types,
const QString defaultType = QString::null
 

Sets the filter up to specify the output type.

Parameters:
types a list of mimetypes that can be used as output format
defaultType the default mimetype to use as output format, if any. If defaultType is set, it will be set as the current item. Otherwise, a first item showing all the mimetypes will be created. Typically, defaultType should be empty for loading and set for saving.
Do not use in conjunction with setFilter()

Definition at line 250 of file kfiledialog.cpp.

References KDirOperator::clearFilter(), QString::isEmpty(), KDirOperator::setMimeFilter(), QStringList::split(), and updateAutoSelectExtension().

Referenced by setFilter(), and setFilterMimeType().

QString KFileDialog::currentMimeFilter  )  const
 

The mimetype for the desired output format.

This is only valid if setMimeFilter() has been called previously.

See also:
setMimeFilter()

Definition at line 278 of file kfiledialog.cpp.

Referenced by currentFilterMimeType().

void KFileDialog::clearFilter  ) 
 

Clears any mime- or namefilter.

Does not reload the directory.

Definition at line 267 of file kfiledialog.cpp.

References KDirOperator::clearFilter(), and updateAutoSelectExtension().

void KFileDialog::setPreviewWidget const QWidget w  ) 
 

Deprecated:
Add a preview widget and enter the preview mode.
In this mode the dialog is split and the right part contains your widget. This widget has to inherit QWidget and it has to implement a slot showPreview(const KURL &); which is called every time the file changes. You may want to look at koffice/lib/kofficecore/koFilterManager.cc for some hints :)

Ownership is transferred to KFileDialog. You need to create the preview-widget with "new", i.e. on the heap.

Definition at line 294 of file kfiledialog.cpp.

References KDirOperator::clearHistory(), and KDirOperator::setPreviewWidget().

Referenced by getImageOpenURL().

void KFileDialog::setPreviewWidget const KPreviewWidgetBase w  ) 
 

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.

Parameters:
w The widget to be used for the preview.

Definition at line 300 of file kfiledialog.cpp.

References KDirOperator::clearHistory(), and KDirOperator::setPreviewWidget().

QString KFileDialog::getOpenFileName const QString startDir = QString::null,
const QString filter = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

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.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1300 of file kfiledialog.cpp.

References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedFile(), KDialog::setCaption(), setMode(), and setOperationMode().

QStringList KFileDialog::getOpenFileNames const QString startDir = QString::null,
const QString filter = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

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.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1316 of file kfiledialog.cpp.

References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedFiles(), KDialog::setCaption(), setMode(), and setOperationMode().

KURL KFileDialog::getOpenURL const QString startDir = QString::null,
const QString filter = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

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.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1332 of file kfiledialog.cpp.

References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedURL(), KDialog::setCaption(), setMode(), and setOperationMode().

KURL::List KFileDialog::getOpenURLs const QString startDir = QString::null,
const QString filter = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

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.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1346 of file kfiledialog.cpp.

References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedURLs(), KDialog::setCaption(), setMode(), and setOperationMode().

QString KFileDialog::getSaveFileName const QString startDir = QString::null,
const QString filter = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

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.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • a relative path or a filename determining the directory to start in and the file to be selected.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1539 of file kfiledialog.cpp.

References KRecentDocument::add(), QString::at(), QDialog::exec(), QString::isEmpty(), QString::isNull(), selectedFile(), KDialog::setCaption(), setOperationMode(), and setSelection().

KURL KFileDialog::getSaveURL const QString startDir = QString::null,
const QString filter = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

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.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • a relative path or a filename determining the directory to start in and the file to be selected.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
filter This is a space separated list of shell globs. You can set the text to be displayed for the glob, and provide multiple globs. See setFilter() for details on how to do this...
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1560 of file kfiledialog.cpp.

References KRecentDocument::add(), QString::at(), QDialog::exec(), QString::isNull(), KURL::isValid(), selectedURL(), KDialog::setCaption(), setOperationMode(), and setSelection().

QString KFileDialog::getExistingDirectory const QString startDir = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1369 of file kfiledialog.cpp.

References KURL::isValid(), KURL::path(), and KDirSelectDialog::selectDirectory().

KURL KFileDialog::getExistingURL const QString startDir = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.

Contrary to getExistingDirectory(), this method allows the selection of a remote directory.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.
Since:
3.1

Definition at line 1362 of file kfiledialog.cpp.

References KDirSelectDialog::selectDirectory().

KURL KFileDialog::getImageOpenURL const QString startDir = QString::null,
QWidget parent = 0,
const QString caption = QString::null
[static]
 

Creates a modal file dialog with an image previewer and returns the selected url or an empty string if none was chosen.

Parameters:
startDir This can either be
  • The URL of the directory to start in.
  • QString::null to start in the current working directory, or the last directory where a file has been selected.
  • ':<keyword>' to start in the directory last used by a filedialog in the same application that specified the same keyword.
  • '::<keyword>' to start in the directory last used by a filedialog in any application that specified the same keyword.
parent The widget the dialog will be centered on initially.
caption The name of the dialog widget.

Definition at line 1381 of file kfiledialog.cpp.

References QDialog::exec(), QString::isNull(), QStringList::join(), KImageIO::mimeTypes(), selectedURL(), KDialog::setCaption(), setMode(), setOperationMode(), and setPreviewWidget().

void KFileDialog::setMode KFile::Mode  m  ) 
 

Convenient overload of the other setMode(unsigned int) method.

Definition at line 1591 of file kfiledialog.cpp.

References KDirOperator::dirOnlyMode(), KDirOperator::setMode(), and updateAutoSelectExtension().

Referenced by KURLRequester::fileDialog(), getImageOpenURL(), getOpenFileName(), KEncodingFileDialog::getOpenFileNameAndEncoding(), getOpenFileNames(), KEncodingFileDialog::getOpenFileNamesAndEncoding(), getOpenURL(), KEncodingFileDialog::getOpenURLAndEncoding(), getOpenURLs(), KEncodingFileDialog::getOpenURLsAndEncoding(), KURLRequester::setMode(), and setMode().

void KFileDialog::setMode unsigned int  m  ) 
 

Sets the mode of the dialog.

The mode is defined as (in kfile.h):

enum Mode { File = 1, Directory = 2, Files = 4, ExistingOnly = 8, LocalOnly = 16 };
You can OR the values, e.g.
KFile::Mode mode = static_cast<KFile::Mode>( KFile::Files | KFile::ExistingOnly | KFile::LocalOnly ); setMode( mode );

Definition at line 1604 of file kfiledialog.cpp.

References setMode().