|
|
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.
|
Construct a KFileDialog
Parameters:
urlName | The 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. |
filter | A shell glob 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. |
~ |
Clean up.
KURL |
[const]
Retrieve the fully qualified filename.
KURL::List |
[const]
Retrieve the list a selected URLs
KURL |
[const]
Retrieve the current directory.
QString |
[const]
Returns: Full path in local filesystem. (Local files only)
QStringList |
[const]
Returns: a list of all selected local files
void |
Set the directory to view.
Parameters:
name | URL to show |
clearforward | Indicate whether the forward queue should be cleared. |
void |
Set the filename to preselect.
This takes absolute URLs and relative file names.
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)");
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 |
[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 |
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 |
[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:
dir | This specifies the path the dialog will start in. |
filter | This is a space seperated list of shell globs. |
parent | The widget the dialog will be centered on initially. |
name | The name of the dialog widget. |
QStringList |
[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:
dir | This specifies the path the dialog will start in. |
filter | This is a space seperated list of shell globs. |
parent | The widget the dialog will be centered on initially. |
name | The name of the dialog widget. |
KURL |
[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:
url | This specifies the path the dialog will start in. |
filter | This is a space seperated list of shell globs. |
parent | The widget the dialog will be centered on initially. |
name | The name of the dialog widget. |
KURL::List |
[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:
url | This specifies the path the dialog will start in. |
filter | This is a space seperated list of shell globs. |
parent | The widget the dialog will be centered on initially. |
name | The name of the dialog widget. |
QString |
[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:
dir | This specifies the path the dialog will start in. |
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]
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:
url | This specifies the path the dialog will start in. |
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]
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:
url | The directory the dialog will start in. |
parent | The widget the dialog will be centered on initially. |
caption | The name of the dialog widget. |
void |
[virtual]
Show the widget.
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 );
You need an explicit cast, which looks a little ugly, but is unavoidable without using (even uglier) #defines
KFile::Mode |
[const]
Retrieve the mode of the filedialog.
void |
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.
KToolBar * |
[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 |
[signal]
Emitted when the user selects a file.
void |
[signal]
Emitted when the user highlights a file.
void |
[signal]
Emitted when the allowable history operations change.
void |
[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 |
[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]
takes action on the new location. If it's a directory, change into it, if it's a file, correct the name, etc.
Parameters:
takeFiles | if set to true, if will close the dialog, if txt is a file name |
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.
void |
[protected slot]
Add the current location to the global bookmarks list