class KFileDialog

A file selection dialog. More...

Definition#include <kfiledialog.h>
InheritsKDialogBase (kdeui)
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Signals

Public Static Methods

Protected Methods

Protected Slots

Protected Members


Detailed Description

Provide a user (and developer) friendly way to select files and directories.

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 (const QString& urlName, const QString& filter, QWidget *parent, const char *name, bool modal)

Construct a file dialog.

Parameters:
urlNameThe URL of the directory to start in. Use QString::null to start in the current working directory, or the last directory where a file has been selected.
filterA shell glob that specifies which files to display. See setFilter() for details on how to use this argument.
acceptURLsIf set to false, KFileDialog will just accept files on the local filesystem.

KFileDialog ()

Destruct the file dialog.

KURL  selectedURL ()

[const]

Returns: The selected fully qualified filename.

KURL::List  selectedURLs ()

[const]

Returns: The list of selected URLs.

KURL  baseURL ()

[const]

Returns: the currently shown directory.

QString  selectedFile ()

[const]

Retrieve the full path of the selected file in the local filesystem. (Local files only)

QStringList  selectedFiles ()

[const]

Retrieve a list of all selected local files.

void  setURL (const KURL &url, bool clearforward = true)

Set the directory to view.

Parameters:
urlURL to show.
clearforwardIndicates whether the forward queue should be cleared.

void  setSelection (const QString& name)

Set the file name to preselect to name

This takes absolute URLs and relative file names.

void  setFilter (const QString& filter)

Set the filter to be used to filter.

You can set more filters for the user to select seperated by '\n'. 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 *.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.

QString  currentFilter ()

[const]

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

WARNING: There is no parameter filter... so what is this doing here ?

Parameters:
filterContains the new filter (only the extension part, not the explanation), for example, "*.cpp" or "*.cpp *.cc".

See also: setFilter(), filterChanged()

void  setFilterMimeType (const QString &label, const KMimeType::List &types, const KMimeType::Ptr &defaultType)

Set the filter up to specify the output type.

Do not use in conjunction with setFilter()

Parameters:
labelthe label to use instead of "Filter:"
typesa list of mimetypes that can be used as output format
defaultTypethe default mimetype to use as output format.

KMimeType::Ptr  currentFilterMimeType ()

The mimetype for the desired output format.

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

void  setPreviewWidget (const QWidget *w)

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 :)

QString  getOpenFileName (const QString& dir= QString::null, const QString& filter= QString::null, QWidget *parent= 0, const QString& caption = QString::null)

[static]

Create 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:
dirThis specifies the path the dialog will start in.
filterThis is a space seperated list of shell globs.
parentThe widget the dialog will be centered on initially.
captionThe name of the dialog widget.

QStringList  getOpenFileNames (const QString& dir= QString::null, const QString& filter= QString::null, QWidget *parent = 0, const QString& caption= QString::null)

[static]

Create a modal file dialog and return the selected filenames or an empty list if none was chosen.

Note that with this method the user must select an existing filename.

Parameters:
dirThis specifies the path the dialog will start in.
filterThis is a space seperated list of shell globs.
parentThe widget the dialog will be centered on initially.
captionThe name of the dialog widget.

KURL  getOpenURL (const QString& url = QString::null, const QString& filter= QString::null, QWidget *parent= 0, const QString& caption = QString::null)

[static]

Create a modal file dialog and return the selected URL or an empty string if none was chosen.

Note that with this method the user must select an existing URL.

Parameters:
urlThis specifies the path the dialog will start in.
filterThis is a space seperated list of shell globs.
parentThe widget the dialog will be centered on initially.
captionThe name of the dialog widget.

KURL::List  getOpenURLs (const QString& url= QString::null, const QString& filter= QString::null, QWidget *parent = 0, const QString& caption= QString::null)

[static]

Create a modal file dialog and return the selected URLs or an empty list if none was chosen.

Note that with this method the user must select an existing filename.

Parameters:
urlThis specifies the path the dialog will start in.
filterThis is a space seperated list of shell globs.
parentThe widget the dialog will be centered on initially.
captionThe name of the dialog widget.

QString  getSaveFileName (const QString& dir= QString::null, const QString& filter= QString::null, QWidget *parent= 0, const QString& caption = QString::null)

[static]

Create a modal file dialog and return 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:
dirThis specifies the path the dialog will start in.
filterThis is a space seperated list of shell globs.
parentThe widget the dialog will be centered on initially.
captionThe name of the dialog widget.

KURL  getSaveURL (const QString& url= QString::null, const QString& filter= QString::null, QWidget *parent= 0, const QString& caption = QString::null)

[static]

Create 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:
urlThis specifies the path the dialog will start in.
filterThis is a space seperated list of shell globs.
parentThe widget the dialog will be centered on initially.
captionThe name of the dialog widget.

QString  getExistingDirectory (const QString & url = QString::null, QWidget * parent = 0, const QString& caption= QString::null)

[static]

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

Note that with this method the user need not select an existing directory.

Parameters:
urlThe directory the dialog will start in.
parentThe widget the dialog will be centered on initially.
captionThe name of the dialog widget.

void  show ()

[virtual]

void  setMode ( KFile::Mode m )

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

You need an explicit cast, which looks a little ugly, but is unavoidable without using (even uglier) #defines. Please not that's at the moment not possible to select multiple files and directories <em>simultaneously</em>. It's possible to select one file or directory at once, though.

KFile::Mode  mode ()

[const]

Retrieve the mode of the filedialog.

void  setLocationLabel (const QString& text)

Set 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.

KToolBartoolBar ()

[const]

Retrieve 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() );

QPushButtonokButton ()

[const]

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

QPushButtoncancelButton ()

[const]

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

void  fileSelected (const QString&)

[signal]

Emitted when the user selects a file.

void  fileHighlighted (const QString&)

[signal]

Emitted when the user highlights a file.

void  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.

void  historyUpdate (bool, bool)

[signal]

Emitted when the allowable history operations change.

void  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:
filtercontains the new filter (only the extension part, not the explanation), i.e. "*.cpp" or "*.cpp *.cc".

See also: setFilter(), currentFilter()

KToolBar * toolbar

[protected]

static KURL * lastDirectory

[protected]

QPopupMenu * bookmarksMenu

[protected]

KFileComboBox * locationEdit

[protected]

KFileFilter * filterWidget

[protected]

KFileBookmarkManager * bookmarks

[protected]

QStringList history

[protected]

void  addDirEntry (KFileViewItem *entry, bool disableUpdating)

[protected]

adds a entry of the current directory. If disableUpdating is set to true, it will care about clever updating

void  initGUI ()

[protected virtual]

rebuild geometry managment.

void  checkPath (const QString& txt, bool takeFiles = false)

[protected]

takes action on the new location. If it's a directory, change into it, if it's a file, correct the name, etc.

Parameters:
takeFilesif set to true, if will close the dialog, if txt is a file name

void  multiSelectionChanged ()

[protected]

called when an item is highlighted/selected in multiselection mode. handles setting the locationEdit.

void  readConfig ( KConfig *, const QString& group = QString::null )

[protected virtual]

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

void  saveConfig ( KConfig *, const QString& group = QString::null )

[protected virtual]

Saves the current configuration

void  readRecentFiles ( KConfig * )

[protected virtual]

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

void  saveRecentFiles ( KConfig * )

[protected virtual]

Saves the entries from the location combobox.

KURL::List  tokenize (const QString& line)

[protected const]

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.

void  urlEntered ( const KURL& )

[protected slot]

void  pathComboActivated ( const KURL& url )

[protected slot]

void  pathComboReturnPressed ( const QString& url )

[protected slot]

void  locationActivated ( const QString& url )

[protected slot]

void  toolbarCallback (int)

[protected slot]

void  toolbarPressedCallback (int)

[protected slot]

void  slotFilterChanged ()

[protected slot]

void  pathComboChanged ( const QString& )

[protected slot]

void  fileHighlighted (const KFileViewItem *i)

[protected slot]

void  fileSelected (const KFileViewItem *i)

[protected slot]

void  slotStatResult (KIO::Job* job)

[protected slot]

void  slotLoadingFinished ()

[protected slot]

void  dirCompletion ( const QString& )

[protected slot]

void  fileCompletion ( const QString& )

[protected slot]

void  updateStatusLine (int dirs, int files)

[protected virtual slot]

void  slotOk ()

[protected virtual slot]

Reimplemented from KDialogBase.

void  accept ()

[protected virtual slot]

void  addToBookmarks ()

[protected slot]

Add the current location to the global bookmarks list

void  bookmarksChanged ()

[protected slot]

void  fillBookmarkMenu ( KFileBookmark *parent, QPopupMenu *menu, int &id )

[protected slot]

KFileDialogPrivate * d

[protected]

KDirOperator * ops

[protected]

bool autoDirectoryFollowing

[protected]

KURL::List&  parseSelectedURLs ()

[protected const]