* SearchAction becomes SearchMatch; fall out of the refactoring
* add camel case headers for those classes now that they've settled in svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=744452
This commit is contained in:
parent
d3c5f72bab
commit
cfd3bfac48
@ -44,7 +44,7 @@ set(plasma_LIB_SRCS
|
||||
plasma.cpp
|
||||
plasma_export.h
|
||||
scriptengine.cpp
|
||||
searchaction.cpp
|
||||
searchmatch.cpp
|
||||
searchcontext.cpp
|
||||
shadowitem.cpp
|
||||
svg.cpp
|
||||
@ -115,7 +115,7 @@ set(plasma_LIB_INCLUDES
|
||||
plasma.h
|
||||
plasma_export.h
|
||||
scriptengine.h
|
||||
searchaction.h
|
||||
searchmatch.h
|
||||
searchcontext.h
|
||||
shadowitem_p.h
|
||||
svg.h
|
||||
@ -176,6 +176,8 @@ install(FILES
|
||||
includes/DataEngine
|
||||
includes/DataEngineManager
|
||||
includes/ScriptEngine
|
||||
includes/SearchContext
|
||||
includes/SearchMatch
|
||||
includes/Svg
|
||||
includes/UiLoader
|
||||
includes/PackageMetadata
|
||||
|
@ -54,9 +54,9 @@ void AbstractRunner::performMatch( Plasma::SearchContext &globalContext )
|
||||
|
||||
match( &localContext );
|
||||
|
||||
QList<SearchAction *> exact = localContext.exactMatches().mid(exactEnd);
|
||||
QList<SearchAction *> possible = localContext.possibleMatches().mid(possibleEnd);
|
||||
QList<SearchAction *> info = localContext.informationalMatches().mid(infoEnd);
|
||||
QList<SearchMatch *> exact = localContext.exactMatches().mid(exactEnd);
|
||||
QList<SearchMatch *> possible = localContext.possibleMatches().mid(possibleEnd);
|
||||
QList<SearchMatch *> info = localContext.informationalMatches().mid(infoEnd);
|
||||
|
||||
//If matches were not added, delete items on the heap
|
||||
if (!globalContext.addMatches(localContext.searchTerm(), exact, possible, info)) {
|
||||
@ -96,7 +96,7 @@ void AbstractRunner::createConfigurationInterface(QWidget *widget)
|
||||
Q_UNUSED(widget)
|
||||
}
|
||||
|
||||
void AbstractRunner::exec(Plasma::SearchAction *action)
|
||||
void AbstractRunner::exec(Plasma::SearchMatch *action)
|
||||
{
|
||||
Q_UNUSED(action)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
#include <plasma/searchaction.h>
|
||||
#include <plasma/searchmatch.h>
|
||||
#include <plasma/searchcontext.h>
|
||||
|
||||
class KCompletion;
|
||||
@ -107,7 +107,7 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
||||
* Called whenever an exact or possible match associated with this
|
||||
* runner is triggered.
|
||||
*/
|
||||
virtual void exec(Plasma::SearchAction *action);
|
||||
virtual void exec(Plasma::SearchMatch *action);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
1
includes/SearchContext
Normal file
1
includes/SearchContext
Normal file
@ -0,0 +1 @@
|
||||
#include "../../plasma/searchcontext.h"
|
1
includes/SearchMatch
Normal file
1
includes/SearchMatch
Normal file
@ -0,0 +1 @@
|
||||
#include "../../plasma/searchmatch.h"
|
@ -30,7 +30,7 @@
|
||||
#include <KStandardDirs>
|
||||
#include <KUrl>
|
||||
|
||||
#include "searchaction.h"
|
||||
#include "searchmatch.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -105,9 +105,9 @@ class SearchContext::Private
|
||||
}
|
||||
|
||||
QReadWriteLock lock;
|
||||
QList<SearchAction *> info;
|
||||
QList<SearchAction *> exact;
|
||||
QList<SearchAction *> possible;
|
||||
QList<SearchMatch *> info;
|
||||
QList<SearchMatch *> exact;
|
||||
QList<SearchMatch *> possible;
|
||||
QString term;
|
||||
QString mimetype;
|
||||
SearchContext::Type type;
|
||||
@ -243,33 +243,33 @@ void SearchContext::addStringCompletions(const QStringList &completion)
|
||||
d->unlock();
|
||||
}
|
||||
|
||||
SearchAction* SearchContext::addInformationalMatch(AbstractRunner *runner)
|
||||
SearchMatch* SearchContext::addInformationalMatch(AbstractRunner *runner)
|
||||
{
|
||||
SearchAction *action = new SearchAction(this, runner);
|
||||
action->setType(SearchAction::InformationalMatch);
|
||||
SearchMatch *action = new SearchMatch(this, runner);
|
||||
action->setType(SearchMatch::InformationalMatch);
|
||||
d->info.append(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
SearchAction* SearchContext::addExactMatch(AbstractRunner *runner)
|
||||
SearchMatch* SearchContext::addExactMatch(AbstractRunner *runner)
|
||||
{
|
||||
SearchAction *action = new SearchAction(this, runner);
|
||||
action->setType(SearchAction::ExactMatch);
|
||||
SearchMatch *action = new SearchMatch(this, runner);
|
||||
action->setType(SearchMatch::ExactMatch);
|
||||
d->exact.append(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
SearchAction* SearchContext::addPossibleMatch(AbstractRunner *runner)
|
||||
SearchMatch* SearchContext::addPossibleMatch(AbstractRunner *runner)
|
||||
{
|
||||
SearchAction *action = new SearchAction(this, runner);
|
||||
action->setType(SearchAction::PossibleMatch);
|
||||
SearchMatch *action = new SearchMatch(this, runner);
|
||||
action->setType(SearchMatch::PossibleMatch);
|
||||
d->possible.append(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
bool SearchContext::addMatches( const QString& term, const QList<SearchAction *> &exactMatches,
|
||||
const QList<SearchAction *> &possibleMatches,
|
||||
const QList<SearchAction *> &informationalMatches )
|
||||
bool SearchContext::addMatches( const QString& term, const QList<SearchMatch *> &exactMatches,
|
||||
const QList<SearchMatch *> &possibleMatches,
|
||||
const QList<SearchMatch *> &informationalMatches )
|
||||
{
|
||||
if (searchTerm() != term) {
|
||||
return false;
|
||||
@ -283,26 +283,26 @@ bool SearchContext::addMatches( const QString& term, const QList<SearchAction *>
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<SearchAction *> SearchContext::informationalMatches() const
|
||||
QList<SearchMatch *> SearchContext::informationalMatches() const
|
||||
{
|
||||
d->lockForRead();
|
||||
QList<SearchAction *> matches = d->info;
|
||||
QList<SearchMatch *> matches = d->info;
|
||||
d->unlock();
|
||||
return matches;
|
||||
}
|
||||
|
||||
QList<SearchAction *> SearchContext::exactMatches() const
|
||||
QList<SearchMatch *> SearchContext::exactMatches() const
|
||||
{
|
||||
d->lockForRead();
|
||||
QList<SearchAction *> matches = d->exact;
|
||||
QList<SearchMatch *> matches = d->exact;
|
||||
d->unlock();
|
||||
return matches;
|
||||
}
|
||||
|
||||
QList<SearchAction *> SearchContext::possibleMatches() const
|
||||
QList<SearchMatch *> SearchContext::possibleMatches() const
|
||||
{
|
||||
d->lockForRead();
|
||||
QList<SearchAction *> matches = d->possible;
|
||||
QList<SearchMatch *> matches = d->possible;
|
||||
d->unlock();
|
||||
return matches;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class KCompletion;
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class SearchAction;
|
||||
class SearchMatch;
|
||||
class AbstractRunner;
|
||||
|
||||
/**
|
||||
@ -106,43 +106,43 @@ class PLASMA_EXPORT SearchContext : public QObject
|
||||
* If string data is added to the action using QAction::setData(), that
|
||||
* string may be used in user interfaces when the item is selected.
|
||||
*/
|
||||
SearchAction* addInformationalMatch(AbstractRunner *runner);
|
||||
SearchMatch* addInformationalMatch(AbstractRunner *runner);
|
||||
|
||||
/**
|
||||
* Add an action that represents an exact match to the current search term.
|
||||
*/
|
||||
SearchAction* addExactMatch(AbstractRunner *runner);
|
||||
SearchMatch* addExactMatch(AbstractRunner *runner);
|
||||
|
||||
/**
|
||||
* Add an action that represents a possible match to the current search term.
|
||||
*/
|
||||
SearchAction* addPossibleMatch(AbstractRunner *runner);
|
||||
SearchMatch* addPossibleMatch(AbstractRunner *runner);
|
||||
|
||||
/**
|
||||
* Appends lists of matches to the lists for exact, possible, and informational matches
|
||||
* @return true if matches were added, false if matches were outdated
|
||||
*/
|
||||
bool addMatches( const QString& term, const QList<SearchAction *> &exactMatches,
|
||||
const QList<SearchAction *> &possibleMatches,
|
||||
const QList<SearchAction *> &informationalMatches );
|
||||
bool addMatches( const QString& term, const QList<SearchMatch *> &exactMatches,
|
||||
const QList<SearchMatch *> &possibleMatches,
|
||||
const QList<SearchMatch *> &informationalMatches );
|
||||
|
||||
/**
|
||||
* Retrieves all available informational matches for the current
|
||||
* search term.
|
||||
*/
|
||||
QList<SearchAction *> informationalMatches() const;
|
||||
QList<SearchMatch *> informationalMatches() const;
|
||||
|
||||
/**
|
||||
* Retrieves all available exact matches for the current
|
||||
* search term.
|
||||
*/
|
||||
QList<SearchAction *> exactMatches() const;
|
||||
QList<SearchMatch *> exactMatches() const;
|
||||
|
||||
/**
|
||||
* Retrieves all available possible matches for the current
|
||||
* search term.
|
||||
*/
|
||||
QList<SearchAction *> possibleMatches() const;
|
||||
QList<SearchMatch *> possibleMatches() const;
|
||||
|
||||
/**
|
||||
* Determines type of query
|
||||
|
@ -17,20 +17,20 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "searchaction.h"
|
||||
#include "searchmatch.h"
|
||||
|
||||
#include "abstractrunner.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class SearchAction::Private
|
||||
class SearchMatch::Private
|
||||
{
|
||||
public:
|
||||
Private(SearchContext* s, AbstractRunner *r)
|
||||
: /*search(s),*/
|
||||
runner(r),
|
||||
type(SearchAction::ExactMatch),
|
||||
type(SearchMatch::ExactMatch),
|
||||
enabled(true),
|
||||
relevance(1)
|
||||
{
|
||||
@ -40,7 +40,7 @@ class SearchAction::Private
|
||||
QString searchTerm;
|
||||
SearchContext *search;
|
||||
AbstractRunner *runner;
|
||||
SearchAction::Type type;
|
||||
SearchMatch::Type type;
|
||||
QString mimetype;
|
||||
QString text;
|
||||
QIcon icon;
|
||||
@ -50,104 +50,104 @@ class SearchAction::Private
|
||||
};
|
||||
|
||||
|
||||
SearchAction::SearchAction(SearchContext *search, AbstractRunner *runner)
|
||||
SearchMatch::SearchMatch(SearchContext *search, AbstractRunner *runner)
|
||||
: d(new Private(search, runner))
|
||||
{
|
||||
}
|
||||
|
||||
SearchAction::~SearchAction()
|
||||
SearchMatch::~SearchMatch()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void SearchAction::setType(Type type)
|
||||
void SearchMatch::setType(Type type)
|
||||
{
|
||||
d->type = type;
|
||||
}
|
||||
|
||||
SearchAction::Type SearchAction::type() const
|
||||
SearchMatch::Type SearchMatch::type() const
|
||||
{
|
||||
return d->type;
|
||||
}
|
||||
|
||||
void SearchAction::setMimetype(const QString &mimetype)
|
||||
void SearchMatch::setMimetype(const QString &mimetype)
|
||||
{
|
||||
d->mimetype = mimetype;
|
||||
}
|
||||
|
||||
QString SearchAction::mimetype() const
|
||||
QString SearchMatch::mimetype() const
|
||||
{
|
||||
return d->mimetype;//.isEmpty() ? d->search->mimetype() : d->mimetype;
|
||||
}
|
||||
|
||||
QString SearchAction::searchTerm() const
|
||||
QString SearchMatch::searchTerm() const
|
||||
{
|
||||
return d->searchTerm;//->searchTerm();
|
||||
}
|
||||
|
||||
void SearchAction::setRelevance(qreal relevance)
|
||||
void SearchMatch::setRelevance(qreal relevance)
|
||||
{
|
||||
d->relevance = qMax(0.0, qMin(1.0, relevance));
|
||||
}
|
||||
|
||||
qreal SearchAction::relevance() const
|
||||
qreal SearchMatch::relevance() const
|
||||
{
|
||||
return d->relevance;
|
||||
}
|
||||
|
||||
AbstractRunner* SearchAction::runner() const
|
||||
AbstractRunner* SearchMatch::runner() const
|
||||
{
|
||||
return d->runner;
|
||||
}
|
||||
|
||||
void SearchAction::setText(const QString& text)
|
||||
void SearchMatch::setText(const QString& text)
|
||||
{
|
||||
d->text = text;
|
||||
}
|
||||
|
||||
void SearchAction::setData(const QVariant& data)
|
||||
void SearchMatch::setData(const QVariant& data)
|
||||
{
|
||||
d->data = data;
|
||||
}
|
||||
|
||||
void SearchAction::setIcon(const QIcon& icon)
|
||||
void SearchMatch::setIcon(const QIcon& icon)
|
||||
{
|
||||
d->icon = icon;
|
||||
}
|
||||
|
||||
QVariant SearchAction::data() const
|
||||
QVariant SearchMatch::data() const
|
||||
{
|
||||
return d->data;
|
||||
}
|
||||
|
||||
QString SearchAction::text() const
|
||||
QString SearchMatch::text() const
|
||||
{
|
||||
return d->text;
|
||||
}
|
||||
|
||||
QIcon SearchAction::icon() const
|
||||
QIcon SearchMatch::icon() const
|
||||
{
|
||||
return d->icon;
|
||||
}
|
||||
|
||||
void SearchAction::setEnabled( bool enabled )
|
||||
void SearchMatch::setEnabled( bool enabled )
|
||||
{
|
||||
d->enabled = enabled;
|
||||
}
|
||||
|
||||
bool SearchAction::isEnabled() const
|
||||
bool SearchMatch::isEnabled() const
|
||||
{
|
||||
return d->enabled;
|
||||
}
|
||||
|
||||
bool SearchAction::operator<(const SearchAction& other) const
|
||||
bool SearchMatch::operator<(const SearchMatch& other) const
|
||||
{
|
||||
return d->relevance < other.d->relevance;
|
||||
}
|
||||
|
||||
void SearchAction::exec()
|
||||
void SearchMatch::exec()
|
||||
{
|
||||
if(d->runner) {
|
||||
if (d->runner) {
|
||||
//TODO: this could be dangerous if the runner is deleted behind our backs.
|
||||
d->runner->exec(this);
|
||||
}
|
||||
@ -155,4 +155,4 @@ void SearchAction::exec()
|
||||
|
||||
}
|
||||
|
||||
#include "searchaction.moc"
|
||||
#include "searchmatch.moc"
|
@ -30,7 +30,7 @@ namespace Plasma
|
||||
class SearchContext;
|
||||
class AbstractRunner;
|
||||
|
||||
class PLASMA_EXPORT SearchAction /*: public QAction*/
|
||||
class PLASMA_EXPORT SearchMatch /*: public QAction*/
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
||||
@ -39,8 +39,8 @@ class PLASMA_EXPORT SearchAction /*: public QAction*/
|
||||
ExactMatch,
|
||||
PossibleMatch };
|
||||
|
||||
SearchAction(SearchContext *search, AbstractRunner *runner);
|
||||
~SearchAction();
|
||||
SearchMatch(SearchContext *search, AbstractRunner *runner);
|
||||
~SearchMatch();
|
||||
|
||||
/**
|
||||
* Sets the type of match this action represents.
|
||||
@ -100,7 +100,7 @@ class PLASMA_EXPORT SearchAction /*: public QAction*/
|
||||
QIcon icon() const;
|
||||
bool isEnabled() const;
|
||||
|
||||
bool operator<(const SearchAction& other) const;
|
||||
bool operator<(const SearchMatch& other) const;
|
||||
|
||||
//Pending a better solution, changing this to public
|
||||
// public Q_SLOTS:
|
Loading…
x
Reference in New Issue
Block a user