|
|
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.
| |
Construct a file dialog.
Parameters:
| startDir | This can either be |
| 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, KFileDialog will
just accept files on the local filesystem.
|
| ~ |
Destruct the file dialog.
| KURL |
[const]
Returns: The selected fully qualified filename.
| KURL::List |
[const]
Returns: The list of selected URLs.
| KURL |
[const]
Returns: the currently shown directory.
| QString |
[const]
Retrieve the full path of the selected file in the local filesystem. (Local files only)
| QStringList |
[const]
Retrieve a list of all selected local files.
| void |
Set the directory to view.
Parameters:
| url | URL to show. |
| clearforward | Indicates whether the forward queue should be cleared. |
| void |
Set the file name to preselect to name
This takes absolute URLs and relative file names.
| void |
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.
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.
| bool |
[const]
Returns: whether the contents of the location edit are kept when changing directories.
| void |
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.
If the filter contains a '/', a mimetype-filter is assumed. You can specify multiple mimetypes like this (separated with space):
kfile->setFilter( "image/png text/html text/plain" );
See also: filterChanged, setMimeFilter
| QString |
[const]
Retrieve 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()
| void |
Set the filter up to specify the output type.
Do not use in conjunction with setFilter()
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. |
| KMimeType::Ptr |
The mimetype for the desired output format.
This is only valid if setFilterMimeType() has been called previously.
| void |
Set the filter up to specify the output type.
Do not use in conjunction with setFilter()
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.
|
| QString |
[const]
The mimetype for the desired output format.
This is only valid if setMimeFilter() has been called previously.
| void |
Clears any mime- or namefilter. Does not reload the directory.
| void |
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.
| void |
Add a preview widget and enter 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. |
| QString |
[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:
| startDir | This can either be |
| filter | This is a space seperated list of shell globs. |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| QStringList |
[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:
| startDir | This can either be |
| filter | This is a space seperated list of shell globs. |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| KURL |
[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:
| startDir | This can either be |
| filter | This is a space seperated list of shell globs. |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| KURL::List |
[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:
| startDir | This can either be |
| filter | This is a space seperated list of shell globs. |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| QString |
[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:
| startDir | This can either be |
| filter | This is a space seperated list of shell globs. |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| KURL |
[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:
| startDir | This can either be |
| filter | This is a space seperated list of shell globs. |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| QString |
[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:
| startDir | This can either be |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| KURL |
[static]
Create 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 |
| parent | The widget the dialog will be centered on initially. |
| caption | The name of the dialog widget. |
| void |
[virtual]
@reimplemented
| void |
| void |
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 );
| KFile::Mode |
[const]
Retrieve the mode of the filedialog.
| void |
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.
| KToolBar * |
[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() );
| QPushButton * |
[const]
Returns: a pointer to the OK-Button in the filedialog. You may use it e.g. to set a custom text to it.
| QPushButton * |
[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 |
[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().
| void |
[signal]
Emitted when the user highlights a file.
| void |
[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 |
[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()
| void |
[protected]
adds a entry of the current directory. If disableUpdating is set to true, it will care about clever updating
| void |
[protected virtual]
rebuild geometry managment.
| void |
[protected]
called when an item is highlighted/selected in multiselection mode. handles setting the locationEdit.
| void |
[protected virtual]
Reads configuration and applies it (size, recent directories, ...)
| void |
[protected virtual]
Saves the current configuration
| void |
[protected virtual]
Reads the recent used files and inserts them into the location combobox
| void |
[protected virtual]
Saves the entries from the location combobox.
| KURL::List |
[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 |
[protected slot]
Add the current location to the global bookmarks list