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., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef KURLCOMPLETION_H 00024 #define KURLCOMPLETION_H 00025 00026 #include <kcompletion.h> 00027 #include <kio/jobclasses.h> 00028 #include <tqstring.h> 00029 #include <tqstringlist.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, SystemExeCompletion }; 00054 00058 KURLCompletion(); 00063 KURLCompletion(Mode); 00067 virtual ~KURLCompletion(); 00068 00082 virtual TQString makeCompletion(const TQString &text); // KDE4: remove return value, it's often null due to threading 00083 00089 virtual void setDir(const TQString &dir); 00090 00095 virtual TQString 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 00160 TQString replacedPath( const TQString& text ); 00161 00166 static TQString replacedPath( const TQString& text, 00167 bool replaceHome, bool replaceEnv = true ); 00168 00169 class MyURL; 00170 protected: 00171 // Called by KCompletion, adds '/' to directories 00172 void postProcessMatch( TQString *match ) const; 00173 void postProcessMatches( TQStringList *matches ) const; 00174 void postProcessMatches( KCompletionMatches* matches ) const; 00175 00176 virtual void customEvent( TQCustomEvent *e ); 00177 00178 protected slots: 00179 void slotEntries( KIO::Job *, const KIO::UDSEntryList& ); 00180 void slotIOFinished( KIO::Job * ); 00181 00182 private: 00183 00184 bool isAutoCompletion(); 00185 00186 bool userCompletion(const MyURL &url, TQString *match); 00187 bool envCompletion(const MyURL &url, TQString *match); 00188 bool exeCompletion(const MyURL &url, TQString *match); 00189 bool systemexeCompletion(const MyURL &url, TQString *match); 00190 bool fileCompletion(const MyURL &url, TQString *match); 00191 bool urlCompletion(const MyURL &url, TQString *match); 00192 00193 // List a directory using readdir() 00194 void listDir( const TQString& dir, 00195 TQStringList *matches, 00196 const TQString& filter, 00197 bool only_exe, 00198 bool no_hidden ); 00199 00200 // List the next dir in m_dirs 00201 TQString listDirectories(const TQStringList &, 00202 const TQString &, 00203 bool only_exe = false, 00204 bool only_dir = false, 00205 bool no_hidden = false, 00206 bool stat_files = true); 00207 00208 void listURLs( const TQValueList<KURL *> &urls, 00209 const TQString &filter = TQString::null, 00210 bool only_exe = false, 00211 bool no_hidden = false ); 00212 00213 void addMatches( const TQStringList & ); 00214 TQString finished(); 00215 00216 void init(); 00217 00218 void setListedURL(int compl_type /* enum ComplType */, 00219 const TQString& dir = TQString::null, 00220 const TQString& filter = TQString::null, 00221 bool no_hidden = false ); 00222 00223 bool isListedURL( int compl_type /* enum ComplType */, 00224 const TQString& dir = TQString::null, 00225 const TQString& filter = TQString::null, 00226 bool no_hidden = false ); 00227 00228 void adjustMatch( TQString& match ) const; 00229 00230 protected: 00231 virtual void virtual_hook( int id, void* data ); 00232 private: 00233 KURLCompletionPrivate *d; 00234 }; 00235 00236 #endif // KURLCOMPLETION_H