time to introduce the ability for runners to decide if they care to that they should return early

svn path=/trunk/KDE/kdelibs/; revision=934729
This commit is contained in:
Aaron J. Seigo 2009-03-03 17:27:28 +00:00
parent 89e8786c5d
commit 546895b775
2 changed files with 25 additions and 0 deletions

View File

@ -299,6 +299,12 @@ QString RunnerContext::mimeType() const
return d->mimeType;
}
bool RunnerContext::isValid()
{
// if our qptr is null, we aren't useful anymore
return d->q;
}
bool RunnerContext::addMatches(const QString &term, const QList<QueryMatch> &matches)
{
Q_UNUSED(term)

View File

@ -102,6 +102,25 @@ class PLASMA_EXPORT RunnerContext : public QObject
*/
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 unecessary processing in runners that may run for an extended
* period (as measured in 10s of ms) and therefore improve the user experience.
*/
bool isValid();
/**
* Appends lists of matches to the list of matches.
*