KDE's file dialogs are implemented in the kfile library, which also contains other widgets.
The classes related to the file dialog are really a file dialog construction set, i.e. the API not only contain the class KFileDialog with its conveniently usable functions to obtain file names for saving or opening, but it also offers the various single widgets that constitute the dialog for separate use.
The main view of the file dialog is a KDirOperator. It is a general browser for files and directories. How these lists and trees are actually represented is configurable by the user. All widgets possible for this are derived from the class KFileView. These are the following:
This is a combo box for selecting from a number of files and directories. It runs in one of three modes. The KURLComboBox at the top of the file dialog is in "Directories" mode, the one at the bottom in "Files" mode. Items in the popup menu are shown as URLs together with their MIME type icon. Additionally, one can add a number of default items which are shown as clear text. For example:
KURL u(QDir::homeDirPath()); QString text = i18n("Home Directory"); QPixmap pixmap = KMimeType::pixmapForURL(u, 0, KIcon::Small); combobox->addDefaultURL(u, pixmap, text); </code> === KFileFilter === This is a combo box for selecting from a number of file filters or MIME types. There are two ways to populate it with items: First, you can give a linebreak-separated list of strings of the following form: <syntaxhighlight lang="cpp-qt"> combo->setFilter("*.cpp|Implementation files\n*.h|Header files"); </code> This displays the clear text strings in the popup in order to select the according patterns. The other method is to give a list of MIME types: <syntaxhighlight lang="cpp-qt"> QStringList mimeTypes; mimeTypes << "image/png"; mimeTypes << "text/html"; combo->setMimeFilter(mimeTypes); </code> == Other widgets == Apart from the widgets used in the file dialog, there is a number of related classes (partially contained in the ksycoca library): === KURLCompletion === This is a subclass of [http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKCompletion.html KCompletion] and specifically designed to provide automatic completions for URLs. It can operate in one of two modes: <tt>ExeCompletion</tt> completes names of executables by searching them in $PATH (if they are not given as absolute file names). <tt>FileCompletion</tt> completes generic URLs. This works even for remote addresses. Completion support can easily be added to line edits (derived from [http://api.kde.org/3.5-api/kdelibs-apidocs/kdeui/html/classKLineEdit.html KLineEdit]) or combo boxes (derived from [http://api.kde.org/3.5-api/kdelibs-apidocs/kdeui/html/classKComboBox.html KComboBox]): <syntaxhighlight lang="cpp-qt"> KCompletion *completion = new KURLCompletion(KURLCompletion::ExeCompletion); lineEdit->setCompletionObject(completion); lineEdit->setAutoDeleteCompletionObject(true); </code> === KURLPixmapProvider === This is a subclass of [http://api.kde.org/3.5-api/kdelibs-apidocs/kdecore/html/classKPixmapProvider.html KPixmapProvider] which resolves pixmaps for URLs. Support for URL icons in combo boxes (derived from [http://api.kde.org/3.5-api/kdelibs-apidocs/kdeui/html/classKComboBox.html KComboBox]) can be easily added: <syntaxhighlight lang="cpp-qt"> KPixmapProver *pixmapProvider = new KURLPixmapProvider(); comboBox->setPixmapProvider(pixmapProvider); </code> === KURLRequester === This is a lineedit combined with a button that invokes a file dialog. It uses the KURLCompletion class described above. === KURLRequesterDlg === A simple dialog for letting the user input a file name or URL. It is a very thin wrapper around the KURLRequester widget. For example, this is used when you choose "Location->Open Location" in Konqueror. === KOpenWithDlg === The dialog shown by Konqueror when you click on a file with unknown MIME type. === KPropertiesDialog === The properties dialog you get when you choose the "Properties" item from Konqueror's context menu or the context menu in the file dialog. The dialog can be extended with more tabs by inserting additional [http://api.kde.org/3.5-api/kdelibs-apidocs/kio/kfile/html/classKPropsDlgPlugin.html KPropsDlgPlugin]) widgets. === KIconDialog === A dialog for selecting icons. Furthermore, a number of additional IO jobs: === KDirSize === This computes the sum of the file sizes in a directory. === KDiskFreeSp === A class for finding out the free disk space on a disk. === KIO::PreviewJob === A job for creating thumbnails for a set of files. ''Initial Author:'' [mailto:firstname.lastname@example.org Bernd Gehrmann] [[Category:KDE3]] [[Category:Architecture]]