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 
00042 class KURLCompletion : public KCompletion
00043 {
00044     Q_OBJECT
00045 
00046 public:
00054     enum Mode { ExeCompletion=1, FileCompletion, DirCompletion };
00055 
00059     KURLCompletion();
00064     KURLCompletion(Mode);
00068     virtual ~KURLCompletion();
00069 
00083     virtual QString makeCompletion(const QString &text);
00084 
00090     virtual void setDir(const QString &dir);
00091 
00096     virtual QString dir() const;
00097 
00102     virtual bool isRunning() const;
00103 
00107     virtual void stop();
00108 
00113     virtual Mode mode() const;
00114 
00119     virtual void setMode( Mode mode );
00120 
00127     virtual bool replaceEnv() const;
00128 
00134     virtual void setReplaceEnv( bool replace );
00135 
00142     virtual bool replaceHome() const;
00143 
00150     virtual void setReplaceHome( bool replace );
00151 
00160     QString replacedPath( const QString& text );
00161 
00166     static QString replacedPath( const QString& text,
00167                                      bool replaceHome, bool replaceEnv = true );
00168 
00169     class MyURL;
00170     class DirLister;
00171 protected:
00172     // Called by KCompletion, adds '/' to directories
00173     void postProcessMatch( QString *match ) const;
00174     void postProcessMatches( QStringList *matches ) const;
00175         void postProcessMatches( KCompletionMatches* matches ) const;
00176 
00177 protected slots:
00178     void slotEntries( KIO::Job *, const KIO::UDSEntryList& );
00179     void slotIOFinished( KIO::Job * );
00180 
00181 private slots:
00182     void slotTimer();
00183 
00184 private:
00185 
00186     bool isAutoCompletion();
00187 
00188     bool userCompletion(const MyURL &url, QString *match);
00189     bool envCompletion(const MyURL &url, QString *match);
00190     bool exeCompletion(const MyURL &url, QString *match);
00191     bool fileCompletion(const MyURL &url, QString *match);
00192     bool urlCompletion(const MyURL &url, QString *match);
00193 
00194     // List a directory using readdir()
00195     void listDir( const QString& dir,
00196                   QStringList *matches,
00197                   const QString& filter,
00198                   bool only_exe,
00199                   bool no_hidden );
00200 
00201     // List the next dir in m_dirs
00202     QString listDirectories(const QStringList &,
00203                             const QString &,
00204                             bool only_exe = false,
00205                             bool only_dir = false,
00206                             bool no_hidden = false,
00207                             bool stat_files = true);
00208 
00209     void listURLs( const QValueList<KURL *> &urls,
00210                    const QString &filter = QString::null,
00211                    bool only_exe = false,
00212                    bool no_hidden = false );
00213 
00214     void addMatches( QStringList * );
00215     QString finished();
00216 
00217     void init();
00218 
00219     void setListedURL(int compl_type /* enum ComplType */,
00220                       QString dir = QString::null,
00221                       QString filter = QString::null,
00222                       bool no_hidden = false );
00223 
00224     bool isListedURL( int compl_type /* enum ComplType */,
00225                       QString dir = QString::null,
00226                       QString filter = QString::null,
00227                       bool no_hidden = false );
00228 
00229 protected:
00230     virtual void virtual_hook( int id, void* data );
00231 private:
00232     KURLCompletionPrivate *d;
00233 };
00234 
00235 #endif // KURLCOMPLETION_H
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 3 19:23:43 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003