/usr/include/KF5/KRunner/krunner/runnercontext.h is in libkf5runner-dev 5.44.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | /*
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_RUNNERCONTEXT_H
#define PLASMA_RUNNERCONTEXT_H
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QSharedDataPointer>
#include "krunner_export.h"
class KConfigGroup;
namespace Plasma
{
class QueryMatch;
class AbstractRunner;
class RunnerContextPrivate;
/**
* @class RunnerContext runnercontext.h <KRunner/RunnerContext>
*
* @short The RunnerContext class provides information related to a search,
* including the search term, metadata on the search term and collected
* matches.
*/
class KRUNNER_EXPORT RunnerContext : public QObject
{
Q_OBJECT
public:
enum Type {
None = 0,
UnknownType = 1,
Directory = 2,
File = 4,
NetworkLocation = 8,
Executable = 16,
ShellCommand = 32,
Help = 64,
FileSystem = Directory | File | Executable | ShellCommand
};
Q_DECLARE_FLAGS(Types, Type)
explicit RunnerContext(QObject *parent = nullptr);
/**
* Copy constructor
*/
RunnerContext(RunnerContext &other, QObject *parent = nullptr);
/**
* Assignment operator
* @since 4.4
*/
RunnerContext &operator=(const RunnerContext &other);
~RunnerContext();
/**
* Resets the search term for this object.
* This removes all current matches in the process and
* turns off single runner query mode.
*/
void reset();
/**
* Sets the query term for this object and attempts to determine
* the type of the search.
*/
void setQuery(const QString &term);
/**
* @return the current search query term.
*/
QString query() const;
/**
* The type of item the search term might refer to.
* @see Type
*/
Type type() const;
/**
* A list of categories of which results should be returned.
* This list is typically populated from the AbstractRunner::categories
* function.
*/
QStringList enabledCategories() const;
/**
* Sets the list of enabled categories. Runners can use this list
* to optimize themselves by only returning results from the enabled
* categories
*/
void setEnabledCategories(const QStringList &categories);
/**
* The mimetype that the search term refers to, if discoverable.
*
* @return QString() if the mimetype can not be determined, otherwise
* the mimetype of the object being referred to by the search
* string.
*/
QString mimeType() 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 provies 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
*/
bool isValid() const;
/**
* Appends lists of matches to the list of matches.
*
* @param matches the matches to add
* @return true if matches were added, false if matches were e.g. outdated
*/
bool addMatches(const QList<QueryMatch> &matches);
/**
* Appends a match to the existing list of matches.
*
* If you are going to be adding multiple matches, use @see addMatches instead.
*
* @param match the match to add
* @return true if the match was added, false otherwise.
*/
bool addMatch(const QueryMatch &match);
/**
* Removes a match from the existing list of matches.
*
* If you are going to be removing multiple matches, use removeMatches instead.
*
* @param matchId the id of match to remove
*
* @return true if the match was removed, false otherwise.
* @since 4.4
*/
bool removeMatch(const QString matchId);
/**
* Removes lists of matches from the existing list of matches.
*
* This method is thread safe and causes the matchesChanged() signal to be emitted.
*
* @param matchIdList the list of matches id to remove
*
* @return true if at least one match was removed, false otherwise.
* @since 4.4
*/
bool removeMatches(const QStringList matchIdList);
/**
* Removes lists of matches from a given AbstractRunner
*
* This method is thread safe and causes the matchesChanged() signal to be emitted.
*
* @param runner the AbstractRunner from which to remove matches
*
* @return true if at least one match was removed, false otherwise.
* @since 4.10
*/
bool removeMatches(AbstractRunner *runner);
/**
* Retrieves all available matches for the current search term.
*
* @return a list of matches
*/
QList<QueryMatch> matches() const;
/**
* Retrieves a match by id.
*
* @param id the id of the match to return
* @return the match associated with this id, or an invalid QueryMatch object
* if the id does not eixst
*/
QueryMatch match(const QString &id) const;
/**
* Sets single runner query mode. Note that a call to reset() will
* turn off single runner query mode.
*
* @see reset()
* @since 4.4
*/
void setSingleRunnerQueryMode(bool enabled);
/**
* @return true if the current query is a single runner query
* @since 4.4
*/
bool singleRunnerQueryMode() const;
/**
* 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.
*
* @param config the config group where launch data was stored
*/
void restore(const KConfigGroup &config);
/**
* @param config the config group where launch data should be stored
*/
void save(KConfigGroup &config);
/**
* 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
*
* @param match the match to run
*/
void run(const QueryMatch &match);
Q_SIGNALS:
void matchesChanged();
private:
QExplicitlySharedDataPointer<RunnerContextPrivate> d;
};
}
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::RunnerContext::Types)
#endif
|