kio Library API Documentation

kfiledialog.cpp

00001 // -*- c++ -*-
00002 /* This file is part of the KDE libraries
00003     Copyright (C) 1997, 1998 Richard Moore <rich@kde.org>
00004                   1998 Stephan Kulow <coolo@kde.org>
00005                   1998 Daniel Grana <grana@ie.iwi.unibe.ch>
00006                   1999,2000,2001,2002,2003 Carsten Pfeiffer <pfeiffer@kde.org>
00007                   2003 Clarence Dang <dang@kde.org>
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Library General Public
00011     License as published by the Free Software Foundation; either
00012     version 2 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Library General Public License for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with this library; see the file COPYING.LIB.  If not, write to
00021     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022     Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #include <unistd.h>
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 
00029 #include <qptrcollection.h>
00030 #include <qcheckbox.h>
00031 #include <qcombobox.h>
00032 #include <qlabel.h>
00033 #include <qlayout.h>
00034 #include <qlineedit.h>
00035 #include <qptrlist.h>
00036 #include <qpixmap.h>
00037 #include <qtextcodec.h>
00038 #include <qtooltip.h>
00039 #include <qtimer.h>
00040 #include <qwhatsthis.h>
00041 
00042 #include <kaccel.h>
00043 #include <kaction.h>
00044 #include <kapplication.h>
00045 #include <kcharsets.h>
00046 #include <kcmdlineargs.h>
00047 #include <kcompletionbox.h>
00048 #include <kconfig.h>
00049 #include <kdebug.h>
00050 #include <kglobal.h>
00051 #include <kglobalsettings.h>
00052 #include <kiconloader.h>
00053 #include <kimageio.h>
00054 #include <kio/job.h>
00055 #include <kio/netaccess.h>
00056 #include <kio/previewjob.h>
00057 #include <kio/scheduler.h>
00058 #include <klocale.h>
00059 #include <kmessagebox.h>
00060 #include <kmimetype.h>
00061 #include <kpopupmenu.h>
00062 #include <kprotocolinfo.h>
00063 #include <kpushbutton.h>
00064 #include <krecentdirs.h>
00065 #include <kshell.h>
00066 #include <kstandarddirs.h>
00067 #include <kstdguiitem.h>
00068 #include <kstaticdeleter.h>
00069 #include <ktoolbar.h>
00070 #include <ktoolbarbutton.h>
00071 #include <kurl.h>
00072 #include <kurlcombobox.h>
00073 #include <kurlcompletion.h>
00074 #include <kuser.h>
00075 
00076 #include "config-kfile.h"
00077 #include "kpreviewwidgetbase.h"
00078 
00079 #include <kdirselectdialog.h>
00080 #include <kfileview.h>
00081 #include <krecentdocument.h>
00082 #include <kfiledialog.h>
00083 #include <kfilefiltercombo.h>
00084 #include <kdiroperator.h>
00085 #include <kimagefilepreview.h>
00086 
00087 #include <kfilespeedbar.h>
00088 #include <kfilebookmarkhandler.h>
00089 
00090 enum Buttons { HOTLIST_BUTTON,
00091                PATH_COMBO, CONFIGURE_BUTTON };
00092 
00093 template class QPtrList<KIO::StatJob>;
00094 
00095 namespace {
00096     static void silenceQToolBar(QtMsgType, const char *)
00097     {
00098     }
00099 }
00100 
00101 struct KFileDialogPrivate
00102 {
00103     // the last selected url
00104     KURL url;
00105 
00106     // the selected filenames in multiselection mode -- FIXME
00107     QString filenames;
00108 
00109     // the name of the filename set by setSelection
00110     QString selection;
00111 
00112     // now following all kind of widgets, that I need to rebuild
00113     // the geometry management
00114     QBoxLayout *boxLayout;
00115     QWidget *mainWidget;
00116 
00117     QLabel *locationLabel;
00118 
00119     // @deprecated remove in KDE4
00120     QLabel *filterLabel;
00121     KURLComboBox *pathCombo;
00122     KPushButton *okButton, *cancelButton;
00123     KFileSpeedBar *urlBar;
00124     QHBoxLayout *urlBarLayout;
00125     QWidget *customWidget;
00126 
00127     // Automatically Select Extension stuff
00128     QCheckBox *autoSelectExtCheckBox;
00129     bool autoSelectExtChecked; // whether or not the _user_ has checked the above box
00130     QString extension; // current extension for this filter
00131 
00132     QPtrList<KIO::StatJob> statJobs;
00133 
00134     KURL::List urlList; //the list of selected urls
00135 
00136     QStringList mimetypes; //the list of possible mimetypes to save as
00137 
00138     // indicates if the location edit should be kept or cleared when changing
00139     // directories
00140     bool keepLocation :1;
00141 
00142     // the KDirOperators view is set in KFileDialog::show(), so to avoid
00143     // setting it again and again, we have this nice little boolean :)
00144     bool hasView :1;
00145 
00146     // do we show the speedbar for the first time?
00147     bool initializeSpeedbar :1;
00148 
00149     bool hasDefaultFilter :1; // necessary for the operationMode
00150     KFileDialog::OperationMode operationMode;
00151 
00152     // The file class used for KRecentDirs
00153     QString fileClass;
00154 
00155     KFileBookmarkHandler *bookmarkHandler;
00156 
00157     // the ID of the path drop down so subclasses can place their custom widgets properly
00158     int m_pathComboIndex;
00159 };
00160 
00161 KURL *KFileDialog::lastDirectory; // to set the start path
00162 
00163 static KStaticDeleter<KURL> ldd;
00164 
00165 KFileDialog::KFileDialog(const QString& startDir, const QString& filter,
00166                          QWidget *parent, const char* name, bool modal)
00167     : KDialogBase( parent, name, modal, QString::null, 0 )
00168 {
00169     init( startDir, filter, 0 );
00170 }
00171 
00172 KFileDialog::KFileDialog(const QString& startDir, const QString& filter,
00173                          QWidget *parent, const char* name, bool modal, QWidget* widget)
00174     : KDialogBase( parent, name, modal, QString::null, 0 )
00175 {
00176     init( startDir, filter, widget );
00177 }
00178 
00179 
00180 KFileDialog::~KFileDialog()
00181 {
00182     hide();
00183 
00184     KConfig *config = KGlobal::config();
00185 
00186     if (d->urlBar)
00187         d->urlBar->save( config );
00188 
00189     config->sync();
00190 
00191     delete d->bookmarkHandler; // Should be deleted before ops!
00192     delete ops;
00193     delete d;
00194 }
00195 
00196 void KFileDialog::setLocationLabel(const QString& text)
00197 {
00198     d->locationLabel->setText(text);
00199 }
00200 
00201 void KFileDialog::setFilter(const QString& filter)
00202 {
00203     int pos = filter.find('/');
00204 
00205     // Check for an un-escaped '/', if found
00206     // interpret as a MIME filter.
00207 
00208     if (pos > 0 && filter[pos - 1] != '\\') {
00209         QStringList filters = QStringList::split( " ", filter );
00210         setMimeFilter( filters );
00211         return;
00212     }
00213 
00214     // Strip the escape characters from
00215     // escaped '/' characters.
00216 
00217     QString copy (filter);
00218     for (pos = 0; (pos = copy.find("\\/", pos)) != -1; ++pos)
00219         copy.remove(pos, 1);
00220 
00221     ops->clearFilter();
00222     filterWidget->setFilter(copy);
00223     ops->setNameFilter(filterWidget->currentFilter());
00224     d->hasDefaultFilter = false;
00225     filterWidget->setEditable( true );
00226 
00227     updateAutoSelectExtension ();
00228 }
00229 
00230 QString KFileDialog::currentFilter() const
00231 {
00232     return filterWidget->currentFilter();
00233 }
00234 
00235 // deprecated
00236 void KFileDialog::setFilterMimeType(const QString &label,
00237                                     const KMimeType::List &types,
00238                                     const KMimeType::Ptr &defaultType)
00239 {
00240     d->mimetypes.clear();
00241     d->filterLabel->setText(label);
00242 
00243     KMimeType::List::ConstIterator it;
00244     for( it = types.begin(); it != types.end(); ++it)
00245         d->mimetypes.append( (*it)->name() );
00246 
00247     setMimeFilter( d->mimetypes, defaultType->name() );
00248 }
00249 
00250 void KFileDialog::setMimeFilter( const QStringList& mimeTypes,
00251                                  const QString& defaultType )
00252 {
00253     d->mimetypes = mimeTypes;
00254     filterWidget->setMimeFilter( mimeTypes, defaultType );
00255 
00256     QStringList types = QStringList::split(" ", filterWidget->currentFilter());
00257     types.append( QString::fromLatin1( "inode/directory" ));
00258     ops->clearFilter();
00259     ops->setMimeFilter( types );
00260     d->hasDefaultFilter = !defaultType.isEmpty();
00261     filterWidget->setEditable( !d->hasDefaultFilter ||
00262                                d->operationMode != Saving );
00263 
00264     updateAutoSelectExtension ();
00265 }
00266 
00267 void KFileDialog::clearFilter()
00268 {
00269     d->mimetypes.clear();
00270     filterWidget->setFilter( QString::null );
00271     ops->clearFilter();
00272     d->hasDefaultFilter = false;
00273     filterWidget->setEditable( true );
00274 
00275     updateAutoSelectExtension ();
00276 }
00277 
00278 QString KFileDialog::currentMimeFilter() const
00279 {
00280     int i = filterWidget->currentItem();
00281     if (filterWidget->showsAllTypes())
00282         i--;
00283 
00284     if ((i >= 0) && (i < (int) d->mimetypes.count()))
00285         return d->mimetypes[i];
00286     return QString::null; // The "all types" item has no mimetype
00287 }
00288 
00289 KMimeType::Ptr KFileDialog::currentFilterMimeType()
00290 {
00291     return KMimeType::mimeType( currentMimeFilter() );
00292 }
00293 
00294 void KFileDialog::setPreviewWidget(const QWidget *w) {
00295     ops->setPreviewWidget(w);
00296     ops->clearHistory();
00297     d->hasView = true;
00298 }
00299 
00300 void KFileDialog::setPreviewWidget(const KPreviewWidgetBase *w) {
00301     ops->setPreviewWidget(w);
00302     ops->clearHistory();
00303     d->hasView = true;
00304 }
00305 
00306 KURL KFileDialog::getCompleteURL(const QString &_url)
00307 {
00308     QString url = KShell::tildeExpand(_url);
00309     KURL u;
00310 
00311     if ( KURL::isRelativeURL(url) ) // only a full URL isn't relative. Even /path is.
00312     {
00313         if (!url.isEmpty() && url[0] == '/' ) // absolute path
00314             u.setPath( url );
00315         else
00316         {
00317             u = ops->url();
00318             u.addPath( url ); // works for filenames and relative paths
00319             u.cleanPath(); // fix "dir/.."
00320         }
00321     }
00322     else // complete URL
00323         u = url;
00324 
00325     return u;
00326 }
00327 
00328 // FIXME: check for "existing" flag here?
00329 void KFileDialog::slotOk()
00330 {
00331     kdDebug(kfile_area) << "slotOK\n";
00332 
00333     // a list of all selected files/directories (if any)
00334     // can only be used if the user didn't type any filenames/urls himself
00335     const KFileItemList *items = ops->selectedItems();
00336 
00337     if ( (mode() & KFile::Directory) != KFile::Directory ) {
00338         if ( locationEdit->currentText().stripWhiteSpace().isEmpty() ) {
00339             if ( !items || items->isEmpty() )
00340             {
00341                 QString msg;
00342                 if ( d->operationMode == Saving )
00343                     msg = i18n("Please specify the filename to save to.");
00344                 else
00345                     msg = i18n("Please select the file to open.");
00346                 KMessageBox::information(this, msg);
00347                 return;
00348             }
00349 
00350             // weird case: the location edit is empty, but there are
00351             // highlighted files
00352             else {
00353 
00354                 bool multi = (mode() & KFile::Files) != 0;
00355                 KFileItemListIterator it( *items );
00356                 QString endQuote = QString::fromLatin1("\" ");
00357                 QString name, files;
00358                 while ( it.current() ) {
00359                     name = (*it)->name();
00360                     if ( multi ) {
00361                         name.prepend( '"' );
00362                         name.append( endQuote );
00363                     }
00364 
00365                     files.append( name );
00366                     ++it;
00367                 }
00368                 setLocationText( files );
00369                 return;
00370             }
00371         }
00372     }
00373 
00374     bool dirOnly = ops->dirOnlyMode();
00375 
00376     // we can use our kfileitems, no need to parse anything
00377     if ( items && !locationEdit->lineEdit()->edited() &&
00378          !(items->isEmpty() && !dirOnly) ) {
00379 
00380         d->urlList.clear();
00381         d->filenames = QString::null;
00382 
00383         if ( dirOnly ) {
00384             d->url = ops->url();
00385         }
00386         else {
00387             if ( !(mode() & KFile::Files) ) {// single selection
00388                 d->url = items->getFirst()->url();
00389             }
00390 
00391             else { // multi (dirs and/or files)
00392                 d->url = ops->url();
00393                 KFileItemListIterator it( *items );
00394                 while ( it.current() ) {
00395                     d->urlList.append( (*it)->url() );
00396                     ++it;
00397                 }
00398             }
00399         }
00400 
00401         if ( (mode() & KFile::LocalOnly) == KFile::LocalOnly &&
00402              !d->url.isLocalFile() ) {
00403 // ### after message freeze, add message for directories!
00404             KMessageBox::sorry( d->mainWidget,
00405                                 i18n("You can only select local files."),
00406                                 i18n("Remote Files not Accepted") );
00407             return;
00408         }
00409 
00410         accept();
00411         return;
00412     }
00413 
00414 
00415     KURL selectedURL;
00416 
00417     if ( (mode() & KFile::Files) == KFile::Files ) {// multiselection mode
00418         QString locationText = locationEdit->currentText();
00419         if ( locationText.contains( '/' )) {
00420             // relative path? -> prepend the current directory
00421             KURL u( ops->url(), KShell::tildeExpand(locationText));
00422             if ( u.isValid() )
00423                 selectedURL = u;
00424             else
00425                 selectedURL = ops->url();
00426         }
00427         else // simple filename -> just use the current URL
00428             selectedURL = ops->url();
00429     }
00430 
00431     else {
00432         selectedURL = getCompleteURL(locationEdit->currentText());
00433 
00434         // appendExtension() may change selectedURL
00435         appendExtension (selectedURL);
00436     }
00437 
00438     if ( !selectedURL.isValid() ) {
00439        KMessageBox::sorry( d->mainWidget, i18n("%1\ndoes not appear to be a valid URL.\n").arg(d->url.url()), i18n("Invalid URL") );
00440        return;
00441     }
00442 
00443     if ( (mode() & KFile::LocalOnly) == KFile::LocalOnly &&
00444          !selectedURL.isLocalFile() ) {
00445         KMessageBox::sorry( d->mainWidget,
00446                             i18n("You can only select local files."),
00447                             i18n("Remote Files not Accepted") );
00448         return;
00449     }
00450 
00451     d->url = selectedURL;
00452 
00453     // d->url is a correct URL now
00454 
00455     if ( (mode() & KFile::Directory) == KFile::Directory ) {
00456         kdDebug(kfile_area) << "Directory" << endl;
00457         bool done = true;
00458         if ( d->url.isLocalFile() ) {
00459             if ( locationEdit->currentText().stripWhiteSpace().isEmpty() ) {
00460                 QFileInfo info( d->url.path() );
00461                 if ( info.isDir() ) {
00462                     d->filenames = QString::null;
00463                     d->urlList.clear();
00464                     d->urlList.append( d->url );
00465                     accept();
00466                 }
00467                 else if (!info.exists() && (mode() & KFile::File) != KFile::File) {
00468                     // directory doesn't exist, create and enter it
00469                     if ( ops->mkdir( d->url.url(), true ))
00470                         return;
00471                     else
00472                         accept();
00473                 }
00474                 else { // d->url is not a directory,
00475                     // maybe we are in File(s) | Directory mode
00476                     if ( mode() & KFile::File == KFile::File ||
00477                         mode() & KFile::Files == KFile::Files )
00478                         done = false;
00479                 }
00480             }
00481             else  // Directory mode, with file[s]/dir[s] selected
00482             {
00483                 if ( mode() & KFile::ExistingOnly )
00484                 {
00485                     if ( ops->dirOnlyMode() )
00486                     {
00487                         KURL fullURL(d->url, locationEdit->currentText());
00488                         if ( QFile::exists( fullURL.path() ) )
00489                         {
00490                             d->url = fullURL;
00491                             d->filenames = QString::null;
00492                             d->urlList.clear();
00493                             accept();
00494                             return;
00495                         }
00496                         else // doesn't exist -> reject
00497                             return;
00498                     }
00499                 }
00500 
00501                 d->filenames = locationEdit->currentText();
00502                 accept(); // what can we do?
00503             }
00504 
00505         }
00506         else { // FIXME: remote directory, should we allow that?
00507 //             qDebug( "**** Selected remote directory: %s", d->url.url().latin1());
00508             d->filenames = QString::null;
00509             d->urlList.clear();
00510             d->urlList.append( d->url );
00511 
00512             if ( mode() & KFile::ExistingOnly )
00513                 done = false;
00514             else
00515                 accept();
00516         }
00517 
00518         if ( done )
00519             return;
00520     }
00521 
00522     if (!kapp->authorizeURLAction("open", KURL(), d->url))
00523     {
00524         QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, d->url.prettyURL());
00525         KMessageBox::error( d->mainWidget, msg);
00526         return;
00527     }
00528 
00529     KIO::StatJob *job = 0L;
00530     d->statJobs.clear();
00531     d->filenames = KShell::tildeExpand(locationEdit->currentText());
00532 
00533     if ( (mode() & KFile::Files) == KFile::Files &&
00534          !locationEdit->currentText().contains( '/' )) {
00535         kdDebug(kfile_area) << "Files\n";
00536         KURL::List list = parseSelectedURLs();
00537         for ( KURL::List::ConstIterator it = list.begin();
00538               it != list.end(); ++it )
00539         {
00540             if (!kapp->authorizeURLAction("open", KURL(), *it))
00541             {
00542                 QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, (*it).prettyURL());
00543                 KMessageBox::error( d->mainWidget, msg);
00544                 return;
00545             }
00546         }
00547         for ( KURL::List::ConstIterator it = list.begin();
00548               it != list.end(); ++it )
00549         {
00550             job = KIO::stat( *it, !(*it).isLocalFile() );
00551             job->setWindow (topLevelWidget());
00552             KIO::Scheduler::scheduleJob( job );
00553             d->statJobs.append( job );
00554             connect( job, SIGNAL( result(KIO::Job *) ),
00555                      SLOT( slotStatResult( KIO::Job *) ));
00556         }
00557         return;
00558     }
00559 
00560     job = KIO::stat(d->url,!d->url.isLocalFile());
00561     job->setWindow (topLevelWidget());
00562     d->statJobs.append( job );
00563     connect(job, SIGNAL(result(KIO::Job*)), SLOT(slotStatResult(KIO::Job*)));
00564 }
00565 
00566 
00567 static bool isDirectory (const KIO::UDSEntry &t)
00568 {
00569     bool isDir = false;
00570 
00571     for (KIO::UDSEntry::ConstIterator it = t.begin();
00572          it != t.end();
00573          it++)
00574     {
00575         if ((*it).m_uds == KIO::UDS_FILE_TYPE)
00576         {
00577             isDir = S_ISDIR ((mode_t) ((*it).m_long));
00578             break;
00579         }
00580     }
00581 
00582     return isDir;
00583 }
00584 
00585 // FIXME : count all errors and show messagebox when d->statJobs.count() == 0
00586 // in case of an error, we cancel the whole operation (clear d->statJobs and
00587 // don't call accept)
00588 void KFileDialog::slotStatResult(KIO::Job* job)
00589 {
00590     kdDebug(kfile_area) << "slotStatResult" << endl;
00591     KIO::StatJob *sJob = static_cast<KIO::StatJob *>( job );
00592 
00593     if ( !d->statJobs.removeRef( sJob ) ) {
00594         return;
00595     }
00596 
00597     int count = d->statJobs.count();
00598 
00599     // errors mean in general, the location is no directory ;/
00600     // Can we be sure that it is exististant at all? (pfeiffer)
00601     if (sJob->error() && count == 0 && !ops->dirOnlyMode())
00602     {
00603         accept();
00604         return;
00605     }
00606 
00607     KIO::UDSEntry t = sJob->statResult();
00608     if (isDirectory (t))
00609     {
00610         if ( ops->dirOnlyMode() )
00611         {
00612             d->filenames = QString::null;
00613             d->urlList.clear();
00614             accept();
00615         }
00616         else // in File[s] mode, directory means error -> cd into it
00617         {
00618             if ( count == 0 ) {
00619                 locationEdit->clearEdit();
00620                 locationEdit->lineEdit()->setEdited( false );
00621                 setURL( sJob->url() );
00622             }
00623         }
00624         d->statJobs.clear();
00625         return;
00626     }
00627     else if ( ops->dirOnlyMode() )
00628     {
00629         return; // ### error message?
00630     }
00631 
00632     kdDebug(kfile_area) << "filename " << sJob->url().url() << endl;
00633 
00634     if ( count == 0 )
00635         accept();
00636 }
00637 
00638 void KFileDialog::accept()
00639 {
00640     setResult( QDialog::Accepted ); // parseSelectedURLs() checks that
00641 
00642     *lastDirectory = ops->url();
00643     if (!d->fileClass.isEmpty())
00644        KRecentDirs::add(d->fileClass, ops->url().url());
00645 
00646     // clear the topmost item, we insert it as full path later on as item 1
00647     locationEdit->changeItem( QString::null, 0 );
00648 
00649     KURL::List list = selectedURLs();
00650     QValueListConstIterator<KURL> it = list.begin();
00651     for ( ; it != list.end(); ++it ) {
00652         const KURL& url = *it;
00653         // we strip the last slash (-1) because KURLComboBox does that as well
00654         // when operating in file-mode. If we wouldn't , dupe-finding wouldn't
00655         // work.
00656         QString file = url.isLocalFile() ? url.path(-1) : url.prettyURL(-1);
00657 
00658         // remove dupes
00659         for ( int i = 1; i < locationEdit->count(); i++ ) {
00660             if ( locationEdit->text( i ) == file ) {
00661                 locationEdit->removeItem( i-- );
00662                 break;
00663             }
00664         }
00665         locationEdit->insertItem( file, 1 );
00666     }
00667 
00668     KConfig *config = KGlobal::config();
00669     config->setForceGlobal( true );
00670     writeConfig( config, ConfigGroup );
00671     config->setForceGlobal( false );
00672 
00673     saveRecentFiles( config );
00674     config->sync();
00675 
00676     KDialogBase::accept();
00677 
00678     addToRecentDocuments();
00679 
00680     if ( (mode() & KFile::Files) != KFile::Files ) // single selection
00681         emit fileSelected(d->url.url());
00682 
00683     ops->close();
00684     emit okClicked();
00685 }
00686 
00687 
00688 void KFileDialog::fileHighlighted(const KFileItem *i)
00689 {
00690     if (i && i->isDir())
00691         return;
00692 
00693 
00694     if ( (ops->mode() & KFile::Files) != KFile::Files ) {
00695         if ( !i )
00696             return;
00697 
00698         d->url = i->url();
00699 
00700         if ( !locationEdit->hasFocus() ) { // don't disturb while editing
00701             setLocationText( i->name() );
00702         }
00703         emit fileHighlighted(d->url.url());
00704     }
00705 
00706     else {
00707         multiSelectionChanged();
00708         emit selectionChanged();
00709     }
00710 }
00711 
00712 void KFileDialog::fileSelected(const KFileItem *i)
00713 {
00714     if (i && i->isDir())
00715         return;
00716 
00717     if ( (ops->mode() & KFile::Files) != KFile::Files ) {
00718         if ( !i )
00719             return;
00720 
00721         d->url = i->url();
00722         setLocationText( i->name() );
00723     }
00724     else {
00725         multiSelectionChanged();
00726         emit selectionChanged();
00727     }
00728     slotOk();
00729 }
00730 
00731 
00732 // I know it's slow to always iterate thru the whole filelist
00733 // (ops->selectedItems()), but what can we do?
00734 void KFileDialog::multiSelectionChanged()
00735 {
00736     if ( locationEdit->hasFocus() ) // don't disturb
00737         return;
00738 
00739     locationEdit->lineEdit()->setEdited( false );
00740     KFileItem *item;
00741     const KFileItemList *list = ops->selectedItems();
00742     if ( !list ) {
00743         locationEdit->clearEdit();
00744         return;
00745     }
00746 
00747     static const QString &begin = KGlobal::staticQString(" \"");
00748     KFileItemListIterator it ( *list );
00749     QString text;
00750     while ( (item = it.current()) ) {
00751         text.append( begin ).append( item->name() ).append( '\"' );
00752         ++it;
00753     }
00754     
00755     setLocationText( text.stripWhiteSpace() );
00756 }
00757 
00758 void KFileDialog::setLocationText( const QString& text )
00759 {
00760     // setCurrentItem() will cause textChanged() being emitted,
00761     // so slotLocationChanged() will be called. Make sure we don't clear
00762     // the KDirOperator's view-selection in there 
00763     disconnect( locationEdit, SIGNAL( textChanged( const QString& ) ),
00764                 this, SLOT( slotLocationChanged( const QString& ) ) );
00765     locationEdit->setCurrentItem( 0 );
00766     connect( locationEdit, SIGNAL( textChanged( const QString& ) ),
00767              SLOT( slotLocationChanged( const QString& )) );
00768     locationEdit->setEditText( text );
00769 }
00770 
00771 static QString autocompletionWhatsThisText = i18n("<p>While typing in the text area, you may be presented "
00772                                                   "with possible matches. "
00773                                                   "This feature can be controlled by clicking with the right mouse button "
00774                                                   "and selecting a preferred mode from the <b>Text Completion</b> menu.") + "</qt>";
00775 void KFileDialog::updateLocationWhatsThis (void)
00776 {
00777     QString whatsThisText;
00778     if (d->operationMode == KFileDialog::Saving)
00779     {
00780         whatsThisText = "<qt>" + i18n("This is the name to save the file as.") +
00781                              autocompletionWhatsThisText;
00782     }
00783     else if (ops->mode() & KFile::Files)
00784     {
00785         whatsThisText = "<qt>" + i18n("This is the list of files to open. More than "
00786                              "one file can be specified by listing several "
00787                              "files, separated by spaces.") +
00788                               autocompletionWhatsThisText;
00789     }
00790     else
00791     {
00792         whatsThisText = "<qt>" + i18n("This is the name of the file to open.") +
00793                              autocompletionWhatsThisText;
00794     }
00795 
00796     QWhatsThis::add(d->locationLabel, whatsThisText);
00797     QWhatsThis::add(locationEdit, whatsThisText);
00798 }
00799 
00800 void KFileDialog::init(const QString& startDir, const QString& filter, QWidget* widget)
00801 {
00802     initStatic();
00803     d = new KFileDialogPrivate();
00804 
00805     d->boxLayout = 0;
00806     d->keepLocation = false;
00807     d->operationMode = Opening;
00808     d->hasDefaultFilter = false;
00809     d->hasView = false;
00810     d->mainWidget = new QWidget( this, "KFileDialog::mainWidget");
00811     setMainWidget( d->mainWidget );
00812     d->okButton = new KPushButton( KStdGuiItem::ok(), d->mainWidget );
00813     d->okButton->setDefault( true );
00814     d->cancelButton = new KPushButton(KStdGuiItem::cancel(), d->mainWidget);
00815     connect( d->okButton, SIGNAL( clicked() ), SLOT( slotOk() ));
00816     connect( d->cancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ));
00817     d->customWidget = widget;
00818     d->autoSelectExtCheckBox = 0; // delayed loading
00819     d->autoSelectExtChecked = false;
00820     d->urlBar = 0; // delayed loading
00821     KConfig *config = KGlobal::config();
00822     KConfigGroupSaver cs( config, ConfigGroup );
00823     d->initializeSpeedbar = config->readBoolEntry( "Set speedbar defaults",
00824                                                    true );
00825 
00826     QtMsgHandler oldHandler = qInstallMsgHandler( silenceQToolBar );
00827     toolbar = new KToolBar( d->mainWidget, "KFileDialog::toolbar", true);
00828     toolbar->setFlat(true);
00829     qInstallMsgHandler( oldHandler );
00830 
00831     d->pathCombo = new KURLComboBox( KURLComboBox::Directories, true,
00832                                      toolbar, "path combo" );
00833     QToolTip::add( d->pathCombo, i18n("Often used folders") );
00834     QWhatsThis::add( d->pathCombo, "<qt>" + i18n("Commonly used locations are listed here. "
00835                                                  "This includes standard locations, such as your home folder, as well as "
00836                                                  "locations that have been visited recently.") + autocompletionWhatsThisText);
00837 
00838     KURL u;
00839     u.setPath( QDir::rootDirPath() );
00840     QString text = i18n("Root Folder: %1").arg( u.path() );
00841     d->pathCombo->addDefaultURL( u,
00842                                  KMimeType::pixmapForURL( u, 0, KIcon::Small ),
00843                                  text );
00844 
00845     u.setPath( QDir::homeDirPath() );
00846     text = i18n("Home Folder: %1").arg( u.path( +1 ) );
00847     d->pathCombo->addDefaultURL( u, KMimeType::pixmapForURL( u, 0, KIcon::Small ),
00848                                  text );
00849 
00850     KURL docPath;
00851     docPath.setPath( KGlobalSettings::documentPath() );
00852     if ( u.path(+1) != docPath.path(+1) ) {
00853         text = i18n("Documents: %1").arg( docPath.path( +1 ) );
00854         d->pathCombo->addDefaultURL( docPath,
00855                                      KMimeType::pixmapForURL( docPath, 0, KIcon::Small ),
00856                                      text );
00857     }
00858 
00859     u.setPath( KGlobalSettings::desktopPath() );
00860     text = i18n("Desktop: %1").arg( u.path( +1 ) );
00861     d->pathCombo->addDefaultURL( u,
00862                                  KMimeType::pixmapForURL( u, 0, KIcon::Small ),
00863                                  text );
00864 
00865     u.setPath( "/tmp" );
00866 
00867     d->url = getStartURL( startDir, d->fileClass );
00868     d->selection = d->url.url();
00869 
00870     // If local, check it exists. If not, go up until it exists.
00871     if ( d->url.isLocalFile() )
00872     {
00873         if ( !QFile::exists( d->url.path() ) )
00874         {
00875             d->url = d->url.upURL();
00876             QDir dir( d->url.path() );
00877             while ( !dir.exists() )
00878             {
00879                 d->url = d->url.upURL();
00880                 dir.setPath( d->url.path() );
00881             }
00882         }
00883     }
00884 
00885     ops = new KDirOperator(d->url, d->mainWidget, "KFileDialog::ops");
00886     ops->setOnlyDoubleClickSelectsFiles( true );
00887     connect(ops, SIGNAL(urlEntered(const KURL&)),
00888             SLOT(urlEntered(const KURL&)));
00889     connect(ops, SIGNAL(fileHighlighted(const KFileItem *)),
00890             SLOT(fileHighlighted(const KFileItem *)));
00891     connect(ops, SIGNAL(fileSelected(const KFileItem *)),
00892             SLOT(fileSelected(const KFileItem *)));
00893     connect(ops, SIGNAL(finishedLoading()),
00894             SLOT(slotLoadingFinished()));
00895 
00896     ops->setupMenu(KDirOperator::SortActions |
00897                    KDirOperator::FileActions |
00898                    KDirOperator::ViewActions);
00899     KActionCollection *coll = ops->actionCollection();
00900 
00901     // plug nav items into the toolbar
00902     coll->action( "up" )->plug( toolbar );
00903     coll->action( "up" )->setWhatsThis(i18n("<qt>Click this button to enter the parent folder.<p>"
00904                                             "For instance, if the current location is file:/home/%1 clicking this "
00905                                             "button will take you to file:/home.</qt>").arg( KUser().loginName() ));
00906     coll->action( "back" )->plug( toolbar );
00907     coll->action( "back" )->setWhatsThis(i18n("Click this button to move backwards one step in the browsing history."));
00908     coll->action( "forward" )->plug( toolbar );
00909     coll->action( "forward" )->setWhatsThis(i18n("Click this button to move forward one step in the browsing history."));
00910     coll->action( "reload" )->plug( toolbar );
00911     coll->action( "reload" )->setWhatsThis(i18n("Click this button to reload the contents of the current location."));
00912     coll->action( "mkdir" )->setShortcut(Key_F10);
00913     coll->action( "mkdir" )->plug( toolbar );
00914     coll->action( "mkdir" )->setWhatsThis(i18n("Click this button to create a new folder."));
00915 
00916     d->bookmarkHandler = new KFileBookmarkHandler( this );
00917     toolbar->insertButton(QString::fromLatin1("bookmark"),
00918                           (int)HOTLIST_BUTTON, true,
00919                           i18n("Bookmarks"));
00920     toolbar->getButton(HOTLIST_BUTTON)->setPopup( d->bookmarkHandler->menu(),
00921                                                   true);
00922     QWhatsThis::add(toolbar->getButton(HOTLIST_BUTTON),
00923                     i18n("<qt>This button allows you to bookmark specific locations. "
00924                          "Click on this button to open the bookmark menu where you may add, "
00925                          "edit or select a bookmark.<p>"
00926                          "These bookmarks are specific to the file dialog, but otherwise operate "
00927                          "like bookmarks elsewhere in KDE.</qt>"));
00928     connect( d->bookmarkHandler, SIGNAL( openURL( const QString& )),
00929              SLOT( enterURL( const QString& )));
00930 
00931     KToggleAction *showSidebarAction =
00932         new KToggleAction(i18n("Show Quick Access Navigation Panel"), Key_F9, coll,"toggleSpeedbar");
00933     connect( showSidebarAction, SIGNAL( toggled( bool ) ),
00934              SLOT( toggleSpeedbar( bool )) );
00935 
00936     KActionMenu *menu = new KActionMenu( i18n("Configure"), "configure", this, "extra menu" );
00937     menu->setWhatsThis(i18n("<qt>This is the configuration menu for the file dialog. "
00938                             "Various options can be accessed from this menu including: <ul>"
00939                             "<li>how files are sorted in the list</li>"
00940                             "<li>types of view, including icon and list</li>"
00941                             "<li>showing of hidden files</li>"
00942                             "<li>the Quick Access navigation panel</li>"
00943                             "<li>file previews</li>"
00944                             "<li>separating folders from files</li></ul></qt>"));
00945     menu->insert( coll->action( "sorting menu" ));
00946     menu->insert( coll->action( "separator" ));
00947     coll->action( "short view" )->setShortcut(Key_F6);
00948     menu->insert( coll->action( "short view" ));
00949     coll->action( "detailed view" )->setShortcut(Key_F7);
00950     menu->insert( coll->action( "detailed view" ));
00951     menu->insert( coll->action( "separator" ));
00952     coll->action( "show hidden" )->setShortcut(Key_F8);
00953     menu->insert( coll->action( "show hidden" ));
00954     menu->insert( showSidebarAction );
00955     coll->action( "preview" )->setShortcut(Key_F11);
00956     menu->insert( coll->action( "preview" ));
00957     coll->action( "separate dirs" )->setShortcut(Key_F12);
00958     menu->insert( coll->action( "separate dirs" ));
00959 
00960     menu->setDelayed( false );
00961     connect( menu->popupMenu(), SIGNAL( aboutToShow() ),
00962              ops, SLOT( updateSelectionDependentActions() ));
00963     menu->plug( toolbar );
00964 
00965     //Insert a separator.
00966     KToolBarSeparator* spacerWidget = new KToolBarSeparator(Horizontal, false /*no line*/,
00967                                                             toolbar);
00968     d->m_pathComboIndex = toolbar->insertWidget(-1, -1, spacerWidget);
00969     toolbar->insertWidget(PATH_COMBO, 0, d->pathCombo);
00970 
00971 
00972     toolbar->setItemAutoSized (PATH_COMBO);
00973     toolbar->setIconText(KToolBar::IconOnly);
00974     toolbar->setBarPos(KToolBar::Top);
00975     toolbar->setMovingEnabled(false);
00976     toolbar->adjustSize();
00977 
00978     KURLCompletion *pathCompletionObj = new KURLCompletion( KURLCompletion::DirCompletion );
00979     d->pathCombo->setCompletionObject( pathCompletionObj );
00980     d->pathCombo->setAutoDeleteCompletionObject( true );
00981 
00982     connect( d->pathCombo, SIGNAL( urlActivated( const KURL&  )),
00983              this,  SLOT( enterURL( const KURL& ) ));
00984     connect( d->pathCombo, SIGNAL( returnPressed( const QString&  )),
00985              this,  SLOT( enterURL( const QString& ) ));
00986 
00987     QString whatsThisText;
00988 
00989     // the Location label/edit
00990     d->locationLabel = new QLabel(i18n("&Location:"), d->mainWidget);
00991     locationEdit = new KURLComboBox(KURLComboBox::Files, true,
00992                                     d->mainWidget, "LocationEdit");
00993     connect( locationEdit, SIGNAL( textChanged( const QString& ) ),
00994              SLOT( slotLocationChanged( const QString& )) );
00995 
00996     updateLocationWhatsThis ();
00997     d->locationLabel->setBuddy(locationEdit);
00998 
00999     locationEdit->setFocus();
01000     KURLCompletion *fileCompletionObj = new KURLCompletion( KURLCompletion::FileCompletion );
01001     QString dir = d->url.url(+1);
01002     pathCompletionObj->setDir( dir );
01003     fileCompletionObj->setDir( dir );
01004     locationEdit->setCompletionObject( fileCompletionObj );
01005     locationEdit->setAutoDeleteCompletionObject( true );
01006     connect( fileCompletionObj, SIGNAL( match( const QString& ) ),
01007              SLOT( fileCompletion( const QString& )) );
01008 
01009     connect( locationEdit, SIGNAL( returnPressed() ),
01010              this, SLOT( slotOk()));
01011     connect(locationEdit, SIGNAL( activated( const QString&  )),
01012             this,  SLOT( locationActivated( const QString& ) ));
01013 
01014     // the Filter label/edit
01015     whatsThisText = i18n("<qt>This is the filter to apply to the file list. "
01016                          "File names that do not match the filter will not be shown.<p>"
01017                          "You may select from one of the preset filters in the "
01018                          "drop down menu, or you may enter a custom filter "
01019                          "directly into the text area.<p>"
01020                          "Wildcards such as * and ? are allowed.</qt>");
01021     d->filterLabel = new QLabel(i18n("&Filter:"), d->mainWidget);
01022     QWhatsThis::add(d->filterLabel, whatsThisText);
01023     filterWidget = new KFileFilterCombo(d->mainWidget,
01024                                         "KFileDialog::filterwidget");
01025     QWhatsThis::add(filterWidget, whatsThisText);
01026     setFilter(filter);
01027     d->filterLabel->setBuddy(filterWidget);
01028     connect(filterWidget, SIGNAL(filterChanged()), SLOT(slotFilterChanged()));
01029 
01030     // the Automatically Select Extension checkbox
01031     // (the text, visibility etc. is set in updateAutoSelectExtension(), which is called by readConfig())
01032     d->autoSelectExtCheckBox = new QCheckBox (d->mainWidget);
01033     connect(d->autoSelectExtCheckBox, SIGNAL(clicked()), SLOT(slotAutoSelectExtClicked()));
01034 
01035     initGUI(); // activate GM
01036 
01037     readRecentFiles( config );
01038 
01039     adjustSize();
01040 
01041     ops->setViewConfig( config, ConfigGroup );
01042     readConfig( config, ConfigGroup );
01043     setSelection(d->selection);
01044 }
01045 
01046 void KFileDialog::initSpeedbar()
01047 {
01048     d->urlBar = new KFileSpeedBar( d->mainWidget, "url bar" );
01049     connect( d->urlBar, SIGNAL( activated( const KURL& )),
01050              SLOT( enterURL( const KURL& )) );
01051 
01052     // need to set the current url of the urlbar manually (not via urlEntered()
01053     // here, because the initial url of KDirOperator might be the same as the
01054     // one that will be set later (and then urlEntered() won't be emitted).
01055     // ### REMOVE THIS when KDirOperator's initial URL (in the c'tor) is gone.
01056     d->urlBar->setCurrentItem( d->url );
01057 
01058     d->urlBarLayout->insertWidget( 0, d->urlBar );
01059 }
01060 
01061 void KFileDialog::initGUI()
01062 {
01063     delete d->boxLayout; // deletes all sub layouts
01064 
01065     d->boxLayout = new QVBoxLayout( d->mainWidget, 0, KDialog::spacingHint());
01066     d->boxLayout->addWidget(toolbar, AlignTop);
01067 
01068     d->urlBarLayout = new QHBoxLayout( d->boxLayout ); // needed for the urlBar that may appear
01069     QVBoxLayout *vbox = new QVBoxLayout( d->urlBarLayout );
01070 
01071     vbox->addWidget(ops, 4);
01072     vbox->addSpacing(3);
01073 
01074     QGridLayout* lafBox= new QGridLayout(2, 3, KDialog::spacingHint());
01075 
01076     lafBox->addWidget(d->locationLabel, 0, 0, AlignVCenter);
01077     lafBox->addWidget(locationEdit, 0, 1, AlignVCenter);
01078     lafBox->addWidget(d->okButton, 0, 2, AlignVCenter);
01079 
01080     lafBox->addWidget(d->filterLabel, 1, 0, AlignVCenter);
01081     lafBox->addWidget(filterWidget, 1, 1, AlignVCenter);
01082     lafBox->addWidget(d->cancelButton, 1, 2, AlignVCenter);
01083 
01084     lafBox->setColStretch(1, 4);
01085 
01086     vbox->addLayout(lafBox, 0);
01087     vbox->addSpacing(3);
01088 
01089     // add the Automatically Select Extension checkbox
01090     vbox->addWidget (d->autoSelectExtCheckBox);
01091     vbox->addSpacing (3);
01092 
01093     setTabOrder(ops, d->autoSelectExtCheckBox);
01094     setTabOrder (d->autoSelectExtCheckBox, locationEdit);
01095     setTabOrder(locationEdit, filterWidget);
01096     setTabOrder(filterWidget, d->okButton);
01097     setTabOrder(d->okButton, d->cancelButton);
01098     setTabOrder(d->cancelButton, d->pathCombo);
01099     setTabOrder(d->pathCombo, ops);
01100 
01101     // If a custom widget was specified...
01102     if ( d->customWidget != 0 )
01103     {
01104         // ...add it to the dialog, below the filter list box.
01105 
01106         // Change the parent so that this widget is a child of the main widget
01107         d->customWidget->reparent( d->mainWidget, QPoint() );
01108 
01109         vbox->addWidget( d->customWidget );
01110         vbox->addSpacing(3);
01111 
01112         // FIXME: This should adjust the tab orders so that the custom widget
01113         // comes after the Cancel button. The code appears to do this, but the result
01114         // somehow screws up the tab order of the file path combo box. Not a major
01115         // problem, but ideally the tab order with a custom widget should be
01116         // the same as the order without one.
01117         setTabOrder(d->cancelButton, d->customWidget);
01118         setTabOrder(d->customWidget, d->pathCombo);
01119     }
01120     else
01121     {
01122         setTabOrder(d->cancelButton, d->pathCombo);
01123     }
01124 
01125     setTabOrder(d->pathCombo, ops);
01126 }
01127 
01128 void KFileDialog::slotFilterChanged()
01129 {
01130     QString filter = filterWidget->currentFilter();
01131     ops->clearFilter();
01132 
01133     if ( filter.find( '/' ) > -1 ) {
01134         QStringList types = QStringList::split( " ", filter );
01135         types.prepend( "inode/directory" );
01136         ops->setMimeFilter( types );
01137     }
01138     else
01139         ops->setNameFilter( filter );
01140 
01141     ops->updateDir();
01142 
01143     updateAutoSelectExtension ();
01144 
01145     emit filterChanged( filter );
01146 }
01147 
01148 
01149 void KFileDialog::setURL(const KURL& url, bool clearforward)
01150 {
01151     d->selection = QString::null;
01152     ops->setURL( url, clearforward);
01153 }
01154 
01155 // Protected
01156 void KFileDialog::urlEntered(const KURL& url)
01157 {
01158     QString filename = locationEdit->currentText();
01159     d->selection = QString::null;
01160 
01161     if ( d->pathCombo->count() != 0 ) { // little hack
01162         d->pathCombo->setURL( url );
01163     }
01164 
01165     locationEdit->blockSignals( true );
01166     locationEdit->setCurrentItem( 0 );
01167     if ( d->keepLocation )
01168         locationEdit->setEditText( filename );
01169 
01170     locationEdit->blockSignals( false );
01171 
01172     QString dir = url.url(+1);
01173     static_cast<KURLCompletion*>( d->pathCombo->completionObject() )->setDir( dir );
01174     static_cast<KURLCompletion*>( locationEdit->completionObject() )->setDir( dir );
01175 
01176     if ( d->urlBar )
01177         d->urlBar->setCurrentItem( url );
01178 }
01179 
01180 void KFileDialog::locationActivated( const QString& url )
01181 {
01182     // This guard prevents any URL _typed_ by the user from being interpreted
01183     // twice (by returnPressed/slotOk and here, activated/locationActivated)
01184     // after the user presses Enter.  Without this, _both_ setSelection and
01185     // slotOk would "u.addPath( url )" ...so instead we leave it up to just
01186     // slotOk....
01187     if (!locationEdit->lineEdit()->edited())
01188         setSelection( url );
01189 }
01190 
01191 void KFileDialog::enterURL( const KURL& url)
01192 {
01193     setURL( url );
01194 }
01195 
01196 void KFileDialog::enterURL( const QString& url )
01197 {
01198     setURL( KURL::fromPathOrURL( KURLCompletion::replacedPath( url, true, true )) );
01199 }
01200 
01201 void KFileDialog::toolbarCallback(int) // SLOT
01202 {
01203     /*
01204      * yes, nothing uses this anymore.
01205      * it used to be used to show the configure dialog
01206      */
01207 }
01208 
01209 
01210 void KFileDialog::setSelection(const QString& url)
01211 {
01212     kdDebug(kfile_area) << "setSelection " << url << endl;
01213 
01214     if (url.isEmpty()) {
01215         d->selection = QString::null;
01216         return;
01217     }
01218 
01219     KURL u = getCompleteURL(url);
01220     if (!u.isValid()) { // if it still is
01221         kdWarning() << url << " is not a correct argument for setSelection!" << endl;
01222         return;
01223     }
01224 
01225 //     #warning FIXME: http URLs, e.g. from KURLCombo
01226 
01227     /* we strip the first / from the path to avoid file://usr which means
01228      *  / on host usr
01229      */
01230     KFileItem i(KFileItem::Unknown, KFileItem::Unknown, u, true );
01231     //    KFileItem i(u.path());
01232     if ( i.isDir() && u.isLocalFile() && QFile::exists( u.path() ) ) {
01233         // trust isDir() only if the file is
01234         // local (we cannot stat non-local urls) and if it exists!
01235         // (as KFileItem does not check if the file exists or not
01236         // -> the statbuffer is undefined -> isDir() is unreliable) (Simon)
01237         setURL(u, true);
01238     }
01239     else {
01240         QString filename = u.url();
01241         int sep = filename.findRev('/');
01242         if (sep >= 0) { // there is a / in it
01243             if ( KProtocolInfo::supportsListing( u ))
01244                 setURL(filename.left(sep), true);
01245 
01246             // filename must be decoded, or "name with space" would become
01247             // "name%20with%20space", so we use KURL::fileName()
01248             filename = u.fileName();
01249             kdDebug(kfile_area) << "filename " << filename << endl;
01250             d->selection = filename;
01251             setLocationText( filename );
01252 
01253             // tell the line edit that it has been edited
01254             // otherwise we won't know this was set by the user
01255             // and it will be ignored if there has been an
01256             // auto completion. this caused bugs where automcompletion
01257             // would start, the user would pick something from the
01258             // history and then hit Ok only to get the autocompleted
01259             // selection. OOOPS.
01260             locationEdit->lineEdit()->setEdited( true );
01261         }
01262 
01263         d->url = ops->url();
01264         d->url.addPath(filename);
01265     }
01266 }
01267 
01268 void KFileDialog::slotLoadingFinished()
01269 {
01270     if ( !d->selection.isNull() )
01271         ops->setCurrentItem( d->selection );
01272 }
01273 
01274 // ### remove in KDE4
01275 void KFileDialog::pathComboChanged( const QString& )
01276 {
01277 }
01278 void KFileDialog::dirCompletion( const QString& ) // SLOT
01279 {
01280 }
01281 void KFileDialog::fileCompletion( const QString& match )
01282 {
01283     if ( match.isEmpty() && ops->