RunnerContext Class Reference
from PyKDE4.plasma import *
Inherits: QObject
Namespace: Plasma
Detailed Description
RunnerContext plasma/runnercontext.h <Plasma/RunnerContext>
The RunnerContext class provides information related to a search, including the search term, metadata on the search term and collected matches.
Enumerations | |
Type | { None, UnknownType, Directory, File, NetworkLocation, Executable, ShellCommand, Help, FileSystem } |
Signals | |
matchesChanged () | |
Methods | |
__init__ (self, QObject parent=0) | |
__init__ (self, Plasma.RunnerContext other, QObject parent=0) | |
bool | addMatch (self, QString term, Plasma.QueryMatch match) |
bool | addMatches (self, QString term, [Plasma.QueryMatch] matches) |
bool | isValid (self) |
Plasma.QueryMatch | match (self, QString id) |
[Plasma.QueryMatch] | matches (self) |
matchesChanged (self) | |
QString | mimeType (self) |
QString | query (self) |
reset (self) | |
restore (self, KConfigGroup config) | |
run (self, Plasma.QueryMatch match) | |
save (self, KConfigGroup config) | |
setQuery (self, QString term) | |
Plasma.RunnerContext.Type | type (self) |
Method Documentation
__init__ | ( | self, | ||
QObject | parent=0 | |||
) |
__init__ | ( | self, | ||
Plasma.RunnerContext | other, | |||
QObject | parent=0 | |||
) |
Copy constructor
bool addMatch | ( | self, | ||
QString | term, | |||
Plasma.QueryMatch | match | |||
) |
Appends a match to the existing list of matches.
If you are going to be adding multiple matches, use addMatches instead.
@arg term the search term that this match was generated for. @arg match the match to add
- Returns:
- true if the match was added, false otherwise.
bool addMatches | ( | self, | ||
QString | term, | |||
[Plasma.QueryMatch] | matches | |||
) |
Appends lists of matches to the list of matches.
This method is thread safe and causes the matchesChanged() signal to be emitted.
- Returns:
- true if matches were added, false if matches were e.g. outdated
bool isValid | ( | self ) |
- Returns:
- true if this context is no longer valid and therefore matching using it should abort. Most useful as an optimization technique inside of AbstractRunner subclasses in the match method, e.g.:
while (.. a possibly large iteration) { if (!context.isValid()) { return; }
... some processing ... }
While not required to be used within runners, it provies a nice way to avoid unecessary processing in runners that may run for an extended period (as measured in 10s of ms) and therefore improve the user experience.
- Since:
- 4.2.3
Plasma.QueryMatch match | ( | self, | ||
QString | id | |||
) |
Retrieves a match by id.
- Parameters:
-
id the id of the match to return
- Returns:
- the match associated with this id, or an invalid QueryMatch object if the id does not eixst
[Plasma.QueryMatch] matches | ( | self ) |
Retrieves all available matches for the current search term.
- Returns:
- a list of matches
matchesChanged | ( | self ) |
- Signal syntax:
QObject.connect(source, SIGNAL("matchesChanged()"), target_slot)
QString mimeType | ( | self ) |
The mimetype that the search term refers to, if discoverable.
- Returns:
- QString() if the mimetype can not be determined, otherwise the mimetype of the object being referred to by the search string.
QString query | ( | self ) |
- Returns:
- the current search query term.
reset | ( | self ) |
Resets the search term for this object. This removes all current matches in the process.
restore | ( | self, | ||
KConfigGroup | config | |||
) |
Sets the launch counts for the associated match ids
If a runner adds a match to this context, the context will check if the match id has been launched before and increase the matches relevance correspondingly. In this manner, any front end can implement adaptive search by sorting items according to relevance.
- Parameters:
-
config the config group where launch data was stored
run | ( | self, | ||
Plasma.QueryMatch | match | |||
) |
Run a match using the information from this context
The context will also keep track of the number of times the match was launched to sort future matches according to user habits
- Parameters:
-
match the match to run
save | ( | self, | ||
KConfigGroup | config | |||
) |
- Parameters:
-
config the config group where launch data should be stored
setQuery | ( | self, | ||
QString | term | |||
) |
Sets the query term for this object and attempts to determine the type of the search.
Plasma.RunnerContext.Type type | ( | self ) |
The type of item the search term might refer to.
- See also:
- Type
Enumeration Documentation
Type |
- Enumerator:
-
None = 0 UnknownType = 1 Directory = 2 File = 4 NetworkLocation = 8 Executable = 16 ShellCommand = 32 Help = 64 FileSystem = Directory|File|Executable|ShellCommand