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:

KDialogBase KDialog QDialog List of all members.

Public Types

enum  OperationMode
 Defines some default behavior of the filedialog. More...


Signals

void fileSelected (const QString &)
 Emitted when the user selects a file.

void fileHighlighted (const QString &)
 Emitted when the user highlights a file.

void selectionChanged ()
 Emitted when the user hilights one or more files in multiselection mode.

void filterChanged (const QString &filter)
 Emitted when the filter changed, i.e.


Public Methods

 KFileDialog (const QString &startDir, const QString &filter, QWidget *parent, const char *name, bool modal)
 Constructs a file dialog.

 KFileDialog (const QString &startDir, const QString &filter, QWidget *parent, const char *name, bool modal, QWidget *widget)
 Constructs a file dialog.

 ~KFileDialog ()
 Destructs the file dialog.

KURL selectedURL () const
KURL::List selectedURLs () const
KURL baseURL () const
QString selectedFile () const
 Returns the full path of the selected file in the local filesystem.

QStringList selectedFiles () const
 Returns a list of all selected local files.

void setURL (const KURL &url, bool clearforward=true)
 Sets the directory to view.

void setSelection (const QString &name)
 Sets the file name to preselect to name.

void setOperationMode (KFileDialog::OperationMode)
 Sets the operational mode of the filedialog to Saving, Opening or Other.

OperationMode operationMode () const
void setKeepLocation (bool keep)
 Sets whether the filename/url should be kept when changing directories.

bool keepsLocation () const
void setFilter (const QString &filter)
 Sets the filter to be used to filter.

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

void setFilterMimeType (const QString &label, const KMimeType::List &types, const KMimeType::Ptr &defaultType)
 Sets the filter up to specify the output type.

KMimeType::Ptr currentFilterMimeType ()
 Returns the mimetype for the desired output format.

void setMimeFilter (const QStringList &types, const QString &defaultType=QString::null)
 Sets the filter up to specify the output type.

QString currentMimeFilter () const
 The mimetype for the desired output format.

void clearFilter ()
 Clears any mime- or namefilter.

void setPreviewWidget (const QWidget *w)
void setPreviewWidget (const KPreviewWidgetBase *w)
 Adds a preview widget and enters the preview mode.

virtual void show ()
void setMode (KFile::Mode m)
void setMode (unsigned int m)
 Sets the mode of the dialog.

KFile::Mode mode () const
 Returns the mode of the filedialog.

void setLocationLabel (const QString &text)
 Sets the text to be displayed in front of the selection.

KToolBartoolBar () const
 Returns a pointer to the toolbar.

KPushButtonokButton () const
KPushButtoncancelButton () const
KActionCollectionactionCollection () const
int pathComboIndex ()

Static Public Methods

QString getOpenFileName (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and return the selected filename or an empty string if none was chosen.

QStringList getOpenFileNames (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and returns the selected filenames or an empty list if none was chosen.

KURL getOpenURL (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and returns the selected URL or an empty string if none was chosen.

KURL::List getOpenURLs (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and returns the selected URLs or an empty list if none was chosen.

QString getSaveFileName (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and returns the selected filename or an empty string if none was chosen.

KURL getSaveURL (const QString &startDir=QString::null, const QString &filter=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and returns the selected filename or an empty string if none was chosen.

QString getExistingDirectory (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.

KURL getExistingURL (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.

KURL getImageOpenURL (const QString &startDir=QString::null, QWidget *parent=0, const QString &caption=QString::null)
 Creates a modal file dialog with an image previewer and returns the selected url or an empty string if none was chosen.

KURL getStartURL (const QString &startDir, QString &recentDirClass)
 This method implements the logic to determine the user's default directory to be listed.


Protected Slots

void toolbarCallback (int)
void toggleSpeedbar (bool)
 
Since:
3.1


virtual void updateStatusLine (int dirs, int files)
virtual void slotOk ()
virtual void accept ()
virtual void slotCancel ()

Protected Methods

void addDirEntry (KFileItem *entry, bool disableUpdating)
 adds a entry of the current directory.

void init (const QString &startDir, const QString &filter, QWidget *widget)
 Perform basic initialization tasks.

virtual void initGUI ()
 rebuild geometry managment.

void multiSelectionChanged ()
 called when an item is highlighted/selected in multiselection mode.

virtual void readConfig (KConfig *, const QString &group=QString::null)
 Reads configuration and applies it (size, recent directories, ...).

virtual void writeConfig (KConfig *, const QString &group=QString::null)
 Saves the current configuration.

virtual void readRecentFiles (KConfig *)
 Reads the recent used files and inserts them into the location combobox.

virtual void saveRecentFiles (KConfig *)
 Saves the entries from the location combobox.

KURL::List tokenize (const QString &line) const
 Parses the string "line" for files.

virtual void virtual_hook (int id, void *data)

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 77 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 93 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 direcotry 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.

Definition at line 159 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 direcotry 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 166 of file kfiledialog.cpp.

References init().

KFileDialog::~KFileDialog  
 

Destructs the file dialog.

Definition at line 173 of file kfiledialog.cpp.

References KGlobal::config().


Member Function Documentation

KURL KFileDialog::selectedURL  
 

Returns:
The selected fully qualified filename.

Definition at line 1429 of file kfiledialog.cpp.

References QDialog::result().

Referenced by getExistingURL(), getImageOpenURL(), getOpenURL(), getSaveURL(), and KURLRequester::slotOpenDialog().

KURL::List KFileDialog::selectedURLs  
 

Returns:
The list of selected URLs.

Definition at line 1437 of file kfiledialog.cpp.

References KDirOperator::mode(), and QDialog::result().

Referenced by getOpenURLs().

KURL KFileDialog::baseURL  
 

Returns:
the currently shown directory.

Definition at line 1558 of file kfiledialog.cpp.

References KDirOperator::url().

QString KFileDialog::selectedFile  
 

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

(Local files only)

Definition at line 1524 of file kfiledialog.cpp.

References QDialog::result().

Referenced by getExistingDirectory(), getOpenFileName(), and getSaveFileName().

QStringList KFileDialog::selectedFiles  
 

Returns a list of all selected local files.

Definition at line 1534 of file kfiledialog.cpp.

References KDirOperator::mode(), and QDialog::result().

Referenced by getOpenFileNames().

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

References KURL::addPath(), QFile::exists(), KURL::fileName(), QString::findRev(), KFileItem::isDir(), QString::isEmpty(), KURL::isLocalFile(), KURL::isMalformed(), KURL::isRelativeURL(), QString::left(), QComboBox::lineEdit(), KURL::path(), KURL::protocol(), KComboBox::setCurrentItem(), QComboBox::setEditText(), KURL::setPath(), setURL(), KProtocolInfo::supportsListing(), KURL::url(), and KDirOperator::url().

Referenced by getSaveFileName(), getSaveURL(), 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 1752 of file kfiledialog.cpp.

References mode(), and QComboBox::setEditable().

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

KFileDialog::OperationMode KFileDialog::operationMode  
 

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

Definition at line 1760 of file kfiledialog.cpp.

References OperationMode.

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

bool KFileDialog::keepsLocation  
 

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

Definition at line 1747 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 seperated 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
*.h|Header files"); kfile->setFilter("*.cpp"); kfile->setFilter("*.cpp|Sources (*.cpp)"); kfile->setFilter("*.cpp *.cc *.C|C++ Source Files
*.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 193 of file kfiledialog.cpp.

References KDirOperator::clearFilter(), QString::find(), QString::remove(), QComboBox::setEditable(), setMimeFilter(), KDirOperator::setNameFilter(), and QStringList::split().

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

QString KFileDialog::currentFilter  
 

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

Parameters:
filter  Contains the new filter (only the extension part, not the explanation), for example, "*.cpp" or "*.cpp *.cc".
See also:
setFilter() , filterChanged()

Definition at line 220 of file kfiledialog.cpp.

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

References QValueList< Ptr >::begin(), QValueList< Ptr >::end(), KStdAccel::label(), and 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 275 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 240 of file kfiledialog.cpp.

References KDirOperator::clearFilter(), QString::fromLatin1(), QString::isEmpty(), QComboBox::setEditable(), KDirOperator::setMimeFilter(), and QStringList::split().

Referenced by setFilter(), and setFilterMimeType().

QString KFileDialog::currentMimeFilter  
 

The mimetype for the desired output format.

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

See also:
setMimeFilter()

Definition at line 264 of file kfiledialog.cpp.

References QComboBox::currentItem().

Referenced by currentFilterMimeType().

void KFileDialog::clearFilter  
 

Clears any mime- or namefilter.

Does not reload the directory.

Definition at line 255 of file kfiledialog.cpp.

References KDirOperator::clearFilter(), and QComboBox::setEditable().

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 280 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 286 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 direcotry last used by a filedialog in any application that specified the same keyword.
filter  This is a space seperated 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 1319 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 direcotry last used by a filedialog in any application that specified the same keyword.
filter  This is a space seperated 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 1335 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 direcotry last used by a filedialog in any application that specified the same keyword.
filter  This is a space seperated 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 1351 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 direcotry last used by a filedialog in any application that specified the same keyword.
filter  This is a space seperated 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 1365 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 direcotry last used by a filedialog in any application that specified the same keyword.
filter  This is a space seperated 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 1563 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 direcotry last used by a filedialog in any application that specified the same keyword.
filter  This is a space seperated 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 1584 of file kfiledialog.cpp.

References KRecentDocument::add(), QString::at(), QDialog::exec(), KURL::isMalformed(), QString::isNull(), 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 direcotry 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 1396 of file kfiledialog.cpp.

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

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

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

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 direcotry 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 1411 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
 

Deprecated:
use setMode( unsigned int ) instead

Definition at line 1615 of file kfiledialog.cpp.

References KDirOperator::dirOnlyMode(), KFile::Mode, and KDirOperator::setMode().

Referenced by KURLRequester::fileDialog(), getExistingDirectory(), getExistingURL(), getImageOpenURL(), getOpenFileName(), getOpenFileNames(), getOpenURL(), getOpenURLs(), 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 1626 of file kfiledialog.cpp.

References setMode().

KFile::Mode KFileDialog::mode  
 

Returns the mode of the filedialog.

See also:
setMode()

Definition at line 1631 of file kfiledialog.cpp.

References KDirOperator::mode(), and KFile::Mode.

Referenced by setOperationMode().

void KFileDialog::setLocationLabel const QString   text
 

Sets the text to be displayed in front of the selection.

The default is "Location". Most useful if you want to make clear what the location is used for.

Definition at line 188 of file kfiledialog.cpp.

KToolBar* KFileDialog::toolBar   const [inline]
 

Returns a pointer to the toolbar.

You can use this to insert custom items into it, e.g.: yourAction = new KAction( i18n("Your Action"), 0, this, SLOT( yourSlot() ), this, "action name" ); yourAction->plug( kfileDialog->toolBar() );

Definition at line 695 of file kfiledialog.h.

KPushButton * KFileDialog::okButton  
 

Returns:
a pointer to the OK-Button in the filedialog. You may use it e.g. to set a custom text to it.

Definition at line 1726 of file kfiledialog.cpp.

KPushButton * KFileDialog::cancelButton  
 

Returns:
a pointer to the Cancel-Button in the filedialog. You may use it e.g. to set a custom text to it.

Definition at line 1731 of file kfiledialog.cpp.

KActionCollection * KFileDialog::actionCollection  
 

Returns:
a pointer to the action collection, holding all the used KActions.

Definition at line 1787 of file kfiledialog.cpp.

References KDirOperator::actionCollection().

Referenced by toggleSpeedbar().

int KFileDialog::pathComboIndex  
 

Returns:
the index of the path combobox so when inserting widgets into the dialog (e.g. subclasses) they can do so without hardcoding in an index

Definition at line 1828 of file kfiledialog.cpp.

KURL KFileDialog::getStartURL const QString   startDir,
QString   recentDirClass
[static]
 

This method implements the logic to determine the user's default directory to be listed.

E.g. the documents direcory, home directory or a recently used directory.

Parameters:
startDir  A url/directory, to be used. May use the ':' and '::' syntax as documented in the KFileDialog() constructor.
recentDirClass  If the ':' or '::' syntax is used, recentDirClass will contain the string to be used later for KRecentDir::dir()
Returns:
The URL that should be listed by default (e.g. by KFileDialog or KDirSelectDialog).
Since:
3.1

Definition at line 1843 of file kfiledialog.cpp.

References QDir::currentDirPath(), KRecentDirs::dir(), KGlobalSettings::documentPath(), QFile::encodeName(), KURL::fromPathOrURL(), QDir::homeDirPath(), KURL::isEmpty(), QString::isEmpty(), KCmdLineArgs::makeURL(), KURL::path(), KURL::protocol(), KURL::setPath(), and KProtocolInfo::supportsListing().

Referenced by init(), and KDirSelectDialog::KDirSelectDialog().

void KFileDialog::fileSelected const QString   [signal]
 

Emitted when the user selects a file.

It is only emitted in single- selection mode. The best way to get notified about selected file(s) is to connect to the okClicked() signal inherited from KDialogBase and call selectedFile(), selectedFiles(), selectedURL() or selectedURLs().

Referenced by init().

void KFileDialog::fileHighlighted const QString   [signal]
 

Emitted when the user highlights a file.

Referenced by init().

void KFileDialog::selectionChanged   [signal]
 

Emitted when the user hilights one or more files in multiselection mode.

Note: fileHighlighted() or fileSelected() are not emitted in multiselection mode. You may use selectedItems() to ask for the current highlighted items.

See also:
fileSelected

void KFileDialog::filterChanged const QString   filter [signal]
 

Emitted when the filter changed, i.e.

the user entered an own filter or chose one of the predefined set via setFilter().

Parameters:
filter  contains the new filter (only the extension part, not the explanation), i.e. "*.cpp" or "*.cpp *.cc".
See also:
setFilter() , currentFilter()

Referenced by init().

void KFileDialog::addDirEntry KFileItem   entry,
bool    disableUpdating
[protected]
 

adds a entry of the current directory.

If disableUpdating is set to true, it will care about clever updating

void KFileDialog::init const QString   startDir,
const QString   filter,
QWidget   widget
[protected]
 

Perform basic initialization tasks.

Called by constructors.

Since:
3.1

Definition at line 696 of file kfiledialog.cpp.

References KDirOperator::actionCollection(), QWhatsThis::add(), QToolTip::add(), KDialogBase::adjustSize(), QString::arg(), KStdAccel::completion(), KComboBox::completionBox(), KDirOperator::completionObject(), KGlobal::config(), KGlobalSettings::desktopPath(), KDirOperator::dirCompletionObject(), KGlobalSettings::documentPath(), QDir::exists(), QFile::exists(), fileHighlighted(), fileSelected(), filterChanged(), QString::fromLatin1(), KToolBar::getButton(), getStartURL(), QDir::homeDirPath(), initGUI(), KToolBar::insertButton(), KToolBar::insertWidget(), KCompletionBase::KeyBindingType, KDirOperator::mode(), KURL::path(), KMimeType::pixmapForURL(), KActionMenu::plug(), readConfig(), readRecentFiles(), QDir::rootDirPath(), KToolBar::setBarPos(), KCompletionBase::setCompletionObject(), KActionMenu::setDelayed(), setFilter(), KCompletionBase::setHandleSignals(), KToolBar::setIconText(), KToolBar::setItemAutoSized(), KDialogBase::setMainWidget(), QWidget::setMaximumWidth(), QWidget::setMinimumWidth(), KDirOperator::setOnlyDoubleClickSelectsFiles(), QDir::setPath(), KURL::setPath(), KToolBarButton::setPopup(), setSelection(), KDirOperator::setupMenu(), KDirOperator::setViewConfig(), KDialogBase::slotCancel(), KDialogBase::slotOk(), KDialog::spacingHint(), and toggleSpeedbar().

Referenced by KFileDialog().

void KFileDialog::initGUI   [protected, virtual]
 

rebuild geometry managment.

Definition at line 984 of file kfiledialog.cpp.

References QGridLayout::addWidget(), QGridLayout::setColStretch(), and KDialog::spacingHint().

Referenced by init().

void KFileDialog::multiSelectionChanged   [protected]
 

called when an item is highlighted/selected in multiselection mode.

handles setting the locationEdit.

Definition at line 672 of file kfiledialog.cpp.

References QString::append(), QComboBox::clearEdit(), QPtrListIterator< KFileItem >::current(), QComboBox::lineEdit(), KFileItem::name(), KDirOperator::selectedItems(), KComboBox::setCurrentItem(), QComboBox::setEditText(), KGlobal::staticQString(), and QString::stripWhiteSpace().

void KFileDialog::readConfig KConfig  ,
const QString   group = QString::null
[protected, virtual]
 

Reads configuration and applies it (size, recent directories, ...).

Definition at line 1637 of file kfiledialog.cpp.

References KGlobalSettings::Completion, KGlobalSettings::CompletionAuto, KGlobalSettings::completionMode(), KDialogBase::configDialogSize(), QString::isEmpty(), KDirOperator::readConfig(), KCompletionBase::setCompletionMode(), KURLComboBox::setMaxItems(), KURLComboBox::setURL(), KURLComboBox::setURLs(), toggleSpeedbar(), and KDirOperator::url().

Referenced by init().

void KFileDialog::writeConfig KConfig  ,
const QString   group = QString::null
[protected, virtual]
 

Saves the current configuration.

Definition at line 1681 of file kfiledialog.cpp.

References KCompletionBase::completionMode(), QString::isEmpty(), KDialogBase::saveDialogSize(), and KDirOperator::writeConfig().

void KFileDialog::readRecentFiles KConfig   [protected, virtual]
 

Reads the recent used files and inserts them into the location combobox.

Definition at line 1701 of file kfiledialog.cpp.

References QComboBox::insertItem(), KComboBox::setCurrentItem(), KURLComboBox::setMaxItems(), and KURLComboBox::setURLs().

Referenced by init().

void KFileDialog::saveRecentFiles KConfig   [protected, virtual]
 

Saves the entries from the location combobox.

Definition at line 1716 of file kfiledialog.cpp.

References KURLComboBox::urls().

KURL::List KFileDialog::tokenize const QString   line const [protected]
 

Parses the string "line" for files.

If line doesn't contain any ", the whole line will be interpreted as one file. If the number of " is odd, an empty list will be returned. Otherwise, all items enclosed in " " will be returned as correct urls.

Definition at line 1482 of file kfiledialog.cpp.

References QString::contains(), QString::find(), KURL::isMalformed(), QString::mid(), KURL::setFileName(), KMessageBox::sorry(), and KDirOperator::url().

void KFileDialog::toolbarCallback int    [protected, slot]
 

Deprecated:

Definition at line 1165 of file kfiledialog.cpp.

void KFileDialog::toggleSpeedbar bool    [protected, slot]
 

Since:
3.1

Definition at line 1792 of file kfiledialog.cpp.

References actionCollection(), KDirOperator::actionCollection(), KURL::equals(), QDir::homeDirPath(), KURL::setPath(), and KURLBarItem::url().

Referenced by init(), and readConfig().

void KFileDialog::updateStatusLine int    dirs,
int    files
[protected, virtual, slot]
 

Deprecated:

Definition at line 1314 of file kfiledialog.cpp.


The documentation for this class was generated from the following files:
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:35 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001