plasma: rework runners classes to not pass around the context

unused in most cases, shared data and dangerous to pass around

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-18 05:15:02 +03:00
parent 2f485d5376
commit a871678ec4
8 changed files with 6 additions and 52 deletions

View file

@ -204,9 +204,8 @@ void AbstractRunner::setIgnoredTypes(RunnerContext::Types types)
d->blackListed = types; d->blackListed = types;
} }
void AbstractRunner::run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action) void AbstractRunner::run(const Plasma::QueryMatch &action)
{ {
Q_UNUSED(search)
Q_UNUSED(action) Q_UNUSED(action)
} }

View file

@ -139,14 +139,11 @@ class PLASMA_EXPORT AbstractRunner : public QObject
void performMatch(Plasma::RunnerContext &context); void performMatch(Plasma::RunnerContext &context);
/** /**
* Called whenever an exact or possible match associated with this * Called whenever a match associated with this runner is triggered.
* runner is triggered.
* *
* @param context The context in which the match is triggered, i.e. for which
* the match was created.
* @param match The actual match to run/execute. * @param match The actual match to run/execute.
*/ */
virtual void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match); virtual void run(const Plasma::QueryMatch &match);
/** /**
* The nominal speed of the runner. * The nominal speed of the runner.

View file

@ -238,11 +238,11 @@ bool QueryMatch::operator!=(const QueryMatch &other) const
return (d != other.d); return (d != other.d);
} }
void QueryMatch::run(const RunnerContext &context) const void QueryMatch::run() const
{ {
//kDebug() << "we run the term" << context->query() << "whose type is" << context->mimetype(); //kDebug() << "we run the term" << context->query() << "whose type is" << context->mimetype();
if (d->runner) { if (d->runner) {
d->runner.data()->run(context, *this); d->runner.data()->run(*this);
} }
} }

View file

@ -93,11 +93,9 @@ class PLASMA_EXPORT QueryMatch
/** /**
* Requests this match to activae using the given context * Requests this match to activae using the given context
* *
* @param context the context to use in conjunction with this run
*
* @sa AbstractRunner::run * @sa AbstractRunner::run
*/ */
void run(const RunnerContext &context) const; void run() const;
/** /**
* Sets data to be used internally by the associated * Sets data to be used internally by the associated

View file

@ -498,11 +498,6 @@ QueryMatch RunnerContext::match(const QString &id) const
return QueryMatch(nullptr); return QueryMatch(nullptr);
} }
void RunnerContext::run(const QueryMatch &match)
{
match.run(*this);
}
} // Plasma namespace } // Plasma namespace
#include "moc_runnercontext.cpp" #include "moc_runnercontext.cpp"

View file

@ -193,16 +193,6 @@ public:
*/ */
QueryMatch match(const QString &id) const; QueryMatch match(const QString &id) const;
/**
* 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: Q_SIGNALS:
void matchesChanged(); void matchesChanged();

View file

@ -275,19 +275,6 @@ QList<QueryMatch> RunnerManager::matches() const
return d->context.matches(); return d->context.matches();
} }
void RunnerManager::run(const QString &id)
{
run(d->context.match(id));
}
void RunnerManager::run(const QueryMatch &match)
{
if (!match.isEnabled()) {
return;
}
d->context.run(match);
}
QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match) QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
{ {
AbstractRunner *runner = match.runner(); AbstractRunner *runner = match.runner();

View file

@ -84,18 +84,6 @@ class PLASMA_EXPORT RunnerManager : public QObject
*/ */
QList<QueryMatch> matches() const; QList<QueryMatch> matches() const;
/**
* Runs a given match
* @param match the match to be executed
*/
void run(const QueryMatch &match);
/**
* Runs a given match
* @param id the id of the match to run
*/
void run(const QString &id);
/** /**
* Retrieves the list of actions, if any, for a match * Retrieves the list of actions, if any, for a match
*/ */