mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
plasma: drop everything related to dataengines
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0ac04f8e9f
commit
52a8caa5ee
53 changed files with 41 additions and 3703 deletions
|
@ -462,9 +462,6 @@ install(
|
||||||
Plasma/Containment
|
Plasma/Containment
|
||||||
Plasma/ContainmentActions
|
Plasma/ContainmentActions
|
||||||
Plasma/Corona
|
Plasma/Corona
|
||||||
Plasma/DataContainer
|
|
||||||
Plasma/DataEngine
|
|
||||||
Plasma/DataEngineManager
|
|
||||||
Plasma/Delegate
|
Plasma/Delegate
|
||||||
Plasma/Dialog
|
Plasma/Dialog
|
||||||
Plasma/DialogShadows
|
Plasma/DialogShadows
|
||||||
|
@ -495,8 +492,6 @@ install(
|
||||||
Plasma/ScrollBar
|
Plasma/ScrollBar
|
||||||
Plasma/ScrollWidget
|
Plasma/ScrollWidget
|
||||||
Plasma/Separator
|
Plasma/Separator
|
||||||
Plasma/Service
|
|
||||||
Plasma/ServiceJob
|
|
||||||
Plasma/SignalPlotter
|
Plasma/SignalPlotter
|
||||||
Plasma/Slider
|
Plasma/Slider
|
||||||
Plasma/SpinBox
|
Plasma/SpinBox
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
#include "../../plasma/datacontainer.h"
|
|
|
@ -1 +0,0 @@
|
||||||
#include "../../plasma/dataengine.h"
|
|
|
@ -1 +0,0 @@
|
||||||
#include "../../plasma/dataenginemanager.h"
|
|
|
@ -1 +0,0 @@
|
||||||
#include "../../plasma/service.h"
|
|
|
@ -1 +0,0 @@
|
||||||
#include "../../plasma/servicejob.h"
|
|
|
@ -37,9 +37,6 @@ set(plasma_LIB_SRCS
|
||||||
containmentactions.cpp
|
containmentactions.cpp
|
||||||
containmentactionspluginsconfig.cpp
|
containmentactionspluginsconfig.cpp
|
||||||
corona.cpp
|
corona.cpp
|
||||||
datacontainer.cpp
|
|
||||||
dataengine.cpp
|
|
||||||
dataenginemanager.cpp
|
|
||||||
delegate.cpp
|
delegate.cpp
|
||||||
dialog.cpp
|
dialog.cpp
|
||||||
dialogshadows.cpp
|
dialogshadows.cpp
|
||||||
|
@ -53,8 +50,6 @@ set(plasma_LIB_SRCS
|
||||||
popupapplet.cpp
|
popupapplet.cpp
|
||||||
private/applethandle.cpp
|
private/applethandle.cpp
|
||||||
private/associatedapplicationmanager.cpp
|
private/associatedapplicationmanager.cpp
|
||||||
private/datacontainer_p.cpp
|
|
||||||
private/dataengineconsumer.cpp
|
|
||||||
private/extenderapplet.cpp
|
private/extenderapplet.cpp
|
||||||
private/extenderitemmimedata.cpp
|
private/extenderitemmimedata.cpp
|
||||||
private/nativetabbar.cpp
|
private/nativetabbar.cpp
|
||||||
|
@ -69,8 +64,6 @@ set(plasma_LIB_SRCS
|
||||||
runnercontext.cpp
|
runnercontext.cpp
|
||||||
runnermanager.cpp
|
runnermanager.cpp
|
||||||
runnersyntax.cpp
|
runnersyntax.cpp
|
||||||
service.cpp
|
|
||||||
servicejob.cpp
|
|
||||||
svg.cpp
|
svg.cpp
|
||||||
theme.cpp
|
theme.cpp
|
||||||
tooltipcontent.cpp
|
tooltipcontent.cpp
|
||||||
|
@ -157,9 +150,6 @@ install(
|
||||||
containmentactions.h
|
containmentactions.h
|
||||||
containmentactionspluginsconfig.h
|
containmentactionspluginsconfig.h
|
||||||
corona.h
|
corona.h
|
||||||
datacontainer.h
|
|
||||||
dataengine.h
|
|
||||||
dataenginemanager.h
|
|
||||||
delegate.h
|
delegate.h
|
||||||
dialog.h
|
dialog.h
|
||||||
dialogshadows.h
|
dialogshadows.h
|
||||||
|
@ -176,8 +166,6 @@ install(
|
||||||
runnercontext.h
|
runnercontext.h
|
||||||
runnermanager.h
|
runnermanager.h
|
||||||
runnersyntax.h
|
runnersyntax.h
|
||||||
service.h
|
|
||||||
servicejob.h
|
|
||||||
svg.h
|
svg.h
|
||||||
theme.h
|
theme.h
|
||||||
tooltipcontent.h
|
tooltipcontent.h
|
||||||
|
@ -232,7 +220,6 @@ install(
|
||||||
data/servicetypes/plasma-applet-popupapplet.desktop
|
data/servicetypes/plasma-applet-popupapplet.desktop
|
||||||
data/servicetypes/plasma-containment.desktop
|
data/servicetypes/plasma-containment.desktop
|
||||||
data/servicetypes/plasma-containmentactions.desktop
|
data/servicetypes/plasma-containmentactions.desktop
|
||||||
data/servicetypes/plasma-dataengine.desktop
|
|
||||||
data/servicetypes/plasma-runner.desktop
|
data/servicetypes/plasma-runner.desktop
|
||||||
data/servicetypes/plasma-toolbox.desktop
|
data/servicetypes/plasma-toolbox.desktop
|
||||||
data/servicetypes/plasma-wallpaper.desktop
|
data/servicetypes/plasma-wallpaper.desktop
|
||||||
|
|
|
@ -6,5 +6,4 @@ and its components. This includes applet and extension definitions and loading,
|
||||||
common GUI elements, data and service interaction, search system, etc.
|
common GUI elements, data and service interaction, search system, etc.
|
||||||
|
|
||||||
Domain specific sets of functionality, e.g. for network awareness or sensors,
|
Domain specific sets of functionality, e.g. for network awareness or sensors,
|
||||||
are not found here but as DataEngine, Service, Applet, PackageStructure, etc
|
are not found here but as Applet, PackageStructure, etc plugins.
|
||||||
plugins.
|
|
||||||
|
|
|
@ -282,11 +282,6 @@ void AbstractRunner::init()
|
||||||
reloadConfiguration();
|
reloadConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine *AbstractRunner::dataEngine(const QString &name) const
|
|
||||||
{
|
|
||||||
return d->dataEngine(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AbstractRunner::isMatchingSuspended() const
|
bool AbstractRunner::isMatchingSuspended() const
|
||||||
{
|
{
|
||||||
return d->suspendMatching;
|
return d->suspendMatching;
|
||||||
|
|
|
@ -39,7 +39,6 @@ class KCompletion;
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class DataEngine;
|
|
||||||
class QueryMatch;
|
class QueryMatch;
|
||||||
class AbstractRunnerPrivate;
|
class AbstractRunnerPrivate;
|
||||||
|
|
||||||
|
@ -397,27 +396,6 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
||||||
*/
|
*/
|
||||||
void setSyntaxes(const QList<RunnerSyntax> &syns);
|
void setSyntaxes(const QList<RunnerSyntax> &syns);
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given DataEngine
|
|
||||||
*
|
|
||||||
* Tries to load the data engine given by @p name. Each engine is
|
|
||||||
* only loaded once, and that instance is re-used on all subsequent
|
|
||||||
* requests.
|
|
||||||
*
|
|
||||||
* If the data engine was not found, an invalid data engine is returned
|
|
||||||
* (see DataEngine::isValid()).
|
|
||||||
*
|
|
||||||
* Note that you should <em>not</em> delete the returned engine.
|
|
||||||
*
|
|
||||||
* @param name Name of the data engine to load
|
|
||||||
* @return pointer to the data engine if it was loaded,
|
|
||||||
* or an invalid data engine if the requested engine
|
|
||||||
* could not be loaded
|
|
||||||
*
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Reimplement this slot to run any initialization routines on first load.
|
* Reimplement this slot to run any initialization routines on first load.
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "abstracttoolbox.h"
|
#include "abstracttoolbox.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
#include "dataenginemanager.h"
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "extenders/extender.h"
|
#include "extenders/extender.h"
|
||||||
#include "extenders/extenderitem.h"
|
#include "extenders/extenderitem.h"
|
||||||
|
@ -54,7 +53,6 @@
|
||||||
#include "private/package_p.h"
|
#include "private/package_p.h"
|
||||||
#include "private/packages_p.h"
|
#include "private/packages_p.h"
|
||||||
#include "private/popupapplet_p.h"
|
#include "private/popupapplet_p.h"
|
||||||
#include "private/service_p.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
@ -602,11 +600,6 @@ void AppletPrivate::destroyMessageOverlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine *Applet::dataEngine(const QString &name) const
|
|
||||||
{
|
|
||||||
return d->dataEngine(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
QGraphicsView *Applet::view() const
|
QGraphicsView *Applet::view() const
|
||||||
{
|
{
|
||||||
// It's assumed that we won't be visible on more than one view here.
|
// It's assumed that we won't be visible on more than one view here.
|
||||||
|
@ -2251,31 +2244,30 @@ bool Applet::isContainment() const
|
||||||
// PRIVATE CLASS IMPLEMENTATION
|
// PRIVATE CLASS IMPLEMENTATION
|
||||||
|
|
||||||
AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet)
|
AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet)
|
||||||
: appletId(uniqueID),
|
: appletId(uniqueID),
|
||||||
q(applet),
|
q(applet),
|
||||||
service(0),
|
preferredBackgroundHints(Applet::StandardBackground),
|
||||||
preferredBackgroundHints(Applet::StandardBackground),
|
backgroundHints(Applet::NoBackground),
|
||||||
backgroundHints(Applet::NoBackground),
|
aspectRatioMode(Plasma::KeepAspectRatio),
|
||||||
aspectRatioMode(Plasma::KeepAspectRatio),
|
immutability(Mutable),
|
||||||
immutability(Mutable),
|
appletDescription(info ? *info : KPluginInfo(service)),
|
||||||
appletDescription(info ? *info : KPluginInfo(service)),
|
background(0),
|
||||||
background(0),
|
mainConfig(0),
|
||||||
mainConfig(0),
|
pendingConstraints(NoConstraint),
|
||||||
pendingConstraints(NoConstraint),
|
messageOverlay(0),
|
||||||
messageOverlay(0),
|
messageOverlayProxy(0),
|
||||||
messageOverlayProxy(0),
|
busyWidget(0),
|
||||||
busyWidget(0),
|
actions(AppletPrivate::defaultActions(applet)),
|
||||||
actions(AppletPrivate::defaultActions(applet)),
|
activationAction(0),
|
||||||
activationAction(0),
|
itemStatus(UnknownStatus),
|
||||||
itemStatus(UnknownStatus),
|
preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored),
|
||||||
preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored),
|
modificationsTimer(0),
|
||||||
modificationsTimer(0),
|
hasConfigurationInterface(false),
|
||||||
hasConfigurationInterface(false),
|
failed(false),
|
||||||
failed(false),
|
isContainment(false),
|
||||||
isContainment(false),
|
transient(false),
|
||||||
transient(false),
|
needsConfig(false),
|
||||||
needsConfig(false),
|
started(false)
|
||||||
started(false)
|
|
||||||
{
|
{
|
||||||
if (appletId == 0) {
|
if (appletId == 0) {
|
||||||
appletId = ++s_maxAppletId;
|
appletId = ++s_maxAppletId;
|
||||||
|
|
|
@ -47,7 +47,6 @@ namespace Plasma
|
||||||
class AppletPrivate;
|
class AppletPrivate;
|
||||||
class Containment;
|
class Containment;
|
||||||
class Context;
|
class Context;
|
||||||
class DataEngine;
|
|
||||||
class Extender;
|
class Extender;
|
||||||
class ExtenderItem;
|
class ExtenderItem;
|
||||||
|
|
||||||
|
@ -59,12 +58,9 @@ class ExtenderItem;
|
||||||
* Applet provides several important roles for add-ons widgets in Plasma.
|
* Applet provides several important roles for add-ons widgets in Plasma.
|
||||||
*
|
*
|
||||||
* First, it is the base class for the plugin system and therefore is the
|
* First, it is the base class for the plugin system and therefore is the
|
||||||
* interface to applets for host applications. It also handles the life time
|
* interface to applets for host applications. It also handles the background
|
||||||
* management of data engines (e.g. all data engines accessed via
|
* painting (allowing for consistent and complex look and feel in just one
|
||||||
* Applet::dataEngine(const QString&) are properly deref'd on Applet
|
* line of code for applets), providing access to the to configuration data.
|
||||||
* destruction), background painting (allowing for consistent and complex
|
|
||||||
* look and feel in just one line of code for applets), providing access to
|
|
||||||
* the to configuration data.
|
|
||||||
*/
|
*/
|
||||||
class PLASMA_EXPORT Applet : public QGraphicsWidget
|
class PLASMA_EXPORT Applet : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
|
@ -158,25 +154,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
||||||
*/
|
*/
|
||||||
KConfigGroup globalConfig() const;
|
KConfigGroup globalConfig() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given DataEngine
|
|
||||||
*
|
|
||||||
* Tries to load the data engine given by @p name. Each engine is
|
|
||||||
* only loaded once, and that instance is re-used on all subsequent
|
|
||||||
* requests.
|
|
||||||
*
|
|
||||||
* If the data engine was not found, an invalid data engine is returned
|
|
||||||
* (see DataEngine::isValid()).
|
|
||||||
*
|
|
||||||
* Note that you should <em>not</em> delete the returned engine.
|
|
||||||
*
|
|
||||||
* @param name Name of the data engine to load
|
|
||||||
* @return pointer to the data engine if it was loaded,
|
|
||||||
* or an invalid data engine if the requested engine
|
|
||||||
* could not be loaded
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the view this widget is visible on, or 0 if none can be found.
|
* Returns the view this widget is visible on, or 0 if none can be found.
|
||||||
* @warning do NOT assume this will always return a view!
|
* @warning do NOT assume this will always return a view!
|
||||||
|
@ -518,7 +495,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* SuperCoolWidget *widget = new SuperCoolWidget();
|
* SuperCoolWidget *widget = new SuperCoolWidget();
|
||||||
* dataEngine("engine")->connectSource(item->config("dataSourceName"), widget);
|
|
||||||
* item->setWidget(widget);
|
* item->setWidget(widget);
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
|
|
|
@ -37,7 +37,6 @@ namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class AppletHandle;
|
class AppletHandle;
|
||||||
class DataEngine;
|
|
||||||
class Corona;
|
class Corona;
|
||||||
class View;
|
class View;
|
||||||
class Wallpaper;
|
class Wallpaper;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "containmentactions.h"
|
#include "containmentactions.h"
|
||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
|
|
||||||
#include "private/dataengineconsumer_p.h"
|
|
||||||
#include "private/containmentactions_p.h"
|
#include "private/containmentactions_p.h"
|
||||||
#include "private/containment_p.h"
|
#include "private/containment_p.h"
|
||||||
|
|
||||||
|
@ -186,11 +185,6 @@ QList<QAction*> ContainmentActions::contextualActions()
|
||||||
return QList<QAction*>();
|
return QList<QAction*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine *ContainmentActions::dataEngine(const QString &name) const
|
|
||||||
{
|
|
||||||
return d->dataEngine(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ContainmentActions::configurationRequired() const
|
bool ContainmentActions::configurationRequired() const
|
||||||
{
|
{
|
||||||
return d->needsConfig;
|
return d->needsConfig;
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class DataEngine;
|
|
||||||
class Containment;
|
class Containment;
|
||||||
class ContainmentActionsPrivate;
|
class ContainmentActionsPrivate;
|
||||||
|
|
||||||
|
@ -162,26 +161,6 @@ class PLASMA_EXPORT ContainmentActions : public QObject
|
||||||
*/
|
*/
|
||||||
virtual QList<QAction*> contextualActions();
|
virtual QList<QAction*> contextualActions();
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given DataEngine
|
|
||||||
*
|
|
||||||
* Tries to load the data engine given by @p name. Each engine is
|
|
||||||
* only loaded once, and that instance is re-used on all subsequent
|
|
||||||
* requests.
|
|
||||||
*
|
|
||||||
* If the data engine was not found, an invalid data engine is returned
|
|
||||||
* (see DataEngine::isValid()).
|
|
||||||
*
|
|
||||||
* Note that you should <em>not</em> delete the returned engine.
|
|
||||||
*
|
|
||||||
* @param name Name of the data engine to load
|
|
||||||
* @return pointer to the data engine if it was loaded,
|
|
||||||
* or an invalid data engine if the requested engine
|
|
||||||
* could not be loaded
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the containmentactions currently needs to be configured,
|
* @return true if the containmentactions currently needs to be configured,
|
||||||
* otherwise, false
|
* otherwise, false
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
[Desktop Entry]
|
|
||||||
Type=ServiceType
|
|
||||||
X-KDE-ServiceType=Plasma/DataEngine
|
|
||||||
|
|
||||||
Comment=Plasma Data Engine
|
|
||||||
Comment[ar]=محرك بيانات بلازما
|
|
||||||
Comment[as]=Plasma Data Engine
|
|
||||||
Comment[ast]=Motor de datos Plasma
|
|
||||||
Comment[be@latin]=Systema dostupu da źviestak „Plasma”
|
|
||||||
Comment[bg]=Ядро за данни на Plasma
|
|
||||||
Comment[bn]=প্লাসমা ডাটা ইঞ্জিন
|
|
||||||
Comment[bn_IN]=Plasma ডাটা ইঞ্জিন
|
|
||||||
Comment[bs]=Plazma datomotor
|
|
||||||
Comment[ca]=Motor de dades del Plasma
|
|
||||||
Comment[ca@valencia]=Motor de dades del Plasma
|
|
||||||
Comment[cs]=Datový nástroj plasma
|
|
||||||
Comment[da]=Plasma datamotor
|
|
||||||
Comment[de]=Plasma-Daten-Treiber
|
|
||||||
Comment[el]=Μηχανή δεδομένων Plasma
|
|
||||||
Comment[en_GB]=Plasma Data Engine
|
|
||||||
Comment[eo]=Plasma Datuma Motoro
|
|
||||||
Comment[es]=Motor de datos para Plasma
|
|
||||||
Comment[et]=Plasma andmemootor
|
|
||||||
Comment[eu]=Plasmaren datu motorra
|
|
||||||
Comment[fi]=Plasma-tietomoottori
|
|
||||||
Comment[fr]=Moteur de données Plasma
|
|
||||||
Comment[fy]=Plasma gegevensmotor
|
|
||||||
Comment[ga]=Inneall Sonraí Plasma
|
|
||||||
Comment[gl]=Motor de datos de plasma
|
|
||||||
Comment[gu]=પ્લાઝમા માહિતી એન્જિન
|
|
||||||
Comment[he]=מנוע מידע עבור Plasma
|
|
||||||
Comment[hne]=प्लाज्मा डाटा इंजिन
|
|
||||||
Comment[hr]=Plasmin podaktovni mehanizam
|
|
||||||
Comment[hsb]=Datowa engine za Plasma
|
|
||||||
Comment[hu]=Plasma adatkezelő
|
|
||||||
Comment[hy]=Պլազմա տվյալների գործիք
|
|
||||||
Comment[ia]=Motor de datos de Plasma
|
|
||||||
Comment[id]=Mesin Data Plasma
|
|
||||||
Comment[is]=Plasma gagnavél
|
|
||||||
Comment[it]=Motore dati Plasma
|
|
||||||
Comment[ja]=Plasma データエンジン
|
|
||||||
Comment[kk]=Plasma деректер тетігі
|
|
||||||
Comment[km]=ម៉ាស៊ីនទិន្នន័យប្លាស្មា
|
|
||||||
Comment[kn]=ಪ್ಲಾಸ್ಮಾ ದತ್ತ ಯಂತ್ರ
|
|
||||||
Comment[ko]=Plasma 데이터 엔진
|
|
||||||
Comment[ku]=Motora Dane ya Plasma
|
|
||||||
Comment[lt]=Plasma duomenų varikliukas
|
|
||||||
Comment[lv]=Plasma datu dzinējs
|
|
||||||
Comment[mai]=प्लाजमा डेटा इंजन
|
|
||||||
Comment[ml]=പ്ലാസ്മ ഡാറ്റ എഞ്ചിന്
|
|
||||||
Comment[mr]=प्लाज्मा डेटा इंजिन
|
|
||||||
Comment[nb]=Plasma datamotor
|
|
||||||
Comment[nds]=Plasma-Datenkarn
|
|
||||||
Comment[nl]=Plasma-gegevensengine
|
|
||||||
Comment[nn]=Plasma-datamotor
|
|
||||||
Comment[pa]=ਪਲਾਜ਼ਮਾ ਡਾਟਾ ਇੰਜਣ
|
|
||||||
Comment[pl]=Silnik danych Plazmy
|
|
||||||
Comment[pt]=Motor de Dados do Plasma
|
|
||||||
Comment[pt_BR]=Mecanismo de dados do Plasma
|
|
||||||
Comment[ro]=Motor de date Plasma
|
|
||||||
Comment[ru]=Источник данных Plasma
|
|
||||||
Comment[se]=Plasma-dáhtamohtor
|
|
||||||
Comment[si]=Plasma දත්ත එංජිම
|
|
||||||
Comment[sk]=Dátový nástroj Plasma
|
|
||||||
Comment[sl]=Podatkovni pogon za Plasmo
|
|
||||||
Comment[sq]=Motor të Dhënash Plasma
|
|
||||||
Comment[sr]=Плазма датомотор
|
|
||||||
Comment[sr@ijekavian]=Плазма датомотор
|
|
||||||
Comment[sr@ijekavianlatin]=Plasma datomotor
|
|
||||||
Comment[sr@latin]=Plasma datomotor
|
|
||||||
Comment[sv]=Plasma datagränssnitt
|
|
||||||
Comment[ta]=பிளாஸ்மா தரவு இயந்திரம்
|
|
||||||
Comment[tg]=Системаи маълумотии Plasma
|
|
||||||
Comment[th]=กลไกข้อมูลของพลาสมา
|
|
||||||
Comment[tr]=Plasma Veri Motoru
|
|
||||||
Comment[tt]=Plasma мәгълүмат коралы
|
|
||||||
Comment[ug]=Plasma سانلىق-مەلۇمات ماتورى
|
|
||||||
Comment[uk]=Рушій даних Плазми
|
|
||||||
Comment[vi]=Cơ chế dữ liệu Plasma
|
|
||||||
Comment[wa]=Moteur di dnêyes di Plasma
|
|
||||||
Comment[x-test]=xxPlasma Data Enginexx
|
|
||||||
Comment[zh_CN]=Plasma 数据引擎
|
|
||||||
Comment[zh_TW]=Plasma 資料引擎
|
|
|
@ -1,237 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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.
|
|
||||||
*/
|
|
||||||
#include "datacontainer.h"
|
|
||||||
#include "private/datacontainer_p.h"
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
#include "plasma.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
DataContainer::DataContainer(QObject *parent)
|
|
||||||
: QObject(parent),
|
|
||||||
d(new DataContainerPrivate(this))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DataContainer::~DataContainer()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DataEngine::Data DataContainer::data() const
|
|
||||||
{
|
|
||||||
return d->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::setData(const QString &key, const QVariant &value)
|
|
||||||
{
|
|
||||||
if (!value.isValid()) {
|
|
||||||
d->data.remove(key);
|
|
||||||
} else {
|
|
||||||
d->data.insert(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
d->dirty = true;
|
|
||||||
d->updateTimer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::removeAllData()
|
|
||||||
{
|
|
||||||
if (d->data.isEmpty()) {
|
|
||||||
// avoid an update if we don't have any data anyways
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->data.clear();
|
|
||||||
d->dirty = true;
|
|
||||||
d->updateTimer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataContainer::visualizationIsConnected(QObject *visualization) const
|
|
||||||
{
|
|
||||||
return d->relayObjects.contains(visualization);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::connectVisualization(QObject *visualization, uint pollingInterval,
|
|
||||||
Plasma::IntervalAlignment alignment)
|
|
||||||
{
|
|
||||||
//kDebug() << "connecting visualization" << visualization << "at interval of"
|
|
||||||
// << pollingInterval << "to" << objectName();
|
|
||||||
QMap<QObject *, SignalRelay *>::iterator objIt = d->relayObjects.find(visualization);
|
|
||||||
bool connected = objIt != d->relayObjects.end();
|
|
||||||
if (connected) {
|
|
||||||
// this visualization is already connected. just adjust the update
|
|
||||||
// frequency if necessary
|
|
||||||
SignalRelay *relay = objIt.value();
|
|
||||||
if (relay) {
|
|
||||||
// connected to a relay
|
|
||||||
//kDebug() << " already connected, but to a relay";
|
|
||||||
if (relay->m_interval == pollingInterval) {
|
|
||||||
//kDebug() << " already connected to a relay of the same interval of"
|
|
||||||
// << pollingInterval << ", nothing to do";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relay->receiverCount() == 1) {
|
|
||||||
//kDebug() << " removing relay, as it is now unused";
|
|
||||||
d->relays.remove(relay->m_interval);
|
|
||||||
delete relay;
|
|
||||||
} else {
|
|
||||||
disconnect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
|
||||||
visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
//relay->isUnused();
|
|
||||||
}
|
|
||||||
} else if (pollingInterval < 1) {
|
|
||||||
// the visualization was connected already, but not to a relay
|
|
||||||
// and it still doesn't want to connect to a relay, so we have
|
|
||||||
// nothing to do!
|
|
||||||
//kDebug() << " already connected, nothing to do";
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
disconnect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
|
||||||
visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
connect(visualization, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(disconnectVisualization(QObject*)));//, Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pollingInterval < 1) {
|
|
||||||
//kDebug() << " connecting directly";
|
|
||||||
d->relayObjects[visualization] = 0;
|
|
||||||
connect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
|
||||||
visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
} else {
|
|
||||||
//kDebug() << " connecting to a relay";
|
|
||||||
// we only want to do an imediate update if this is not the first object to connect to us
|
|
||||||
// if it is the first visualization, then the source will already have been populated
|
|
||||||
// engine's sourceRequested method
|
|
||||||
bool immediateUpdate = connected || d->relayObjects.count() > 1;
|
|
||||||
SignalRelay *relay = d->signalRelay(this, visualization, pollingInterval,
|
|
||||||
alignment, immediateUpdate);
|
|
||||||
connect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
|
||||||
visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine* DataContainer::getDataEngine()
|
|
||||||
{
|
|
||||||
QObject *o = this;
|
|
||||||
DataEngine *de = NULL;
|
|
||||||
while (de == NULL)
|
|
||||||
{
|
|
||||||
o = qobject_cast<QObject *> (o->parent());
|
|
||||||
if (o == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
de = qobject_cast<DataEngine *> (o);
|
|
||||||
}
|
|
||||||
return de;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::disconnectVisualization(QObject *visualization)
|
|
||||||
{
|
|
||||||
QMap<QObject *, SignalRelay *>::iterator objIt = d->relayObjects.find(visualization);
|
|
||||||
disconnect(visualization, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(disconnectVisualization(QObject*)));//, Qt::QueuedConnection);
|
|
||||||
|
|
||||||
if (objIt == d->relayObjects.end() || !objIt.value()) {
|
|
||||||
// it is connected directly to the DataContainer itself
|
|
||||||
disconnect(this, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
|
||||||
visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
} else {
|
|
||||||
SignalRelay *relay = objIt.value();
|
|
||||||
|
|
||||||
if (relay->receiverCount() == 1) {
|
|
||||||
d->relays.remove(relay->m_interval);
|
|
||||||
delete relay;
|
|
||||||
} else {
|
|
||||||
disconnect(relay, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
|
|
||||||
visualization, SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
d->relayObjects.erase(objIt);
|
|
||||||
checkUsage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::checkForUpdate()
|
|
||||||
{
|
|
||||||
//kDebug() << objectName() << d->dirty;
|
|
||||||
if (d->dirty) {
|
|
||||||
emit dataUpdated(objectName(), d->data);
|
|
||||||
|
|
||||||
foreach (SignalRelay *relay, d->relays) {
|
|
||||||
relay->checkQueueing();
|
|
||||||
}
|
|
||||||
|
|
||||||
d->dirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::forceImmediateUpdate()
|
|
||||||
{
|
|
||||||
if (d->dirty) {
|
|
||||||
d->dirty = false;
|
|
||||||
emit dataUpdated(objectName(), d->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (SignalRelay *relay, d->relays) {
|
|
||||||
relay->forceImmediateUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint DataContainer::timeSinceLastUpdate() const
|
|
||||||
{
|
|
||||||
return d->updateTimer.elapsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::setNeedsUpdate(bool update)
|
|
||||||
{
|
|
||||||
d->cached = update;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::checkUsage()
|
|
||||||
{
|
|
||||||
if (!d->checkUsageTimer.isActive()) {
|
|
||||||
d->checkUsageTimer.start(10, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataContainer::timerEvent(QTimerEvent * event)
|
|
||||||
{
|
|
||||||
if (event->timerId() == d->checkUsageTimer.timerId()) {
|
|
||||||
if (d->relays.count() < 1 &&
|
|
||||||
receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) < 1) {
|
|
||||||
// DO NOT CALL ANYTHING AFTER THIS LINE AS IT MAY GET DELETED!
|
|
||||||
kDebug() << objectName() << "is unused";
|
|
||||||
emit becameUnused(objectName());
|
|
||||||
}
|
|
||||||
d->checkUsageTimer.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Plasma namespace
|
|
||||||
|
|
||||||
#include "moc_datacontainer.cpp"
|
|
||||||
|
|
|
@ -1,238 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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_DATACONTAINER_H
|
|
||||||
#define PLASMA_DATACONTAINER_H
|
|
||||||
|
|
||||||
#include <QtCore/QHash>
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QTimer>
|
|
||||||
|
|
||||||
#include <kjob.h>
|
|
||||||
#include <plasma/plasma_export.h>
|
|
||||||
#include <plasma/dataengine.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class DataContainerPrivate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class DataContainer plasma/datacontainer.h <Plasma/DataContainer>
|
|
||||||
*
|
|
||||||
* @brief A set of data exported via a DataEngine
|
|
||||||
*
|
|
||||||
* Plasma::DataContainer wraps the data exported by a DataEngine
|
|
||||||
* implementation, providing a generic wrapper for the data.
|
|
||||||
*
|
|
||||||
* A DataContainer may have zero or more associated pieces of data which
|
|
||||||
* are keyed by strings. The data itself is stored as QVariants. This allows
|
|
||||||
* easy and flexible retrieval of the information associated with this object
|
|
||||||
* without writing DataContainer or DataEngine specific code in visualizations.
|
|
||||||
*
|
|
||||||
* If you are creating your own DataContainer objects (and are passing them to
|
|
||||||
* DataEngine::addSource()), you normally just need to listen to the
|
|
||||||
* updateRequested() signal (as well as any other methods you might have of
|
|
||||||
* being notified of new data) and call setData() to actually update the data.
|
|
||||||
* Then you need to either trigger the scheduleSourcesUpdated signal of the
|
|
||||||
* parent DataEngine or call checkForUpdate() on the DataContainer.
|
|
||||||
*
|
|
||||||
* You also need to set a suitable name for the source with setObjectName().
|
|
||||||
* See DataEngine::addSource() for more information.
|
|
||||||
*
|
|
||||||
* Note that there is normally no need to subclass DataContainer, except as
|
|
||||||
* a way of encapsulating the data retrieval for a source, since all notifications
|
|
||||||
* are done via signals rather than virtual methods.
|
|
||||||
**/
|
|
||||||
class PLASMA_EXPORT DataContainer : public QObject
|
|
||||||
{
|
|
||||||
friend class DataEngine;
|
|
||||||
friend class DataEnginePrivate;
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Constructs a default DataContainer that has no name or data
|
|
||||||
* associated with it
|
|
||||||
**/
|
|
||||||
explicit DataContainer(QObject *parent = 0);
|
|
||||||
virtual ~DataContainer();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the data for this DataContainer
|
|
||||||
**/
|
|
||||||
const DataEngine::Data data() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a value for a key.
|
|
||||||
*
|
|
||||||
* This also marks this source as needing to signal an update.
|
|
||||||
*
|
|
||||||
* If you call setData() directly on a DataContainer, you need to
|
|
||||||
* either trigger the scheduleSourcesUpdated() slot for the
|
|
||||||
* data engine it belongs to or call checkForUpdate() on the
|
|
||||||
* DataContainer.
|
|
||||||
*
|
|
||||||
* @param key a string used as the key for the data
|
|
||||||
* @param value a QVariant holding the actual data. If a invalid
|
|
||||||
* QVariant is passed in and the key currently exists in the
|
|
||||||
* data, then the data entry is removed
|
|
||||||
**/
|
|
||||||
void setData(const QString &key, const QVariant &value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all data currently associated with this source
|
|
||||||
*
|
|
||||||
* If you call removeAllData() on a DataContainer, you need to
|
|
||||||
* either trigger the scheduleSourcesUpdated() slot for the
|
|
||||||
* data engine it belongs to or call checkForUpdate() on the
|
|
||||||
* DataContainer.
|
|
||||||
**/
|
|
||||||
void removeAllData();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return true if the visualization is currently connected
|
|
||||||
*/
|
|
||||||
bool visualizationIsConnected(QObject *visualization) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects an object to this DataContainer.
|
|
||||||
*
|
|
||||||
* May be called repeatedly for the same visualization without
|
|
||||||
* side effects
|
|
||||||
*
|
|
||||||
* @param visualization the object to connect to this DataContainer
|
|
||||||
* @param pollingInterval the time in milliseconds between updates
|
|
||||||
* @param alignment the clock position to align updates to
|
|
||||||
**/
|
|
||||||
void connectVisualization(QObject *visualization, uint pollingInterval,
|
|
||||||
Plasma::IntervalAlignment alignment);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the DataEngine that the DataContainer is
|
|
||||||
* a child of.
|
|
||||||
*/
|
|
||||||
DataEngine* getDataEngine();
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
/**
|
|
||||||
* Disconnects an object from this DataContainer.
|
|
||||||
*
|
|
||||||
* Note that if this source was created by DataEngine::sourceRequestEvent(),
|
|
||||||
* it will be deleted by DataEngine once control returns to the event loop.
|
|
||||||
**/
|
|
||||||
void disconnectVisualization(QObject *visualization);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Forces immediate update signals to all visualizations
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
void forceImmediateUpdate();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
/**
|
|
||||||
* Emitted when the data has been updated, allowing visualizations to
|
|
||||||
* reflect the new data.
|
|
||||||
*
|
|
||||||
* Note that you should not normally emit this directly. Instead, use
|
|
||||||
* checkForUpdate() or the DataEngine::scheduleSourcesUpdated() slot.
|
|
||||||
*
|
|
||||||
* @param source the objectName() of the DataContainer (and hence the name
|
|
||||||
* of the source) that updated its data
|
|
||||||
* @param data the updated data
|
|
||||||
**/
|
|
||||||
void dataUpdated(const QString &source, const Plasma::DataEngine::Data &data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when the last visualization is disconnected.
|
|
||||||
*
|
|
||||||
* Note that if this source was created by DataEngine::sourceRequestEvent(),
|
|
||||||
* it will be deleted by DataEngine once control returns to the event loop
|
|
||||||
* after this signal is emitted.
|
|
||||||
*
|
|
||||||
* @param source the name of the source that became unused
|
|
||||||
**/
|
|
||||||
void becameUnused(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when an update is requested.
|
|
||||||
*
|
|
||||||
* If a polling interval was passed connectVisualization(), this signal
|
|
||||||
* will be emitted every time the interval expires.
|
|
||||||
*
|
|
||||||
* Note that if you create your own DataContainer (and pass it to
|
|
||||||
* DataEngine::addSource()), you will need to listen to this signal
|
|
||||||
* and refresh the data when it is triggered.
|
|
||||||
*
|
|
||||||
* @param source the datacontainer the update was requested for. Useful
|
|
||||||
* for classes that update the data for several containers.
|
|
||||||
**/
|
|
||||||
void updateRequested(DataContainer *source);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* Checks whether any data has changed and, if so, emits dataUpdated().
|
|
||||||
**/
|
|
||||||
void checkForUpdate();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns how long ago, in msecs, that the data in this container was last updated.
|
|
||||||
*
|
|
||||||
* This is used by DataEngine to compress updates that happen more quickly than the
|
|
||||||
* minimum polling interval by calling setNeedsUpdate() instead of calling
|
|
||||||
* updateSourceEvent() immediately.
|
|
||||||
**/
|
|
||||||
uint timeSinceLastUpdate() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that the data should be treated as dirty the next time hasUpdates() is called.
|
|
||||||
*
|
|
||||||
* This is needed for the case where updateRequested() is triggered but we don't want to
|
|
||||||
* update the data immediately because it has just been updated. The second request won't
|
|
||||||
* be fulfilled in this case, because we never updated the data and so never called
|
|
||||||
* checkForUpdate(). So we claim it needs an update anyway.
|
|
||||||
**/
|
|
||||||
void setNeedsUpdate(bool update = true);
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
|
||||||
/**
|
|
||||||
* Check if the DataContainer is still in use.
|
|
||||||
*
|
|
||||||
* If not the signal "becameUnused" will be emitted.
|
|
||||||
*
|
|
||||||
* Warning: The DataContainer may be invalid after calling this function, because a listener
|
|
||||||
* to becameUnused() may have deleted it.
|
|
||||||
**/
|
|
||||||
void checkUsage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @reimp from QObject
|
|
||||||
*/
|
|
||||||
void timerEvent(QTimerEvent * event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class SignalRelay;
|
|
||||||
friend class DataContainerPrivate;
|
|
||||||
friend class DataEngineManager;
|
|
||||||
DataContainerPrivate *const d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Plasma namespace
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
|
|
@ -1,617 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dataengine.h"
|
|
||||||
#include "private/dataengine_p.h"
|
|
||||||
#include "private/datacontainer_p.h"
|
|
||||||
|
|
||||||
#include <QQueue>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QtCore/qdatetime.h>
|
|
||||||
#include <QtCore/qcoreevent.h>
|
|
||||||
#include <QVariant>
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
#include <kplugininfo.h>
|
|
||||||
#include <kservice.h>
|
|
||||||
#include <kstandarddirs.h>
|
|
||||||
|
|
||||||
#include "datacontainer.h"
|
|
||||||
#include "service.h"
|
|
||||||
#include "private/service_p.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
DataEngine::DataEngine(QObject *parent, KService::Ptr service)
|
|
||||||
: QObject(parent),
|
|
||||||
d(new DataEnginePrivate(this, KPluginInfo(service)))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine::DataEngine(QObject *parent, const QVariantList &args)
|
|
||||||
: QObject(parent),
|
|
||||||
d(new DataEnginePrivate(this, KPluginInfo(KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()))))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine::~DataEngine()
|
|
||||||
{
|
|
||||||
//kDebug() << objectName() << ": bye bye birdy! ";
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList DataEngine::sources() const
|
|
||||||
{
|
|
||||||
return d->sources.keys();
|
|
||||||
}
|
|
||||||
|
|
||||||
Service *DataEngine::serviceForSource(const QString &source)
|
|
||||||
{
|
|
||||||
return new NullService(source, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::connectSource(const QString &source, QObject *visualization,
|
|
||||||
uint pollingInterval,
|
|
||||||
Plasma::IntervalAlignment intervalAlignment) const
|
|
||||||
{
|
|
||||||
//kDebug() << "connectSource" << source;
|
|
||||||
bool newSource;
|
|
||||||
DataContainer *s = d->requestSource(source, &newSource);
|
|
||||||
|
|
||||||
if (s) {
|
|
||||||
// we suppress the immediate invocation of dataUpdated here if the
|
|
||||||
// source was prexisting and they don't request delayed updates
|
|
||||||
// (we want to do an immediate update in that case so they don't
|
|
||||||
// have to wait for the first time out)
|
|
||||||
if (newSource && !s->data().isEmpty()) {
|
|
||||||
newSource = false;
|
|
||||||
}
|
|
||||||
d->connectSource(s, visualization, pollingInterval, intervalAlignment,
|
|
||||||
!newSource || pollingInterval > 0);
|
|
||||||
//kDebug() << " ==> source connected";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::connectAllSources(QObject *visualization, uint pollingInterval,
|
|
||||||
Plasma::IntervalAlignment intervalAlignment) const
|
|
||||||
{
|
|
||||||
foreach (DataContainer *s, d->sources) {
|
|
||||||
d->connectSource(s, visualization, pollingInterval, intervalAlignment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::disconnectSource(const QString &source, QObject *visualization) const
|
|
||||||
{
|
|
||||||
DataContainer *s = d->source(source, false);
|
|
||||||
|
|
||||||
if (s) {
|
|
||||||
s->disconnectVisualization(visualization);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DataContainer *DataEngine::containerForSource(const QString &source)
|
|
||||||
{
|
|
||||||
return d->source(source, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine::Data DataEngine::query(const QString &source) const
|
|
||||||
{
|
|
||||||
bool newSource;
|
|
||||||
DataContainer *s = d->requestSource(source, &newSource);
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
return DataEngine::Data();
|
|
||||||
} else if (!newSource && d->minPollingInterval >= 0 &&
|
|
||||||
s->timeSinceLastUpdate() >= uint(d->minPollingInterval)) {
|
|
||||||
DataEngine *unconstThis = const_cast<DataEngine*>(this);
|
|
||||||
if (unconstThis->updateSourceEvent(source)) {
|
|
||||||
unconstThis->scheduleSourcesUpdated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine::Data data = s->data();
|
|
||||||
s->checkUsage();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::init()
|
|
||||||
{
|
|
||||||
// kDebug() << "called";
|
|
||||||
// default implementation does nothing. this is for engines that have to
|
|
||||||
// start things in motion external to themselves before they can work
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataEngine::sourceRequestEvent(const QString &name)
|
|
||||||
{
|
|
||||||
Q_UNUSED(name)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataEngine::updateSourceEvent(const QString &source)
|
|
||||||
{
|
|
||||||
Q_UNUSED(source)
|
|
||||||
//kDebug() << source;
|
|
||||||
return false; //TODO: should this be true to trigger, even needless, updates on every tick?
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setData(const QString &source, const QVariant &value)
|
|
||||||
{
|
|
||||||
setData(source, source, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setData(const QString &source, const QString &key, const QVariant &value)
|
|
||||||
{
|
|
||||||
DataContainer *s = d->source(source, false);
|
|
||||||
bool isNew = !s;
|
|
||||||
|
|
||||||
if (isNew) {
|
|
||||||
s = d->source(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
s->setData(key, value);
|
|
||||||
|
|
||||||
if (isNew && source != d->waitingSourceRequest) {
|
|
||||||
emit sourceAdded(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduleSourcesUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setData(const QString &source, const Data &data)
|
|
||||||
{
|
|
||||||
DataContainer *s = d->source(source, false);
|
|
||||||
bool isNew = !s;
|
|
||||||
|
|
||||||
if (isNew) {
|
|
||||||
s = d->source(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
Data::const_iterator it = data.constBegin();
|
|
||||||
while (it != data.constEnd()) {
|
|
||||||
s->setData(it.key(), it.value());
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNew && source != d->waitingSourceRequest) {
|
|
||||||
emit sourceAdded(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduleSourcesUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::removeAllData(const QString &source)
|
|
||||||
{
|
|
||||||
DataContainer *s = d->source(source, false);
|
|
||||||
if (s) {
|
|
||||||
s->removeAllData();
|
|
||||||
scheduleSourcesUpdated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::removeData(const QString &source, const QString &key)
|
|
||||||
{
|
|
||||||
DataContainer *s = d->source(source, false);
|
|
||||||
if (s) {
|
|
||||||
s->setData(key, QVariant());
|
|
||||||
scheduleSourcesUpdated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::addSource(DataContainer *source)
|
|
||||||
{
|
|
||||||
if (d->sources.contains(source->objectName())) {
|
|
||||||
kDebug() << "source named \"" << source->objectName() << "\" already exists.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QObject::connect(source, SIGNAL(updateRequested(DataContainer*)),
|
|
||||||
this, SLOT(internalUpdateSource(DataContainer*)));
|
|
||||||
QObject::connect(source, SIGNAL(destroyed(QObject*)), this, SLOT(sourceDestroyed(QObject*)));
|
|
||||||
d->sources.insert(source->objectName(), source);
|
|
||||||
emit sourceAdded(source->objectName());
|
|
||||||
scheduleSourcesUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setMaxSourceCount(uint limit)
|
|
||||||
{
|
|
||||||
if (d->limit == limit) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->limit = limit;
|
|
||||||
|
|
||||||
if (d->limit > 0) {
|
|
||||||
d->trimQueue();
|
|
||||||
} else {
|
|
||||||
d->sourceQueue.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint DataEngine::maxSourceCount() const
|
|
||||||
{
|
|
||||||
return d->limit;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setMinimumPollingInterval(int minimumMs)
|
|
||||||
{
|
|
||||||
d->minPollingInterval = minimumMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DataEngine::minimumPollingInterval() const
|
|
||||||
{
|
|
||||||
return d->minPollingInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setPollingInterval(uint frequency)
|
|
||||||
{
|
|
||||||
killTimer(d->updateTimerId);
|
|
||||||
d->updateTimerId = 0;
|
|
||||||
|
|
||||||
if (frequency > 0) {
|
|
||||||
d->updateTimerId = startTimer(frequency);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::removeSource(const QString &source)
|
|
||||||
{
|
|
||||||
SourceDict::iterator it = d->sources.find(source);
|
|
||||||
if (it != d->sources.end()) {
|
|
||||||
DataContainer *s = it.value();
|
|
||||||
|
|
||||||
// remove it from the limit queue if we're keeping one
|
|
||||||
if (d->limit > 0) {
|
|
||||||
QQueue<DataContainer*>::iterator it = d->sourceQueue.begin();
|
|
||||||
while (it != d->sourceQueue.end()) {
|
|
||||||
if (*it == s) {
|
|
||||||
d->sourceQueue.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s->disconnect(this);
|
|
||||||
s->deleteLater();
|
|
||||||
d->sources.erase(it);
|
|
||||||
emit sourceRemoved(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::removeAllSources()
|
|
||||||
{
|
|
||||||
QMutableHashIterator<QString, Plasma::DataContainer*> it(d->sources);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
Plasma::DataContainer *s = it.value();
|
|
||||||
const QString source = it.key();
|
|
||||||
it.remove();
|
|
||||||
s->disconnect(this);
|
|
||||||
s->deleteLater();
|
|
||||||
emit sourceRemoved(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataEngine::isValid() const
|
|
||||||
{
|
|
||||||
return d->valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataEngine::isEmpty() const
|
|
||||||
{
|
|
||||||
return d->sources.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setValid(bool valid)
|
|
||||||
{
|
|
||||||
d->valid = valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine::SourceDict DataEngine::containerDict() const
|
|
||||||
{
|
|
||||||
return d->sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::timerEvent(QTimerEvent *event)
|
|
||||||
{
|
|
||||||
//kDebug();
|
|
||||||
if (event->timerId() == d->updateTimerId) {
|
|
||||||
// if the freq update is less than 0, don't bother
|
|
||||||
if (d->minPollingInterval < 0) {
|
|
||||||
//kDebug() << "uh oh.. no polling allowed!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// minPollingInterval
|
|
||||||
if (d->updateTimer.elapsed() < d->minPollingInterval) {
|
|
||||||
//kDebug() << "hey now.. slow down!";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->updateTimer.start();
|
|
||||||
updateAllSources();
|
|
||||||
} else if (event->timerId() == d->checkSourcesTimerId) {
|
|
||||||
killTimer(d->checkSourcesTimerId);
|
|
||||||
d->checkSourcesTimerId = 0;
|
|
||||||
|
|
||||||
QHashIterator<QString, Plasma::DataContainer*> it(d->sources);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
it.value()->checkForUpdate();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
QObject::timerEvent(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::updateAllSources()
|
|
||||||
{
|
|
||||||
QHashIterator<QString, Plasma::DataContainer*> it(d->sources);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
//kDebug() << "updating" << it.key();
|
|
||||||
updateSourceEvent(it.key());
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduleSourcesUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::forceImmediateUpdateOfAllVisualizations()
|
|
||||||
{
|
|
||||||
foreach (DataContainer *source, d->sources) {
|
|
||||||
source->forceImmediateUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setIcon(const QString &icon)
|
|
||||||
{
|
|
||||||
d->icon = icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DataEngine::icon() const
|
|
||||||
{
|
|
||||||
return d->icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DataEngine::pluginName() const
|
|
||||||
{
|
|
||||||
if (!d->dataEngineDescription.isValid()) {
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return d->dataEngineDescription.pluginName();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::scheduleSourcesUpdated()
|
|
||||||
{
|
|
||||||
if (d->checkSourcesTimerId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
d->checkSourcesTimerId = startTimer(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DataEngine::name() const
|
|
||||||
{
|
|
||||||
return d->engineName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngine::setName(const QString &name)
|
|
||||||
{
|
|
||||||
d->engineName = name;
|
|
||||||
setObjectName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private class implementations
|
|
||||||
DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
|
|
||||||
: q(e),
|
|
||||||
dataEngineDescription(info),
|
|
||||||
refCount(-1), // first ref
|
|
||||||
checkSourcesTimerId(0),
|
|
||||||
updateTimerId(0),
|
|
||||||
minPollingInterval(-1),
|
|
||||||
limit(0),
|
|
||||||
valid(true)
|
|
||||||
{
|
|
||||||
updateTimer.start();
|
|
||||||
|
|
||||||
if (!info.isValid()) {
|
|
||||||
engineName = i18n("Unnamed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
engineName = info.name();
|
|
||||||
if (engineName.isEmpty()) {
|
|
||||||
engineName = i18n("Unnamed");
|
|
||||||
}
|
|
||||||
e->setObjectName(engineName);
|
|
||||||
icon = info.icon();
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEnginePrivate::~DataEnginePrivate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEnginePrivate::internalUpdateSource(DataContainer *source)
|
|
||||||
{
|
|
||||||
if (minPollingInterval > 0 &&
|
|
||||||
source->timeSinceLastUpdate() < (uint)minPollingInterval) {
|
|
||||||
// skip updating this source; it's been too soon
|
|
||||||
//kDebug() << "internal update source is delaying" << source->timeSinceLastUpdate() << minPollingInterval;
|
|
||||||
//but fake an update so that the signalrelay that triggered this gets the data from the
|
|
||||||
//recent update. this way we don't have to worry about queuing - the relay will send a
|
|
||||||
//signal immediately and everyone else is undisturbed.
|
|
||||||
source->setNeedsUpdate();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (q->updateSourceEvent(source->objectName())) {
|
|
||||||
//kDebug() << "queuing an update";
|
|
||||||
q->scheduleSourcesUpdated();
|
|
||||||
}/* else {
|
|
||||||
kDebug() << "no update";
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEnginePrivate::ref()
|
|
||||||
{
|
|
||||||
--refCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEnginePrivate::deref()
|
|
||||||
{
|
|
||||||
++refCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataEnginePrivate::isUsed() const
|
|
||||||
{
|
|
||||||
return refCount != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataContainer *DataEnginePrivate::source(const QString &sourceName, bool createWhenMissing)
|
|
||||||
{
|
|
||||||
DataEngine::SourceDict::const_iterator it = sources.constFind(sourceName);
|
|
||||||
if (it != sources.constEnd()) {
|
|
||||||
DataContainer *s = it.value();
|
|
||||||
if (limit > 0) {
|
|
||||||
QQueue<DataContainer*>::iterator it = sourceQueue.begin();
|
|
||||||
while (it != sourceQueue.end()) {
|
|
||||||
if (*it == s) {
|
|
||||||
sourceQueue.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
sourceQueue.enqueue(s);
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!createWhenMissing) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//kDebug() << "DataEngine " << q->objectName() << ": could not find DataContainer " << sourceName << ", creating";
|
|
||||||
DataContainer *s = new DataContainer(q);
|
|
||||||
s->setObjectName(sourceName);
|
|
||||||
sources.insert(sourceName, s);
|
|
||||||
QObject::connect(s, SIGNAL(destroyed(QObject*)), q, SLOT(sourceDestroyed(QObject*)));
|
|
||||||
QObject::connect(s, SIGNAL(updateRequested(DataContainer*)),
|
|
||||||
q, SLOT(internalUpdateSource(DataContainer*)));
|
|
||||||
|
|
||||||
if (limit > 0) {
|
|
||||||
trimQueue();
|
|
||||||
sourceQueue.enqueue(s);
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization,
|
|
||||||
uint pollingInterval,
|
|
||||||
Plasma::IntervalAlignment align,
|
|
||||||
bool immediateCall)
|
|
||||||
{
|
|
||||||
//kDebug() << "connect source called" << s->objectName() << "with interval" << pollingInterval;
|
|
||||||
|
|
||||||
if (pollingInterval > 0) {
|
|
||||||
// never more frequently than allowed, never more than 20 times per second
|
|
||||||
uint min = qMax(50, minPollingInterval); // for qMax below
|
|
||||||
pollingInterval = qMax(min, pollingInterval);
|
|
||||||
|
|
||||||
// align on the 50ms
|
|
||||||
pollingInterval = pollingInterval - (pollingInterval % 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (immediateCall) {
|
|
||||||
// we don't want to do an immediate call if we are simply
|
|
||||||
// reconnecting
|
|
||||||
//kDebug() << "immediate call requested, we have:" << s->visualizationIsConnected(visualization);
|
|
||||||
immediateCall = !s->data().isEmpty() &&
|
|
||||||
!s->visualizationIsConnected(visualization);
|
|
||||||
}
|
|
||||||
|
|
||||||
s->connectVisualization(visualization, pollingInterval, align);
|
|
||||||
|
|
||||||
if (immediateCall) {
|
|
||||||
QMetaObject::invokeMethod(visualization, "dataUpdated",
|
|
||||||
Q_ARG(QString, s->objectName()),
|
|
||||||
Q_ARG(Plasma::DataEngine::Data, s->data()));
|
|
||||||
s->d->dirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEnginePrivate::sourceDestroyed(QObject *object)
|
|
||||||
{
|
|
||||||
DataEngine::SourceDict::iterator it = sources.begin();
|
|
||||||
while (it != sources.end()) {
|
|
||||||
if (it.value() == object) {
|
|
||||||
sources.erase(it);
|
|
||||||
emit q->sourceRemoved(object->objectName());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DataContainer *DataEnginePrivate::requestSource(const QString &sourceName, bool *newSource)
|
|
||||||
{
|
|
||||||
if (newSource) {
|
|
||||||
*newSource = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//kDebug() << "requesting source " << sourceName;
|
|
||||||
DataContainer *s = source(sourceName, false);
|
|
||||||
|
|
||||||
if (!s) {
|
|
||||||
// we didn't find a data source, so give the engine an opportunity to make one
|
|
||||||
/*kDebug() << "DataEngine " << q->objectName()
|
|
||||||
<< ": could not find DataContainer " << sourceName
|
|
||||||
<< " will create on request" << endl;*/
|
|
||||||
waitingSourceRequest = sourceName;
|
|
||||||
if (q->sourceRequestEvent(sourceName)) {
|
|
||||||
s = source(sourceName, false);
|
|
||||||
if (s) {
|
|
||||||
// now we have a source; since it was created on demand, assume
|
|
||||||
// it should be removed when not used
|
|
||||||
if (newSource) {
|
|
||||||
*newSource = true;
|
|
||||||
}
|
|
||||||
QObject::connect(s, SIGNAL(becameUnused(QString)), q, SLOT(removeSource(QString)));
|
|
||||||
emit q->sourceAdded(sourceName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
waitingSourceRequest.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEnginePrivate::trimQueue()
|
|
||||||
{
|
|
||||||
uint queueCount = sourceQueue.count();
|
|
||||||
while (queueCount >= limit && !sourceQueue.isEmpty()) {
|
|
||||||
DataContainer *punted = sourceQueue.dequeue();
|
|
||||||
q->removeSource(punted->objectName());
|
|
||||||
queueCount = sourceQueue.count();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_dataengine.cpp"
|
|
|
@ -1,469 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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_DATAENGINE_H
|
|
||||||
#define PLASMA_DATAENGINE_H
|
|
||||||
|
|
||||||
#include <QtCore/QHash>
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
|
|
||||||
#include <kservice.h>
|
|
||||||
#include <kdeversion.h>
|
|
||||||
|
|
||||||
#include <plasma/plasma.h>
|
|
||||||
#include <plasma/service.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class DataContainer;
|
|
||||||
class Service;
|
|
||||||
class DataEnginePrivate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class DataEngine plasma/dataengine.h <Plasma/DataEngine>
|
|
||||||
*
|
|
||||||
* @short 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.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
**/
|
|
||||||
class PLASMA_EXPORT DataEngine : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QStringList sources READ sources)
|
|
||||||
Q_PROPERTY(bool valid READ isValid)
|
|
||||||
Q_PROPERTY(QString icon READ icon WRITE setIcon)
|
|
||||||
Q_PROPERTY(QString name READ name)
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef QHash<QString, DataEngine*> Dict;
|
|
||||||
typedef QHash<QString, QVariant> Data;
|
|
||||||
typedef QHashIterator<QString, QVariant> DataIterator;
|
|
||||||
typedef QHash<QString, DataContainer*> SourceDict;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param parent The parent object.
|
|
||||||
* @param service pointer to the service that describes the engine
|
|
||||||
**/
|
|
||||||
explicit DataEngine(QObject *parent = 0, KService::Ptr service = KService::Ptr(0));
|
|
||||||
DataEngine(QObject *parent, const QVariantList &args);
|
|
||||||
~DataEngine();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 need to perform a startup routine.
|
|
||||||
*
|
|
||||||
* The default implementation does nothing. Reimplementations in
|
|
||||||
* subclasses don't need to call this one.
|
|
||||||
**/
|
|
||||||
virtual void init();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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.
|
|
||||||
**/
|
|
||||||
virtual QStringList sources() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param source the source to target the Service at
|
|
||||||
* @return a Service that has the source as a destination. The service
|
|
||||||
* is parented to the DataEngine, but should be deleted by the
|
|
||||||
* caller when finished with it
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE virtual Service *serviceForSource(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the engine name for the DataEngine
|
|
||||||
*/
|
|
||||||
QString name() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects a source to an object for data updates. The object must
|
|
||||||
* have a slot with the following signature:
|
|
||||||
*
|
|
||||||
* dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* @param pollingInterval the frequency, in milliseconds, with which to check for updates;
|
|
||||||
* 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.
|
|
||||||
* If the data has not changed, no update will be sent.
|
|
||||||
* @param intervalAlignment the number of ms to align the interval to
|
|
||||||
**/
|
|
||||||
Q_INVOKABLE void connectSource(
|
|
||||||
const QString &source, QObject *visualization,
|
|
||||||
uint pollingInterval = 0,
|
|
||||||
Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects all currently existing sources to an object for data updates.
|
|
||||||
* The object must have a slot with the following signature:
|
|
||||||
*
|
|
||||||
* SLOT(dataUpdated(QString,Plasma::DataEngine::Data))
|
|
||||||
*
|
|
||||||
* The data is a QHash of QVariants keyed by QString names, allowing
|
|
||||||
* one data source to provide sets of related data.
|
|
||||||
*
|
|
||||||
* This method may be called multiple times for the same visualization
|
|
||||||
* without side-effects. This can be useful to change the pollingInterval.
|
|
||||||
*
|
|
||||||
* Note that this method does not automatically connect sources that
|
|
||||||
* may appear later on. Connecting and responding to the sourceAdded signal
|
|
||||||
* is still required to achieve that.
|
|
||||||
*
|
|
||||||
* @param visualization the object to connect the data source to
|
|
||||||
* @param pollingInterval the frequency, in milliseconds, with which to check for updates;
|
|
||||||
* 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.
|
|
||||||
* If the data has not changed, no update will be sent.
|
|
||||||
* @param intervalAlignment the number of ms to align the interval to
|
|
||||||
**/
|
|
||||||
Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0,
|
|
||||||
Plasma::IntervalAlignment intervalAlignment =
|
|
||||||
NoAlignment) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects a source from 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
|
|
||||||
**/
|
|
||||||
Q_INVOKABLE void disconnectSource(const QString &source, QObject *visualization) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a pointer to the DataContainer for a given source. This method
|
|
||||||
* should not be used if possible.
|
|
||||||
*
|
|
||||||
* @param source the name of the source.
|
|
||||||
* @return pointer to a DataContainer, or zero on failure
|
|
||||||
**/
|
|
||||||
Q_INVOKABLE DataContainer *containerForSource(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
**/
|
|
||||||
Q_INVOKABLE DataEngine::Data query(const QString &source) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this engine is valid, otherwise returns false
|
|
||||||
*
|
|
||||||
* @return true if the engine is valid
|
|
||||||
**/
|
|
||||||
bool isValid() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the data engine is empty, which is to say that it has no
|
|
||||||
* data sources currently.
|
|
||||||
*
|
|
||||||
* @return true if the engine has no sources currently
|
|
||||||
*/
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the maximum number of sources this DataEngine will have
|
|
||||||
* at any given time.
|
|
||||||
*
|
|
||||||
* @return the maximum number of sources; zero means no limit.
|
|
||||||
*/
|
|
||||||
uint maxSourceCount() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the name of the icon for this data engine; and empty string
|
|
||||||
* is returned if there is no associated icon.
|
|
||||||
**/
|
|
||||||
QString icon() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the plugin name for the applet
|
|
||||||
*/
|
|
||||||
QString pluginName() const;
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
/**
|
|
||||||
* Emitted when a new data source is created
|
|
||||||
*
|
|
||||||
* Note that you do not need to emit this yourself unless
|
|
||||||
* you are reimplementing sources() and want to advertise
|
|
||||||
* that a new source is available (but hasn't been created
|
|
||||||
* yet).
|
|
||||||
*
|
|
||||||
* @param source the name of the new data source
|
|
||||||
**/
|
|
||||||
void sourceAdded(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when a data source is removed.
|
|
||||||
*
|
|
||||||
* Note that you do not need to emit this yourself unless
|
|
||||||
* you have reimplemented sources() and want to signal that
|
|
||||||
* a source that was available but was never created is no
|
|
||||||
* longer available.
|
|
||||||
*
|
|
||||||
* @param source the name of the data source that was removed
|
|
||||||
**/
|
|
||||||
void sourceRemoved(const QString &source);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* The name of the data source (e.g. the source parameter passed into
|
|
||||||
* setData) must be the same as the name passed to sourceRequestEvent
|
|
||||||
* otherwise the requesting visualization may not receive notice of a
|
|
||||||
* data update.
|
|
||||||
*
|
|
||||||
* 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());
|
|
||||||
*
|
|
||||||
* @param source the name of the source that has been requested
|
|
||||||
* @return true if a DataContainer was set up, false otherwise
|
|
||||||
*/
|
|
||||||
virtual bool sourceRequestEvent(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by internal updating mechanisms to trigger the engine
|
|
||||||
* to refresh the data contained in a given source. Reimplement this
|
|
||||||
* method when using facilities such as setPollingInterval.
|
|
||||||
* @see setPollingInterval
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
**/
|
|
||||||
virtual bool updateSourceEvent(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
**/
|
|
||||||
void setData(const QString &source, const QVariant &value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
**/
|
|
||||||
void setData(const QString &source, const QString &key, const QVariant &value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all the data associated with a data source.
|
|
||||||
*
|
|
||||||
* @param source the name of the data source
|
|
||||||
**/
|
|
||||||
void removeAllData(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds an already constructed data source. The DataEngine takes
|
|
||||||
* ownership of the DataContainer object. The objectName of the source
|
|
||||||
* is used for the source name.
|
|
||||||
*
|
|
||||||
* @param source the DataContainer to add to the DataEngine
|
|
||||||
**/
|
|
||||||
void addSource(DataContainer *source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
**/
|
|
||||||
void setMaxSourceCount(uint limit);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* The default minimumPollingInterval is -1, or "never perform automatic updates"
|
|
||||||
*
|
|
||||||
* @param minimumMs the minimum time lapse, in milliseconds, between updates.
|
|
||||||
* 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.
|
|
||||||
**/
|
|
||||||
void setMinimumPollingInterval(int minimumMs);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the minimum time between updates. @see setMinimumPollingInterval
|
|
||||||
**/
|
|
||||||
int minimumPollingInterval() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up an internal update tick for all data sources. On every update,
|
|
||||||
* updateSourceEvent will be called for each applicable source.
|
|
||||||
* @see updateSourceEvent
|
|
||||||
*
|
|
||||||
* @param frequency the time, in milliseconds, between updates. A value of 0
|
|
||||||
* will stop internally triggered updates.
|
|
||||||
**/
|
|
||||||
void setPollingInterval(uint frequency);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all data sources
|
|
||||||
**/
|
|
||||||
void removeAllSources();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
**/
|
|
||||||
void setValid(bool valid);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the list of active DataContainers.
|
|
||||||
*/
|
|
||||||
SourceDict containerDict() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reimplemented from QObject
|
|
||||||
**/
|
|
||||||
void timerEvent(QTimerEvent *event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the engine name for the DataEngine
|
|
||||||
*/
|
|
||||||
void setName(const QString &name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the icon for this data engine
|
|
||||||
**/
|
|
||||||
void setIcon(const QString &icon);
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
|
||||||
/**
|
|
||||||
* Call this method when you call setData directly on a DataContainer instead
|
|
||||||
* of using the DataEngine::setData methods.
|
|
||||||
* If this method is not called, no dataUpdated(..) signals will be emitted!
|
|
||||||
*/
|
|
||||||
void scheduleSourcesUpdated();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a data source.
|
|
||||||
* @param source the name of the data source to remove
|
|
||||||
**/
|
|
||||||
void removeSource(const QString &source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Immediately updates all existing sources when called
|
|
||||||
*/
|
|
||||||
void updateAllSources();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Forces an immediate update to all connected sources, even those with
|
|
||||||
* timeouts that haven't yet expired. This should _only_ be used when
|
|
||||||
* there was no data available, e.g. due to network non-availability,
|
|
||||||
* and then it becomes available. Normal changes in data values due to
|
|
||||||
* calls to updateSource or in the natural progression of the monitored
|
|
||||||
* object (e.g. CPU heat) should not result in a call to this method!
|
|
||||||
*
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
void forceImmediateUpdateOfAllVisualizations();
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class DataEnginePrivate;
|
|
||||||
friend class DataEngineManager;
|
|
||||||
friend class NullEngine;
|
|
||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source))
|
|
||||||
Q_PRIVATE_SLOT(d, void sourceDestroyed(QObject *object))
|
|
||||||
|
|
||||||
DataEnginePrivate *const d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Plasma namespace
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a data engine when it is contained in a loadable module
|
|
||||||
*/
|
|
||||||
#define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
|
|
||||||
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
|
||||||
K_EXPORT_PLUGIN(factory("plasma_engine_" #libname))
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Plasma::DataEngine*)
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
|
|
@ -1,248 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dataenginemanager.h"
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QTextStream>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
#include <kglobal.h>
|
|
||||||
#include <kstandarddirs.h>
|
|
||||||
#include <kservicetypetrader.h>
|
|
||||||
|
|
||||||
#include "datacontainer.h"
|
|
||||||
#include "pluginloader.h"
|
|
||||||
#include "private/dataengine_p.h"
|
|
||||||
#include "private/datacontainer_p.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class NullEngine : public DataEngine
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NullEngine(QObject *parent = 0)
|
|
||||||
: DataEngine(parent)
|
|
||||||
{
|
|
||||||
setValid(false);
|
|
||||||
|
|
||||||
// ref() ourselves to ensure we never get deleted
|
|
||||||
d->ref();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class DataEngineManagerPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataEngineManagerPrivate()
|
|
||||||
: nullEng(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~DataEngineManagerPrivate()
|
|
||||||
{
|
|
||||||
foreach (Plasma::DataEngine *engine, engines) {
|
|
||||||
delete engine;
|
|
||||||
}
|
|
||||||
engines.clear();
|
|
||||||
delete nullEng;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine *nullEngine()
|
|
||||||
{
|
|
||||||
if (!nullEng) {
|
|
||||||
nullEng = new NullEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullEng;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine::Dict engines;
|
|
||||||
DataEngine *nullEng;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DataEngineManagerSingleton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataEngineManager self;
|
|
||||||
};
|
|
||||||
|
|
||||||
K_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf)
|
|
||||||
|
|
||||||
DataEngineManager *DataEngineManager::self()
|
|
||||||
{
|
|
||||||
return &privateDataEngineManagerSelf->self;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngineManager::DataEngineManager()
|
|
||||||
: d(new DataEngineManagerPrivate)
|
|
||||||
{
|
|
||||||
//startTimer(30000);
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngineManager::~DataEngineManager()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::DataEngine *DataEngineManager::engine(const QString &name) const
|
|
||||||
{
|
|
||||||
if (name.isEmpty()) {
|
|
||||||
return d->nullEngine();
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
|
|
||||||
if (it != d->engines.constEnd()) {
|
|
||||||
// ref and return the engine
|
|
||||||
//Plasma::DataEngine *engine = *it;
|
|
||||||
return *it;
|
|
||||||
}
|
|
||||||
|
|
||||||
return d->nullEngine();
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::DataEngine *DataEngineManager::loadEngine(const QString &name)
|
|
||||||
{
|
|
||||||
Plasma::DataEngine::Dict::const_iterator it = d->engines.constFind(name);
|
|
||||||
|
|
||||||
if (it != d->engines.constEnd()) {
|
|
||||||
DataEngine *engine = *it;
|
|
||||||
engine->d->ref();
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine *engine = PluginLoader::loadDataEngine(name);
|
|
||||||
if (!engine) {
|
|
||||||
return d->nullEngine();
|
|
||||||
}
|
|
||||||
|
|
||||||
engine->init();
|
|
||||||
d->engines[name] = engine;
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngineManager::unloadEngine(const QString &name)
|
|
||||||
{
|
|
||||||
Plasma::DataEngine::Dict::iterator it = d->engines.find(name);
|
|
||||||
|
|
||||||
if (it != d->engines.end()) {
|
|
||||||
Plasma::DataEngine *engine = *it;
|
|
||||||
engine->d->deref();
|
|
||||||
|
|
||||||
if (!engine->d->isUsed()) {
|
|
||||||
d->engines.erase(it);
|
|
||||||
delete engine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList DataEngineManager::listAllEngines(const QString &parentApp)
|
|
||||||
{
|
|
||||||
QString constraint;
|
|
||||||
|
|
||||||
if (parentApp.isEmpty()) {
|
|
||||||
constraint.append("(not exist [X-KDE-ParentApp] or [X-KDE-ParentApp] == '')");
|
|
||||||
} else {
|
|
||||||
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
|
|
||||||
}
|
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint);
|
|
||||||
|
|
||||||
QStringList engines;
|
|
||||||
foreach (const KService::Ptr &service, offers) {
|
|
||||||
QString name = service->property("X-KDE-PluginInfo-Name").toString();
|
|
||||||
if (!name.isEmpty()) {
|
|
||||||
engines.append(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return engines;
|
|
||||||
}
|
|
||||||
|
|
||||||
KPluginInfo::List DataEngineManager::listEngineInfo(const QString &parentApp)
|
|
||||||
{
|
|
||||||
return PluginLoader::listDataEngineInfo(parentApp);
|
|
||||||
}
|
|
||||||
|
|
||||||
KPluginInfo::List DataEngineManager::listEngineInfoByCategory(const QString &category, const QString &parentApp)
|
|
||||||
{
|
|
||||||
QString constraint = QString("[X-KDE-PluginInfo-Category] == '%1'").arg(category);
|
|
||||||
|
|
||||||
if (parentApp.isEmpty()) {
|
|
||||||
constraint.append(" and not exist [X-KDE-ParentApp]");
|
|
||||||
} else {
|
|
||||||
constraint.append(" and [X-KDE-ParentApp] == '").append(parentApp).append("'");
|
|
||||||
}
|
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint);
|
|
||||||
return KPluginInfo::fromServices(offers);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataEngineManager::timerEvent(QTimerEvent *)
|
|
||||||
{
|
|
||||||
#ifndef NDEBUG
|
|
||||||
QString path = KGlobal::dirs()->locateLocal("appdata", "plasma_dataenginemanager_log");
|
|
||||||
QFile f(path);
|
|
||||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
|
|
||||||
kDebug() << "faild to open" << path;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream out(&f);
|
|
||||||
|
|
||||||
QHashIterator<QString, DataEngine*> it(d->engines);
|
|
||||||
out << "================================== " << KGlobal::locale()->formatDateTime(QDateTime::currentDateTime()) << endl;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
DataEngine *engine = it.value();
|
|
||||||
out << "DataEngine: " << it.key() << ' ' << (QString::fromLatin1("0x") + QString::number(quintptr(engine), 16)) << endl;
|
|
||||||
out << " Claimed # of sources: " << engine->sources().count() << endl;
|
|
||||||
out << " Actual # of sources: " << engine->containerDict().count() << endl;
|
|
||||||
out << endl << " Source Details" << endl;
|
|
||||||
|
|
||||||
foreach (DataContainer *dc, engine->containerDict()) {
|
|
||||||
out << " * " << dc->objectName() << endl;
|
|
||||||
out << " Data count: " << dc->d->data.count() << endl;
|
|
||||||
const int directs = dc->receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
if (directs > 0) {
|
|
||||||
out << " Direction Connections: " << directs << ' ' << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int relays = dc->d->relays.count();
|
|
||||||
if (relays > 0) {
|
|
||||||
out << " Relays: " << dc->d->relays.count() << endl;
|
|
||||||
QString times;
|
|
||||||
foreach (SignalRelay *relay, dc->d->relays) {
|
|
||||||
times.append(' ').append(QString::number(relay->m_interval));
|
|
||||||
}
|
|
||||||
out << " Relay Timeouts: " << times << ' ' << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
out << endl << "-----" << endl;
|
|
||||||
}
|
|
||||||
out << endl << endl;
|
|
||||||
#endif
|
|
||||||
// killTimer(event->timerId());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#include "moc_dataenginemanager.cpp"
|
|
|
@ -1,139 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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_DATAENGINEMANAGER_H
|
|
||||||
#define PLASMA_DATAENGINEMANAGER_H
|
|
||||||
|
|
||||||
#include <QtCore/QHash>
|
|
||||||
|
|
||||||
#include <kplugininfo.h>
|
|
||||||
|
|
||||||
#include <plasma/dataengine.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class DataEngineManagerPrivate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class DataEngineManager plasma/dataenginemanager.h <Plasma/DataEngineManager>
|
|
||||||
*
|
|
||||||
* @short DataEngine loader and life time manager
|
|
||||||
*
|
|
||||||
* Plasma::DataEngineManager provides facilities for listing, loading and
|
|
||||||
* according to reference count unloading of DataEngines.
|
|
||||||
**/
|
|
||||||
class PLASMA_EXPORT DataEngineManager: public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Singleton pattern accessor.
|
|
||||||
*/
|
|
||||||
static DataEngineManager *self();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a data engine object if one is loaded and available.
|
|
||||||
* On failure, the fallback NullEngine (which does nothing and
|
|
||||||
* !isValid()) is returned.
|
|
||||||
*
|
|
||||||
* @param name the name of the engine
|
|
||||||
*/
|
|
||||||
Plasma::DataEngine *engine(const QString &name) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a data engine and increases the reference count on it.
|
|
||||||
* This should be called once per object (or set of objects) using the
|
|
||||||
* DataEngine. Afterwards, dataEngine should be used or the return
|
|
||||||
* value cached. Call unloadDataEngine when finished with the engine.
|
|
||||||
*
|
|
||||||
* @param name the name of the engine
|
|
||||||
* @return the data engine that was loaded, or the NullEngine on failure.
|
|
||||||
*/
|
|
||||||
Plasma::DataEngine *loadEngine(const QString &name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decreases the reference count on the engine. If the count reaches
|
|
||||||
* zero, then the engine is deleted to save resources.
|
|
||||||
*/
|
|
||||||
void unloadEngine(const QString &name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a listing of all known DataEngines by name
|
|
||||||
*
|
|
||||||
* @param parentApp the application to filter applets on. Uses the
|
|
||||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
|
||||||
* The default value of QString() will result in a
|
|
||||||
* list containing only applets not specifically
|
|
||||||
* registered to an application.
|
|
||||||
*/
|
|
||||||
static QStringList listAllEngines(const QString &parentApp = QString());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all known DataEngines.
|
|
||||||
*
|
|
||||||
* @param parentApp the application to filter applets on. Uses the
|
|
||||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
|
||||||
* The default value of QString() will result in a
|
|
||||||
* list containing only applets not specifically
|
|
||||||
* registered to an application.
|
|
||||||
* @return list of DataEngines
|
|
||||||
**/
|
|
||||||
static KPluginInfo::List listEngineInfo(const QString &parentApp = QString());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all known DataEngines filtering by category.
|
|
||||||
*
|
|
||||||
* @param category the category to filter applets on. Uses the
|
|
||||||
* X-KDE-PluginInfo-Category entry (if any) in the
|
|
||||||
* plugin info. The value of QString() will
|
|
||||||
* result in a list of engines with an empty category.
|
|
||||||
*
|
|
||||||
* @param parentApp the application to filter applets on. Uses the
|
|
||||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
|
||||||
* The default value of QString() will result in a
|
|
||||||
* list containing only applets not specifically
|
|
||||||
* registered to an application.
|
|
||||||
* @return list of DataEngines
|
|
||||||
* @since 4.3
|
|
||||||
**/
|
|
||||||
static KPluginInfo::List listEngineInfoByCategory(const QString &category, const QString &parentApp = QString());
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* Reimplemented from QObject
|
|
||||||
**/
|
|
||||||
void timerEvent(QTimerEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* Default constructor. The singleton method self() is the
|
|
||||||
* preferred access mechanism.
|
|
||||||
*/
|
|
||||||
DataEngineManager();
|
|
||||||
~DataEngineManager();
|
|
||||||
|
|
||||||
DataEngineManagerPrivate *const d;
|
|
||||||
|
|
||||||
friend class DataEngineManagerSingleton;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
|
|
@ -70,8 +70,6 @@ class ExtenderItemPrivate;
|
||||||
* void MyApplet::initExtenderItem(Plasma::ExtenderItem *item)
|
* void MyApplet::initExtenderItem(Plasma::ExtenderItem *item)
|
||||||
* {
|
* {
|
||||||
* QGraphicsWidget *myNetworkMonitorWidget = new NetworkMonitorWidget(item);
|
* QGraphicsWidget *myNetworkMonitorWidget = new NetworkMonitorWidget(item);
|
||||||
* dataEngine("networktraffic")->connectSource(item->config().readEntry("device", ""),
|
|
||||||
* myNetworkMonitorWidget);
|
|
||||||
* item->setWidget(myNetworkMonitorWidget);
|
* item->setWidget(myNetworkMonitorWidget);
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
#include "packagemetadata.h"
|
#include "packagemetadata.h"
|
||||||
#include "private/package_p.h"
|
#include "private/package_p.h"
|
||||||
#include "private/service_p.h"
|
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
@ -68,7 +67,6 @@ Package &Package::operator=(const Package &rhs)
|
||||||
if (&rhs != this) {
|
if (&rhs != this) {
|
||||||
*d = *rhs.d;
|
*d = *rhs.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,23 +277,20 @@ QStringList Package::listInstalledPaths(const QString &packageRoot) // static
|
||||||
}
|
}
|
||||||
|
|
||||||
PackagePrivate::PackagePrivate(const PackageStructure::Ptr st, const QString &p)
|
PackagePrivate::PackagePrivate(const PackageStructure::Ptr st, const QString &p)
|
||||||
: structure(st),
|
: structure(st)
|
||||||
service(0)
|
|
||||||
{
|
{
|
||||||
setPathFromStructure(p);
|
setPathFromStructure(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
PackagePrivate::PackagePrivate(const PackageStructure::Ptr st, const QString &packageRoot, const QString &path)
|
PackagePrivate::PackagePrivate(const PackageStructure::Ptr st, const QString &packageRoot, const QString &path)
|
||||||
: structure(st),
|
: structure(st)
|
||||||
service(0)
|
|
||||||
{
|
{
|
||||||
setPathFromStructure(packageRoot.isEmpty() ? path : packageRoot + "/" + path);
|
setPathFromStructure(packageRoot.isEmpty() ? path : packageRoot + "/" + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
PackagePrivate::PackagePrivate(const PackagePrivate &other)
|
PackagePrivate::PackagePrivate(const PackagePrivate &other)
|
||||||
: structure(other.structure),
|
: structure(other.structure),
|
||||||
service(other.service),
|
valid(other.valid)
|
||||||
valid(other.valid)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +301,6 @@ PackagePrivate::~PackagePrivate()
|
||||||
PackagePrivate &PackagePrivate::operator=(const PackagePrivate &rhs)
|
PackagePrivate &PackagePrivate::operator=(const PackagePrivate &rhs)
|
||||||
{
|
{
|
||||||
structure = rhs.structure;
|
structure = rhs.structure;
|
||||||
service = rhs.service;
|
|
||||||
valid = rhs.valid;
|
valid = rhs.valid;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,9 +124,6 @@ PackageStructure::Ptr PackageStructure::load(const QString &packageFormat)
|
||||||
if (packageFormat == "Plasma/Applet") {
|
if (packageFormat == "Plasma/Applet") {
|
||||||
structure = defaultPackageStructure();
|
structure = defaultPackageStructure();
|
||||||
structure->d->type = "Plasma/Applet";
|
structure->d->type = "Plasma/Applet";
|
||||||
} else if (packageFormat == "Plasma/DataEngine") {
|
|
||||||
structure = defaultPackageStructure();
|
|
||||||
structure->d->type = "Plasma/DataEngine";
|
|
||||||
} else if (packageFormat == "Plasma/Runner") {
|
} else if (packageFormat == "Plasma/Runner") {
|
||||||
structure = defaultPackageStructure();
|
structure = defaultPackageStructure();
|
||||||
structure->d->type = "Plasma/Runner";
|
structure->d->type = "Plasma/Runner";
|
||||||
|
|
|
@ -82,32 +82,6 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
|
||||||
return applet;
|
return applet;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine *PluginLoader::loadDataEngine(const QString &name)
|
|
||||||
{
|
|
||||||
// load the engine, add it to the engines
|
|
||||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine",
|
|
||||||
constraint);
|
|
||||||
|
|
||||||
DataEngine *engine = 0;
|
|
||||||
QString error;
|
|
||||||
if (offers.isEmpty()) {
|
|
||||||
kDebug() << "offers are empty for " << name << " with constraint " << constraint;
|
|
||||||
} else {
|
|
||||||
QVariantList allArgs;
|
|
||||||
allArgs << offers.first()->storageId();
|
|
||||||
if (offers.first()) {
|
|
||||||
engine = offers.first()->createInstance<Plasma::DataEngine>(0, allArgs, &error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!engine) {
|
|
||||||
kDebug() << "Couldn't load engine \"" << name << "\". Error given: " << error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractRunner *PluginLoader::loadRunner(const QString &name)
|
AbstractRunner *PluginLoader::loadRunner(const QString &name)
|
||||||
{
|
{
|
||||||
// FIXME: RunnerManager is all wrapped around runner loading; that should be sorted out
|
// FIXME: RunnerManager is all wrapped around runner loading; that should be sorted out
|
||||||
|
@ -140,19 +114,6 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS
|
||||||
return KPluginInfo::fromServices(offers);
|
return KPluginInfo::fromServices(offers);
|
||||||
}
|
}
|
||||||
|
|
||||||
KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
|
|
||||||
{
|
|
||||||
QString constraint;
|
|
||||||
if (parentApp.isEmpty()) {
|
|
||||||
constraint.append("not exist [X-KDE-ParentApp]");
|
|
||||||
} else {
|
|
||||||
constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
|
|
||||||
}
|
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint);
|
|
||||||
return KPluginInfo::fromServices(offers);
|
|
||||||
}
|
|
||||||
|
|
||||||
KPluginInfo::List PluginLoader::listRunnerInfo(const QString &parentApp)
|
KPluginInfo::List PluginLoader::listRunnerInfo(const QString &parentApp)
|
||||||
{
|
{
|
||||||
QString constraint;
|
QString constraint;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
namespace Plasma {
|
namespace Plasma {
|
||||||
|
|
||||||
class Applet;
|
class Applet;
|
||||||
class DataEngine;
|
|
||||||
class AbstractRunner;
|
class AbstractRunner;
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
|
@ -40,7 +39,7 @@ class AbstractRunner;
|
||||||
* default PluginLoader implementation will be used. The reimplemented version should
|
* default PluginLoader implementation will be used. The reimplemented version should
|
||||||
* not do more than simply returning a loaded plugin. It should not init() it, and it should not
|
* not do more than simply returning a loaded plugin. It should not init() it, and it should not
|
||||||
* hang on to it. The associated methods will be called only when a component of Plasma
|
* hang on to it. The associated methods will be called only when a component of Plasma
|
||||||
* needs to load a _new_ plugin. (e.g. DataEngine does its own caching).
|
* needs to load a _new_ plugin.
|
||||||
*
|
*
|
||||||
* @author Ryan Rix <ry@n.rix.si>
|
* @author Ryan Rix <ry@n.rix.si>
|
||||||
* @since 4.6
|
* @since 4.6
|
||||||
|
@ -60,14 +59,6 @@ public:
|
||||||
static Applet *loadApplet(const QString &name, uint appletId = 0,
|
static Applet *loadApplet(const QString &name, uint appletId = 0,
|
||||||
const QVariantList &args = QVariantList());
|
const QVariantList &args = QVariantList());
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a DataEngine plugin.
|
|
||||||
*
|
|
||||||
* @param name the name of the engine
|
|
||||||
* @return the DataEngine that was loaded, or the NullEngine on failure.
|
|
||||||
**/
|
|
||||||
static DataEngine *loadDataEngine(const QString &name);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a Runner plugin
|
* Load a Runner plugin
|
||||||
*
|
*
|
||||||
|
@ -94,18 +85,6 @@ public:
|
||||||
**/
|
**/
|
||||||
static KPluginInfo::List listAppletInfo(const QString &category, const QString &parentApp = QString());
|
static KPluginInfo::List listAppletInfo(const QString &category, const QString &parentApp = QString());
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all known DataEngines.
|
|
||||||
*
|
|
||||||
* @param parentApp the application to filter applets on. Uses the
|
|
||||||
* X-KDE-ParentApp entry (if any) in the plugin info.
|
|
||||||
* The default value of QString() will result in a
|
|
||||||
* list containing only applets not specifically
|
|
||||||
* registered to an application.
|
|
||||||
* @return list of DataEngines
|
|
||||||
**/
|
|
||||||
static KPluginInfo::List listDataEngineInfo(const QString &parentApp = QString());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all known Runner implementations
|
* Returns a list of all known Runner implementations
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,16 +20,14 @@
|
||||||
#ifndef ABSTRACTRUNNER_P_H
|
#ifndef ABSTRACTRUNNER_P_H
|
||||||
#define ABSTRACTRUNNER_P_H
|
#define ABSTRACTRUNNER_P_H
|
||||||
|
|
||||||
#include <QMutex>
|
#include <plasma/plasma.h>
|
||||||
|
|
||||||
#include "dataengineconsumer_p.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class AbstractRunner;
|
class AbstractRunner;
|
||||||
|
|
||||||
class AbstractRunnerPrivate : public DataEngineConsumer
|
class AbstractRunnerPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractRunnerPrivate(AbstractRunner *r);
|
AbstractRunnerPrivate(AbstractRunner *r);
|
||||||
|
@ -50,6 +48,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
#include "plasma/animator.h"
|
#include "plasma/animator.h"
|
||||||
#include "plasma/private/applethandle_p.h"
|
#include "plasma/private/applethandle_p.h"
|
||||||
#include "plasma/private/dataengineconsumer_p.h"
|
|
||||||
|
|
||||||
class KKeySequenceWidget;
|
class KKeySequenceWidget;
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ protected Q_SLOTS:
|
||||||
void overlayAnimationComplete();
|
void overlayAnimationComplete();
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppletPrivate : public DataEngineConsumer
|
class AppletPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet);
|
AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet);
|
||||||
|
@ -143,7 +142,6 @@ public:
|
||||||
|
|
||||||
// applet attributes
|
// applet attributes
|
||||||
QWeakPointer<Extender> extender;
|
QWeakPointer<Extender> extender;
|
||||||
Service *service;
|
|
||||||
Applet::BackgroundHints preferredBackgroundHints;
|
Applet::BackgroundHints preferredBackgroundHints;
|
||||||
Applet::BackgroundHints backgroundHints;
|
Applet::BackgroundHints backgroundHints;
|
||||||
Plasma::AspectRatioMode aspectRatioMode;
|
Plasma::AspectRatioMode aspectRatioMode;
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
#ifndef PLASMA_CONTAINMENTACTIONSPRIVATE_H
|
#ifndef PLASMA_CONTAINMENTACTIONSPRIVATE_H
|
||||||
#define PLASMA_CONTAINMENTACTIONSPRIVATE_H
|
#define PLASMA_CONTAINMENTACTIONSPRIVATE_H
|
||||||
|
|
||||||
#include "plasma/private/dataengineconsumer_p.h"
|
#include <plasma/plasma.h>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class ContainmentActionsPrivate : public DataEngineConsumer
|
class ContainmentActionsPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ContainmentActionsPrivate(KService::Ptr service, ContainmentActions *containmentActions) :
|
ContainmentActionsPrivate(KService::Ptr service, ContainmentActions *containmentActions) :
|
||||||
|
|
|
@ -1,172 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
#include "datacontainer.h" //krazy:exclude=includes
|
|
||||||
#include "datacontainer_p.h" //krazy:exclude=includes
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
SignalRelay *DataContainerPrivate::signalRelay(const DataContainer *dc, QObject *visualization,
|
|
||||||
uint pollingInterval,
|
|
||||||
Plasma::IntervalAlignment align,
|
|
||||||
bool immediateUpdate)
|
|
||||||
{
|
|
||||||
QMap<uint, SignalRelay *>::const_iterator relayIt = relays.constFind(pollingInterval);
|
|
||||||
SignalRelay *relay = 0;
|
|
||||||
|
|
||||||
//FIXME what if we have two applets with the same interval and different alignment?
|
|
||||||
if (relayIt == relays.constEnd()) {
|
|
||||||
relay = new SignalRelay(const_cast<DataContainer*>(dc), this,
|
|
||||||
pollingInterval, align, immediateUpdate);
|
|
||||||
relays[pollingInterval] = relay;
|
|
||||||
} else {
|
|
||||||
relay = relayIt.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
relayObjects[visualization] = relay;
|
|
||||||
return relay;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DataContainerPrivate::hasUpdates()
|
|
||||||
{
|
|
||||||
if (cached) {
|
|
||||||
// SignalRelay needs us to pretend we did an update
|
|
||||||
cached = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dirty;
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalRelay::SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint ival,
|
|
||||||
Plasma::IntervalAlignment align, bool immediateUpdate)
|
|
||||||
: QObject(parent),
|
|
||||||
dc(parent),
|
|
||||||
d(data),
|
|
||||||
m_interval(ival),
|
|
||||||
m_align(align),
|
|
||||||
m_resetTimer(true),
|
|
||||||
m_queued(true)
|
|
||||||
{
|
|
||||||
//kDebug() << "signal relay with time of" << m_timerId << "being set up";
|
|
||||||
m_timerId = startTimer(immediateUpdate ? 0 : m_interval);
|
|
||||||
if (m_align != Plasma::NoAlignment) {
|
|
||||||
checkAlignment();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int SignalRelay::receiverCount() const
|
|
||||||
{
|
|
||||||
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SignalRelay::isUnused() const
|
|
||||||
{
|
|
||||||
return receivers(SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data))) < 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SignalRelay::checkAlignment()
|
|
||||||
{
|
|
||||||
int newTime = 0;
|
|
||||||
|
|
||||||
QTime t = QTime::currentTime();
|
|
||||||
if (m_align == Plasma::AlignToMinute) {
|
|
||||||
int seconds = t.second();
|
|
||||||
if (seconds > 2) {
|
|
||||||
newTime = ((60 - seconds) * 1000) + 500;
|
|
||||||
}
|
|
||||||
} else if (m_align == Plasma::AlignToHour) {
|
|
||||||
int minutes = t.minute();
|
|
||||||
int seconds = t.second();
|
|
||||||
if (minutes > 1 || seconds > 10) {
|
|
||||||
newTime = ((60 - minutes) * 1000 * 60) +
|
|
||||||
((60 - seconds) * 1000) + 500;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newTime) {
|
|
||||||
killTimer(m_timerId);
|
|
||||||
m_timerId = startTimer(newTime);
|
|
||||||
m_resetTimer = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SignalRelay::checkQueueing()
|
|
||||||
{
|
|
||||||
//kDebug() << m_queued;
|
|
||||||
if (m_queued) {
|
|
||||||
emit dataUpdated(dc->objectName(), d->data);
|
|
||||||
m_queued = false;
|
|
||||||
//TODO: should we re-align our timer at this point, to avoid
|
|
||||||
// constant queueing due to more-or-less constant time
|
|
||||||
// async update time? this might make sense for
|
|
||||||
// staggered accesses to the same source by multiple
|
|
||||||
// visualizations causing a minimumPollingInterval violation.
|
|
||||||
// it may not make sense for purely async-and-takes-a-while
|
|
||||||
// type operations (e.g. network fetching).
|
|
||||||
// we need more real world data before making such a change
|
|
||||||
// change
|
|
||||||
//
|
|
||||||
// killTimer(m_timerId);
|
|
||||||
// m_timerId = startTime(m_interval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SignalRelay::forceImmediateUpdate()
|
|
||||||
{
|
|
||||||
emit dataUpdated(dc->objectName(), d->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SignalRelay::timerEvent(QTimerEvent *event)
|
|
||||||
{
|
|
||||||
if (event->timerId() != m_timerId) {
|
|
||||||
QObject::timerEvent(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_resetTimer) {
|
|
||||||
killTimer(m_timerId);
|
|
||||||
m_timerId = startTimer(m_interval);
|
|
||||||
m_resetTimer = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_align != Plasma::NoAlignment) {
|
|
||||||
checkAlignment();
|
|
||||||
}
|
|
||||||
|
|
||||||
emit dc->updateRequested(dc);
|
|
||||||
if (d->hasUpdates()) {
|
|
||||||
//kDebug() << "emitting data updated directly" << d->data;
|
|
||||||
emit dataUpdated(dc->objectName(), d->data);
|
|
||||||
m_queued = false;
|
|
||||||
} else {
|
|
||||||
// the source wasn't actually updated; so let's put ourselves in the queue
|
|
||||||
// so we get a dataUpdated() call when the data does arrive
|
|
||||||
//kDebug() << "queued";
|
|
||||||
m_queued = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Plasma namespace
|
|
||||||
|
|
||||||
#include "moc_datacontainer_p.cpp"
|
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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_DATACONTAINER_P_H
|
|
||||||
#define PLASMA_DATACONTAINER_P_H
|
|
||||||
|
|
||||||
#include <QtCore/qcoreevent.h>
|
|
||||||
#include <QtCore/QElapsedTimer>
|
|
||||||
#include <QtCore/QBasicTimer>
|
|
||||||
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
class SignalRelay;
|
|
||||||
|
|
||||||
class DataContainerPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataContainerPrivate(DataContainer *container)
|
|
||||||
: q(container),
|
|
||||||
dirty(false),
|
|
||||||
cached(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization,
|
|
||||||
uint pollingInterval, Plasma::IntervalAlignment align,
|
|
||||||
bool immediateUpdate);
|
|
||||||
|
|
||||||
bool hasUpdates();
|
|
||||||
|
|
||||||
DataContainer *q;
|
|
||||||
DataEngine::Data data;
|
|
||||||
QMap<QObject *, SignalRelay *> relayObjects;
|
|
||||||
QMap<uint, SignalRelay *> relays;
|
|
||||||
QElapsedTimer updateTimer;
|
|
||||||
QBasicTimer checkUsageTimer;
|
|
||||||
bool dirty : 1;
|
|
||||||
bool cached : 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SignalRelay : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
SignalRelay(DataContainer *parent, DataContainerPrivate *data,
|
|
||||||
uint ival, Plasma::IntervalAlignment align, bool immediateUpdate);
|
|
||||||
|
|
||||||
int receiverCount() const;
|
|
||||||
bool isUnused() const;
|
|
||||||
|
|
||||||
void checkAlignment();
|
|
||||||
void checkQueueing();
|
|
||||||
void forceImmediateUpdate();
|
|
||||||
|
|
||||||
DataContainer *dc;
|
|
||||||
DataContainerPrivate *d;
|
|
||||||
uint m_interval;
|
|
||||||
Plasma::IntervalAlignment m_align;
|
|
||||||
int m_timerId;
|
|
||||||
bool m_resetTimer;
|
|
||||||
bool m_queued;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void dataUpdated(const QString &, const Plasma::DataEngine::Data &);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void timerEvent(QTimerEvent *event);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Plasma namespace
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2006-2007 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 DATAENGINE_P_H
|
|
||||||
#define DATAENGINE_P_H
|
|
||||||
|
|
||||||
#include <QQueue>
|
|
||||||
#include <QElapsedTimer>
|
|
||||||
|
|
||||||
#include <kplugininfo.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class Service;
|
|
||||||
|
|
||||||
class DataEnginePrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataEnginePrivate(DataEngine *e, const KPluginInfo &info);
|
|
||||||
~DataEnginePrivate();
|
|
||||||
DataContainer *source(const QString &sourceName, bool createWhenMissing = true);
|
|
||||||
void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval,
|
|
||||||
Plasma::IntervalAlignment align, bool immediateCall = true);
|
|
||||||
DataContainer *requestSource(const QString &sourceName, bool *newSource = 0);
|
|
||||||
void trimQueue();
|
|
||||||
void internalUpdateSource(DataContainer*);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reference counting method. Calling this method increases the count
|
|
||||||
* by one.
|
|
||||||
**/
|
|
||||||
void ref();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reference counting method. Calling this method decreases the count
|
|
||||||
* by one.
|
|
||||||
**/
|
|
||||||
void deref();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reference counting method. Used to determine if this DataEngine is
|
|
||||||
* used.
|
|
||||||
* @return true if the reference count is non-zero
|
|
||||||
**/
|
|
||||||
bool isUsed() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* a datacontainer has been destroyed, clean up stuff
|
|
||||||
*/
|
|
||||||
void sourceDestroyed(QObject *object);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stores the source
|
|
||||||
* @param sourceName the name of the source to store
|
|
||||||
*/
|
|
||||||
void storeSource(DataContainer *source) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* stores all sources marked for storage
|
|
||||||
*/
|
|
||||||
void storeAllSources();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* retrieves source data
|
|
||||||
* @param the data container to populate
|
|
||||||
*/
|
|
||||||
void retrieveStoredData(DataContainer *s);
|
|
||||||
|
|
||||||
DataEngine *q;
|
|
||||||
KPluginInfo dataEngineDescription;
|
|
||||||
int refCount;
|
|
||||||
int checkSourcesTimerId;
|
|
||||||
int updateTimerId;
|
|
||||||
int minPollingInterval;
|
|
||||||
QElapsedTimer updateTimer;
|
|
||||||
DataEngine::SourceDict sources;
|
|
||||||
QQueue<DataContainer*> sourceQueue;
|
|
||||||
QString icon;
|
|
||||||
uint limit;
|
|
||||||
bool valid;
|
|
||||||
QString engineName;
|
|
||||||
QString waitingSourceRequest;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Plasma namespace
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2005 by Aaron Seigo <aseigo@kde.org>
|
|
||||||
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
|
|
||||||
* Copyright 2008 by Ménard Alexis <darktears31@gmail.com>
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dataengineconsumer_p.h"
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
|
|
||||||
#include "plasma/dataenginemanager.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
DataEngineConsumer::DataEngineConsumer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngineConsumer::~DataEngineConsumer()
|
|
||||||
{
|
|
||||||
foreach (const QString &engine, m_loadedEngines) {
|
|
||||||
DataEngineManager::self()->unloadEngine(engine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine *DataEngineConsumer::dataEngine(const QString &name)
|
|
||||||
{
|
|
||||||
if (m_loadedEngines.contains(name)) {
|
|
||||||
DataEngine *engine = DataEngineManager::self()->engine(name);
|
|
||||||
if (engine->isValid()) {
|
|
||||||
return engine;
|
|
||||||
} else {
|
|
||||||
m_loadedEngines.remove(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DataEngine *engine = DataEngineManager::self()->loadEngine(name);
|
|
||||||
if (engine->isValid()) {
|
|
||||||
m_loadedEngines.insert(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2005 by Aaron Seigo <aseigo@kde.org>
|
|
||||||
* Copyright 2007 by Riccardo Iaconelli <riccardo@kde.org>
|
|
||||||
* Copyright 2008 by Ménard Alexis <darktears31@gmail.com>
|
|
||||||
*
|
|
||||||
* 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_DATAENGINECONSUMER_H
|
|
||||||
#define PLASMA_DATAENGINECONSUMER_H
|
|
||||||
|
|
||||||
#include <QtCore/QSet>
|
|
||||||
|
|
||||||
#include "plasma/dataengine.h"
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class DataEngineConsumer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataEngineConsumer();
|
|
||||||
~DataEngineConsumer();
|
|
||||||
DataEngine *dataEngine(const QString &name);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QSet<QString> m_loadedEngines;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "../plasma.h"
|
#include "../plasma.h"
|
||||||
#include "../package.h"
|
#include "../package.h"
|
||||||
#include "../service.h"
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
@ -43,7 +42,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
PackageStructure::Ptr structure;
|
PackageStructure::Ptr structure;
|
||||||
Service *service;
|
|
||||||
bool valid;
|
bool valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2008 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 SERVICE_P_H
|
|
||||||
#define SERVICE_P_H
|
|
||||||
|
|
||||||
#include "servicejob.h"
|
|
||||||
#include "service.h"
|
|
||||||
|
|
||||||
#include <QGraphicsObject>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QMultiHash>
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QSet>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class NullServiceJob : public ServiceJob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NullServiceJob(const QString &destination, const QString &operation, QObject *parent)
|
|
||||||
: ServiceJob(destination, operation, QMap<QString, QVariant>(), parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void start()
|
|
||||||
{
|
|
||||||
setErrorText(i18nc("Error message, tried to start an invalid service", "Invalid (null) service, can not perform any operations."));
|
|
||||||
emitResult();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NullService : public Service
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NullService(const QString &target, QObject *parent)
|
|
||||||
: Service(parent)
|
|
||||||
{
|
|
||||||
setDestination(target);
|
|
||||||
setName("NullService");
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceJob *createJob(const QString &operation, const QMap<QString, QVariant> &)
|
|
||||||
{
|
|
||||||
return new NullServiceJob(destination(), operation, this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class ServicePrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ServicePrivate(Service *service)
|
|
||||||
: q(service)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void jobFinished(KJob *job);
|
|
||||||
|
|
||||||
void associatedWidgetDestroyed(QObject *obj);
|
|
||||||
|
|
||||||
void associatedGraphicsWidgetDestroyed(QObject *obj);
|
|
||||||
|
|
||||||
Service *q;
|
|
||||||
QString destination;
|
|
||||||
QString name;
|
|
||||||
QStringList operationNames;
|
|
||||||
QSet<QString> disabledOperations;
|
|
||||||
QMultiHash<QWidget *, QString> associatedWidgets;
|
|
||||||
QMultiHash<QGraphicsObject *, QString> associatedGraphicsWidgets;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
#include <QtCore/QQueue>
|
#include <QtCore/QQueue>
|
||||||
#include <QtCore/qsharedpointer.h>
|
#include <QtCore/qsharedpointer.h>
|
||||||
|
|
||||||
#include "plasma/private/dataengineconsumer_p.h"
|
#include "plasma/plasma.h"
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class WallpaperPrivate : public DataEngineConsumer
|
class WallpaperPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper);
|
WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper);
|
||||||
|
|
|
@ -1,265 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2008 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "service.h"
|
|
||||||
#include "servicejob.h"
|
|
||||||
#include "private/service_p.h"
|
|
||||||
|
|
||||||
#include <QGraphicsWidget>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
Service::Service(QObject *parent)
|
|
||||||
: QObject(parent),
|
|
||||||
d(new ServicePrivate(this))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Service::~Service()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServicePrivate::jobFinished(KJob *job)
|
|
||||||
{
|
|
||||||
emit q->finished(static_cast<ServiceJob*>(job));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServicePrivate::associatedWidgetDestroyed(QObject *obj)
|
|
||||||
{
|
|
||||||
associatedWidgets.remove(static_cast<QWidget*>(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServicePrivate::associatedGraphicsWidgetDestroyed(QObject *obj)
|
|
||||||
{
|
|
||||||
associatedGraphicsWidgets.remove(static_cast<QGraphicsObject*>(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::setDestination(const QString &destination)
|
|
||||||
{
|
|
||||||
d->destination = destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Service::destination() const
|
|
||||||
{
|
|
||||||
return d->destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Service::operationNames() const
|
|
||||||
{
|
|
||||||
if (d->operationNames.isEmpty()) {
|
|
||||||
kDebug() << "No operations are set";
|
|
||||||
}
|
|
||||||
return d->operationNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, QVariant> Service::operationParameters(const QString &operation)
|
|
||||||
{
|
|
||||||
if (!d->operationNames.contains(operation)) {
|
|
||||||
kDebug() << operation << "is not valid operations name";
|
|
||||||
}
|
|
||||||
// NOTE: default implementation returns nothing on purpose, here for future
|
|
||||||
// expansion and binding the parameters type to variable in plasmoids easier
|
|
||||||
return QMap<QString, QVariant>();
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceJob *Service::startOperationCall(const QString &operation, const QMap<QString, QVariant> ¶meters, QObject *parent)
|
|
||||||
{
|
|
||||||
ServiceJob *job = 0;
|
|
||||||
if (!operation.isEmpty() && d->operationNames.contains(operation)) {
|
|
||||||
if (d->disabledOperations.contains(operation)) {
|
|
||||||
kDebug() << "Operation" << operation << "is disabled";
|
|
||||||
} else {
|
|
||||||
job = createJob(operation, parameters);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
kDebug() << operation << "is not valid, valid are:" << d->operationNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!job) {
|
|
||||||
job = new NullServiceJob(destination(), operation, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
job->setParent(parent ? parent : this);
|
|
||||||
connect(job, SIGNAL(finished(KJob*)), this, SLOT(jobFinished(KJob*)));
|
|
||||||
QTimer::singleShot(0, job, SLOT(autoStart()));
|
|
||||||
return job;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::associateWidget(QWidget *widget, const QString &operation)
|
|
||||||
{
|
|
||||||
if (!widget) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
disassociateWidget(widget);
|
|
||||||
d->associatedWidgets.insert(widget, operation);
|
|
||||||
connect(
|
|
||||||
widget, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(associatedWidgetDestroyed(QObject*))
|
|
||||||
);
|
|
||||||
widget->setEnabled(!d->disabledOperations.contains(operation));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::disassociateWidget(QWidget *widget)
|
|
||||||
{
|
|
||||||
if (!widget) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnect(
|
|
||||||
widget, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(associatedWidgetDestroyed(QObject*))
|
|
||||||
);
|
|
||||||
d->associatedWidgets.remove(widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::associateWidget(QGraphicsWidget *widget, const QString &operation)
|
|
||||||
{
|
|
||||||
associateItem(widget, operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::disassociateWidget(QGraphicsWidget *widget)
|
|
||||||
{
|
|
||||||
disassociateItem(widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::associateItem(QGraphicsObject *widget, const QString &operation)
|
|
||||||
{
|
|
||||||
if (!widget) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
disassociateItem(widget);
|
|
||||||
d->associatedGraphicsWidgets.insert(widget, operation);
|
|
||||||
connect(
|
|
||||||
widget, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(associatedGraphicsWidgetDestroyed(QObject*))
|
|
||||||
);
|
|
||||||
widget->setEnabled(!d->disabledOperations.contains(operation));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::disassociateItem(QGraphicsObject *widget)
|
|
||||||
{
|
|
||||||
if (!widget) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnect(
|
|
||||||
widget, SIGNAL(destroyed(QObject*)),
|
|
||||||
this, SLOT(associatedGraphicsWidgetDestroyed(QObject*))
|
|
||||||
);
|
|
||||||
d->associatedGraphicsWidgets.remove(widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Service::name() const
|
|
||||||
{
|
|
||||||
return d->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::setName(const QString &name)
|
|
||||||
{
|
|
||||||
d->name = name;
|
|
||||||
|
|
||||||
if (d->name.isEmpty()) {
|
|
||||||
kDebug() << "Name is set to empty";
|
|
||||||
emit serviceReady(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit operationsChanged();
|
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QWidget *, QString> it(d->associatedWidgets);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
it.key()->setEnabled(isOperationEnabled(it.value()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QGraphicsObject *, QString> it(d->associatedGraphicsWidgets);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
it.key()->setEnabled(isOperationEnabled(it.value()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emit serviceReady(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::setOperationNames(const QStringList &operations)
|
|
||||||
{
|
|
||||||
d->operationNames = operations;
|
|
||||||
|
|
||||||
if (d->operationNames.isEmpty()) {
|
|
||||||
kDebug() << "Operation names is set to empty";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit operationsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Service::setOperationEnabled(const QString &operation, bool enable)
|
|
||||||
{
|
|
||||||
if (!d->operationNames.contains(operation)) {
|
|
||||||
kDebug() << operation << "is not valid operations name";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enable) {
|
|
||||||
d->disabledOperations.remove(operation);
|
|
||||||
} else {
|
|
||||||
d->disabledOperations.insert(operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QWidget *, QString> it(d->associatedWidgets);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
if (it.value() == operation) {
|
|
||||||
it.key()->setEnabled(enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
QHashIterator<QGraphicsObject *, QString> it(d->associatedGraphicsWidgets);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
if (it.value() == operation) {
|
|
||||||
it.key()->setEnabled(enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Service::isOperationEnabled(const QString &operation) const
|
|
||||||
{
|
|
||||||
return d->operationNames.contains(operation) && !d->disabledOperations.contains(operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#include "moc_service.cpp"
|
|
||||||
|
|
283
plasma/service.h
283
plasma/service.h
|
@ -1,283 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2008 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_SERVICE_H
|
|
||||||
#define PLASMA_SERVICE_H
|
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
#include <kconfiggroup.h>
|
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
|
||||||
#include <plasma/plasma.h>
|
|
||||||
|
|
||||||
#include <QGraphicsObject>
|
|
||||||
#include <QIODevice>
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class ServiceJob;
|
|
||||||
class ServicePrivate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class Service plasma/service.h <Plasma/Service>
|
|
||||||
*
|
|
||||||
* @short This class provides a generic API for write access services.
|
|
||||||
*
|
|
||||||
* Plasma::Service allows interaction with a "destination", the definition of which
|
|
||||||
* depends on the Service itself. For a network settings Service this might be a
|
|
||||||
* profile name ("Home", "Office", "Road Warrior") while a web based Service this
|
|
||||||
* might be a username ("aseigo", "stranger65").
|
|
||||||
*
|
|
||||||
* A Service provides one or more operations, each of which provides some sort
|
|
||||||
* of interaction with the destination. Operations are set by the service itself
|
|
||||||
* and their availability can be changed at any time.
|
|
||||||
*
|
|
||||||
* A service is started with a QVariantMap representing the parameters, after
|
|
||||||
* completion a signal is emitted. The service job is automatically deleted,
|
|
||||||
* see KJob for more information on this part of the process.
|
|
||||||
*
|
|
||||||
* Services may be loaded from a DataEngine by passing in a source name to be used
|
|
||||||
* as the destination.
|
|
||||||
*
|
|
||||||
* Sample use might look like:
|
|
||||||
*
|
|
||||||
* @code
|
|
||||||
* Plasma::DataEngine *twitter = dataEngine("twitter");
|
|
||||||
* Plasma::Service *service = twitter.serviceForSource("aseigo");
|
|
||||||
* QVariantMap args = service->operationParameters("update");
|
|
||||||
* args["tweet"] = "Hacking on plasma!";
|
|
||||||
* Plasma::ServiceJob *job = service->startOperationCall("update", args);
|
|
||||||
* connect(job, SIGNAL(finished(KJob*)), this, SLOT(jobCompeted()));
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
* Please remember, the service needs to be deleted when it will no longer be
|
|
||||||
* used. This can be done manually or by these (perhaps easier) alternatives:
|
|
||||||
*
|
|
||||||
* If it is needed throughout the lifetime of the object:
|
|
||||||
* @code
|
|
||||||
* service->setParent(this);
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
* If the service will not be used after just one operation call, use:
|
|
||||||
* @code
|
|
||||||
* connect(job, SIGNAL(finished(KJob*)), service, SLOT(deleteLater()));
|
|
||||||
* @endcode
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class PLASMA_EXPORT Service : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_DECLARE_PRIVATE(Service)
|
|
||||||
Q_PROPERTY(QString destination READ destination WRITE setDestination)
|
|
||||||
Q_PROPERTY(QStringList operationNames READ operationNames)
|
|
||||||
Q_PROPERTY(QString name READ name)
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~Service();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the destination for this Service to operate on
|
|
||||||
*
|
|
||||||
* @param destination specific to each Service, this sets which
|
|
||||||
* target or address for ServiceJobs to operate on
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void setDestination(const QString &destination);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the target destination, if any, that this service is associated with
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QString destination() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the possible operations for this Service
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QStringList operationNames() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the parameters for a given operation
|
|
||||||
*
|
|
||||||
* @param operation the operation to retrieve parameters for
|
|
||||||
* @return QVariantMap containing the default parameters
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QMap<QString, QVariant> operationParameters(const QString &operation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called to create a ServiceJob which is associated with a given
|
|
||||||
* operation and parameter set.
|
|
||||||
*
|
|
||||||
* @return a started ServiceJob; the consumer may connect to relevant
|
|
||||||
* signals before returning to the event loop
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE ServiceJob *startOperationCall(const QString &operation, const QMap<QString, QVariant> ¶meters,
|
|
||||||
QObject *parent = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query to find if an operation is enabled or not.
|
|
||||||
*
|
|
||||||
* @param operation the name of the operation to check
|
|
||||||
* @return true if the operation is enabled, false otherwise
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE bool isOperationEnabled(const QString &operation) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of this service
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE QString name() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Assoicates a widget with an operation, which allows the service to
|
|
||||||
* automatically manage, for example, the enabled state of a widget.
|
|
||||||
*
|
|
||||||
* This will remove any previous associations the widget had with
|
|
||||||
* operations on this engine.
|
|
||||||
*
|
|
||||||
* @param widget the QWidget to associate with the service
|
|
||||||
* @param operation the operation to associate the widget with
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void associateWidget(QWidget *widget, const QString &operation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disassociates a widget if it has been associated with an operation
|
|
||||||
* on this service.
|
|
||||||
*
|
|
||||||
* This will not change the enabled state of the widget.
|
|
||||||
*
|
|
||||||
* @param widget the QWidget to disassociate.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void disassociateWidget(QWidget *widget);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method only exists to maintain binary compatibility.
|
|
||||||
*
|
|
||||||
* @see associateItem
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void associateWidget(QGraphicsWidget *widget, const QString &operation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method only exists to maintain binary compatibility.
|
|
||||||
*
|
|
||||||
* @see disassociateItem
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Associates a graphics item with an operation, which allows the service to
|
|
||||||
* automatically manage, for example, the enabled state of the item.
|
|
||||||
*
|
|
||||||
* This will remove any previous associations the item had with
|
|
||||||
* operations on this engine.
|
|
||||||
*
|
|
||||||
* @param item the QGraphicsObject to associate with the service
|
|
||||||
* @param operation the operation to associate the item with
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void associateItem(QGraphicsObject *item, const QString &operation);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disassociates a graphics item if it has been associated with an operation
|
|
||||||
* on this service.
|
|
||||||
*
|
|
||||||
* This will not change the enabled state of the item.
|
|
||||||
*
|
|
||||||
* @param widget the QGraphicsItem to disassociate.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void disassociateItem(QGraphicsObject *widget);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
/**
|
|
||||||
* Emitted when a job associated with this Service completes its task
|
|
||||||
*/
|
|
||||||
void finished(Plasma::ServiceJob *job);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when the Service's operations change. For example, a
|
|
||||||
* media player service may change what operations are available
|
|
||||||
* in response to the state of the player.
|
|
||||||
*/
|
|
||||||
void operationsChanged();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Emitted when this service is ready for use
|
|
||||||
*/
|
|
||||||
void serviceReady(Plasma::Service *service);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* Default constructor
|
|
||||||
*
|
|
||||||
* @param parent the parent object for this service
|
|
||||||
*/
|
|
||||||
explicit Service(QObject *parent = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a job should be created by the Service.
|
|
||||||
*
|
|
||||||
* @param operation which operation to work on
|
|
||||||
* @param parameters the parameters set by the user for the operation
|
|
||||||
* @return a ServiceJob that can be started and monitored by the consumer
|
|
||||||
*/
|
|
||||||
virtual ServiceJob *createJob(const QString &operation,
|
|
||||||
const QMap<QString, QVariant> ¶meters) = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name of the Service.
|
|
||||||
*
|
|
||||||
* @param name the name to use for this service
|
|
||||||
*/
|
|
||||||
void setName(const QString &name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the operations of the Service.
|
|
||||||
*
|
|
||||||
* @param operations the operations this service supports
|
|
||||||
*/
|
|
||||||
void setOperationNames(const QStringList &operations);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables or disables given operation
|
|
||||||
*
|
|
||||||
* @param operation the name of the operation to enable or disable
|
|
||||||
* @param enable true if the operation should be enabld, false if disabled
|
|
||||||
*/
|
|
||||||
void setOperationEnabled(const QString &operation, bool enable);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_PRIVATE_SLOT(d, void jobFinished(KJob *))
|
|
||||||
Q_PRIVATE_SLOT(d, void associatedWidgetDestroyed(QObject *))
|
|
||||||
Q_PRIVATE_SLOT(d, void associatedGraphicsWidgetDestroyed(QObject *))
|
|
||||||
|
|
||||||
ServicePrivate * const d;
|
|
||||||
|
|
||||||
friend class Applet;
|
|
||||||
friend class DataEnginePrivate;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Plasma::Service *)
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2008 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "servicejob.h"
|
|
||||||
|
|
||||||
#include <kdebug.h>
|
|
||||||
|
|
||||||
#include <plasma/private/servicejob_p.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest,
|
|
||||||
const QString &op, const QMap<QString, QVariant> ¶ms)
|
|
||||||
: q(owner),
|
|
||||||
destination(dest),
|
|
||||||
operation(op),
|
|
||||||
parameters(params),
|
|
||||||
m_allowAutoStart(true)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceJobPrivate::preventAutoStart()
|
|
||||||
{
|
|
||||||
m_allowAutoStart = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceJobPrivate::autoStart()
|
|
||||||
{
|
|
||||||
if (m_allowAutoStart) {
|
|
||||||
q->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceJob::ServiceJob(const QString &destination, const QString &operation,
|
|
||||||
const QMap<QString, QVariant> ¶meters, QObject *parent)
|
|
||||||
: KJob(parent),
|
|
||||||
d(new ServiceJobPrivate(this, destination, operation, parameters))
|
|
||||||
{
|
|
||||||
connect(this, SIGNAL(finished(KJob*)), this, SLOT(preventAutoStart()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ServiceJob::~ServiceJob()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ServiceJob::destination() const
|
|
||||||
{
|
|
||||||
return d->destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ServiceJob::operationName() const
|
|
||||||
{
|
|
||||||
return d->operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, QVariant> ServiceJob::parameters() const
|
|
||||||
{
|
|
||||||
return d->parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant ServiceJob::result() const
|
|
||||||
{
|
|
||||||
return d->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceJob::setResult(const QVariant &result)
|
|
||||||
{
|
|
||||||
d->result = result;
|
|
||||||
emitResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServiceJob::start()
|
|
||||||
{
|
|
||||||
setResult(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
#include "moc_servicejob.cpp"
|
|
||||||
|
|
|
@ -1,130 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2008 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_SERVICEJOB_H
|
|
||||||
#define PLASMA_SERVICEJOB_H
|
|
||||||
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
|
|
||||||
#include <kjob.h>
|
|
||||||
#include <kservice.h>
|
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
|
||||||
{
|
|
||||||
|
|
||||||
class ServiceJobPrivate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class ServiceJob plasma/servicejob.h <Plasma/ServiceJob>
|
|
||||||
*
|
|
||||||
* @short This class provides jobs for use with Plasma::Service
|
|
||||||
*
|
|
||||||
* Unlike KJob, you can do the work in start(), since Plasma::Service already
|
|
||||||
* delays the call to start() until the event loop is reached.
|
|
||||||
*
|
|
||||||
* If the job is quick enough that it is not worth reporting the progress,
|
|
||||||
* you just need to implement start() to do the task, then call emitResult()
|
|
||||||
* at the end of it. If the task does not complete successfully, you should
|
|
||||||
* set a non-zero error code with setError(int) and an error message with
|
|
||||||
* setErrorText(QString).
|
|
||||||
*
|
|
||||||
* If the job is longer (involving network access, for instance), you should
|
|
||||||
* report the progress at regular intervals. See the KJob documentation for
|
|
||||||
* information on how to do this.
|
|
||||||
*/
|
|
||||||
class PLASMA_EXPORT ServiceJob : public KJob
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString destination READ destination)
|
|
||||||
Q_PROPERTY(QString operationName READ operationName)
|
|
||||||
Q_PROPERTY(QVariant result READ result)
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Default constructor
|
|
||||||
*
|
|
||||||
* @param destination the subject that the job is acting on
|
|
||||||
* @param operation the action that the job is performing on the @p destination
|
|
||||||
* @param parameters the parameters of the @p action
|
|
||||||
* @param parent the parent object for this service
|
|
||||||
*/
|
|
||||||
ServiceJob(const QString &destination, const QString &operation,
|
|
||||||
const QMap<QString, QVariant> ¶meters, QObject *parent = 0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
~ServiceJob();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the subject that the job is acting on
|
|
||||||
*/
|
|
||||||
QString destination() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the operation the job is performing on the destination
|
|
||||||
*/
|
|
||||||
QString operationName() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the parameters for the operation
|
|
||||||
*/
|
|
||||||
QMap<QString, QVariant> parameters() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the result of the operation
|
|
||||||
*
|
|
||||||
* The result will be invalid if the job has not completed yet, or
|
|
||||||
* if the job does not have a meaningful result.
|
|
||||||
*
|
|
||||||
* Note that this should not be used to find out whether the operation
|
|
||||||
* was successful. Instead, you should check the value of error().
|
|
||||||
*
|
|
||||||
* @return the result of the operation
|
|
||||||
*/
|
|
||||||
QVariant result() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default implementation of start, which simply sets the results to false.
|
|
||||||
* This makes it easy to create a "failure" job.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE virtual void start();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/**
|
|
||||||
* Sets the result for an operation.
|
|
||||||
*/
|
|
||||||
void setResult(const QVariant &result);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Q_PRIVATE_SLOT(d, void autoStart())
|
|
||||||
Q_PRIVATE_SLOT(d, void preventAutoStart())
|
|
||||||
|
|
||||||
ServiceJobPrivate * const d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Plasma
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Plasma::ServiceJob *)
|
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "wallpaper.h"
|
#include "wallpaper.h"
|
||||||
#include "plasma/plasma.h"
|
#include "plasma/plasma.h"
|
||||||
#include "plasma/package.h"
|
#include "plasma/package.h"
|
||||||
#include "plasma/private/dataengineconsumer_p.h"
|
|
||||||
#include "plasma/private/packages_p.h"
|
#include "plasma/private/packages_p.h"
|
||||||
#include "plasma/private/wallpaper_p.h"
|
#include "plasma/private/wallpaper_p.h"
|
||||||
|
|
||||||
|
@ -280,11 +279,6 @@ void Wallpaper::wheelEvent(QGraphicsSceneWheelEvent *event)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine *Wallpaper::dataEngine(const QString &name) const
|
|
||||||
{
|
|
||||||
return d->dataEngine(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Wallpaper::configurationRequired() const
|
bool Wallpaper::configurationRequired() const
|
||||||
{
|
{
|
||||||
return d->needsConfig;
|
return d->needsConfig;
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class DataEngine;
|
|
||||||
class WallpaperPrivate;
|
class WallpaperPrivate;
|
||||||
class Package;
|
class Package;
|
||||||
|
|
||||||
|
@ -279,27 +278,6 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||||
*/
|
*/
|
||||||
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
|
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given DataEngine
|
|
||||||
*
|
|
||||||
* Tries to load the data engine given by @p name. Each engine is
|
|
||||||
* only loaded once, and that instance is re-used on all subsequent
|
|
||||||
* requests.
|
|
||||||
*
|
|
||||||
* If the data engine was not found, an invalid data engine is returned
|
|
||||||
* (see DataEngine::isValid()).
|
|
||||||
*
|
|
||||||
* Note that you should <em>not</em> delete the returned engine.
|
|
||||||
*
|
|
||||||
* @param name Name of the data engine to load
|
|
||||||
* @return pointer to the data engine if it was loaded,
|
|
||||||
* or an invalid data engine if the requested engine
|
|
||||||
* could not be loaded
|
|
||||||
*
|
|
||||||
* @since 4.3
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the wallpaper currently needs to be configured,
|
* @return true if the wallpaper currently needs to be configured,
|
||||||
* otherwise, false
|
* otherwise, false
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <QtGui/QIcon>
|
#include <QtGui/QIcon>
|
||||||
#include <QtGui/QGraphicsWidget>
|
#include <QtGui/QGraphicsWidget>
|
||||||
|
|
||||||
#include <plasma/dataengine.h>
|
|
||||||
#include <plasma/animator.h>
|
#include <plasma/animator.h>
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
|
|
||||||
|
|
|
@ -212,20 +212,6 @@ QLabel *Label::nativeWidget() const
|
||||||
return static_cast<QLabel*>(widget());
|
return static_cast<QLabel*>(widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Label::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
|
||||||
{
|
|
||||||
Q_UNUSED(sourceName);
|
|
||||||
|
|
||||||
QStringList texts;
|
|
||||||
foreach (const QVariant &v, data) {
|
|
||||||
if (v.canConvert(QVariant::String)) {
|
|
||||||
texts << v.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setText(texts.join(" "));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Label::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void Label::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
if (d->textSelectable || d->hasLinks){
|
if (d->textSelectable || d->hasLinks){
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <QtGui/QGraphicsProxyWidget>
|
#include <QtGui/QGraphicsProxyWidget>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
#include <plasma/dataengine.h>
|
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
|
@ -157,9 +156,6 @@ Q_SIGNALS:
|
||||||
void linkActivated(const QString &link);
|
void linkActivated(const QString &link);
|
||||||
void linkHovered(const QString &link);
|
void linkHovered(const QString &link);
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
|
@ -399,21 +399,6 @@ QRectF Meter::labelRect(int index) const
|
||||||
return d->image->elementRect(elementID);
|
return d->image->elementRect(elementID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meter::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
|
||||||
{
|
|
||||||
Q_UNUSED(sourceName)
|
|
||||||
|
|
||||||
foreach (const QVariant &v, data) {
|
|
||||||
if (v.type() == QVariant::Int ||
|
|
||||||
v.type() == QVariant::UInt ||
|
|
||||||
v.type() == QVariant::LongLong ||
|
|
||||||
v.type() == QVariant::ULongLong) {
|
|
||||||
setValue(v.toInt());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Meter::setSvg(const QString &svg)
|
void Meter::setSvg(const QString &svg)
|
||||||
{
|
{
|
||||||
if (d->svg == svg) {
|
if (d->svg == svg) {
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#define PLASMA_METER_H
|
#define PLASMA_METER_H
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
#include <plasma/dataengine.h>
|
|
||||||
#include <QtGui/QGraphicsWidget>
|
#include <QtGui/QGraphicsWidget>
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
|
@ -181,11 +180,6 @@ public:
|
||||||
QRectF labelRect(int index) const;
|
QRectF labelRect(int index) const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
|
||||||
* Used when connecting to a DataEngine
|
|
||||||
*/
|
|
||||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set maximum value for the meter
|
* Set maximum value for the meter
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -140,20 +140,6 @@ void TextBrowser::append(const QString &text)
|
||||||
return nativeWidget()->append(text);
|
return nativeWidget()->append(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBrowser::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
|
||||||
{
|
|
||||||
Q_UNUSED(sourceName)
|
|
||||||
|
|
||||||
QTextBrowser *te = nativeWidget();
|
|
||||||
te->clear();
|
|
||||||
|
|
||||||
foreach (const QVariant &v, data) {
|
|
||||||
if (v.canConvert(QVariant::String)) {
|
|
||||||
te->append(v.toString() + '\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextBrowser::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void TextBrowser::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QMenu *popup = nativeWidget()->createStandardContextMenu(event->screenPos());
|
QMenu *popup = nativeWidget()->createStandardContextMenu(event->screenPos());
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <QtGui/QTextBrowser>
|
#include <QtGui/QTextBrowser>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
#include <plasma/dataengine.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
@ -97,8 +96,6 @@ public Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
void append(const QString &text);
|
void append(const QString &text);
|
||||||
|
|
||||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
|
||||||
|
|
|
@ -123,20 +123,6 @@ void TextEdit::append(const QString &text)
|
||||||
return nativeWidget()->append(text);
|
return nativeWidget()->append(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEdit::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
|
||||||
{
|
|
||||||
Q_UNUSED(sourceName)
|
|
||||||
|
|
||||||
KTextEdit *te = nativeWidget();
|
|
||||||
te->clear();
|
|
||||||
|
|
||||||
foreach (const QVariant &v, data) {
|
|
||||||
if (v.canConvert(QVariant::String)) {
|
|
||||||
te->append(v.toString() + '\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextEdit::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void TextEdit::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QMenu *popup = nativeWidget()->mousePopupMenu();
|
QMenu *popup = nativeWidget()->mousePopupMenu();
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
class KTextEdit;
|
class KTextEdit;
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
#include <plasma/dataengine.h>
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
@ -107,8 +106,6 @@ public Q_SLOTS:
|
||||||
*/
|
*/
|
||||||
void append(const QString &text);
|
void append(const QString &text);
|
||||||
|
|
||||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue