2006-04-13 02:11:16 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
|
2006-04-13 02:11:16 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-08-06 13:20:02 +02:00
|
|
|
* 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.
|
2006-04-13 02:11:16 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2007-05-20 22:36:59 +02:00
|
|
|
#ifndef PLASMA_DATAENGINE_H
|
|
|
|
#define PLASMA_DATAENGINE_H
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2007-05-21 16:28:03 +02:00
|
|
|
#include <QtCore/QHash>
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtCore/QStringList>
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2008-03-02 03:18:10 +01:00
|
|
|
#include <KDE/KGenericFactory>
|
|
|
|
#include <KDE/KService>
|
2007-05-24 22:01:12 +02:00
|
|
|
|
2008-07-17 03:27:43 +02:00
|
|
|
#include <plasma/version.h>
|
2007-09-12 19:53:54 +02:00
|
|
|
#include <plasma/plasma.h>
|
2007-03-01 00:35:26 +01:00
|
|
|
|
2006-04-13 02:11:16 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-07-23 02:22:16 +02:00
|
|
|
class DataContainer;
|
2008-02-04 05:41:40 +01:00
|
|
|
class DataEngineScript;
|
2008-04-13 17:01:46 +02:00
|
|
|
class Package;
|
2008-05-18 06:27:54 +02:00
|
|
|
class Service;
|
2008-07-01 20:56:43 +02:00
|
|
|
class DataEnginePrivate;
|
2007-05-23 08:38:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @class DataEngine
|
|
|
|
* @brief Data provider for plasmoids (Plasma plugins)
|
|
|
|
*
|
|
|
|
* This is the base class for DataEngines, which provide access to bodies of
|
|
|
|
* data via a common and consistent interface. The common use of a DataEngine
|
|
|
|
* is to provide data to a widget for display. This allows a user interface
|
|
|
|
* element to show all sorts of data: as long as there is a DataEngine, the
|
|
|
|
* data is retrievable.
|
|
|
|
*
|
2007-05-23 09:13:00 +02:00
|
|
|
* DataEngines are loaded as plugins on demand and provide zero, one or more
|
|
|
|
* data sources which are identified by name. For instance, a network
|
|
|
|
* DataEngine might provide a data source for each network interface.
|
2007-05-23 08:38:44 +02:00
|
|
|
**/
|
2007-05-20 22:13:46 +02:00
|
|
|
class PLASMA_EXPORT DataEngine : public QObject
|
2006-04-13 02:11:16 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2007-08-04 14:46:29 +02:00
|
|
|
Q_PROPERTY( QStringList sources READ sources )
|
|
|
|
Q_PROPERTY( bool valid READ isValid )
|
|
|
|
Q_PROPERTY( QString icon READ icon WRITE setIcon )
|
2006-04-13 02:11:16 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef QHash<QString, DataEngine*> Dict;
|
2007-05-20 22:36:59 +02:00
|
|
|
typedef QHash<QString, QVariant> Data;
|
2007-05-21 06:29:00 +02:00
|
|
|
typedef QHashIterator<QString, QVariant> DataIterator;
|
2007-07-23 02:22:16 +02:00
|
|
|
typedef QHash<QString, DataContainer*> SourceDict;
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2007-05-23 08:38:44 +02:00
|
|
|
/**
|
2008-02-25 12:24:37 +01:00
|
|
|
* Constructor.
|
2007-05-23 08:38:44 +02:00
|
|
|
*
|
|
|
|
* @param parent The parent object.
|
2008-02-25 12:24:37 +01:00
|
|
|
* @param service pointer to the service that describes the engine
|
2007-05-23 08:38:44 +02:00
|
|
|
**/
|
2008-02-25 12:24:37 +01:00
|
|
|
explicit DataEngine(QObject* parent = 0, KService::Ptr service = KService::Ptr(0));
|
2008-02-04 05:41:40 +01:00
|
|
|
DataEngine(QObject* parent, const QVariantList& args);
|
2008-05-18 06:27:54 +02:00
|
|
|
~DataEngine();
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2008-03-06 06:18:36 +01:00
|
|
|
/**
|
|
|
|
* This method is called when the DataEngine is started. When this
|
|
|
|
* method is called the DataEngine is fully constructed and ready to be
|
|
|
|
* used. This method should be reimplemented by DataEngine subclasses
|
|
|
|
* which have the need to perform a startup routine.
|
|
|
|
**/
|
|
|
|
virtual void init();
|
|
|
|
|
2007-05-23 08:38:44 +02:00
|
|
|
/**
|
2007-06-13 06:56:49 +02:00
|
|
|
* @return a list of all the data sources available via this DataEngine
|
|
|
|
* Whether these sources are currently available (which is what
|
|
|
|
* the default implementation provides) or not is up to the
|
|
|
|
* DataEngine to decide.
|
2007-05-23 08:38:44 +02:00
|
|
|
**/
|
2007-06-13 06:56:49 +02:00
|
|
|
virtual QStringList sources() const;
|
2007-05-23 08:38:44 +02:00
|
|
|
|
2008-05-18 06:27:54 +02:00
|
|
|
/**
|
|
|
|
* @param source the source to targe the Service at
|
|
|
|
* @return a Service that has the source as a destination. The service
|
|
|
|
* is parented to the DataEngine, but may be deleted by the
|
|
|
|
* caller when finished with it
|
|
|
|
*/
|
|
|
|
virtual Service* serviceForSource(const QString &source);
|
|
|
|
|
2008-02-04 05:41:40 +01:00
|
|
|
/**
|
|
|
|
* Returns the engine name for the DataEngine
|
|
|
|
*/
|
2008-04-24 00:40:03 +02:00
|
|
|
QString name() const;
|
2008-02-04 05:41:40 +01:00
|
|
|
|
2007-05-23 08:38:44 +02:00
|
|
|
/**
|
|
|
|
* Connects a source to an object for data updates. The object must
|
|
|
|
* have a slot with the following signature:
|
|
|
|
*
|
2007-11-06 08:20:08 +01:00
|
|
|
* dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
2007-05-23 08:38:44 +02:00
|
|
|
*
|
|
|
|
* The data is a QHash of QVariants keyed by QString names, allowing
|
|
|
|
* one data source to provide sets of related data.
|
|
|
|
*
|
|
|
|
* @param source the name of the data source
|
|
|
|
* @param visualization the object to connect the data source to
|
2008-04-24 04:21:22 +02:00
|
|
|
* @param pollingInterval the frequency, in milliseconds, with which to check for updates;
|
2007-09-11 02:49:51 +02:00
|
|
|
* a value of 0 (the default) means to update only
|
|
|
|
* when there is new data spontaneously generated
|
|
|
|
* (e.g. by the engine); any other value results in
|
|
|
|
* periodic updates from this source. This value is
|
|
|
|
* per-visualization and can be handy for items that require
|
|
|
|
* constant updates such as scrolling graphs or clocks.
|
2008-04-14 16:37:04 +02:00
|
|
|
* If the data has not changed, no update will be sent.
|
|
|
|
* @param intervalAlignment the number of ms to align the interval to
|
2007-05-23 08:38:44 +02:00
|
|
|
**/
|
2007-09-12 19:53:54 +02:00
|
|
|
Q_INVOKABLE void connectSource(const QString& source, QObject* visualization,
|
2008-04-24 04:21:22 +02:00
|
|
|
uint pollingInterval = 0,
|
2007-09-12 19:53:54 +02:00
|
|
|
Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
|
2007-06-10 07:39:27 +02:00
|
|
|
|
2007-05-28 07:43:54 +02:00
|
|
|
/**
|
2008-03-20 21:54:51 +01:00
|
|
|
* Connects all currently existing sources to an object for data updates.
|
|
|
|
* The object must have a slot with the following signature:
|
2007-05-28 07:43:54 +02:00
|
|
|
*
|
2008-03-20 21:54:51 +01:00
|
|
|
* SLOT(dataUpdated(QString,Plasma::DataEngine::Data))
|
2007-05-28 07:43:54 +02:00
|
|
|
*
|
|
|
|
* The data is a QHash of QVariants keyed by QString names, allowing
|
|
|
|
* one data source to provide sets of related data.
|
|
|
|
*
|
2007-09-12 19:04:21 +02:00
|
|
|
* This method may be called multiple times for the same visualization
|
2008-04-24 04:21:22 +02:00
|
|
|
* without side-effects. This can be useful to change the pollingInterval.
|
2007-09-12 19:04:21 +02:00
|
|
|
*
|
2008-03-20 21:54:51 +01:00
|
|
|
* Note that this method does not automatically connect sources that
|
|
|
|
* may appear later on. Connecting and responding to the sourceAdded sigal
|
|
|
|
* is still required to achieve that.
|
|
|
|
*
|
2007-05-28 07:43:54 +02:00
|
|
|
* @param visualization the object to connect the data source to
|
2008-04-24 04:21:22 +02:00
|
|
|
* @param pollingInterval the frequency, in milliseconds, with which to check for updates;
|
2007-09-11 02:49:51 +02:00
|
|
|
* a value of 0 (the default) means to update only
|
|
|
|
* when there is new data spontaneously generated
|
|
|
|
* (e.g. by the engine); any other value results in
|
|
|
|
* periodic updates from this source. This value is
|
|
|
|
* per-visualization and can be handy for items that require
|
|
|
|
* constant updates such as scrolling graphs or clocks.
|
2008-04-14 16:37:04 +02:00
|
|
|
* If the data has not changed, no update will be sent.
|
|
|
|
* @param intervalAlignment the number of ms to align the interval to
|
2007-09-11 02:49:51 +02:00
|
|
|
**/
|
2008-04-24 04:21:22 +02:00
|
|
|
Q_INVOKABLE void connectAllSources(QObject* visualization, uint pollingInterval = 0,
|
2007-09-12 19:53:54 +02:00
|
|
|
Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
|
2007-09-11 02:49:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Disconnects a source to an object that was receiving data updates.
|
|
|
|
*
|
|
|
|
* @param source the name of the data source
|
|
|
|
* @param visualization the object to connect the data source to
|
2007-05-28 07:43:54 +02:00
|
|
|
**/
|
2007-09-11 02:49:51 +02:00
|
|
|
Q_INVOKABLE void disconnectSource(const QString& source, QObject* visualization) const;
|
2007-05-28 07:43:54 +02:00
|
|
|
|
2007-08-29 04:57:04 +02:00
|
|
|
/**
|
|
|
|
* Retrevies a pointer to the DataContainer for a given source. This method
|
2008-02-04 05:41:40 +01:00
|
|
|
* should not be used if possible. An exception is for script engines that
|
2007-08-29 04:57:04 +02:00
|
|
|
* can not provide a QMetaObject as required by connectSource for the initial
|
2007-11-06 08:20:08 +01:00
|
|
|
* call to dataUpdated. Using this method, such engines can provide their own
|
2007-08-29 04:57:04 +02:00
|
|
|
* connectSource API.
|
|
|
|
*
|
2008-03-28 08:46:49 +01:00
|
|
|
* @param source the name of the source.
|
2007-08-29 04:57:04 +02:00
|
|
|
* @return pointer to a DataContainer, or zero on failure
|
|
|
|
**/
|
|
|
|
Q_INVOKABLE DataContainer* containerForSource(const QString &source);
|
|
|
|
|
2007-05-23 08:38:44 +02:00
|
|
|
/**
|
|
|
|
* Gets the Data associated with a data source.
|
|
|
|
*
|
|
|
|
* The data is a QHash of QVariants keyed by QString names, allowing
|
|
|
|
* one data source to provide sets of related data.
|
|
|
|
*
|
|
|
|
* @param source the data source to retrieve the data for
|
|
|
|
* @return the Data associated with the source; if the source doesn't
|
|
|
|
* exist an empty data set is returned
|
|
|
|
**/
|
2007-08-28 16:26:31 +02:00
|
|
|
Q_INVOKABLE DataEngine::Data query(const QString& source) const;
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2007-06-03 00:23:26 +02:00
|
|
|
/**
|
|
|
|
* Returns true if this engine is valid, otherwise returns false
|
|
|
|
**/
|
|
|
|
bool isValid() const;
|
|
|
|
|
2007-11-18 02:32:11 +01:00
|
|
|
/**
|
|
|
|
* Returns true if the data engine is empty, which is to say that it has no
|
|
|
|
* data sources currently.
|
|
|
|
*/
|
|
|
|
bool isEmpty() const;
|
|
|
|
|
2008-04-24 22:16:21 +02:00
|
|
|
/**
|
2008-04-25 17:52:13 +02:00
|
|
|
* Returns the maximum number of sources this DataEngine will have
|
2008-04-24 22:16:21 +02:00
|
|
|
* at any given time.
|
|
|
|
*
|
|
|
|
* @return the maximum number of sources; zero means no limit.
|
|
|
|
*/
|
2008-04-25 17:52:13 +02:00
|
|
|
uint maxSourceCount() const;
|
2008-04-24 22:16:21 +02:00
|
|
|
|
2007-05-23 09:13:00 +02:00
|
|
|
/**
|
|
|
|
* @return the name of the icon for this data engine; and empty string
|
|
|
|
* is returned if there is no associated icon.
|
|
|
|
**/
|
2007-05-23 10:27:09 +02:00
|
|
|
QString icon() const;
|
|
|
|
|
2008-04-13 17:01:46 +02:00
|
|
|
/**
|
|
|
|
* Accessor for the associated Package object if any.
|
|
|
|
*
|
|
|
|
* @return the Package object, or 0 if none
|
|
|
|
**/
|
|
|
|
const Package* package() const;
|
|
|
|
|
2007-05-22 04:49:54 +02:00
|
|
|
Q_SIGNALS:
|
2007-05-23 08:38:44 +02:00
|
|
|
/**
|
|
|
|
* Emitted when a new data source is created
|
|
|
|
* @param source the name of the new data source
|
|
|
|
**/
|
2008-04-24 09:15:26 +02:00
|
|
|
void sourceAdded(const QString& source);
|
2007-05-23 08:38:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Emitted when a data source is removed.
|
|
|
|
* @param source the name of the data source that was removed
|
|
|
|
**/
|
2007-06-13 06:56:49 +02:00
|
|
|
void sourceRemoved(const QString& source);
|
2007-05-22 04:49:54 +02:00
|
|
|
|
2006-04-13 02:11:16 +02:00
|
|
|
protected:
|
2007-06-10 06:03:50 +02:00
|
|
|
/**
|
|
|
|
* When a source that does not currently exist is requested by the
|
|
|
|
* consumer, this method is called to give the DataEngine the
|
|
|
|
* opportunity to create one.
|
|
|
|
*
|
2007-07-02 12:16:39 +02:00
|
|
|
* The name of the data source (e.g. the source parameter passed into
|
2008-04-24 09:32:46 +02:00
|
|
|
* setData) must be the same as the name passed to sourceRequestEvent
|
2007-07-02 12:16:39 +02:00
|
|
|
* otherwise the requesting visualization may not receive notice of a
|
|
|
|
* data update.
|
|
|
|
*
|
2007-09-18 23:21:05 +02:00
|
|
|
* If the source can not be populated with data immediately (e.g. due to
|
|
|
|
* an asynchronous data acquisition method such as an HTTP request)
|
|
|
|
* the source must still be created, even if it is empty. This can
|
|
|
|
* be accomplished in these cases with the follow line:
|
|
|
|
*
|
|
|
|
* setData(name, DataEngine::Data());
|
|
|
|
*
|
2008-03-28 08:46:49 +01:00
|
|
|
* @param source the name of the source that has been requested
|
2007-07-23 02:22:16 +02:00
|
|
|
* @return true if a DataContainer was set up, false otherwise
|
2007-06-10 06:03:50 +02:00
|
|
|
*/
|
2008-04-24 09:32:46 +02:00
|
|
|
virtual bool sourceRequestEvent(const QString &source);
|
2007-06-10 06:03:50 +02:00
|
|
|
|
2007-09-11 02:49:51 +02:00
|
|
|
/**
|
|
|
|
* Called by internal updating mechanisms to trigger the engine
|
|
|
|
* to refresh the data contained in a given source. Reimplement this
|
2008-04-24 04:21:22 +02:00
|
|
|
* method when using facilities such as setPollingInterval.
|
|
|
|
* @see setPollingInterval
|
2007-09-11 02:49:51 +02:00
|
|
|
*
|
|
|
|
* @param source the name of the source that should be updated
|
|
|
|
* @return true if the data was changed, or false if there was no
|
|
|
|
* change or if the change will occur later
|
|
|
|
**/
|
2008-04-24 10:01:18 +02:00
|
|
|
virtual bool updateSourceEvent(const QString& source);
|
2007-09-11 02:49:51 +02:00
|
|
|
|
2007-05-23 08:38:44 +02:00
|
|
|
/**
|
|
|
|
* Sets a value for a data source. If the source
|
|
|
|
* doesn't exist then it is created.
|
|
|
|
*
|
|
|
|
* @param source the name of the data source
|
|
|
|
* @param value the data to associated with the source
|
|
|
|
**/
|
2007-06-10 06:03:50 +02:00
|
|
|
void setData(const QString &source, const QVariant &value);
|
2007-05-23 08:38:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a value for a data source. If the source
|
|
|
|
* doesn't exist then it is created.
|
|
|
|
*
|
|
|
|
* @param source the name of the data source
|
|
|
|
* @param key the key to use for the data
|
|
|
|
* @param value the data to associated with the source
|
|
|
|
**/
|
2007-05-19 10:38:46 +02:00
|
|
|
void setData(const QString& source, const QString& key, const QVariant& value);
|
2007-05-23 08:38:44 +02:00
|
|
|
|
2007-07-17 20:08:57 +02:00
|
|
|
/**
|
|
|
|
* Adds a set of data to a data source. If the source
|
|
|
|
* doesn't exist then it is created.
|
|
|
|
*
|
|
|
|
* @param source the name of the data source
|
|
|
|
* @param data the data to add to the source
|
|
|
|
**/
|
|
|
|
void setData(const QString &source, const Data &data);
|
|
|
|
|
2007-07-09 11:33:15 +02:00
|
|
|
/**
|
2008-04-24 10:10:30 +02:00
|
|
|
* Removes all the data associated with a data source.
|
2007-07-09 11:33:15 +02:00
|
|
|
*
|
|
|
|
* @param source the name of the data source
|
|
|
|
**/
|
2008-04-24 10:10:30 +02:00
|
|
|
void removeAllData(const QString& source);
|
2007-07-09 11:33:15 +02:00
|
|
|
|
2007-06-17 19:38:54 +02:00
|
|
|
/**
|
|
|
|
* Removes a data entry from a source
|
|
|
|
*
|
|
|
|
* @param source the name of the data source
|
|
|
|
* @param key the data entry to remove
|
|
|
|
**/
|
|
|
|
void removeData(const QString& source, const QString& key);
|
|
|
|
|
2007-05-23 08:38:44 +02:00
|
|
|
/**
|
|
|
|
* Adds an already constructed data source. The DataEngine takes
|
2008-07-29 05:28:25 +02:00
|
|
|
* ownership of the DataContainer object. The objectName of the source
|
|
|
|
* is used for the source name.
|
|
|
|
*
|
2007-07-23 02:22:16 +02:00
|
|
|
* @param source the DataContainer to add to the DataEngine
|
2007-05-23 08:38:44 +02:00
|
|
|
**/
|
2007-07-23 02:22:16 +02:00
|
|
|
void addSource(DataContainer* source);
|
2007-05-23 08:38:44 +02:00
|
|
|
|
2008-04-24 22:16:21 +02:00
|
|
|
/**
|
|
|
|
* Sets an upper limit on the number of data sources to keep in this engine.
|
|
|
|
* If the limit is exceeded, then the oldest data source, as defined by last
|
|
|
|
* update, is dropped.
|
|
|
|
*
|
|
|
|
* @param limit the maximum number of sources to keep active
|
|
|
|
**/
|
2008-04-25 17:52:13 +02:00
|
|
|
void setMaxSourceCount(uint limit);
|
2008-04-24 22:16:21 +02:00
|
|
|
|
2007-09-11 02:49:51 +02:00
|
|
|
/**
|
|
|
|
* Sets the minimum amount of time, in milliseconds, that must pass between
|
|
|
|
* successive updates of data. This can help prevent too many updates happening
|
|
|
|
* due to multiple update requests coming in, which can be useful for
|
|
|
|
* expensive (time- or resource-wise) update mechanisms.
|
|
|
|
*
|
2008-03-28 08:46:49 +01:00
|
|
|
* @param minimumMs the minimum time lapse, in milliseconds, between updates.
|
2007-09-11 02:49:51 +02:00
|
|
|
* A value less than 0 means to never perform automatic updates,
|
|
|
|
* a value of 0 means update immediately on every update request,
|
|
|
|
* a value >0 will result in a minimum time lapse being enforced.
|
|
|
|
**/
|
2008-04-24 04:21:22 +02:00
|
|
|
void setMinimumPollingInterval(int minimumMs);
|
2007-09-11 02:49:51 +02:00
|
|
|
|
|
|
|
/**
|
2008-04-24 04:21:22 +02:00
|
|
|
* @return the minimum time between updates. @see setMinimumPollingInterval
|
2007-09-11 02:49:51 +02:00
|
|
|
**/
|
2008-04-24 04:21:22 +02:00
|
|
|
int minimumPollingInterval() const;
|
2007-09-11 02:49:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up an internal update tick for all data sources. On every update,
|
2008-04-24 10:01:18 +02:00
|
|
|
* updateSourceEvent will be called for each applicable source.
|
|
|
|
* @see updateSourceEvent
|
2007-09-11 02:49:51 +02:00
|
|
|
*
|
|
|
|
* @param frequency the time, in milliseconds, between updates. A value of 0
|
|
|
|
* will stop internally triggered updates.
|
|
|
|
**/
|
2008-04-24 04:21:22 +02:00
|
|
|
void setPollingInterval(uint frequency);
|
2007-09-11 02:49:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current update frequency.
|
2008-04-24 04:21:22 +02:00
|
|
|
* @see setPollingInterval
|
2007-09-11 02:49:51 +02:00
|
|
|
NOTE: This is not implemented to prevent having to store the value internally.
|
|
|
|
When there is a good use case for needing access to this value, we can
|
|
|
|
add another member to the Private class and add this method.
|
2008-04-24 04:21:22 +02:00
|
|
|
uint pollingInterval();
|
2007-09-11 02:49:51 +02:00
|
|
|
**/
|
2007-05-23 08:38:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all data sources
|
|
|
|
**/
|
2008-04-24 08:38:14 +02:00
|
|
|
void removeAllSources();
|
2006-04-13 02:11:16 +02:00
|
|
|
|
2007-06-03 00:23:26 +02:00
|
|
|
/**
|
|
|
|
* Sets whether or not this engine is valid, e.g. can be used.
|
|
|
|
* In practice, only the internal fall-back engine, the NullEngine
|
|
|
|
* should have need for this.
|
|
|
|
*
|
|
|
|
* @param valid whether or not the engine is valid
|
|
|
|
**/
|
2007-06-04 18:11:55 +02:00
|
|
|
void setValid(bool valid);
|
2007-06-03 00:23:26 +02:00
|
|
|
|
2007-06-10 06:03:50 +02:00
|
|
|
/**
|
2007-07-23 02:22:16 +02:00
|
|
|
* @return the list of active DataContainers.
|
2007-06-10 06:03:50 +02:00
|
|
|
*/
|
2008-04-23 21:57:20 +02:00
|
|
|
SourceDict containerDict() const;
|
2007-06-10 06:03:50 +02:00
|
|
|
|
2007-09-11 02:49:51 +02:00
|
|
|
/**
|
|
|
|
* Reimplemented from QObject
|
|
|
|
**/
|
|
|
|
void timerEvent(QTimerEvent *event);
|
|
|
|
|
2008-04-24 00:40:03 +02:00
|
|
|
/**
|
|
|
|
* Sets the engine name for the DataEngine
|
|
|
|
*/
|
|
|
|
void setName(const QString &name);
|
|
|
|
|
2008-04-24 09:04:03 +02:00
|
|
|
/**
|
|
|
|
* Sets the icon for this data engine
|
|
|
|
**/
|
|
|
|
void setIcon(const QString& icon);
|
|
|
|
|
2007-06-10 06:03:50 +02:00
|
|
|
protected Q_SLOTS:
|
|
|
|
/**
|
2007-07-23 02:22:16 +02:00
|
|
|
* Call this method when you call setData directly on a DataContainer instead
|
2007-07-02 12:16:39 +02:00
|
|
|
* of using the DataEngine::setData methods.
|
2007-11-06 08:20:08 +01:00
|
|
|
* If this method is not called, no dataUpdated(..) signals will be emitted!
|
2007-06-10 06:03:50 +02:00
|
|
|
*/
|
2008-04-24 12:07:34 +02:00
|
|
|
void scheduleSourcesUpdated();
|
2007-05-19 10:38:46 +02:00
|
|
|
|
2007-06-10 07:39:27 +02:00
|
|
|
/**
|
|
|
|
* Removes a data source.
|
|
|
|
* @param source the name of the data source to remove
|
|
|
|
**/
|
2007-06-11 23:10:44 +02:00
|
|
|
void removeSource(const QString& source);
|
2007-06-10 07:39:27 +02:00
|
|
|
|
2006-04-13 02:11:16 +02:00
|
|
|
private:
|
2008-08-02 19:46:32 +02:00
|
|
|
friend class DataEnginePrivate;
|
|
|
|
friend class DataEngineScript;
|
|
|
|
friend class DataEngineManager;
|
|
|
|
friend class NullEngine;
|
|
|
|
|
2008-04-29 03:17:12 +02:00
|
|
|
Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer* source))
|
2008-04-23 23:55:54 +02:00
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
DataEnginePrivate* const d;
|
2006-04-13 02:11:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
2008-07-14 02:06:33 +02:00
|
|
|
/**
|
|
|
|
* Register a data engine when it is contained in a loadable module
|
|
|
|
*/
|
2007-05-20 22:36:59 +02:00
|
|
|
#define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
|
2007-08-29 03:49:44 +02:00
|
|
|
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
2008-07-17 03:27:43 +02:00
|
|
|
K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
|
|
|
|
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
|
|
|
|
2006-04-13 02:11:16 +02:00
|
|
|
#endif // multiple inclusion guard
|
|
|
|
|