SearchMatch -> QueryMatch
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=803385
This commit is contained in:
parent
a8647e4ecc
commit
f3188fb672
@ -41,9 +41,9 @@ set(plasma_LIB_SRCS
|
||||
packages.cpp
|
||||
plasma.cpp
|
||||
plasma_export.h
|
||||
querymatch.cpp
|
||||
runnercontext.cpp
|
||||
runnermanager.cpp
|
||||
searchmatch.cpp
|
||||
shadowitem.cpp
|
||||
svg.cpp
|
||||
panelsvg.cpp
|
||||
@ -116,7 +116,7 @@ set(plasma_LIB_INCLUDES
|
||||
plasma_export.h
|
||||
runnercontext.h
|
||||
runnermanager.h
|
||||
searchmatch.h
|
||||
querymatch.h
|
||||
shadowitem_p.h
|
||||
svg.h
|
||||
panelsvg.h
|
||||
@ -173,7 +173,7 @@ install(FILES
|
||||
includes/DataEngine
|
||||
includes/DataEngineManager
|
||||
includes/RunnerContext
|
||||
includes/SearchMatch
|
||||
includes/QueryMatch
|
||||
includes/Svg
|
||||
includes/PanelSvg
|
||||
includes/UiLoader
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <KStandardDirs>
|
||||
#include <QTimer>
|
||||
|
||||
#include <plasma/searchmatch.h>
|
||||
#include <plasma/querymatch.h>
|
||||
#include <plasma/package.h>
|
||||
|
||||
#include "scripting/runnerscript.h"
|
||||
@ -225,7 +225,7 @@ QMutex* AbstractRunner::bigLock() const
|
||||
return &Private::bigLock;
|
||||
}
|
||||
|
||||
void AbstractRunner::run(const Plasma::RunnerContext *search, const Plasma::SearchMatch *action)
|
||||
void AbstractRunner::run(const Plasma::RunnerContext *search, const Plasma::QueryMatch *action)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->run(search, action);
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
#include <plasma/runnercontext.h>
|
||||
#include <plasma/searchmatch.h>
|
||||
#include <plasma/querymatch.h>
|
||||
|
||||
class KCompletion;
|
||||
|
||||
@ -38,7 +38,7 @@ namespace Plasma
|
||||
|
||||
class Package;
|
||||
class RunnerScript;
|
||||
class SearchMatch;
|
||||
class QueryMatch;
|
||||
|
||||
/**
|
||||
* An abstract base class for Plasma Runner plugins
|
||||
@ -70,12 +70,12 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
||||
|
||||
/**
|
||||
* This is the main query method. It should trigger creation of
|
||||
* SearchMatch instances through RunnerContext::addInformationalMatch,
|
||||
* QueryMatch instances through RunnerContext::addInformationalMatch,
|
||||
* RunnerContext::addExactMatch, and RunnerContext::addPossibleMatch.
|
||||
*
|
||||
* If the runner can run precisely the requested term (RunnerContext::query()),
|
||||
* it should create an exact match (RunnerContext::addExactMatch).
|
||||
* The first runner that creates a SearchMatch will be the
|
||||
* The first runner that creates a QueryMatch will be the
|
||||
* default runner. Other runner's matches will be suggested in the
|
||||
* interface. Non-exact matches should be offered via RunnerContext::addPossibleMatch.
|
||||
*
|
||||
@ -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::RunnerContext *context, const Plasma::SearchMatch *action);
|
||||
virtual void run(const Plasma::RunnerContext *context, const Plasma::QueryMatch *action);
|
||||
|
||||
/**
|
||||
* The nominal speed of the runner.
|
||||
|
1
includes/QueryMatch
Normal file
1
includes/QueryMatch
Normal file
@ -0,0 +1 @@
|
||||
#include "../../plasma/querymatch.h"
|
@ -1 +0,0 @@
|
||||
#include "../../plasma/searchmatch.h"
|
@ -17,7 +17,7 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "searchmatch.h"
|
||||
#include "querymatch.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QVariant>
|
||||
@ -31,19 +31,19 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class SearchMatch::Private
|
||||
class QueryMatch::Private
|
||||
{
|
||||
public:
|
||||
Private(AbstractRunner *r)
|
||||
: runner(r),
|
||||
type(SearchMatch::ExactMatch),
|
||||
type(QueryMatch::ExactMatch),
|
||||
enabled(true),
|
||||
relevance(.7)
|
||||
{
|
||||
}
|
||||
|
||||
QPointer<AbstractRunner> runner;
|
||||
SearchMatch::Type type;
|
||||
QueryMatch::Type type;
|
||||
QString text;
|
||||
QString subtext;
|
||||
QIcon icon;
|
||||
@ -53,98 +53,98 @@ class SearchMatch::Private
|
||||
};
|
||||
|
||||
|
||||
SearchMatch::SearchMatch(AbstractRunner *runner)
|
||||
QueryMatch::QueryMatch(AbstractRunner *runner)
|
||||
: d(new Private(runner))
|
||||
{
|
||||
// kDebug() << "new match created";
|
||||
}
|
||||
|
||||
SearchMatch::~SearchMatch()
|
||||
QueryMatch::~QueryMatch()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void SearchMatch::setType(Type type)
|
||||
void QueryMatch::setType(Type type)
|
||||
{
|
||||
d->type = type;
|
||||
}
|
||||
|
||||
SearchMatch::Type SearchMatch::type() const
|
||||
QueryMatch::Type QueryMatch::type() const
|
||||
{
|
||||
return d->type;
|
||||
}
|
||||
|
||||
void SearchMatch::setRelevance(qreal relevance)
|
||||
void QueryMatch::setRelevance(qreal relevance)
|
||||
{
|
||||
d->relevance = qMax(qreal(0.0), qMin(qreal(1.0), relevance));
|
||||
}
|
||||
|
||||
qreal SearchMatch::relevance() const
|
||||
qreal QueryMatch::relevance() const
|
||||
{
|
||||
return d->relevance;
|
||||
}
|
||||
|
||||
AbstractRunner* SearchMatch::runner() const
|
||||
AbstractRunner* QueryMatch::runner() const
|
||||
{
|
||||
return d->runner;
|
||||
}
|
||||
|
||||
void SearchMatch::setText(const QString& text)
|
||||
void QueryMatch::setText(const QString& text)
|
||||
{
|
||||
d->text = text;
|
||||
}
|
||||
|
||||
void SearchMatch::setSubtext(const QString& subtext)
|
||||
void QueryMatch::setSubtext(const QString& subtext)
|
||||
{
|
||||
d->subtext = subtext;
|
||||
}
|
||||
|
||||
void SearchMatch::setData(const QVariant& data)
|
||||
void QueryMatch::setData(const QVariant& data)
|
||||
{
|
||||
d->data = data;
|
||||
}
|
||||
|
||||
void SearchMatch::setIcon(const QIcon& icon)
|
||||
void QueryMatch::setIcon(const QIcon& icon)
|
||||
{
|
||||
d->icon = icon;
|
||||
}
|
||||
|
||||
QVariant SearchMatch::data() const
|
||||
QVariant QueryMatch::data() const
|
||||
{
|
||||
return d->data;
|
||||
}
|
||||
|
||||
QString SearchMatch::text() const
|
||||
QString QueryMatch::text() const
|
||||
{
|
||||
return d->text;
|
||||
}
|
||||
|
||||
QString SearchMatch::subtext() const
|
||||
QString QueryMatch::subtext() const
|
||||
{
|
||||
return d->subtext;
|
||||
}
|
||||
|
||||
QIcon SearchMatch::icon() const
|
||||
QIcon QueryMatch::icon() const
|
||||
{
|
||||
return d->icon;
|
||||
}
|
||||
|
||||
void SearchMatch::setEnabled( bool enabled )
|
||||
void QueryMatch::setEnabled( bool enabled )
|
||||
{
|
||||
d->enabled = enabled;
|
||||
}
|
||||
|
||||
bool SearchMatch::isEnabled() const
|
||||
bool QueryMatch::isEnabled() const
|
||||
{
|
||||
return d->enabled;
|
||||
}
|
||||
|
||||
bool SearchMatch::operator<(const SearchMatch& other) const
|
||||
bool QueryMatch::operator<(const QueryMatch& other) const
|
||||
{
|
||||
return d->relevance < other.d->relevance;
|
||||
}
|
||||
|
||||
void SearchMatch::run(const RunnerContext *context) const
|
||||
void QueryMatch::run(const RunnerContext *context) const
|
||||
{
|
||||
Q_ASSERT(context);
|
||||
|
@ -17,8 +17,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef SEARCHMATCH_H
|
||||
#define SEARCHMATCH_H
|
||||
#ifndef QUERYMATCH_H
|
||||
#define QUERYMATCH_H
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
@ -32,7 +32,7 @@ namespace Plasma
|
||||
class RunnerContext;
|
||||
class AbstractRunner;
|
||||
|
||||
class PLASMA_EXPORT SearchMatch
|
||||
class PLASMA_EXPORT QueryMatch
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -60,8 +60,8 @@ class PLASMA_EXPORT SearchMatch
|
||||
* @arg search the RunnerContext this match belongs to
|
||||
* @arg runner the runner this match belongs to
|
||||
*/
|
||||
explicit SearchMatch(AbstractRunner *runner);
|
||||
~SearchMatch();
|
||||
explicit QueryMatch(AbstractRunner *runner);
|
||||
~QueryMatch();
|
||||
|
||||
/**
|
||||
* Sets the type of match this action represents.
|
||||
@ -106,7 +106,7 @@ class PLASMA_EXPORT SearchMatch
|
||||
QIcon icon() const;
|
||||
bool isEnabled() const;
|
||||
|
||||
bool operator<(const SearchMatch& other) const;
|
||||
bool operator<(const QueryMatch& other) const;
|
||||
|
||||
void run(const RunnerContext *context) const;
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <KStandardDirs>
|
||||
#include <KUrl>
|
||||
|
||||
#include "searchmatch.h"
|
||||
#include "querymatch.h"
|
||||
|
||||
#define LOCK_FOR_READ(context) if (context->d->policy == Shared) { context->d->lock.lockForRead(); }
|
||||
#define LOCK_FOR_WRITE(context) if (context->d->policy == Shared) { context->d->lock.lockForWrite(); }
|
||||
@ -125,7 +125,7 @@ class RunnerContext::Private : public QSharedData
|
||||
}
|
||||
|
||||
QReadWriteLock lock;
|
||||
QList<SearchMatch*> matches;
|
||||
QList<QueryMatch*> matches;
|
||||
QString term;
|
||||
QString mimeType;
|
||||
RunnerContext::Type type;
|
||||
@ -210,7 +210,7 @@ QString RunnerContext::mimeType() const
|
||||
return d->mimeType;
|
||||
}
|
||||
|
||||
bool RunnerContext::addMatches(const QString& term, const QList<SearchMatch*> &matches)
|
||||
bool RunnerContext::addMatches(const QString& term, const QList<QueryMatch*> &matches)
|
||||
{
|
||||
if (query() != term || matches.isEmpty()) {
|
||||
return false;
|
||||
@ -227,7 +227,7 @@ bool RunnerContext::addMatches(const QString& term, const QList<SearchMatch*> &m
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RunnerContext::addMatch(const QString &term, SearchMatch *match)
|
||||
bool RunnerContext::addMatch(const QString &term, QueryMatch *match)
|
||||
{
|
||||
if (query() != term) {
|
||||
return false;
|
||||
@ -243,10 +243,10 @@ bool RunnerContext::addMatch(const QString &term, SearchMatch *match)
|
||||
}
|
||||
|
||||
|
||||
QList<SearchMatch *> RunnerContext::matches() const
|
||||
QList<QueryMatch *> RunnerContext::matches() const
|
||||
{
|
||||
LOCK_FOR_READ(this)
|
||||
QList<SearchMatch *> matches = d->matches;
|
||||
QList<QueryMatch *> matches = d->matches;
|
||||
UNLOCK(this);
|
||||
return matches;
|
||||
}
|
||||
@ -255,7 +255,7 @@ void RunnerContext::removeAllMatches()
|
||||
{
|
||||
LOCK_FOR_WRITE(this)
|
||||
if (!d->matches.isEmpty()) {
|
||||
QList<SearchMatch*> matches = d->matches;
|
||||
QList<QueryMatch*> matches = d->matches;
|
||||
d->matches.clear();
|
||||
UNLOCK(this);
|
||||
|
||||
|
@ -32,7 +32,7 @@ class KCompletion;
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class SearchMatch;
|
||||
class QueryMatch;
|
||||
class AbstractRunner;
|
||||
|
||||
/**
|
||||
@ -115,7 +115,7 @@ class PLASMA_EXPORT RunnerContext : public QObject
|
||||
*
|
||||
* @return true if matches were added, false if matches were e.g. outdated
|
||||
*/
|
||||
bool addMatches(const QString& term, const QList<SearchMatch *> &matches);
|
||||
bool addMatches(const QString& term, const QList<QueryMatch *> &matches);
|
||||
|
||||
/**
|
||||
* Appends a match to the existing list of matches.
|
||||
@ -129,7 +129,7 @@ class PLASMA_EXPORT RunnerContext : public QObject
|
||||
*
|
||||
* @return true if the match was added, false otherwise.
|
||||
*/
|
||||
bool addMatch(const QString &term, SearchMatch *match);
|
||||
bool addMatch(const QString &term, QueryMatch *match);
|
||||
|
||||
/**
|
||||
* Takes the matches from this RunnerContext and copies to them another.
|
||||
@ -144,7 +144,7 @@ class PLASMA_EXPORT RunnerContext : public QObject
|
||||
/**
|
||||
* Retrieves all available matches for the current search term.
|
||||
*/
|
||||
QList<SearchMatch *> matches() const;
|
||||
QList<QueryMatch *> matches() const;
|
||||
|
||||
/**
|
||||
* Removes all matches from this RunnerContext.
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <QTimer>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "searchmatch.h"
|
||||
#include "querymatch.h"
|
||||
|
||||
#include "runnermanager.h"
|
||||
|
||||
@ -323,12 +323,12 @@ RunnerContext* RunnerManager::searchContext() const
|
||||
}
|
||||
|
||||
//Reordering is here so data is not reordered till strictly needed
|
||||
QList<SearchMatch *> RunnerManager::matches() const
|
||||
QList<QueryMatch *> RunnerManager::matches() const
|
||||
{
|
||||
return d->context.matches();
|
||||
}
|
||||
|
||||
void RunnerManager::run(const SearchMatch *match)
|
||||
void RunnerManager::run(const QueryMatch *match)
|
||||
{
|
||||
//TODO: this function is not const as it may be used for learning
|
||||
match->run(&d->context);
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class SearchMatch;
|
||||
class QueryMatch;
|
||||
class AbstractRunner;
|
||||
class RunnerContext;
|
||||
|
||||
@ -65,13 +65,13 @@ class PLASMA_EXPORT RunnerManager : public QObject
|
||||
* Retrieves all available matches found so far for the previously launched query
|
||||
* @return List of matches
|
||||
*/
|
||||
QList<SearchMatch *> matches() const;
|
||||
QList<QueryMatch *> matches() const;
|
||||
|
||||
/**
|
||||
* Runs a given match
|
||||
* @arg pointer to the match to be executed
|
||||
*/
|
||||
void run(const SearchMatch *match);
|
||||
void run(const QueryMatch *match);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ void RunnerScript::match(Plasma::RunnerContext *search)
|
||||
Q_UNUSED(search)
|
||||
}
|
||||
|
||||
void RunnerScript::run(const Plasma::RunnerContext *search, const Plasma::SearchMatch *action)
|
||||
void RunnerScript::run(const Plasma::RunnerContext *search, const Plasma::QueryMatch *action)
|
||||
{
|
||||
Q_UNUSED(search)
|
||||
Q_UNUSED(action)
|
||||
|
@ -30,7 +30,7 @@ namespace Plasma
|
||||
|
||||
class AbstractRunner;
|
||||
class RunnerContext;
|
||||
class SearchMatch;
|
||||
class QueryMatch;
|
||||
|
||||
class PLASMA_EXPORT RunnerScript : public ScriptEngine
|
||||
{
|
||||
@ -58,7 +58,7 @@ public:
|
||||
AbstractRunner* runner() const;
|
||||
|
||||
/**
|
||||
* Called when the script should create SearchMatch instances through
|
||||
* Called when the script should create QueryMatch instances through
|
||||
* RunnerContext::addInformationalMatch, RunnerContext::addExactMatch, and
|
||||
* RunnerContext::addPossibleMatch.
|
||||
*/
|
||||
@ -68,7 +68,7 @@ public:
|
||||
* Called whenever an exact or possible match associated with this
|
||||
* runner is triggered.
|
||||
*/
|
||||
virtual void run(const Plasma::RunnerContext *search, const Plasma::SearchMatch *action);
|
||||
virtual void run(const Plasma::RunnerContext *search, const Plasma::QueryMatch *action);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user