plasma-framework/scripting/runnerscript.h
Aaron J. Seigo 2954087e8d * eliminate the three search lists and have just one
* remove add*Match since they broke the pattern of usage (who owns the match? do you have to add it again? etc..)
* add addMatch to compliment addMatches for those runners that just ever have one match
* make the default SearchMatch type Possible rather than Exact (making Exact and Informational the exceptions, which matches usage patterns)
* const'ify the API a bit better

generally more performant, lower memory usage and clearer API having seen what is beign done in the runners. also makes it a bit easier to turn the Matches into a qt model

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=776931
2008-02-19 03:59:21 +00:00

83 lines
2.4 KiB
C++

/*
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_RUNNERSCRIPT_H
#define PLASMA_RUNNERSCRIPT_H
#include <plasma/plasma_export.h>
#include <plasma/scripting/scriptengine.h>
namespace Plasma
{
class AbstractRunner;
class SearchContext;
class SearchMatch;
class PLASMA_EXPORT RunnerScript : public ScriptEngine
{
Q_OBJECT
public:
/**
* Default constructor for a RunnerScript.
* Subclasses should not attempt to access the Plasma::AbstractRunner
* associated with this RunnerScript in the constructor. All
* such set up that requires the AbstractRunner itself should be done
* in the init() method.
*/
explicit RunnerScript(QObject *parent = 0);
~RunnerScript();
/**
* Sets the Plasma::AbstractRunner associated with this RunnerScript
*/
void setRunner(AbstractRunner *runner);
/**
* Returns the Plasma::AbstractRunner associated with this script component
*/
AbstractRunner* runner() const;
/**
* Called when the script should create SearchMatch instances through
* SearchContext::addInformationalMatch, SearchContext::addExactMatch, and
* SearchContext::addPossibleMatch.
*/
void match(const Plasma::SearchContext *search);
/**
* Called whenever an exact or possible match associated with this
* runner is triggered.
*/
void exec(const Plasma::SearchContext *search, const Plasma::SearchMatch *action);
private:
class Private;
Private * const d;
};
#define K_EXPORT_PLASMA_RUNNERSCRIPTENGINE(libname, classname) \
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
K_EXPORT_PLUGIN(factory("plasma_runnerscriptengine_" #libname))
} //Plasma namespace
#endif