KRunner::QueryMatch Class
class KRunner::QueryMatchA match returned by an AbstractRunner in response to a given RunnerContext. More...
Header: | #include <KRunner/QueryMatch> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Runner) target_link_libraries(mytarget PRIVATE KF6::Runner) |
Public Types
enum class | CategoryRelevance { Lowest, Low, Moderate, High, Highest } |
Public Functions
QueryMatch(KRunner::AbstractRunner *runner = nullptr) | |
(since 5.75) QList<KRunner::Action> | actions() const |
(since 5.75) void | addAction(const KRunner::Action &action) |
(since 6.0) qreal | categoryRelevance() const |
QVariant | data() const |
QIcon | icon() const |
(since 5.24) QString | iconName() const |
QString | id() const |
bool | isEnabled() const |
(since 5.82) bool | isMultiLine() const |
bool | isValid() const |
QString | matchCategory() const |
qreal | relevance() const |
KRunner::AbstractRunner * | runner() const |
KRunner::Action | selectedAction() const |
(since 5.75) void | setActions(const QList<KRunner::Action> &actions) |
(since 6.0) void | setCategoryRelevance(KRunner::QueryMatch::CategoryRelevance relevance) |
void | setData(const QVariant &data) |
void | setEnabled(bool enable) |
void | setIcon(const QIcon &icon) |
(since 5.24) void | setIconName(const QString &iconName) |
void | setId(const QString &id) |
void | setMatchCategory(const QString &category) |
(since 5.82) void | setMultiLine(bool multiLine) |
void | setRelevance(qreal relevance) |
void | setSubtext(const QString &text) |
void | setText(const QString &text) |
void | setUrls(const QList<QUrl> &urls) |
QString | subtext() const |
QString | text() const |
QList<QUrl> | urls() const |
Detailed Description
Member Type Documentation
enum class QueryMatch::CategoryRelevance
Helper for reading standardized category relevance values
Constant | Value |
---|---|
KRunner::QueryMatch::CategoryRelevance::Lowest | 0 |
KRunner::QueryMatch::CategoryRelevance::Low | 30 |
KRunner::QueryMatch::CategoryRelevance::Moderate | 50 |
KRunner::QueryMatch::CategoryRelevance::High | 70 |
KRunner::QueryMatch::CategoryRelevance::Highest | 100 |
Member Function Documentation
[explicit]
QueryMatch::QueryMatch(KRunner::AbstractRunner *runner = nullptr)
Constructs a PossibleMatch associated with a given RunnerContext and runner.
runner the runner this match belongs to
[since 5.75]
QList<KRunner::Action> QueryMatch::actions() const
List of actions set for this match Returns actions
This function was introduced in 5.75.
See also setActions().
[since 5.75]
void QueryMatch::addAction(const KRunner::Action &action)
Adds an action to this match
This function was introduced in 5.75.
See also setActions.
[since 6.0]
qreal QueryMatch::categoryRelevance() const
Category relevance for this match
This function was introduced in 6.0.
See also setCategoryRelevance().
QVariant QueryMatch::data() const
Returns the data associated with this match; usually runner-specific
See also setData().
QIcon QueryMatch::icon() const
Returns the icon for this match
See also setIcon().
[since 5.24]
QString QueryMatch::iconName() const
Returns the name of the icon for this match
This function was introduced in 5.24.
See also setIconName().
QString QueryMatch::id() const
Returns 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.
See also setId().
bool QueryMatch::isEnabled() const
Returns true if the match is enabled and therefore runnable, otherwise false
[since 5.82]
bool 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 Returns bool
This function was introduced in 5.82.
bool QueryMatch::isValid() const
Returns true if the match is valid and can therefore be run, an invalid match does not have an associated AbstractRunner
QString QueryMatch::matchCategory() const
Extra information about the match which can be used to categorize the type.
The default is AbstractRunner::name
See also setMatchCategory().
qreal QueryMatch::relevance() const
The relevance of this action to the search. By default, the relevance is 1.
Returns a number between 0 and 1
See also setRelevance().
KRunner::AbstractRunner *QueryMatch::runner() const
Returns the runner associated with this action
KRunner::Action QueryMatch::selectedAction() const
The action that the user has selected when running the match. This returns a nullptr if no action was selected.
[since 5.75]
void QueryMatch::setActions(const QList<KRunner::Action> &actions)
Set the actions for this match. This method allows you to set the actions inside of the AbstractRunner::match method
This function was introduced in 5.75.
See also RunnerManager::actionsForMatch.
[since 6.0]
void QueryMatch::setCategoryRelevance(KRunner::QueryMatch::CategoryRelevance relevance)
Relevance for matches in the category. The match with the highest relevance is respected for the entire category. This value only affects the sorting of categories and not the sorting within the category. Use setRelevance for this. The value should be from 0 to 100.
This function was introduced in 6.0.
See also categoryRelevance().
void QueryMatch::setData(const QVariant &data)
Sets data to be used internally by the runner's AbstractRunner::run implementation.
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
See also data().
void QueryMatch::setEnabled(bool enable)
Sets whether or not this match can be activited
enable true if the match is enabled and therefore runnable
See also isEnabled().
void QueryMatch::setIcon(const QIcon &icon)
Sets the icon associated with this match
Prefer using setIconName.
icon the icon to show along with the match
See also icon().
[since 5.24]
void QueryMatch::setIconName(const QString &iconName)
Sets the icon name associated with this match
icon the name of the icon to show along with the match
This function was introduced in 5.24.
See also iconName().
void 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.
If the "X-Plasma-Runner-Unique-Results" property from the metadata is set to true, the runnerId will not be prepended to the ID. This allows KRunner to de-duplicate results from different runners. In case the runner's matches are less specific than ones from other runners, the "X-Plasma-Runner-Weak-Results" property can be set so that duplicates from this runner are removed.
id the new identifying string to use to refer to this entry
See also id().
void QueryMatch::setMatchCategory(const QString &category)
Sets information about the type of the match which is used to group the matches.
This string should be translated as it is displayed in an UI. The default is AbstractRunner::name
See also matchCategory().
[since 5.82]
void QueryMatch::setMultiLine(bool multiLine)
Set if the text should be displayed as a multiLine string
multiLine
This function was introduced in 5.82.
See also isMultiLine().
void QueryMatch::setRelevance(qreal relevance)
Sets the relevance of this action for the search it was created for.
relevance a number between 0 and 1.
See also relevance().
void QueryMatch::setSubtext(const QString &text)
Sets the descriptive text for this match; can be longer than the main title text
text the text to use as the description
See also subtext().
void 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 For styled and multiline text, setMultiLine should be set to true
text the text to use as the title
See also text().
void QueryMatch::setUrls(const QList<QUrl> &urls)
Sets the urls, if any, associated with this match
See also urls().
QString QueryMatch::subtext() const
Returns the descriptive text for this match
See also setSubtext().
QString QueryMatch::text() const
Returns the title text for this match
See also setText().
QList<QUrl> QueryMatch::urls() const
Returns the urls for this match, empty list if none These will be used in the default implementation of AbstractRunner::mimeDataForMatch
See also setUrls().