kurlcompletion.h
/* This file is part of the KDE libraries
Copyright (C) 2000 David Smith <dsmith@algonet.se>
This class was inspired by a previous KURLCompletion by
Henner Zeller <zeller@think.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KURLCOMPLETION_H
#define KURLCOMPLETION_H
#include <kcompletion.h>
#include <kio/jobclasses.h>
#include <qstring.h>
#include <qstringlist.h>
class KURL;
class KURLCompletionPrivate;
class KIO_EXPORT KURLCompletion : public KCompletion
{
Q_OBJECT
public:
enum Mode { ExeCompletion=1, FileCompletion, DirCompletion };
KURLCompletion();
KURLCompletion(Mode);
virtual ~KURLCompletion();
virtual QString makeCompletion(const QString &text); // KDE4: remove return value, it's often null due to threading
virtual void setDir(const QString &dir);
virtual QString dir() const;
virtual bool isRunning() const;
virtual void stop();
virtual Mode mode() const;
virtual void setMode( Mode mode );
virtual bool replaceEnv() const;
virtual void setReplaceEnv( bool replace );
virtual bool replaceHome() const;
virtual void setReplaceHome( bool replace );
QString replacedPath( const QString& text );
static QString replacedPath( const QString& text,
bool replaceHome, bool replaceEnv = true );
class MyURL;
protected:
// Called by KCompletion, adds '/' to directories
void postProcessMatch( QString *match ) const;
void postProcessMatches( QStringList *matches ) const;
void postProcessMatches( KCompletionMatches* matches ) const;
virtual void customEvent( QCustomEvent *e );
protected slots:
void slotEntries( KIO::Job *, const KIO::UDSEntryList& );
void slotIOFinished( KIO::Job * );
private:
bool isAutoCompletion();
bool userCompletion(const MyURL &url, QString *match);
bool envCompletion(const MyURL &url, QString *match);
bool exeCompletion(const MyURL &url, QString *match);
bool fileCompletion(const MyURL &url, QString *match);
bool urlCompletion(const MyURL &url, QString *match);
// List a directory using readdir()
void listDir( const QString& dir,
QStringList *matches,
const QString& filter,
bool only_exe,
bool no_hidden );
// List the next dir in m_dirs
QString listDirectories(const QStringList &,
const QString &,
bool only_exe = false,
bool only_dir = false,
bool no_hidden = false,
bool stat_files = true);
void listURLs( const QValueList<KURL *> &urls,
const QString &filter = QString::null,
bool only_exe = false,
bool no_hidden = false );
void addMatches( const QStringList & );
QString finished();
void init();
void setListedURL(int compl_type /* enum ComplType */,
const QString& dir = QString::null,
const QString& filter = QString::null,
bool no_hidden = false );
bool isListedURL( int compl_type /* enum ComplType */,
const QString& dir = QString::null,
const QString& filter = QString::null,
bool no_hidden = false );
void adjustMatch( QString& match ) const;
protected:
virtual void virtual_hook( int id, void* data );
private:
KURLCompletionPrivate *d;
};
#endif // KURLCOMPLETION_H
KURLCompletion
This class does completion of URLs including user directories (~user) and environment variables...
Definition: kurlcompletion.h:41
KURLCompletion::Mode
Mode
Determines how completion is done.
Definition: kurlcompletion.h:53
KIO::Job
The base class for all jobs.
Definition: jobclasses.h:68

KDE Home | KDE Accessibility Home | Description of Access Keys