Search for usage in LXR

Plasma::QueryMatch Class Reference

#include <KRunner/QueryMatch>

Public Types

enum  Type {
  NoMatch = 0, CompletionMatch = 10, PossibleMatch = 30, InformationalMatch,
  HelperMatch = 70, ExactMatch = 100

Public Member Functions

 QueryMatch (AbstractRunner *runner=nullptr)
 QueryMatch (const QueryMatch &other)
QList< QAction * > actions () const
void addAction (QAction *actions)
void createConfigurationInterface (QWidget *parent)
QVariant data () const
bool hasConfigurationInterface () const
QIcon icon () const
QString iconName () const
QString id () const
bool isEnabled () const
bool isMultiLine () const
bool isValid () const
QString matchCategory () const
QString mimeType () const
bool operator!= (const QueryMatch &other) const
bool operator< (const QueryMatch &other) const
QueryMatchoperator= (const QueryMatch &other)
bool operator== (const QueryMatch &other) const
qreal relevance () const
void run (const RunnerContext &context) const
AbstractRunnerrunner () const
QActionselectedAction () const
void setActions (const QList< QAction * > &actions)
void setData (const QVariant &data)
void setEnabled (bool enable)
void setIcon (const QIcon &icon)
void setIconName (const QString &iconName)
void setId (const QString &id)
void setMatchCategory (const QString &category)
void setMimeType (const QString &mimeType)
void setMultiLine (bool multiLine)
void setRelevance (qreal relevance)
void setSelectedAction (QAction *action)
void setSubtext (const QString &text)
void setText (const QString &text)
void setType (Type type)
void setUrls (const QList< QUrl > &urls)
QString subtext () const
QString text () const
Type type () const
QList< QUrlurls () const

Detailed Description

A match returned by an AbstractRunner in response to a given RunnerContext.

Definition at line 34 of file querymatch.h.

Member Enumeration Documentation

◆ Type

The type of match.

Value is important here as it is used for sorting


Null match.


Possible completion for the data of the query.


Something that may match the query.


A purely informational, non-runnable match, such as the answer to a question or calculation.

The data of the match will be converted to a string and set in the search field.

Since 5.99, call RunnerContext::requestQueryStringUpdate in AbstractRunner::run method instead

A match that represents an action not directly related to activating the given search term, such as a search in an external tool or a command learning trigger.

Helper matches tend to be generic to the query and should not be autoactivated just because the user hits "Enter" while typing. They must be explicitly selected to be activated, but unlike InformationalMatch cause an action to be triggered.


An exact match to the query.

Definition at line 40 of file querymatch.h.

Constructor & Destructor Documentation

◆ QueryMatch() [1/2]

Plasma::QueryMatch::QueryMatch ( AbstractRunner runner = nullptr)

Constructs a PossibleMatch associated with a given RunnerContext and runner.

runnerthe runner this match belongs to

Definition at line 81 of file querymatch.cpp.

◆ QueryMatch() [2/2]

Plasma::QueryMatch::QueryMatch ( const QueryMatch other)

Copy constructor.

Definition at line 86 of file querymatch.cpp.

Member Function Documentation

◆ actions()

QList< QAction * > Plasma::QueryMatch::actions ( ) const

List of actions set for this match.


Definition at line 360 of file querymatch.cpp.

◆ addAction()

void Plasma::QueryMatch::addAction ( QAction actions)

Adds an action to this match.

See also

Definition at line 354 of file querymatch.cpp.

◆ createConfigurationInterface()

void Plasma::QueryMatch::createConfigurationInterface ( QWidget parent)

If hasConfigurationInterface() returns true, this method may be called to get a widget displaying the options the user can interact with to modify the behaviour of what happens when the match is run.

widgetthe parent of the options widgets.
Since 5.0, this feature has been defunct

Definition at line 342 of file querymatch.cpp.

◆ data()

QVariant Plasma::QueryMatch::data ( ) const
the data associated with this match; usually runner-specific

Definition at line 201 of file querymatch.cpp.

◆ hasConfigurationInterface()

bool Plasma::QueryMatch::hasConfigurationInterface ( ) const
true if this match can be configured before being run
Since 5.0, this feature has been defunct

Definition at line 335 of file querymatch.cpp.

◆ icon()

QIcon Plasma::QueryMatch::icon ( ) const
the icon for this match

Definition at line 219 of file querymatch.cpp.

◆ iconName()

QString Plasma::QueryMatch::iconName ( ) const
the name of the icon for this match

Definition at line 225 of file querymatch.cpp.

◆ id()

QString Plasma::QueryMatch::id ( ) const
a string that can be used as an ID for this match, even between different queries. It is based in part on the source of the match (the AbstractRunner) and distinguishing information provided by the runner, ensuring global uniqueness as well as consistency between query matches.

Definition at line 100 of file querymatch.cpp.

◆ isEnabled()

bool Plasma::QueryMatch::isEnabled ( ) const
true if the match is enabled and therefore runnable, otherwise false

Definition at line 262 of file querymatch.cpp.

◆ isMultiLine()

bool Plasma::QueryMatch::isMultiLine ( ) const

If the text should be displayed as a multiLine string If no explicit value is set set using setMultiline it will default to false.


Definition at line 303 of file querymatch.cpp.

◆ isValid()

bool Plasma::QueryMatch::isValid ( ) const
true if the match is valid and can therefore be run, an invalid match does not have an associated AbstractRunner

Definition at line 95 of file querymatch.cpp.

◆ matchCategory()

QString Plasma::QueryMatch::matchCategory ( ) const

Extra information about the match which can be used to categorize the type.

By default this returns the internal name of the runner which returned this result

Definition at line 124 of file querymatch.cpp.

◆ mimeType()

QString Plasma::QueryMatch::mimeType ( ) const
the mimtype for this match, or QString() is none
Since 5.82, deprecated for lack of usage

Definition at line 238 of file querymatch.cpp.

◆ relevance()

qreal Plasma::QueryMatch::relevance ( ) const

The relevance of this action to the search.

By default, the relevance is 1.

a number between 0 and 1

Definition at line 137 of file querymatch.cpp.

◆ run()

void Plasma::QueryMatch::run ( const RunnerContext context) const

Requests this match to activae using the given context.

contextthe context to use in conjunction with this run
See also

Definition at line 327 of file querymatch.cpp.

◆ runner()

AbstractRunner * Plasma::QueryMatch::runner ( ) const
the runner associated with this action

Definition at line 142 of file querymatch.cpp.

◆ selectedAction()

QAction * Plasma::QueryMatch::selectedAction ( ) const

The current action.

Definition at line 267 of file querymatch.cpp.

◆ setActions()

void Plasma::QueryMatch::setActions ( const QList< QAction * > &  actions)

Set the actions for this match.

This method allows you to set the actions inside of the AbstractRunner::match() method and the default implementation of AbstractRunner::actionsForMatch() will return these.


Definition at line 348 of file querymatch.cpp.

◆ setData()

void Plasma::QueryMatch::setData ( const QVariant data)

Sets data to be used internally by the associated AbstractRunner.

When set, it is also used to form part of the id() for this match. If that is inappropriate as an id, the runner may generate its own id and set that with setId(const QString&) directly after calling setData

Definition at line 159 of file querymatch.cpp.

◆ setEnabled()

void Plasma::QueryMatch::setEnabled ( bool  enable)

Sets whether or not this match can be activited.

enabletrue if the match is enabled and therefore runnable

Definition at line 257 of file querymatch.cpp.

◆ setIcon()

void Plasma::QueryMatch::setIcon ( const QIcon icon)

Sets the icon associated with this match.

Prefer using setIconName.

iconthe icon to show along with the match

Definition at line 189 of file querymatch.cpp.

◆ setIconName()

void Plasma::QueryMatch::setIconName ( const QString iconName)

Sets the icon name associated with this match.

iconthe name of the icon to show along with the match

Definition at line 195 of file querymatch.cpp.

◆ setId()

void Plasma::QueryMatch::setId ( const QString id)

Sets the id for this match; useful if the id does not match data().toString().

The id must be unique to all matches from this runner, and should remain constant for the same query for best results.

idthe new identifying string to use to refer to this entry

Definition at line 173 of file querymatch.cpp.

◆ setMatchCategory()

void Plasma::QueryMatch::setMatchCategory ( const QString category)

Sets information about the type of the match which can be used to categorize the match.

This string should be translated as it can be displayed in an UI

Definition at line 119 of file querymatch.cpp.

◆ setMimeType()

void Plasma::QueryMatch::setMimeType ( const QString mimeType)

Sets the MimeType, if any, associated with this match.

This overrides the MimeType provided by QueryContext, and should only be set when it is different from the QueryContext MimeType

Since 5.82, deprecated for lack of usage

Definition at line 232 of file querymatch.cpp.

◆ setMultiLine()

void Plasma::QueryMatch::setMultiLine ( bool  multiLine)

Set if the text should be displayed as a multiLine string.


Definition at line 298 of file querymatch.cpp.

◆ setRelevance()

void Plasma::QueryMatch::setRelevance ( qreal  relevance)

Sets the relevance of this action for the search it was created for.

relevancea number between 0 and 1.

Definition at line 132 of file querymatch.cpp.

◆ setSelectedAction()

void Plasma::QueryMatch::setSelectedAction ( QAction action)

Sets the selected action.

Definition at line 272 of file querymatch.cpp.

◆ setSubtext()

void Plasma::QueryMatch::setSubtext ( const QString text)

Sets the descriptive text for this match; can be longer than the main title text.

textthe text to use as the description

Definition at line 153 of file querymatch.cpp.

◆ setText()

void Plasma::QueryMatch::setText ( const QString text)

Sets the main title text for this match; should be short enough to fit nicely on one line in a user interface.

textthe text to use as the title

Definition at line 147 of file querymatch.cpp.

◆ setType()

void Plasma::QueryMatch::setType ( Type  type)

Sets the type of match this action represents.

Definition at line 109 of file querymatch.cpp.

◆ setUrls()

void Plasma::QueryMatch::setUrls ( const QList< QUrl > &  urls)

Sets the urls, if any, associated with this match.

Definition at line 245 of file querymatch.cpp.

◆ subtext()

QString Plasma::QueryMatch::subtext ( ) const
the descriptive text for this match

Definition at line 213 of file querymatch.cpp.

◆ text()

QString Plasma::QueryMatch::text ( ) const
the title text for this match

Definition at line 207 of file querymatch.cpp.

◆ type()

QueryMatch::Type Plasma::QueryMatch::type ( ) const

The type of action this is.

Defaults to PossibleMatch.

Definition at line 114 of file querymatch.cpp.

◆ urls()

QList< QUrl > Plasma::QueryMatch::urls ( ) const
the mimtype for this match, or QString() is none

Definition at line 251 of file querymatch.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 6 2023 04:18:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.