24#include <QReadWriteLock>
28#include <QWeakPointer>
40 QueryMatchPrivate(AbstractRunner *r)
42 lock(new QReadWriteLock(QReadWriteLock::Recursive)),
44 type(QueryMatch::ExactMatch),
52 QueryMatchPrivate(
const QueryMatchPrivate &other)
54 lock(new QReadWriteLock(QReadWriteLock::Recursive))
56 QReadLocker lock(other.lock);
57 runner = other.runner;
59 relevance = other.relevance;
60 selAction = other.selAction;
61 enabled = other.enabled;
62 idSetByData = other.idSetByData;
65 subtext = other.subtext;
76 QWeakPointer<AbstractRunner> runner;
90 : d(new QueryMatchPrivate(runner))
100QueryMatch::~QueryMatch()
104bool QueryMatch::isValid()
const
106 return d->runner != 0;
109QString QueryMatch::id()
const
111 if (d->id.isEmpty() && d->runner) {
112 return d->runner.data()->id();
118void QueryMatch::setType(
Type type)
128void QueryMatch::setRelevance(qreal relevance)
130 d->relevance = qMax(qreal(0.0),
relevance);
133qreal QueryMatch::relevance()
const
140 return d->runner.data();
143void QueryMatch::setText(
const QString &text)
145 QWriteLocker locker(d->lock);
149void QueryMatch::setSubtext(
const QString &subtext)
151 QWriteLocker locker(d->lock);
155void QueryMatch::setData(
const QVariant & data)
157 QWriteLocker locker(d->lock);
160 if (d->id.isEmpty() || d->idSetByData) {
161 const QString
id =
data.toString();
164 d->idSetByData =
true;
169void QueryMatch::setId(
const QString &
id)
171 QWriteLocker locker(d->lock);
173 d->id = d->runner.data()->id();
177 d->id.append(
'_').append(
id);
180 d->idSetByData =
false;
183void QueryMatch::setIcon(
const QIcon &icon)
185 QWriteLocker locker(d->lock);
189QVariant QueryMatch::data()
const
191 QReadLocker locker(d->lock);
195QString QueryMatch::text()
const
197 QReadLocker locker(d->lock);
201QString QueryMatch::subtext()
const
203 QReadLocker locker(d->lock);
207QIcon QueryMatch::icon()
const
209 QReadLocker locker(d->lock);
213void QueryMatch::setEnabled(
bool enabled)
215 d->enabled = enabled;
218bool QueryMatch::isEnabled()
const
220 return d->enabled && d->runner;
223QAction* QueryMatch::selectedAction()
const
228void QueryMatch::setSelectedAction(QAction *action)
230 d->selAction = action;
235 if (d->type == other.d->type) {
240 if (d->relevance != other.d->relevance) {
241 return d->relevance < other.d->relevance;
244 QReadLocker locker(d->lock);
245 QReadLocker otherLocker(other.d->lock);
248 return d->text > other.d->text;
251 return d->type < other.d->type;
265 return (d == other.d);
270 return (d != other.d);
277 d->runner.data()->run(context, *
this);
281bool QueryMatch::hasConfigurationInterface()
const
283 return d->runner && d->runner.data()->hasRunOptions();
286void QueryMatch::createConfigurationInterface(
QWidget *parent)
289 d->runner.data()->createRunOptions(parent);
An abstract base class for Plasma Runner plugins.
A match returned by an AbstractRunner in response to a given RunnerContext.
bool hasConfigurationInterface() const
qreal relevance() const
The relevance of this action to the search.
Type type() const
The type of action this is.
void setId(const QString &id)
Sets the id for this match; useful if the id does not match data().toString().
The RunnerContext class provides information related to a search, including the search term,...
Namespace for everything in libplasma.