Plasma::RunnerContext
#include <KRunner/RunnerContext>

Public Types | |
enum | Type { None = 0, UnknownType = 1, Directory = 2, File = 4, NetworkLocation = 8, Executable = 16, ShellCommand = 32, Help = 64, FileSystem = Directory | File | Executable | ShellCommand } |
typedef QFlags< Type > | Types |
Signals | |
void | matchesChanged () |
Public Member Functions | |
RunnerContext (QObject *parent=nullptr) | |
RunnerContext (RunnerContext &other, QObject *parent=nullptr) | |
bool | addMatch (const QueryMatch &match) |
bool | addMatches (const QList< QueryMatch > &matches) |
QStringList | enabledCategories () const |
void | ignoreCurrentMatchForHistory () const |
bool | isValid () const |
QueryMatch | match (const QString &id) const |
QList< QueryMatch > | matches () const |
QString | mimeType () const |
RunnerContext & | operator= (const RunnerContext &other) |
QString | query () const |
bool | removeMatch (const QString matchId) |
bool | removeMatches (AbstractRunner *runner) |
bool | removeMatches (const QStringList matchIdList) |
void | requestQueryStringUpdate (const QString &text, int cursorPosition) const |
void | reset () |
void | restore (const KConfigGroup &config) |
void | run (const QueryMatch &match) |
void | save (KConfigGroup &config) |
void | setEnabledCategories (const QStringList &categories) |
void | setQuery (const QString &term) |
void | setSingleRunnerQueryMode (bool enabled) |
bool | singleRunnerQueryMode () const |
Type | type () const |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () |
void | dumpObjectInfo () const const |
void | dumpObjectTree () |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
QThread * | thread () const const |
Additional Inherited Members | |
![]() | |
objectName | |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
typedef | QObjectList |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Detailed Description
The RunnerContext class provides information related to a search, including the search term, metadata on the search term and collected matches.
Definition at line 31 of file runnercontext.h.
Constructor & Destructor Documentation
◆ RunnerContext()
Plasma::RunnerContext::RunnerContext | ( | RunnerContext & | other, |
QObject * | parent = nullptr |
||
) |
Copy constructor.
Definition at line 192 of file runnercontext.cpp.
Member Function Documentation
◆ addMatch()
bool Plasma::RunnerContext::addMatch | ( | const QueryMatch & | match | ) |
Appends a match to the existing list of matches.
If you are going to be adding multiple matches, use
- See also
- addMatches instead.
- Parameters
-
match the match to add
- Returns
- true if the match was added, false otherwise.
Definition at line 338 of file runnercontext.cpp.
◆ addMatches()
bool Plasma::RunnerContext::addMatches | ( | const QList< QueryMatch > & | matches | ) |
Appends lists of matches to the list of matches.
- Parameters
-
matches the matches to add
- Returns
- true if matches were added, false if matches were e.g. outdated
Definition at line 313 of file runnercontext.cpp.
◆ enabledCategories()
QStringList Plasma::RunnerContext::enabledCategories | ( | ) | const |
A list of categories of which results should be returned.
This list is typically populated from the AbstractRunner::categories function.
- Deprecated:
- Since 5.76, feature is unused and not supported by most runners
Definition at line 284 of file runnercontext.cpp.
◆ ignoreCurrentMatchForHistory()
void Plasma::RunnerContext::ignoreCurrentMatchForHistory | ( | ) | const |
Set this to true in the AbstractRunner::run method to prevent the entry from being saved to the history.
- Since
- 5.90
Definition at line 444 of file runnercontext.cpp.
◆ isValid()
bool Plasma::RunnerContext::isValid | ( | ) | const |
- 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 provides a nice way to avoid unnecessary 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
Definition at line 304 of file runnercontext.cpp.
◆ match()
QueryMatch Plasma::RunnerContext::match | ( | const QString & | id | ) | const |
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 exist
- Deprecated:
- Since 5.79, deprecated due to lack of usage. Instead filter the matches manually based on the id
Definition at line 419 of file runnercontext.cpp.
◆ matches()
QList< QueryMatch > Plasma::RunnerContext::matches | ( | ) | const |
Retrieves all available matches for the current search term.
- Returns
- a list of matches
Definition at line 410 of file runnercontext.cpp.
◆ mimeType()
QString Plasma::RunnerContext::mimeType | ( | ) | const |
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.
- Deprecated:
- feature is unused, determine the mime type manually if needed
Definition at line 298 of file runnercontext.cpp.
◆ operator=()
RunnerContext & Plasma::RunnerContext::operator= | ( | const RunnerContext & | other | ) |
◆ query()
QString Plasma::RunnerContext::query | ( | ) | const |
- Returns
- the current search query term.
Definition at line 268 of file runnercontext.cpp.
◆ removeMatch()
bool Plasma::RunnerContext::removeMatch | ( | const QString | matchId | ) |
Removes a match from the existing list of matches.
If you are going to be removing multiple matches, use removeMatches instead.
- Parameters
-
matchId the id of match to remove
- Returns
- true if the match was removed, false otherwise.
- Since
- 4.4
- Deprecated:
- Since 5.81, feature is unused, aggregate and filter the matches before adding them to the runnercontext instead
Definition at line 358 of file runnercontext.cpp.
◆ removeMatches() [1/2]
bool Plasma::RunnerContext::removeMatches | ( | Plasma::AbstractRunner * | runner | ) |
Removes lists of matches from a given AbstractRunner.
This method is thread safe and causes the matchesChanged() signal to be emitted.
- Parameters
-
runner the AbstractRunner from which to remove matches
- Returns
- true if at least one match was removed, false otherwise.
- Since
- 4.10
- Deprecated:
- Since 5.81, feature is unused, aggregate and filter the matches before adding them to the runnercontext instead
Definition at line 379 of file runnercontext.cpp.
◆ removeMatches() [2/2]
bool Plasma::RunnerContext::removeMatches | ( | const QStringList | matchIdList | ) |
Removes lists of matches from the existing list of matches.
This method is thread safe and causes the matchesChanged() signal to be emitted.
- Parameters
-
matchIdList the list of matches id to remove
- Returns
- true if at least one match was removed, false otherwise.
- Since
- 4.4
- Deprecated:
- Since 5.81, feature is unused, aggregate and filter the matches before adding them to the runnercontext instead
Definition at line 344 of file runnercontext.cpp.
◆ requestQueryStringUpdate()
void Plasma::RunnerContext::requestQueryStringUpdate | ( | const QString & | text, |
int | cursorPosition | ||
) | const |
Request that KRunner updates the query string and stasy open, even after running a match.
This method is const so it can be called in a const context.
- Parameters
-
text Text that will be displayed in the search field cursorPosition Position of the cursor, if this is different than the length of the text, the characters between the position and text will be selected
- Since
- 5.90
Definition at line 428 of file runnercontext.cpp.
◆ reset()
void Plasma::RunnerContext::reset | ( | ) |
Resets the search term for this object.
This removes all current matches in the process and turns off single runner query mode.
Definition at line 219 of file runnercontext.cpp.
◆ restore()
void Plasma::RunnerContext::restore | ( | const 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
Definition at line 454 of file runnercontext.cpp.
◆ run()
void Plasma::RunnerContext::run | ( | const 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
Definition at line 484 of file runnercontext.cpp.
◆ save()
void Plasma::RunnerContext::save | ( | KConfigGroup & | config | ) |
- Parameters
-
config the config group where launch data should be stored
Definition at line 470 of file runnercontext.cpp.
◆ setEnabledCategories()
void Plasma::RunnerContext::setEnabledCategories | ( | const QStringList & | categories | ) |
Sets the list of enabled categories.
Runners can use this list to optimize themselves by only returning results from the enabled categories
- Deprecated:
- Since 5.76, feature is unused and not supported by most runners
Definition at line 277 of file runnercontext.cpp.
◆ setQuery()
void Plasma::RunnerContext::setQuery | ( | const QString & | term | ) |
Sets the query term for this object and attempts to determine the type of the search.
Definition at line 251 of file runnercontext.cpp.
◆ setSingleRunnerQueryMode()
void Plasma::RunnerContext::setSingleRunnerQueryMode | ( | bool | enabled | ) |
Sets single runner query mode.
Note that a call to reset() will turn off single runner query mode.
- Note
- This method is considered internal. To set the single runner mode you should pass in a runnerId to RunnerManager::launchQuery
- See also
- reset()
- Since
- 4.4
Definition at line 434 of file runnercontext.cpp.
◆ singleRunnerQueryMode()
bool Plasma::RunnerContext::singleRunnerQueryMode | ( | ) | const |
- Returns
- true if the current query is a single runner query
- Since
- 4.4
Definition at line 439 of file runnercontext.cpp.
◆ type()
RunnerContext::Type Plasma::RunnerContext::type | ( | ) | const |
The type of item the search term might refer to.
- See also
- Type
- Deprecated:
- feature is deprecated. Do the checks manually inside of the match logic
Definition at line 291 of file runnercontext.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 04:09:29 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.