2008-05-01 09:51:59 +02:00
|
|
|
/*
|
2008-09-11 08:37:09 +02:00
|
|
|
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright (C) 2007 Ryan P. Bitanga <ryan.bitanga@gmail.com>
|
|
|
|
* Copyright (C) 2008 Jordi Polo <mumismo@gmail.com>
|
2008-05-01 09:51:59 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2008-08-06 11:19:29 +02:00
|
|
|
#ifndef PLASMA_RUNNERMANAGER_H
|
|
|
|
#define PLASMA_RUNNERMANAGER_H
|
2008-05-01 09:51:59 +02:00
|
|
|
|
|
|
|
#include <QtCore/QList>
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
#include "abstractrunner.h"
|
|
|
|
|
2008-05-19 19:02:15 +02:00
|
|
|
class KConfigGroup;
|
|
|
|
|
2008-05-01 09:51:59 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
2008-05-02 20:46:05 +02:00
|
|
|
class QueryMatch;
|
2008-05-01 09:51:59 +02:00
|
|
|
class AbstractRunner;
|
2008-09-11 08:37:09 +02:00
|
|
|
class RunnerContext;
|
2008-07-01 20:56:43 +02:00
|
|
|
class RunnerManagerPrivate;
|
2008-05-01 19:42:34 +02:00
|
|
|
|
2008-05-01 09:51:59 +02:00
|
|
|
/**
|
2008-08-25 19:47:48 +02:00
|
|
|
* @class RunnerManager plasma/runnermanager.h <Plasma/RunnerManager>
|
|
|
|
*
|
2008-05-01 09:51:59 +02:00
|
|
|
* @short The RunnerManager class decides what installed runners are runnable,
|
|
|
|
* and their ratings. It is the main proxy to the runners.
|
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT RunnerManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2008-05-01 19:42:34 +02:00
|
|
|
|
2008-05-01 09:51:59 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
explicit RunnerManager(QObject *parent=0);
|
2008-09-11 08:37:09 +02:00
|
|
|
explicit RunnerManager(KConfigGroup &config, QObject *parent=0);
|
2008-05-01 09:51:59 +02:00
|
|
|
~RunnerManager();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Finds and returns a loaded runner or NULL
|
|
|
|
* @arg name the name of the runner
|
2008-09-11 08:37:09 +02:00
|
|
|
* @return Pointer to the runner
|
2008-05-01 09:51:59 +02:00
|
|
|
*/
|
|
|
|
AbstractRunner* runner(const QString &name) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the current context
|
|
|
|
* @return pointer to the current context
|
|
|
|
*/
|
2008-05-01 20:40:10 +02:00
|
|
|
RunnerContext* searchContext() const;
|
2008-05-01 09:51:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves all available matches found so far for the previously launched query
|
|
|
|
* @return List of matches
|
|
|
|
*/
|
2008-05-09 05:49:11 +02:00
|
|
|
QList<QueryMatch> matches() const;
|
2008-05-01 19:42:34 +02:00
|
|
|
|
2008-05-01 09:51:59 +02:00
|
|
|
/**
|
|
|
|
* Runs a given match
|
2008-05-12 06:53:42 +02:00
|
|
|
* @arg match the match to be executed
|
2008-05-01 09:51:59 +02:00
|
|
|
*/
|
2008-05-09 05:49:11 +02:00
|
|
|
void run(const QueryMatch &match);
|
2008-05-01 09:51:59 +02:00
|
|
|
|
2008-05-12 06:53:42 +02:00
|
|
|
/**
|
|
|
|
* Runs a given match
|
|
|
|
* @arg id the id of the match to run
|
|
|
|
*/
|
|
|
|
void run(const QString &id);
|
|
|
|
|
2008-05-10 01:14:00 +02:00
|
|
|
/**
|
|
|
|
* @return the current query term
|
|
|
|
*/
|
|
|
|
QString query() const;
|
|
|
|
|
2008-05-19 19:02:15 +02:00
|
|
|
/**
|
|
|
|
* Causes a reload of the current configuration
|
|
|
|
*/
|
|
|
|
void reloadConfiguration();
|
|
|
|
|
2008-05-01 09:51:59 +02:00
|
|
|
public Q_SLOTS:
|
|
|
|
/**
|
2008-09-11 08:37:09 +02:00
|
|
|
* Launch a query, this will create threads and return inmediately.
|
|
|
|
* When the information will be available can be known using the
|
2008-05-06 21:52:50 +02:00
|
|
|
* matchesChanged signal.
|
|
|
|
*
|
2008-05-01 09:51:59 +02:00
|
|
|
* @arg term the term we want to find matches for
|
2008-09-11 08:37:09 +02:00
|
|
|
* @arg runner optional, if only one specific runner is to be used
|
2008-05-01 09:51:59 +02:00
|
|
|
*/
|
2008-09-11 08:37:09 +02:00
|
|
|
void launchQuery(const QString &term, const QString &runnerName);
|
2008-05-10 01:14:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience version of above
|
|
|
|
*/
|
|
|
|
void launchQuery(const QString &term);
|
2008-05-01 09:51:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute a query, this method will only return when the query is executed
|
|
|
|
* This means that the method may be dangerous as it wait a variable amount
|
|
|
|
* of time for the runner to finish.
|
|
|
|
* The runner parameter is mandatory, to avoid launching unwanted runners.
|
|
|
|
* @arg term the term we want to find matches for
|
|
|
|
* @arg runner the runner we will use, it is mandatory
|
|
|
|
* @return 0 if nothing was launched, 1 if launched.
|
|
|
|
*/
|
2008-09-11 08:37:09 +02:00
|
|
|
bool execQuery(const QString &term, const QString &runnerName);
|
2008-05-01 09:51:59 +02:00
|
|
|
|
2008-05-09 19:19:27 +02:00
|
|
|
/**
|
2008-05-10 01:14:00 +02:00
|
|
|
* Convenience version of above
|
2008-05-09 19:19:27 +02:00
|
|
|
*/
|
2008-05-10 01:14:00 +02:00
|
|
|
bool execQuery(const QString &term);
|
2008-05-09 19:19:27 +02:00
|
|
|
|
2008-05-01 09:51:59 +02:00
|
|
|
/**
|
|
|
|
* Reset the current data and stops the query
|
|
|
|
*/
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
2008-05-09 07:32:15 +02:00
|
|
|
* Emitted each time a new match is added to the list
|
2008-05-01 09:51:59 +02:00
|
|
|
*/
|
2008-05-09 05:49:11 +02:00
|
|
|
void matchesChanged(const QList<Plasma::QueryMatch> &matches);
|
2008-05-01 19:42:34 +02:00
|
|
|
|
2008-05-01 09:51:59 +02:00
|
|
|
private:
|
2008-05-07 18:33:10 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void scheduleMatchesChanged())
|
2008-05-06 23:25:51 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void matchesChanged())
|
2008-05-09 19:19:27 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void jobDone(ThreadWeaver::Job*))
|
2008-05-07 18:33:10 +02:00
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
RunnerManagerPrivate * const d;
|
|
|
|
|
|
|
|
friend class RunnerManagerPrivate;
|
2008-05-01 09:51:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|