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:

Public Types | |
enum | OperationMode { Other = 0, Opening, Saving } |
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 Member Functions | |
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) |
This class or method is obsolete, it is provided for compatibility only. Add a preview widget and enter the preview mode. | |
void | setPreviewWidget (const KPreviewWidgetBase *w) |
Adds a preview widget and enters the preview mode. | |
virtual void | show () |
void | setMode (KFile::Mode m) |
This class or method is obsolete, it is provided for compatibility only. use setMode( unsigned int ) instead | |
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. | |
KToolBar * | toolBar () const |
Returns a pointer to the toolbar. | |
KPushButton * | okButton () const |
KPushButton * | cancelButton () const |
KActionCollection * | actionCollection () const |
int | pathComboIndex () |
Static Public Member Functions | |
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 | urlEntered (const KURL &) |
void | enterURL (const KURL &url) |
void | enterURL (const QString &url) |
void | locationActivated (const QString &url) |
void | toolbarCallback (int) |
This class or method is obsolete, it is provided for compatibility only. | |
void | slotFilterChanged () |
void | pathComboChanged (const QString &) |
void | fileHighlighted (const KFileItem *i) |
void | fileSelected (const KFileItem *i) |
void | slotStatResult (KIO::Job *job) |
void | slotLoadingFinished () |
void | dirCompletion (const QString &) |
void | fileCompletion (const QString &) |
void | toggleSpeedbar (bool) |
| |
virtual void | updateStatusLine (int dirs, int files) |
This class or method is obsolete, it is provided for compatibility only. | |
virtual void | slotOk () |
virtual void | accept () |
virtual void | slotCancel () |
void | addToRecentDocuments () |
void | initSpeedbar () |
Protected Member Functions | |
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. | |
KURL::List & | parseSelectedURLs () const |
virtual void | virtual_hook (int id, void *data) |
Protected Attributes | |
KToolBar * | toolbar |
KURLComboBox * | locationEdit |
KFileFilterCombo * | filterWidget |
KDirOperator * | ops |
bool | autoDirectoryFollowing |
Static Protected Attributes | |
KURL * | lastDirectory |
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.

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
|
Defines some default behavior of the filedialog.
E.g. in mode
Definition at line 93 of file kfiledialog.h. Referenced by operationMode(). |
Constructor & Destructor Documentation
|
Constructs a file dialog.
Definition at line 159 of file kfiledialog.cpp. References init(), and KStdAccel::name(). |
|
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.
Definition at line 166 of file kfiledialog.cpp. References init(), and KStdAccel::name(). |
|
Destructs the file dialog.
Definition at line 173 of file kfiledialog.cpp. References KGlobal::config(), and KConfigBase::sync(). |
Member Function Documentation
|
Definition at line 1454 of file kfiledialog.cpp. References QDialog::result(). Referenced by getExistingURL(), getImageOpenURL(), getOpenURL(), getSaveURL(), and KURLRequester::slotOpenDialog(). |
|
Definition at line 1462 of file kfiledialog.cpp. References QValueList< KURL >::append(), KDirOperator::mode(), and QDialog::result(). Referenced by getOpenURLs(). |
|
Definition at line 1583 of file kfiledialog.cpp. References KDirOperator::url(). |
|
Returns the full path of the selected file in the local filesystem. (Local files only) Definition at line 1549 of file kfiledialog.cpp. References QDialog::result(). Referenced by getExistingDirectory(), getOpenFileName(), and getSaveFileName(). |
|
Returns a list of all selected local files.
Definition at line 1559 of file kfiledialog.cpp. References QValueList< KURL >::begin(), QValueList< KURL >::end(), KDirOperator::mode(), and QDialog::result(). Referenced by getOpenFileNames(). |
|
Sets the directory to view.
Definition at line 1141 of file kfiledialog.cpp. References KDirOperator::setURL(). Referenced by setSelection(). |
|
Sets the file name to preselect to This takes absolute URLs and relative file names. Definition at line 1199 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(). |
|
Sets the operational mode of the filedialog to 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
The default mode is Call this method right after instantiating KFileDialog.
Definition at line 1777 of file kfiledialog.cpp. Referenced by getImageOpenURL(), getOpenFileName(), getOpenFileNames(), getOpenURL(), getOpenURLs(), getSaveFileName(), and getSaveURL(). |
|
Definition at line 1785 of file kfiledialog.cpp. References OperationMode. |
|
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 1767 of file kfiledialog.cpp. |
|
Definition at line 1772 of file kfiledialog.cpp. |
|
Sets the filter to be used to
You can set more filters for the user to select seperated by '
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):
Definition at line 193 of file kfiledialog.cpp. References KDirOperator::clearFilter(), KStdAccel::copy(), QString::find(), setMimeFilter(), KDirOperator::setNameFilter(), and QStringList::split(). Referenced by KURLRequester::fileDialog(), getExistingDirectory(), getExistingURL(), init(), and KURLRequester::setFilter(). |
|
Returns the current filter as entered by the user or one of the predefined set via setFilter().
Definition at line 220 of file kfiledialog.cpp. |
|
Sets the filter up to specify the output type.
Definition at line 226 of file kfiledialog.cpp. References QValueList::begin(), QValueList::end(), KStdAccel::label(), and setMimeFilter(). |
|
Returns the mimetype for the desired output format. This is only valid if setFilterMimeType() has been called previously.
Definition at line 275 of file kfiledialog.cpp. References currentMimeFilter(), and KMimeType::mimeType(). |
|
Sets the filter up to specify the output type.
Definition at line 240 of file kfiledialog.cpp. References KDirOperator::clearFilter(), QString::fromLatin1(), QString::isEmpty(), KDirOperator::setMimeFilter(), and QStringList::split(). Referenced by setFilter(), and setFilterMimeType(). |
|
The mimetype for the desired output format. This is only valid if setMimeFilter() has been called previously.
Definition at line 264 of file kfiledialog.cpp. Referenced by currentFilterMimeType(). |
|
Clears any mime- or namefilter. Does not reload the directory. Definition at line 255 of file kfiledialog.cpp. References KDirOperator::clearFilter(). |
|
This class or method is obsolete, it is provided for compatibility only. 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(). |
|
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.
Definition at line 286 of file kfiledialog.cpp. References KDirOperator::clearHistory(), and KDirOperator::setPreviewWidget(). |
|
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.
Definition at line 1344 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedFile(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
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.
Definition at line 1360 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedFiles(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
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.
Definition at line 1376 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedURL(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
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.
Definition at line 1390 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedURLs(), KDialog::setCaption(), setMode(), and setOperationMode(). |
|
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.
Definition at line 1588 of file kfiledialog.cpp. References KRecentDocument::add(), QString::at(), QDialog::exec(), QString::isEmpty(), QString::isNull(), selectedFile(), KDialog::setCaption(), setOperationMode(), and setSelection(). |
|
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.
Definition at line 1609 of file kfiledialog.cpp. References KRecentDocument::add(), QString::at(), QDialog::exec(), KURL::isMalformed(), QString::isNull(), selectedURL(), KDialog::setCaption(), setOperationMode(), and setSelection(). |
|
Creates a modal file dialog and returns the selected directory or an empty string if none was chosen.
Definition at line 1421 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedFile(), KDialog::setCaption(), setFilter(), and setMode(). |
|
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.
Definition at line 1406 of file kfiledialog.cpp. References KDirOperator::clearHistory(), QDialog::exec(), QString::isNull(), ops, selectedURL(), KDialog::setCaption(), setFilter(), and setMode(). |
|
Creates a modal file dialog with an image previewer and returns the selected url or an empty string if none was chosen.
Definition at line 1436 of file kfiledialog.cpp. References QDialog::exec(), QString::isNull(), QStringList::join(), KImageIO::mimeTypes(), selectedURL(), KDialog::setCaption(), setMode(), setOperationMode(), and setPreviewWidget(). |
|
This class or method is obsolete, it is provided for compatibility only. use setMode( unsigned int ) instead
Definition at line 1640 of file kfiledialog.cpp. References KDirOperator::dirOnlyMode(), and KDirOperator::setMode(). Referenced by KURLRequester::fileDialog(), getExistingDirectory(), getExistingURL(), getImageOpenURL(), getOpenFileName(), getOpenFileNames(), getOpenURL(), getOpenURLs(), KURLRequester::setMode(), and setMode(). |
|
Sets the mode of the dialog.
The mode is defined as (in kfile.h): Definition at line 1651 of file kfiledialog.cpp. References setMode(). |
|
Returns the mode of the filedialog.
Definition at line 1656 of file kfiledialog.cpp. References KDirOperator::mode(), and KFile::Mode. |
|
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. |
|
Returns a pointer to the toolbar.
You can use this to insert custom items into it, e.g.: Definition at line 695 of file kfiledialog.h. |
|
Definition at line 1751 of file kfiledialog.cpp. |
|
Definition at line 1756 of file kfiledialog.cpp. |
|
Definition at line 1812 of file kfiledialog.cpp. References KDirOperator::actionCollection(). Referenced by toggleSpeedbar(). |
|
Definition at line 1853 of file kfiledialog.cpp. |
|
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.
Definition at line 1868 of file kfiledialog.cpp. References QDir::currentDirPath(), KRecentDirs::dir(), KGlobalSettings::documentPath(), QFile::encodeName(), KURL::fromPathOrURL(), KStdAccel::home(), QDir::homeDirPath(), KURL::isEmpty(), QString::isEmpty(), KCmdLineArgs::makeURL(), KURL::path(), KURL::protocol(), and KProtocolInfo::supportsListing(). Referenced by init(), and KDirSelectDialog::KDirSelectDialog(). |
|
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(). |
|
Emitted when the user highlights a file.
Referenced by init(). |
|
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.
|
|
Emitted when the filter changed, i.e. the user entered an own filter or chose one of the predefined set via setFilter().
Referenced by init(). |
|
adds a entry of the current directory. If disableUpdating is set to true, it will care about clever updating |
|
|
rebuild geometry managment.
Definition at line 1003 of file kfiledialog.cpp. References QGridLayout::addWidget(), QGridLayout::setColStretch(), and KDialog::spacingHint(). Referenced by init(). |
|
called when an item is highlighted/selected in multiselection mode. handles setting the locationEdit. Definition at line 691 of file kfiledialog.cpp. References QString::append(), QComboBox::clearEdit(), QPtrListIterator::current(), QComboBox::lineEdit(), KFileItem::name(), KDirOperator::selectedItems(), KComboBox::setCurrentItem(), QComboBox::setEditText(), KGlobal::staticQString(), and QString::stripWhiteSpace(). |
|
Reads configuration and applies it (size, recent directories, ...).
Definition at line 1662 of file kfiledialog.cpp. References KGlobalSettings::Completion, KGlobalSettings::CompletionAuto, KGlobalSettings::completionMode(), KDialogBase::configDialogSize(), KConfigBase::group(), QString::isEmpty(), KConfigBase::readBoolEntry(), KDirOperator::readConfig(), KConfigBase::readNumEntry(), KConfigBase::readPathListEntry(), KCompletionBase::setCompletionMode(), KConfigBase::setGroup(), KURLComboBox::setMaxItems(), KURLComboBox::setURL(), KURLComboBox::setURLs(), KToolBar::sizeHint(), toggleSpeedbar(), KDirOperator::url(), and QSize::width(). Referenced by init(). |
|
Saves the current configuration.
Definition at line 1706 of file kfiledialog.cpp. References KCompletionBase::completionMode(), KConfigBase::group(), QString::isEmpty(), KDialogBase::saveDialogSize(), KConfigBase::setGroup(), KDirOperator::writeConfig(), and KConfigBase::writeEntry(). |
|
Reads the recent used files and inserts them into the location combobox.
Definition at line 1726 of file kfiledialog.cpp. References KConfigBase::group(), QComboBox::insertItem(), KConfigBase::readNumEntry(), KConfigBase::readPathListEntry(), KComboBox::setCurrentItem(), KConfigBase::setGroup(), KURLComboBox::setMaxItems(), and KURLComboBox::setURLs(). Referenced by init(). |
|
Saves the entries from the location combobox.
Definition at line 1741 of file kfiledialog.cpp. References KConfigBase::group(), KConfigBase::setGroup(), KURLComboBox::urls(), and KConfigBase::writeEntry(). |
|
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 1507 of file kfiledialog.cpp. References QValueList< KURL >::append(), QString::contains(), QString::find(), KURL::isMalformed(), QString::mid(), KStdAccel::name(), KURL::setFileName(), KMessageBox::sorry(), and KDirOperator::url(). |
|
This class or method is obsolete, it is provided for compatibility only.
Definition at line 1190 of file kfiledialog.cpp. |
|
Definition at line 1817 of file kfiledialog.cpp. References KActionCollection::action(), actionCollection(), KDirOperator::actionCollection(), KURL::equals(), QDir::homeDirPath(), KAction::isPlugged(), KAction::plug(), KURL::setPath(), KAction::unplug(), and KURLBarItem::url(). Referenced by init(), and readConfig(). |
|
This class or method is obsolete, it is provided for compatibility only.
Definition at line 1339 of file kfiledialog.cpp. |
The documentation for this class was generated from the following files: