SearchContext -> RunnerContext

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=803041
This commit is contained in:
Aaron J. Seigo 2008-05-01 18:40:10 +00:00
parent bbddbccd1b
commit f55bbb73f9
13 changed files with 87 additions and 87 deletions

View File

@ -41,9 +41,9 @@ set(plasma_LIB_SRCS
packages.cpp
plasma.cpp
plasma_export.h
runnercontext.cpp
runnermanager.cpp
searchmatch.cpp
searchcontext.cpp
shadowitem.cpp
svg.cpp
panelsvg.cpp
@ -114,9 +114,9 @@ set(plasma_LIB_INCLUDES
dialog.h
plasma.h
plasma_export.h
runnercontext.h
runnermanager.h
searchmatch.h
searchcontext.h
shadowitem_p.h
svg.h
panelsvg.h
@ -172,7 +172,7 @@ install(FILES
includes/DataContainer
includes/DataEngine
includes/DataEngineManager
includes/SearchContext
includes/RunnerContext
includes/SearchMatch
includes/Svg
includes/PanelSvg

View File

@ -33,7 +33,7 @@
#include "scripting/runnerscript.h"
#include "searchcontext.h"
#include "runnercontext.h"
namespace Plasma
{
@ -77,7 +77,7 @@ public:
bool hasConfig;
Priority priority;
Speed speed;
SearchContext::Types blackListed;
RunnerContext::Types blackListed;
RunnerScript* script;
KPluginInfo runnerDescription;
AbstractRunner* runner;
@ -118,14 +118,14 @@ KConfigGroup AbstractRunner::config() const
return KConfigGroup(&runners, group);
}
void AbstractRunner::performMatch( Plasma::SearchContext &globalContext )
void AbstractRunner::performMatch( Plasma::RunnerContext &globalContext )
{
static const int reasonableRunTime = 1500;
static const int fastEnoughTime = 250;
d->runtime.restart();
//TODO :this is a copy ctor
SearchContext localContext(globalContext,0);
RunnerContext localContext(globalContext,0);
match(&localContext);
// automatically rate limit runners that become slooow
const int runtime = d->runtime.elapsed();
@ -202,12 +202,12 @@ void AbstractRunner::setPriority(Priority priority)
d->priority = priority;
}
SearchContext::Types AbstractRunner::ignoredTypes() const
RunnerContext::Types AbstractRunner::ignoredTypes() const
{
return d->blackListed;
}
void AbstractRunner::setIgnoredTypes(SearchContext::Types types)
void AbstractRunner::setIgnoredTypes(RunnerContext::Types types)
{
d->blackListed = types;
}
@ -225,14 +225,14 @@ QMutex* AbstractRunner::bigLock() const
return &Private::bigLock;
}
void AbstractRunner::run(const Plasma::SearchContext *search, const Plasma::SearchMatch *action)
void AbstractRunner::run(const Plasma::RunnerContext *search, const Plasma::SearchMatch *action)
{
if (d->script) {
return d->script->run(search, action);
}
}
void AbstractRunner::match(Plasma::SearchContext *search)
void AbstractRunner::match(Plasma::RunnerContext *search)
{
if (d->script) {
return d->script->match(search);

View File

@ -28,7 +28,7 @@
#include <KDE/KService>
#include <plasma/plasma_export.h>
#include <plasma/searchcontext.h>
#include <plasma/runnercontext.h>
#include <plasma/searchmatch.h>
class KCompletion;
@ -70,14 +70,14 @@ class PLASMA_EXPORT AbstractRunner : public QObject
/**
* This is the main query method. It should trigger creation of
* SearchMatch instances through SearchContext::addInformationalMatch,
* SearchContext::addExactMatch, and SearchContext::addPossibleMatch.
* SearchMatch instances through RunnerContext::addInformationalMatch,
* RunnerContext::addExactMatch, and RunnerContext::addPossibleMatch.
*
* If the runner can run precisely the requested term (SearchContext::searchTerm),
* it should create an exact match (SearchContext::addExactMatch).
* If the runner can run precisely the requested term (RunnerContext::searchTerm),
* it should create an exact match (RunnerContext::addExactMatch).
* The first runner that creates a SearchMatch will be the
* default runner. Other runner's matches will be suggested in the
* interface. Non-exact matches should be offered via SearchContext::addPossibleMatch.
* interface. Non-exact matches should be offered via RunnerContext::addPossibleMatch.
*
* The match will be activated if the user selects it.
*
@ -89,14 +89,14 @@ class PLASMA_EXPORT AbstractRunner : public QObject
* to return from this method right away, nor to create all matches
* here.
*/
virtual void match(Plasma::SearchContext *search);
virtual void match(Plasma::RunnerContext *search);
/**
* Triggers a call to match.
*
* @arg globalContext the search context used in executing this match.
*/
void performMatch(Plasma::SearchContext &globalContext);
void performMatch(Plasma::RunnerContext &globalContext);
/**
* If the runner has options that the user can interact with to modify
@ -132,7 +132,7 @@ class PLASMA_EXPORT AbstractRunner : public QObject
* Called whenever an exact or possible match associated with this
* runner is triggered.
*/
virtual void run(const Plasma::SearchContext *context, const Plasma::SearchMatch *action);
virtual void run(const Plasma::RunnerContext *context, const Plasma::SearchMatch *action);
/**
* The nominal speed of the runner.
@ -147,17 +147,17 @@ class PLASMA_EXPORT AbstractRunner : public QObject
Priority priority() const;
/**
* Returns the OR'ed value of all the Information types (as defined in SearchContext::Type)
* Returns the OR'ed value of all the Information types (as defined in RunnerContext::Type)
* this runner is not interested in.
* @return OR'ed value of black listed types
*/
SearchContext::Types ignoredTypes() const;
RunnerContext::Types ignoredTypes() const;
/**
* Sets the types this runner will ignore
* @param types OR'ed listed of ignored types
*/
void setIgnoredTypes(SearchContext::Types types);
void setIgnoredTypes(RunnerContext::Types types);
/**
* Returns the engine name for the Runner

1
includes/RunnerContext Normal file
View File

@ -0,0 +1 @@
#include "../../plasma/runnercontext.h"

View File

@ -1 +0,0 @@
#include "../../plasma/searchcontext.h"

View File

@ -17,7 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "searchcontext.h"
#include "runnercontext.h"
#include <QReadWriteLock>
@ -37,18 +37,18 @@
namespace Plasma
{
class SearchContext::Private : public QSharedData
class RunnerContext::Private : public QSharedData
{
public:
Private(SearchContext *context, SearchContext::DataPolicy p)
Private(RunnerContext *context, RunnerContext::DataPolicy p)
: QSharedData(),
type(SearchContext::UnknownType),
type(RunnerContext::UnknownType),
q(context),
policy(p)
{
}
Private(const SearchContext::Private& p)
Private(const RunnerContext::Private& p)
: QSharedData(),
term(p.term),
mimeType(p.mimeType),
@ -131,20 +131,20 @@ class SearchContext::Private : public QSharedData
QList<SearchMatch*> matches;
QString term;
QString mimeType;
SearchContext::Type type;
SearchContext * q;
const SearchContext::DataPolicy policy;
RunnerContext::Type type;
RunnerContext * q;
const RunnerContext::DataPolicy policy;
};
SearchContext::SearchContext(QObject *parent, DataPolicy policy)
RunnerContext::RunnerContext(QObject *parent, DataPolicy policy)
: QObject(parent),
d(new Private(this, policy))
{
}
//copy ctor
SearchContext::SearchContext(SearchContext &other, QObject *parent)
RunnerContext::RunnerContext(RunnerContext &other, QObject *parent)
: QObject(parent)
{
other.d->lockForRead();
@ -152,35 +152,35 @@ SearchContext::SearchContext(SearchContext &other, QObject *parent)
other.d->unlock();
}
SearchContext::~SearchContext()
RunnerContext::~RunnerContext()
{
}
void SearchContext::reset()
void RunnerContext::reset()
{
// Locks are needed as other contexts can be copied of this one
// We will detach if we are a copy of someone. But we will reset
// if we are the 'main' context others copied from. Resetting
// one SearchContext makes all the copies oneobsolete.
// one RunnerContext makes all the copies oneobsolete.
d.detach();
//kDebug() << "reset searchContext";
d->lockForWrite();
d->type = SearchContext::UnknownType;
d->type = RunnerContext::UnknownType;
d->term.clear();
d->mimeType.clear();
d->unlock();
// we still have to remove all the matches, since if the
// ref count was 1 (e.g. only the SearchContext is using
// ref count was 1 (e.g. only the RunnerContext is using
// the dptr) then we won't get a copy made
removeAllMatches();
//kDebug() << "match count" << d->matches.count();
}
void SearchContext::setSearchTerm(const QString &term)
void RunnerContext::setSearchTerm(const QString &term)
{
reset();
@ -195,7 +195,7 @@ void SearchContext::setSearchTerm(const QString &term)
}
QString SearchContext::searchTerm() const
QString RunnerContext::searchTerm() const
{
d->lockForRead();
QString term = d->term;
@ -203,17 +203,17 @@ QString SearchContext::searchTerm() const
return term;
}
SearchContext::Type SearchContext::type() const
RunnerContext::Type RunnerContext::type() const
{
return d->type;
}
QString SearchContext::mimeType() const
QString RunnerContext::mimeType() const
{
return d->mimeType;
}
bool SearchContext::addMatches(const QString& term, const QList<SearchMatch*> &matches)
bool RunnerContext::addMatches(const QString& term, const QList<SearchMatch*> &matches)
{
if (searchTerm() != term || matches.isEmpty()) {
return false;
@ -230,7 +230,7 @@ bool SearchContext::addMatches(const QString& term, const QList<SearchMatch*> &m
return true;
}
bool SearchContext::addMatch(const QString &term, SearchMatch *match)
bool RunnerContext::addMatch(const QString &term, SearchMatch *match)
{
if (searchTerm() != term) {
return false;
@ -246,7 +246,7 @@ bool SearchContext::addMatch(const QString &term, SearchMatch *match)
}
QList<SearchMatch *> SearchContext::matches() const
QList<SearchMatch *> RunnerContext::matches() const
{
d->lockForRead();
QList<SearchMatch *> matches = d->matches;
@ -254,7 +254,7 @@ QList<SearchMatch *> SearchContext::matches() const
return matches;
}
void SearchContext::removeAllMatches()
void RunnerContext::removeAllMatches()
{
d->lockForWrite();
if (!d->matches.isEmpty()) {
@ -273,4 +273,4 @@ void SearchContext::removeAllMatches()
}
#include "searchcontext.moc"
#include "runnercontext.moc"

View File

@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SEARCHCONTEXT_H
#define SEARCHCONTEXT_H
#ifndef RUNNERCONTEXT_H
#define RUNNERCONTEXT_H
#include <QtCore/QList>
#include <QtCore/QObject>
@ -36,11 +36,11 @@ class SearchMatch;
class AbstractRunner;
/**
* @short The SearchContext class provides information related to a search,
* @short The RunnerContext class provides information related to a search,
* including the search term, metadata on the search term and collected
* matches.
*/
class PLASMA_EXPORT SearchContext : public QObject
class PLASMA_EXPORT RunnerContext : public QObject
{
Q_OBJECT
@ -61,18 +61,18 @@ class PLASMA_EXPORT SearchContext : public QObject
enum DataPolicy { Shared = 0,
SingleConsumer
};
explicit SearchContext(QObject *parent = 0, DataPolicy policy = Shared);
explicit RunnerContext(QObject *parent = 0, DataPolicy policy = Shared);
/**
* Constructs a SearchContext with a DataPolicy of SingleConsumer that
* Constructs a RunnerContext with a DataPolicy of SingleConsumer that
* contains the search metadata (though none of the currently registered
* matches) from the passed in SearchContext. Primarily useful for creating
* a thread-local copy of a Shared SearchContext.
* matches) from the passed in RunnerContext. Primarily useful for creating
* a thread-local copy of a Shared RunnerContext.
*/
explicit SearchContext(SearchContext& other, QObject *parent = 0);
explicit RunnerContext(RunnerContext& other, QObject *parent = 0);
~SearchContext();
~RunnerContext();
/**
@ -109,7 +109,7 @@ class PLASMA_EXPORT SearchContext : public QObject
/**
* Appends lists of matches to the list of matches.
* The SearchContext takes over ownership of the matches on successful addition.
* The RunnerContext takes over ownership of the matches on successful addition.
*
* This method is thread safe and causes the matchesChanged() signal to be emitted.
*
@ -119,7 +119,7 @@ class PLASMA_EXPORT SearchContext : public QObject
/**
* Appends a match to the existing list of matches.
* The SearchContext takes over ownership of the match on successful addition.
* The RunnerContext takes over ownership of the match on successful addition.
*
* If you are going to be adding multiple matches, it is better to use
* addMatches instead.
@ -132,14 +132,14 @@ class PLASMA_EXPORT SearchContext : public QObject
bool addMatch(const QString &term, SearchMatch *match);
/**
* Takes the matches from this SearchContext and copies to them another.
* If successful, the matches are removed from this SearchContext and
* ownership passed to the other SearchContext
* Takes the matches from this RunnerContext and copies to them another.
* If successful, the matches are removed from this RunnerContext and
* ownership passed to the other RunnerContext
*
* @arg other the SearchContext to move this object's Matches to
* @arg other the RunnerContext to move this object's Matches to
* @return true if matches were added, false if matches were e.g. outdated
*/
bool moveMatchesTo(SearchContext &other);
bool moveMatchesTo(RunnerContext &other);
/**
* Retrieves all available matches for the current search term.
@ -147,7 +147,7 @@ class PLASMA_EXPORT SearchContext : public QObject
QList<SearchMatch *> matches() const;
/**
* Removes all matches from this SearchContext.
* Removes all matches from this RunnerContext.
*/
void removeAllMatches();
@ -161,6 +161,6 @@ class PLASMA_EXPORT SearchContext : public QObject
}
Q_DECLARE_OPERATORS_FOR_FLAGS (Plasma::SearchContext::Types)
Q_DECLARE_OPERATORS_FOR_FLAGS(Plasma::RunnerContext::Types)
#endif

View File

@ -143,7 +143,7 @@ void RunnerRestrictionPolicy::destructed(Job* job)
class FindMatchesJob : public Job
{
public:
FindMatchesJob(const QString& term, Plasma::AbstractRunner* runner, Plasma::SearchContext* context, QObject* parent = 0);
FindMatchesJob(const QString& term, Plasma::AbstractRunner* runner, Plasma::RunnerContext* context, QObject* parent = 0);
int priority() const;
@ -151,12 +151,12 @@ protected:
void run();
private:
QString m_term;
Plasma::SearchContext* m_context;
Plasma::RunnerContext* m_context;
Plasma::AbstractRunner* m_runner;
};
FindMatchesJob::FindMatchesJob( const QString& term, Plasma::AbstractRunner* runner,
Plasma::SearchContext* context, QObject* parent )
Plasma::RunnerContext* context, QObject* parent )
: ThreadWeaver::Job(parent),
m_term(term),
m_context(context),
@ -263,7 +263,7 @@ public:
}
RunnerManager *q;
SearchContext context;
RunnerContext context;
AbstractRunner::List runners;
QList<ThreadWeaver::Job*> searchJobs;
QStringList prioritylist;
@ -317,7 +317,7 @@ AbstractRunner* RunnerManager::runner(const QString &name) const
}
SearchContext* RunnerManager::searchContext() const
RunnerContext* RunnerManager::searchContext() const
{
return &d->context;
}

View File

@ -32,7 +32,7 @@ namespace Plasma
{
class SearchMatch;
class AbstractRunner;
class SearchContext;
class RunnerContext;
/**
* @short The RunnerManager class decides what installed runners are runnable,
@ -59,7 +59,7 @@ class PLASMA_EXPORT RunnerManager : public QObject
* Retrieves the current context
* @return pointer to the current context
*/
SearchContext* searchContext() const;
RunnerContext* searchContext() const;
/**
* Retrieves all available matches found so far for the previously launched query

View File

@ -52,12 +52,12 @@ AbstractRunner* RunnerScript::runner() const
return d->runner;
}
void RunnerScript::match(Plasma::SearchContext *search)
void RunnerScript::match(Plasma::RunnerContext *search)
{
Q_UNUSED(search)
}
void RunnerScript::run(const Plasma::SearchContext *search, const Plasma::SearchMatch *action)
void RunnerScript::run(const Plasma::RunnerContext *search, const Plasma::SearchMatch *action)
{
Q_UNUSED(search)
Q_UNUSED(action)

View File

@ -29,7 +29,7 @@ namespace Plasma
{
class AbstractRunner;
class SearchContext;
class RunnerContext;
class SearchMatch;
class PLASMA_EXPORT RunnerScript : public ScriptEngine
@ -59,16 +59,16 @@ public:
/**
* Called when the script should create SearchMatch instances through
* SearchContext::addInformationalMatch, SearchContext::addExactMatch, and
* SearchContext::addPossibleMatch.
* RunnerContext::addInformationalMatch, RunnerContext::addExactMatch, and
* RunnerContext::addPossibleMatch.
*/
virtual void match(Plasma::SearchContext *search);
virtual void match(Plasma::RunnerContext *search);
/**
* Called whenever an exact or possible match associated with this
* runner is triggered.
*/
virtual void run(const Plasma::SearchContext *search, const Plasma::SearchMatch *action);
virtual void run(const Plasma::RunnerContext *search, const Plasma::SearchMatch *action);
protected:
/**

View File

@ -144,7 +144,7 @@ bool SearchMatch::operator<(const SearchMatch& other) const
return d->relevance < other.d->relevance;
}
void SearchMatch::run(const SearchContext *context) const
void SearchMatch::run(const RunnerContext *context) const
{
Q_ASSERT(context);

View File

@ -29,7 +29,7 @@ class QString;
namespace Plasma
{
class SearchContext;
class RunnerContext;
class AbstractRunner;
class PLASMA_EXPORT SearchMatch
@ -54,10 +54,10 @@ class PLASMA_EXPORT SearchMatch
/**
* Constructs a PossibleMatch associated with a given SearchContext
* Constructs a PossibleMatch associated with a given RunnerContext
* and runner.
*
* @arg search the SearchContext this match belongs to
* @arg search the RunnerContext this match belongs to
* @arg runner the runner this match belongs to
*/
explicit SearchMatch(AbstractRunner *runner);
@ -108,7 +108,7 @@ class PLASMA_EXPORT SearchMatch
bool operator<(const SearchMatch& other) const;
void run(const SearchContext *context) const;
void run(const RunnerContext *context) const;
private:
class Private;