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.

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 which will be incorporated into the layout.

 KFileDialog (const QString& urlName, const QString& filter, QWidget *parent, const char *name, bool modal)

Construct a KFileDialog

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

Clean up.

KURL  selectedURL ()

[const]

Retrieve the fully qualified filename.

KURL::List  selectedURLs ()

[const]

Retrieve the list a selected URLs

KURL  baseURL ()

[const]

Retrieve the current directory.

QString  selectedFile ()

[const]

Returns: Full path in local filesystem. (Local files only)

QStringList  selectedFiles ()

[const]

Returns: a list of all selected local files

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

Set the directory to view.

Parameters:
nameURL to show
clearforwardIndicate whether the forward queue should be cleared.

void  setSelection (const QString& name)

Set the filename to preselect.

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

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.

See also: setFilter, filterChanged

QString  currentFilter ()

[const]

Returns: the current filter, i.e. entered by the user or one of the predefined set via setFilter(). @param filter contains the new filter (only the extension part, not the explanation), i.e. "*.cpp" or "*.cpp *.cc".

See also: setFilter, filterChanged

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]

This method 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 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.
nameThe 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]

This method 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:
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.
nameThe 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]

This method 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:
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.
nameThe 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]

This method 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:
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.
nameThe 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]

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

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

Creates 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]

Show the widget.

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

KFile::Mode  mode ()

[const]

Retrieve the mode of the filedialog.

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

KToolBartoolBar ()

[const]

yourAction = new KAction( i18n("Your Action"), 0,
                                this, SLOT( yourSlot() ),
                                this, "action name" );
      yourAction->plug( kfileDialog->toolBar() );
     

Returns: a pointer to the toolbar. You can use this to insert custom items into it, e.g.:

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

See also: setFilter, currentFilter

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 (const KFileViewItem *)

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

void  addToBookmarks ()

[protected slot]

Add the current location to the global bookmarks list