kio Library API Documentation

kurlcompletion.h

00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2000 David Smith  <dsmith@algonet.se>
00003 
00004     This class was inspired by a previous KURLCompletion by
00005     Henner Zeller <zeller@think.de>
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Library General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Library General Public License for more details.
00016 
00017     You should have received a copy of the GNU Library General Public License
00018     along with this library; see the file COPYING.LIB.  If not, write to
00019     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020     Boston, MA 02111-1307, USA.
00021 */
00022 
00023 #ifndef KURLCOMPLETION_H
00024 #define KURLCOMPLETION_H
00025 
00026 #include <kcompletion.h>
00027 #include <kio/jobclasses.h>
00028 #include <qstring.h>
00029 #include <qstringlist.h>
00030 
00031 class KURL;
00032 class KURLCompletionPrivate;
00033 
00041 class KIO_EXPORT KURLCompletion : public KCompletion
00042 {
00043     Q_OBJECT
00044 
00045 public:
00053     enum Mode { ExeCompletion=1, FileCompletion, DirCompletion };
00054 
00058     KURLCompletion();
00063     KURLCompletion(Mode);
00067     virtual ~KURLCompletion();
00068 
00082     virtual QString makeCompletion(const QString &text);
00083 
00089     virtual void setDir(const QString &dir);
00090 
00095     virtual QString dir() const;
00096 
00101     virtual bool isRunning() const;
00102 
00106     virtual void stop();
00107 
00112     virtual Mode mode() const;
00113 
00118     virtual void setMode( Mode mode );
00119 
00126     virtual bool replaceEnv() const;
00127 
00133     virtual void setReplaceEnv( bool replace );
00134 
00141     virtual bool replaceHome() const;
00142 
00149     virtual void setReplaceHome( bool replace );
00150 
00159     QString replacedPath( const QString& text );
00160 
00165     static QString replacedPath( const QString& text,
00166                                      bool replaceHome, bool replaceEnv = true );
00167 
00168     class MyURL;
00169 protected:
00170     // Called by KCompletion, adds '/' to directories
00171     void postProcessMatch( QString *match ) const;
00172     void postProcessMatches( QStringList *matches ) const;
00173     void postProcessMatches( KCompletionMatches* matches ) const;
00174 
00175     virtual void customEvent( QCustomEvent *e );
00176 
00177 protected slots:
00178     void slotEntries( KIO::Job *, const KIO::UDSEntryList& );
00179     void slotIOFinished( KIO::Job * );
00180 
00181 private:
00182 
00183     bool isAutoCompletion();
00184 
00185     bool userCompletion(const MyURL &url, QString *match);
00186     bool envCompletion(const MyURL &url, QString *match);
00187     bool exeCompletion(const MyURL &url, QString *match);
00188     bool fileCompletion(const MyURL &url, QString *match);
00189     bool urlCompletion(const MyURL &url, QString *match);
00190 
00191     // List a directory using readdir()
00192     void listDir( const QString& dir,
00193                   QStringList *matches,
00194                   const QString& filter,
00195                   bool only_exe,
00196                   bool no_hidden );
00197 
00198     // List the next dir in m_dirs
00199     QString listDirectories(const QStringList &,
00200                             const QString &,
00201                             bool only_exe = false,
00202                             bool only_dir = false,
00203                             bool no_hidden = false,
00204                             bool stat_files = true);
00205 
00206     void listURLs( const QValueList<KURL *> &urls,
00207                    const QString &filter = QString::null,
00208                    bool only_exe = false,
00209                    bool no_hidden = false );
00210 
00211     void addMatches( const QStringList & );
00212     QString finished();
00213 
00214     void init();
00215 
00216     void setListedURL(int compl_type /* enum ComplType */,
00217                       QString dir = QString::null,
00218                       QString filter = QString::null,
00219                       bool no_hidden = false );
00220 
00221     bool isListedURL( int compl_type /* enum ComplType */,
00222                       QString dir = QString::null,
00223                       QString filter = QString::null,
00224                       bool no_hidden = false );
00225 
00226 protected:
00227     virtual void virtual_hook( int id, void* data );
00228 private:
00229     KURLCompletionPrivate *d;
00230 };
00231 
00232 #endif // KURLCOMPLETION_H
KDE Logo
This file is part of the documentation for kio Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:15:31 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003