KRunner 5.109.0
querymatch.h
1/*
2 SPDX-FileCopyrightText: 2006-2007 Aaron Seigo <aseigo@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef PLASMA_QUERYMATCH_H
8#define PLASMA_QUERYMATCH_H
9
10#include <QList>
11#include <QSharedDataPointer>
12#include <QUrl>
13
14#include "krunner_export.h"
15
16class QAction;
17class QIcon;
18class QString;
19class QVariant;
20class QWidget;
21
22namespace Plasma
23{
24class RunnerContext;
25class AbstractRunner;
26class QueryMatchPrivate;
27
34class KRUNNER_EXPORT QueryMatch
35{
36public:
40 enum Type {
41 NoMatch = 0,
42 CompletionMatch = 10,
43 PossibleMatch = 30,
44#if KRUNNER_ENABLE_DEPRECATED_SINCE(5, 99)
50 InformationalMatch KRUNNER_ENUMERATOR_DEPRECATED_VERSION(5, 99, "Call RunnerContext::requestQueryStringUpdate in AbstractRunner::run method instead") =
51 50,
52#endif
63 HelperMatch = 70,
64 ExactMatch = 100,
65 };
66
73 explicit QueryMatch(AbstractRunner *runner = nullptr);
74
78 QueryMatch(const QueryMatch &other);
79
81 QueryMatch &operator=(const QueryMatch &other);
82 bool operator==(const QueryMatch &other) const;
83 bool operator!=(const QueryMatch &other) const;
84 bool operator<(const QueryMatch &other) const;
85
90
98 void run(const RunnerContext &context) const;
99
104 bool isValid() const;
105
109 void setType(Type type);
110
114 Type type() const;
115
123 void setMatchCategory(const QString &category);
124
132 QString matchCategory() const;
133
140 void setRelevance(qreal relevance);
141
148 qreal relevance() const;
149
159 void setData(const QVariant &data);
160
164 QVariant data() const;
165
175 void setId(const QString &id);
176
185 QString id() const;
186
193 void setText(const QString &text);
194
198 QString text() const;
199
206 void setSubtext(const QString &text);
207
211 QString subtext() const;
212
220 void setIcon(const QIcon &icon);
221
225 QIcon icon() const;
226
233 void setIconName(const QString &iconName);
234
239 QString iconName() const;
240
241#if KRUNNER_ENABLE_DEPRECATED_SINCE(5, 82)
248 KRUNNER_DEPRECATED_VERSION(5, 82, "deprecated for lack of usage")
249 void setMimeType(const QString &mimeType);
250
255 KRUNNER_DEPRECATED_VERSION(5, 82, "deprecated for lack of usage")
256 QString mimeType() const;
257#endif
258
262 void setUrls(const QList<QUrl> &urls);
263
267 QList<QUrl> urls() const;
268
274 void setEnabled(bool enable);
275
279 bool isEnabled() const;
280
287 void setActions(const QList<QAction *> &actions);
288
294 void addAction(QAction *actions);
295
301 QList<QAction *> actions() const;
302
306 QAction *selectedAction() const;
307
311 void setSelectedAction(QAction *action);
312
318 void setMultiLine(bool multiLine);
319
326 bool isMultiLine() const;
327
328#if KRUNNER_ENABLE_DEPRECATED_SINCE(5, 71)
334 KRUNNER_DEPRECATED_VERSION_BELATED(5, 71, 5, 0, "No longer use, feature removed")
335 bool hasConfigurationInterface() const;
336#endif
337
338#if KRUNNER_ENABLE_DEPRECATED_SINCE(5, 71)
348 KRUNNER_DEPRECATED_VERSION_BELATED(5, 71, 5, 0, "No longer use, feature removed")
349 void createConfigurationInterface(QWidget *parent);
350#endif
351
352private:
353 QSharedDataPointer<QueryMatchPrivate> d;
354};
355
356}
357
358#if !KRUNNER_ENABLE_DEPRECATED_SINCE(5, 91)
359namespace KRunner
360{
361using QueryMatch = Plasma::QueryMatch;
362using AbstractRunner = Plasma::AbstractRunner;
363}
364#endif
365
366#endif
An abstract base class for Plasma Runner plugins.
Definition abstractrunner.h:69
A match returned by an AbstractRunner in response to a given RunnerContext.
Definition querymatch.h:35
Type
The type of match.
Definition querymatch.h:40
QList< QUrl > urls() const
QAction * selectedAction() const
The current action.
Type type() const
The type of action this is.
QString id() const
QueryMatch(const QueryMatch &other)
Copy constructor.
QString iconName() const
void setIcon(const QIcon &icon)
Sets the icon associated with this match.
void setEnabled(bool enable)
Sets whether or not this match can be activited.
void setRelevance(qreal relevance)
Sets the relevance of this action for the search it was created for.
bool isMultiLine() const
If the text should be displayed as a multiLine string If no explicit value is set set using setMultil...
void 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 i...
QString text() const
void setMultiLine(bool multiLine)
Set if the text should be displayed as a multiLine string.
void setActions(const QList< QAction * > &actions)
Set the actions for this match.
QIcon icon() const
QList< QAction * > actions() const
List of actions set for this match.
qreal relevance() const
The relevance of this action to the search.
void addAction(QAction *actions)
Adds an action to this match.
QVariant data() const
void setUrls(const QList< QUrl > &urls)
Sets the urls, if any, associated with this match.
void setSubtext(const QString &text)
Sets the descriptive text for this match; can be longer than the main title text.
QueryMatch(AbstractRunner *runner=nullptr)
Constructs a PossibleMatch associated with a given RunnerContext and runner.
void setId(const QString &id)
Sets the id for this match; useful if the id does not match data().toString().
QString matchCategory() const
Extra information about the match which can be used to categorize the type.
void setIconName(const QString &iconName)
Sets the icon name associated with this match.
void setData(const QVariant &data)
Sets data to be used internally by the associated AbstractRunner.
void setType(Type type)
Sets the type of match this action represents.
void run(const RunnerContext &context) const
Requests this match to activae using the given context.
AbstractRunner * runner() const
void setSelectedAction(QAction *action)
Sets the selected action.
bool isEnabled() const
bool isValid() const
void setMatchCategory(const QString &category)
Sets information about the type of the match which can be used to categorize the match.
QString subtext() const
The RunnerContext class provides information related to a search, including the search term,...
Definition runnercontext.h:32