KUrlCompletion Class Reference
from PyKDE4.kio import *
Inherits: KCompletion → QObject
Subclasses: KShellCompletion
Detailed Description
This class does completion of URLs including user directories (~user) and environment variables. Remote URLs are passed to KIO.
Completion of a single URL
Enumerations | |
Mode | { ExeCompletion, FileCompletion, DirCompletion } |
Methods | |
__init__ (self) | |
__init__ (self, KUrlCompletion.Mode a0) | |
customEvent (self, QEvent e) | |
QString | dir (self) |
bool | isRunning (self) |
QString | makeCompletion (self, QString text) |
KUrlCompletion.Mode | mode (self) |
postProcessMatch (self, QString match) | |
postProcessMatches (self, QStringList matches) | |
postProcessMatches (self, KCompletionMatches matches) | |
bool | replaceEnv (self) |
bool | replaceHome (self) |
QString | replacedPath (self, QString text) |
setDir (self, QString dir) | |
setMode (self, KUrlCompletion.Mode mode) | |
setReplaceEnv (self, bool replace) | |
setReplaceHome (self, bool replace) | |
stop (self) | |
Static Methods | |
QString | replacedPath (QString text, bool replaceHome, bool replaceEnv=1) |
Method Documentation
__init__ | ( | self ) |
Constructs a KUrlCompletion object in FileCompletion mode.
__init__ | ( | self, | ||
KUrlCompletion.Mode | a0 | |||
) |
This overloaded constructor allows you to set the Mode to ExeCompletion or FileCompletion without using setMode. Default is FileCompletion.
customEvent | ( | self, | ||
QEvent | e | |||
) |
QString dir | ( | self ) |
Returns the current directory, as it was given in setDir
- Returns:
- the current directory (path or URL)
bool isRunning | ( | self ) |
Check whether asynchronous completion is in progress.
- Returns:
- true if asynchronous completion is in progress
Finds completions to the given text.
Remote URLs are listed with KIO. For performance reasons, local files are listed with KIO only if KURLCOMPLETION_LOCAL_KIO is set. The completion is done asyncronously if KIO is used.
Returns the first match for user, environment, and local dir completion and QString() for asynchronous completion (KIO or threaded).
- Parameters:
-
text the text to complete
- Returns:
- the first match, or QString() if not found
KUrlCompletion.Mode mode | ( | self ) |
Returns the completion mode: exe or file completion (default FileCompletion).
- Returns:
- the completion mode
postProcessMatch | ( | self, | ||
QString | match | |||
) |
postProcessMatches | ( | self, | ||
QStringList | matches | |||
) |
postProcessMatches | ( | self, | ||
KCompletionMatches | matches | |||
) |
bool replaceEnv | ( | self ) |
Checks whether environment variables are completed and whether they are replaced internally while finding completions. Default is enabled.
- Returns:
- true if environment vvariables will be replaced
bool replaceHome | ( | self ) |
Returns whether ~username is completed and whether ~username is replaced internally with the user's home directory while finding completions. Default is enabled.
- Returns:
- true to replace tilde with the home directory
Replaces username and/or environment variables, depending on the current settings and returns the filtered url. Only works with local files, i.e. returns back the original string for non-local urls.
- Parameters:
-
text the text to process
- Returns:
- the path or URL resulting from this operation. If you want to convert it to a KUrl, use KUrl.fromPathOrUrl.
- Internal:
- I'll let ossi add a real one to KShell :)
setDir | ( | self, | ||
QString | dir | |||
) |
Sets the current directory (used as base for completion). Default = $HOME.
- Parameters:
-
dir the current directory, either as a path or URL
setMode | ( | self, | ||
KUrlCompletion.Mode | mode | |||
) |
Changes the completion mode: exe or file completion
- Parameters:
-
mode the new completion mode
setReplaceEnv | ( | self, | ||
bool | replace | |||
) |
Enables/disables completion and replacement (internally) of environment variables in URLs. Default is enabled.
- Parameters:
-
replace true to replace environment variables
setReplaceHome | ( | self, | ||
bool | replace | |||
) |
Enables/disables completion of ~username and replacement (internally) of ~username with the user's home directory. Default is enabled.
- Parameters:
-
replace true to replace tilde with the home directory
stop | ( | self ) |
Stops asynchronous completion.
Enumeration Documentation
Mode |
Determines how completion is done.
- Enumerator:
-
ExeCompletion = 1 FileCompletion DirCompletion