From 52a8caa5eed6a1b5a5db6bd987852d2ebf044e9d Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 8 Apr 2024 11:32:12 +0300 Subject: [PATCH] plasma: drop everything related to dataengines Signed-off-by: Ivailo Monev --- includes/CMakeLists.txt | 5 - includes/Plasma/DataContainer | 1 - includes/Plasma/DataEngine | 1 - includes/Plasma/DataEngineManager | 1 - includes/Plasma/Service | 1 - includes/Plasma/ServiceJob | 1 - plasma/CMakeLists.txt | 13 - plasma/README | 3 +- plasma/abstractrunner.cpp | 5 - plasma/abstractrunner.h | 22 - plasma/applet.cpp | 56 +- plasma/applet.h | 30 +- plasma/containment.h | 1 - plasma/containmentactions.cpp | 6 - plasma/containmentactions.h | 21 - .../servicetypes/plasma-dataengine.desktop | 83 --- plasma/datacontainer.cpp | 237 ------- plasma/datacontainer.h | 238 ------- plasma/dataengine.cpp | 617 ------------------ plasma/dataengine.h | 469 ------------- plasma/dataenginemanager.cpp | 248 ------- plasma/dataenginemanager.h | 139 ---- plasma/extenders/extenderitem.h | 2 - plasma/package.cpp | 14 +- plasma/packagestructure.cpp | 3 - plasma/pluginloader.cpp | 39 -- plasma/pluginloader.h | 23 +- plasma/private/abstractrunner_p.h | 7 +- plasma/private/applet_p.h | 4 +- plasma/private/containmentactions_p.h | 4 +- plasma/private/datacontainer_p.cpp | 172 ----- plasma/private/datacontainer_p.h | 92 --- plasma/private/dataengine_p.h | 104 --- plasma/private/dataengineconsumer.cpp | 61 -- plasma/private/dataengineconsumer_p.h | 45 -- plasma/private/package_p.h | 2 - plasma/private/service_p.h | 92 --- plasma/private/wallpaper_p.h | 4 +- plasma/service.cpp | 265 -------- plasma/service.h | 283 -------- plasma/servicejob.cpp | 98 --- plasma/servicejob.h | 130 ---- plasma/wallpaper.cpp | 6 - plasma/wallpaper.h | 22 - plasma/widgets/iconwidget.h | 1 - plasma/widgets/label.cpp | 14 - plasma/widgets/label.h | 4 - plasma/widgets/meter.cpp | 15 - plasma/widgets/meter.h | 6 - plasma/widgets/textbrowser.cpp | 14 - plasma/widgets/textbrowser.h | 3 - plasma/widgets/textedit.cpp | 14 - plasma/widgets/textedit.h | 3 - 53 files changed, 41 insertions(+), 3703 deletions(-) delete mode 100644 includes/Plasma/DataContainer delete mode 100644 includes/Plasma/DataEngine delete mode 100644 includes/Plasma/DataEngineManager delete mode 100644 includes/Plasma/Service delete mode 100644 includes/Plasma/ServiceJob delete mode 100644 plasma/data/servicetypes/plasma-dataengine.desktop delete mode 100644 plasma/datacontainer.cpp delete mode 100644 plasma/datacontainer.h delete mode 100644 plasma/dataengine.cpp delete mode 100644 plasma/dataengine.h delete mode 100644 plasma/dataenginemanager.cpp delete mode 100644 plasma/dataenginemanager.h delete mode 100644 plasma/private/datacontainer_p.cpp delete mode 100644 plasma/private/datacontainer_p.h delete mode 100644 plasma/private/dataengine_p.h delete mode 100644 plasma/private/dataengineconsumer.cpp delete mode 100644 plasma/private/dataengineconsumer_p.h delete mode 100644 plasma/private/service_p.h delete mode 100644 plasma/service.cpp delete mode 100644 plasma/service.h delete mode 100644 plasma/servicejob.cpp delete mode 100644 plasma/servicejob.h diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index 74077ca3..3abf7a13 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -462,9 +462,6 @@ install( Plasma/Containment Plasma/ContainmentActions Plasma/Corona - Plasma/DataContainer - Plasma/DataEngine - Plasma/DataEngineManager Plasma/Delegate Plasma/Dialog Plasma/DialogShadows @@ -495,8 +492,6 @@ install( Plasma/ScrollBar Plasma/ScrollWidget Plasma/Separator - Plasma/Service - Plasma/ServiceJob Plasma/SignalPlotter Plasma/Slider Plasma/SpinBox diff --git a/includes/Plasma/DataContainer b/includes/Plasma/DataContainer deleted file mode 100644 index a9314954..00000000 --- a/includes/Plasma/DataContainer +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/datacontainer.h" diff --git a/includes/Plasma/DataEngine b/includes/Plasma/DataEngine deleted file mode 100644 index 951ef3b9..00000000 --- a/includes/Plasma/DataEngine +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/dataengine.h" diff --git a/includes/Plasma/DataEngineManager b/includes/Plasma/DataEngineManager deleted file mode 100644 index 44d61302..00000000 --- a/includes/Plasma/DataEngineManager +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/dataenginemanager.h" diff --git a/includes/Plasma/Service b/includes/Plasma/Service deleted file mode 100644 index 1aeea7be..00000000 --- a/includes/Plasma/Service +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/service.h" diff --git a/includes/Plasma/ServiceJob b/includes/Plasma/ServiceJob deleted file mode 100644 index 6e2b1365..00000000 --- a/includes/Plasma/ServiceJob +++ /dev/null @@ -1 +0,0 @@ -#include "../../plasma/servicejob.h" diff --git a/plasma/CMakeLists.txt b/plasma/CMakeLists.txt index be3bbc93..e5b71818 100644 --- a/plasma/CMakeLists.txt +++ b/plasma/CMakeLists.txt @@ -37,9 +37,6 @@ set(plasma_LIB_SRCS containmentactions.cpp containmentactionspluginsconfig.cpp corona.cpp - datacontainer.cpp - dataengine.cpp - dataenginemanager.cpp delegate.cpp dialog.cpp dialogshadows.cpp @@ -53,8 +50,6 @@ set(plasma_LIB_SRCS popupapplet.cpp private/applethandle.cpp private/associatedapplicationmanager.cpp - private/datacontainer_p.cpp - private/dataengineconsumer.cpp private/extenderapplet.cpp private/extenderitemmimedata.cpp private/nativetabbar.cpp @@ -69,8 +64,6 @@ set(plasma_LIB_SRCS runnercontext.cpp runnermanager.cpp runnersyntax.cpp - service.cpp - servicejob.cpp svg.cpp theme.cpp tooltipcontent.cpp @@ -157,9 +150,6 @@ install( containmentactions.h containmentactionspluginsconfig.h corona.h - datacontainer.h - dataengine.h - dataenginemanager.h delegate.h dialog.h dialogshadows.h @@ -176,8 +166,6 @@ install( runnercontext.h runnermanager.h runnersyntax.h - service.h - servicejob.h svg.h theme.h tooltipcontent.h @@ -232,7 +220,6 @@ install( data/servicetypes/plasma-applet-popupapplet.desktop data/servicetypes/plasma-containment.desktop data/servicetypes/plasma-containmentactions.desktop - data/servicetypes/plasma-dataengine.desktop data/servicetypes/plasma-runner.desktop data/servicetypes/plasma-toolbox.desktop data/servicetypes/plasma-wallpaper.desktop diff --git a/plasma/README b/plasma/README index 27dd9845..81a56ab9 100644 --- a/plasma/README +++ b/plasma/README @@ -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. Domain specific sets of functionality, e.g. for network awareness or sensors, -are not found here but as DataEngine, Service, Applet, PackageStructure, etc -plugins. +are not found here but as Applet, PackageStructure, etc plugins. diff --git a/plasma/abstractrunner.cpp b/plasma/abstractrunner.cpp index 9e214b1b..c94f4e2b 100644 --- a/plasma/abstractrunner.cpp +++ b/plasma/abstractrunner.cpp @@ -282,11 +282,6 @@ void AbstractRunner::init() reloadConfiguration(); } -DataEngine *AbstractRunner::dataEngine(const QString &name) const -{ - return d->dataEngine(name); -} - bool AbstractRunner::isMatchingSuspended() const { return d->suspendMatching; diff --git a/plasma/abstractrunner.h b/plasma/abstractrunner.h index 44dd44a5..1b8790ae 100644 --- a/plasma/abstractrunner.h +++ b/plasma/abstractrunner.h @@ -39,7 +39,6 @@ class KCompletion; namespace Plasma { -class DataEngine; class QueryMatch; class AbstractRunnerPrivate; @@ -397,27 +396,6 @@ class PLASMA_EXPORT AbstractRunner : public QObject */ void setSyntaxes(const QList &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 not 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: /** * Reimplement this slot to run any initialization routines on first load. diff --git a/plasma/applet.cpp b/plasma/applet.cpp index 7eaec897..9742c8bc 100644 --- a/plasma/applet.cpp +++ b/plasma/applet.cpp @@ -24,7 +24,6 @@ #include "abstracttoolbox.h" #include "containment.h" #include "corona.h" -#include "dataenginemanager.h" #include "dialog.h" #include "extenders/extender.h" #include "extenders/extenderitem.h" @@ -54,7 +53,6 @@ #include "private/package_p.h" #include "private/packages_p.h" #include "private/popupapplet_p.h" -#include "private/service_p.h" #include #include @@ -602,11 +600,6 @@ void AppletPrivate::destroyMessageOverlay() } } -DataEngine *Applet::dataEngine(const QString &name) const -{ - return d->dataEngine(name); -} - QGraphicsView *Applet::view() const { // 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 AppletPrivate::AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet) - : appletId(uniqueID), - q(applet), - service(0), - preferredBackgroundHints(Applet::StandardBackground), - backgroundHints(Applet::NoBackground), - aspectRatioMode(Plasma::KeepAspectRatio), - immutability(Mutable), - appletDescription(info ? *info : KPluginInfo(service)), - background(0), - mainConfig(0), - pendingConstraints(NoConstraint), - messageOverlay(0), - messageOverlayProxy(0), - busyWidget(0), - actions(AppletPrivate::defaultActions(applet)), - activationAction(0), - itemStatus(UnknownStatus), - preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored), - modificationsTimer(0), - hasConfigurationInterface(false), - failed(false), - isContainment(false), - transient(false), - needsConfig(false), - started(false) + : appletId(uniqueID), + q(applet), + preferredBackgroundHints(Applet::StandardBackground), + backgroundHints(Applet::NoBackground), + aspectRatioMode(Plasma::KeepAspectRatio), + immutability(Mutable), + appletDescription(info ? *info : KPluginInfo(service)), + background(0), + mainConfig(0), + pendingConstraints(NoConstraint), + messageOverlay(0), + messageOverlayProxy(0), + busyWidget(0), + actions(AppletPrivate::defaultActions(applet)), + activationAction(0), + itemStatus(UnknownStatus), + preferredSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored), + modificationsTimer(0), + hasConfigurationInterface(false), + failed(false), + isContainment(false), + transient(false), + needsConfig(false), + started(false) { if (appletId == 0) { appletId = ++s_maxAppletId; diff --git a/plasma/applet.h b/plasma/applet.h index ab7ea3c9..092fb2e8 100644 --- a/plasma/applet.h +++ b/plasma/applet.h @@ -47,7 +47,6 @@ namespace Plasma class AppletPrivate; class Containment; class Context; -class DataEngine; class Extender; class ExtenderItem; @@ -59,12 +58,9 @@ class ExtenderItem; * 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 - * interface to applets for host applications. It also handles the life time - * management of data engines (e.g. all data engines accessed via - * Applet::dataEngine(const QString&) are properly deref'd on Applet - * 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. + * interface to applets for host applications. It also handles the 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 { @@ -158,25 +154,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget */ 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 not 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. * @warning do NOT assume this will always return a view! @@ -518,7 +495,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget * * @code * SuperCoolWidget *widget = new SuperCoolWidget(); - * dataEngine("engine")->connectSource(item->config("dataSourceName"), widget); * item->setWidget(widget); * @endcode * diff --git a/plasma/containment.h b/plasma/containment.h index f482d67d..329c9467 100644 --- a/plasma/containment.h +++ b/plasma/containment.h @@ -37,7 +37,6 @@ namespace Plasma { class AppletHandle; -class DataEngine; class Corona; class View; class Wallpaper; diff --git a/plasma/containmentactions.cpp b/plasma/containmentactions.cpp index 0b3e7aa7..fd38f615 100644 --- a/plasma/containmentactions.cpp +++ b/plasma/containmentactions.cpp @@ -20,7 +20,6 @@ #include "containmentactions.h" #include "containment.h" -#include "private/dataengineconsumer_p.h" #include "private/containmentactions_p.h" #include "private/containment_p.h" @@ -186,11 +185,6 @@ QList ContainmentActions::contextualActions() return QList(); } -DataEngine *ContainmentActions::dataEngine(const QString &name) const -{ - return d->dataEngine(name); -} - bool ContainmentActions::configurationRequired() const { return d->needsConfig; diff --git a/plasma/containmentactions.h b/plasma/containmentactions.h index eb7f151a..b65db53a 100644 --- a/plasma/containmentactions.h +++ b/plasma/containmentactions.h @@ -31,7 +31,6 @@ namespace Plasma { -class DataEngine; class Containment; class ContainmentActionsPrivate; @@ -162,26 +161,6 @@ class PLASMA_EXPORT ContainmentActions : public QObject */ virtual QList 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 not 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, * otherwise, false diff --git a/plasma/data/servicetypes/plasma-dataengine.desktop b/plasma/data/servicetypes/plasma-dataengine.desktop deleted file mode 100644 index 18ccb914..00000000 --- a/plasma/data/servicetypes/plasma-dataengine.desktop +++ /dev/null @@ -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 資料引擎 diff --git a/plasma/datacontainer.cpp b/plasma/datacontainer.cpp deleted file mode 100644 index cd7da787..00000000 --- a/plasma/datacontainer.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 -#include - -#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::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 (o->parent()); - if (o == NULL) { - return NULL; - } - de = qobject_cast (o); - } - return de; -} - -void DataContainer::disconnectVisualization(QObject *visualization) -{ - QMap::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" - diff --git a/plasma/datacontainer.h b/plasma/datacontainer.h deleted file mode 100644 index e12aa4c1..00000000 --- a/plasma/datacontainer.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 -#include -#include - -#include -#include -#include - -namespace Plasma -{ - -class DataContainerPrivate; - -/** - * @class DataContainer plasma/datacontainer.h - * - * @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 diff --git a/plasma/dataengine.cpp b/plasma/dataengine.cpp deleted file mode 100644 index a00325f6..00000000 --- a/plasma/dataengine.cpp +++ /dev/null @@ -1,617 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 -#include -#include -#include -#include - -#include -#include -#include -#include - -#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(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::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 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 it(d->sources); - while (it.hasNext()) { - it.next(); - it.value()->checkForUpdate(); - } - } else { - QObject::timerEvent(event); - } -} - -void DataEngine::updateAllSources() -{ - QHashIterator 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::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" diff --git a/plasma/dataengine.h b/plasma/dataengine.h deleted file mode 100644 index 2635352c..00000000 --- a/plasma/dataengine.h +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 -#include -#include - -#include -#include - -#include -#include - -namespace Plasma -{ - -class DataContainer; -class Service; -class DataEnginePrivate; - -/** - * @class DataEngine plasma/dataengine.h - * - * @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 Dict; - typedef QHash Data; - typedef QHashIterator DataIterator; - typedef QHash 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();) \ -K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) - -Q_DECLARE_METATYPE(Plasma::DataEngine*) - -#endif // multiple inclusion guard diff --git a/plasma/dataenginemanager.cpp b/plasma/dataenginemanager.cpp deleted file mode 100644 index 40b0cd5a..00000000 --- a/plasma/dataenginemanager.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 -#include -#include - -#include -#include -#include -#include - -#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 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" diff --git a/plasma/dataenginemanager.h b/plasma/dataenginemanager.h deleted file mode 100644 index 66f68fad..00000000 --- a/plasma/dataenginemanager.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 - -#include - -#include - -namespace Plasma -{ - -class DataEngineManagerPrivate; - -/** - * @class DataEngineManager plasma/dataenginemanager.h - * - * @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 diff --git a/plasma/extenders/extenderitem.h b/plasma/extenders/extenderitem.h index 393eb1d9..ece4c6fd 100644 --- a/plasma/extenders/extenderitem.h +++ b/plasma/extenders/extenderitem.h @@ -70,8 +70,6 @@ class ExtenderItemPrivate; * void MyApplet::initExtenderItem(Plasma::ExtenderItem *item) * { * QGraphicsWidget *myNetworkMonitorWidget = new NetworkMonitorWidget(item); - * dataEngine("networktraffic")->connectSource(item->config().readEntry("device", ""), - * myNetworkMonitorWidget); * item->setWidget(myNetworkMonitorWidget); * } * @endcode diff --git a/plasma/package.cpp b/plasma/package.cpp index 49a7bfcf..6a1fe17a 100644 --- a/plasma/package.cpp +++ b/plasma/package.cpp @@ -21,7 +21,6 @@ #include "package.h" #include "packagemetadata.h" #include "private/package_p.h" -#include "private/service_p.h" #include #include @@ -68,7 +67,6 @@ Package &Package::operator=(const Package &rhs) if (&rhs != this) { *d = *rhs.d; } - return *this; } @@ -279,23 +277,20 @@ QStringList Package::listInstalledPaths(const QString &packageRoot) // static } PackagePrivate::PackagePrivate(const PackageStructure::Ptr st, const QString &p) - : structure(st), - service(0) + : structure(st) { setPathFromStructure(p); } PackagePrivate::PackagePrivate(const PackageStructure::Ptr st, const QString &packageRoot, const QString &path) - : structure(st), - service(0) + : structure(st) { setPathFromStructure(packageRoot.isEmpty() ? path : packageRoot + "/" + path); } PackagePrivate::PackagePrivate(const PackagePrivate &other) - : structure(other.structure), - service(other.service), - valid(other.valid) + : structure(other.structure), + valid(other.valid) { } @@ -306,7 +301,6 @@ PackagePrivate::~PackagePrivate() PackagePrivate &PackagePrivate::operator=(const PackagePrivate &rhs) { structure = rhs.structure; - service = rhs.service; valid = rhs.valid; return *this; } diff --git a/plasma/packagestructure.cpp b/plasma/packagestructure.cpp index 01494c15..1e5a4eda 100644 --- a/plasma/packagestructure.cpp +++ b/plasma/packagestructure.cpp @@ -124,9 +124,6 @@ PackageStructure::Ptr PackageStructure::load(const QString &packageFormat) if (packageFormat == "Plasma/Applet") { structure = defaultPackageStructure(); structure->d->type = "Plasma/Applet"; - } else if (packageFormat == "Plasma/DataEngine") { - structure = defaultPackageStructure(); - structure->d->type = "Plasma/DataEngine"; } else if (packageFormat == "Plasma/Runner") { structure = defaultPackageStructure(); structure->d->type = "Plasma/Runner"; diff --git a/plasma/pluginloader.cpp b/plasma/pluginloader.cpp index 8bf421c4..2b246bb5 100644 --- a/plasma/pluginloader.cpp +++ b/plasma/pluginloader.cpp @@ -82,32 +82,6 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari 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(0, allArgs, &error); - } - } - - if (!engine) { - kDebug() << "Couldn't load engine \"" << name << "\". Error given: " << error; - } - - return engine; -} - AbstractRunner *PluginLoader::loadRunner(const QString &name) { // 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); } -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) { QString constraint; diff --git a/plasma/pluginloader.h b/plasma/pluginloader.h index b13b253b..0b394f28 100644 --- a/plasma/pluginloader.h +++ b/plasma/pluginloader.h @@ -26,7 +26,6 @@ namespace Plasma { class Applet; -class DataEngine; class AbstractRunner; //TODO: @@ -40,7 +39,7 @@ class AbstractRunner; * 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 * 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 * @since 4.6 @@ -60,14 +59,6 @@ public: static Applet *loadApplet(const QString &name, uint appletId = 0, 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 * @@ -94,18 +85,6 @@ public: **/ 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 * diff --git a/plasma/private/abstractrunner_p.h b/plasma/private/abstractrunner_p.h index d099f48c..3978c5fc 100644 --- a/plasma/private/abstractrunner_p.h +++ b/plasma/private/abstractrunner_p.h @@ -20,16 +20,14 @@ #ifndef ABSTRACTRUNNER_P_H #define ABSTRACTRUNNER_P_H -#include - -#include "dataengineconsumer_p.h" +#include namespace Plasma { class AbstractRunner; -class AbstractRunnerPrivate : public DataEngineConsumer +class AbstractRunnerPrivate { public: AbstractRunnerPrivate(AbstractRunner *r); @@ -50,6 +48,7 @@ public: }; } // namespace Plasma + #endif diff --git a/plasma/private/applet_p.h b/plasma/private/applet_p.h index a407d953..cbc517ff 100644 --- a/plasma/private/applet_p.h +++ b/plasma/private/applet_p.h @@ -30,7 +30,6 @@ #include "plasma/animator.h" #include "plasma/private/applethandle_p.h" -#include "plasma/private/dataengineconsumer_p.h" class KKeySequenceWidget; @@ -89,7 +88,7 @@ protected Q_SLOTS: void overlayAnimationComplete(); }; -class AppletPrivate : public DataEngineConsumer +class AppletPrivate { public: AppletPrivate(KService::Ptr service, const KPluginInfo *info, int uniqueID, Applet *applet); @@ -143,7 +142,6 @@ public: // applet attributes QWeakPointer extender; - Service *service; Applet::BackgroundHints preferredBackgroundHints; Applet::BackgroundHints backgroundHints; Plasma::AspectRatioMode aspectRatioMode; diff --git a/plasma/private/containmentactions_p.h b/plasma/private/containmentactions_p.h index c6fb73a5..905b2b78 100644 --- a/plasma/private/containmentactions_p.h +++ b/plasma/private/containmentactions_p.h @@ -20,12 +20,12 @@ #ifndef PLASMA_CONTAINMENTACTIONSPRIVATE_H #define PLASMA_CONTAINMENTACTIONSPRIVATE_H -#include "plasma/private/dataengineconsumer_p.h" +#include namespace Plasma { -class ContainmentActionsPrivate : public DataEngineConsumer +class ContainmentActionsPrivate { public: ContainmentActionsPrivate(KService::Ptr service, ContainmentActions *containmentActions) : diff --git a/plasma/private/datacontainer_p.cpp b/plasma/private/datacontainer_p.cpp deleted file mode 100644 index e7e861c8..00000000 --- a/plasma/private/datacontainer_p.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 - -#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::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(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" - diff --git a/plasma/private/datacontainer_p.h b/plasma/private/datacontainer_p.h deleted file mode 100644 index 71195c7c..00000000 --- a/plasma/private/datacontainer_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 -#include -#include - -#include - -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 relayObjects; - QMap 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 - diff --git a/plasma/private/dataengine_p.h b/plasma/private/dataengine_p.h deleted file mode 100644 index 77f47986..00000000 --- a/plasma/private/dataengine_p.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2006-2007 Aaron Seigo - * - * 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 -#include - -#include - -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 sourceQueue; - QString icon; - uint limit; - bool valid; - QString engineName; - QString waitingSourceRequest; -}; - -} // Plasma namespace - -#endif // multiple inclusion guard diff --git a/plasma/private/dataengineconsumer.cpp b/plasma/private/dataengineconsumer.cpp deleted file mode 100644 index 3cc572d6..00000000 --- a/plasma/private/dataengineconsumer.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2005 by Aaron Seigo - * Copyright 2007 by Riccardo Iaconelli - * Copyright 2008 by Ménard Alexis - * - * 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 - -#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 diff --git a/plasma/private/dataengineconsumer_p.h b/plasma/private/dataengineconsumer_p.h deleted file mode 100644 index efea5702..00000000 --- a/plasma/private/dataengineconsumer_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2005 by Aaron Seigo - * Copyright 2007 by Riccardo Iaconelli - * Copyright 2008 by Ménard Alexis - * - * 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 - -#include "plasma/dataengine.h" - -namespace Plasma -{ - -class DataEngineConsumer -{ -public: - DataEngineConsumer(); - ~DataEngineConsumer(); - DataEngine *dataEngine(const QString &name); - -private: - QSet m_loadedEngines; -}; - -} // namespace Plasma - -#endif diff --git a/plasma/private/package_p.h b/plasma/private/package_p.h index fe6f0f90..33c625d5 100644 --- a/plasma/private/package_p.h +++ b/plasma/private/package_p.h @@ -21,7 +21,6 @@ #include "../plasma.h" #include "../package.h" -#include "../service.h" #include @@ -43,7 +42,6 @@ public: PackageStructure::Ptr structure; - Service *service; bool valid; }; diff --git a/plasma/private/service_p.h b/plasma/private/service_p.h deleted file mode 100644 index b217f9a4..00000000 --- a/plasma/private/service_p.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2008 Aaron Seigo - * - * 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 -#include -#include -#include -#include - -namespace Plasma -{ - -class NullServiceJob : public ServiceJob -{ -public: - NullServiceJob(const QString &destination, const QString &operation, QObject *parent) - : ServiceJob(destination, operation, QMap(), 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 &) - { - 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 disabledOperations; - QMultiHash associatedWidgets; - QMultiHash associatedGraphicsWidgets; -}; - -} // namespace Plasma - -#endif - diff --git a/plasma/private/wallpaper_p.h b/plasma/private/wallpaper_p.h index b1a1488b..76c853a6 100644 --- a/plasma/private/wallpaper_p.h +++ b/plasma/private/wallpaper_p.h @@ -24,12 +24,12 @@ #include #include -#include "plasma/private/dataengineconsumer_p.h" +#include "plasma/plasma.h" namespace Plasma { -class WallpaperPrivate : public DataEngineConsumer +class WallpaperPrivate { public: WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper); diff --git a/plasma/service.cpp b/plasma/service.cpp deleted file mode 100644 index 05c69852..00000000 --- a/plasma/service.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 2008 Aaron Seigo - * - * 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 -#include - -#include - -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(job)); -} - -void ServicePrivate::associatedWidgetDestroyed(QObject *obj) -{ - associatedWidgets.remove(static_cast(obj)); -} - -void ServicePrivate::associatedGraphicsWidgetDestroyed(QObject *obj) -{ - associatedGraphicsWidgets.remove(static_cast(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 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(); -} - -ServiceJob *Service::startOperationCall(const QString &operation, const QMap ¶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 it(d->associatedWidgets); - while (it.hasNext()) { - it.next(); - it.key()->setEnabled(isOperationEnabled(it.value())); - } - } - - { - QHashIterator 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 it(d->associatedWidgets); - while (it.hasNext()) { - it.next(); - if (it.value() == operation) { - it.key()->setEnabled(enable); - } - } - } - - { - QHashIterator 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" - diff --git a/plasma/service.h b/plasma/service.h deleted file mode 100644 index cfd0175b..00000000 --- a/plasma/service.h +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright 2008 Aaron Seigo - * - * 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 -#include -#include - -#include - -#include -#include - -#include -#include -#include - -namespace Plasma -{ - -class ServiceJob; -class ServicePrivate; - -/** - * @class Service plasma/service.h - * - * @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 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 ¶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 ¶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 - diff --git a/plasma/servicejob.cpp b/plasma/servicejob.cpp deleted file mode 100644 index 4d06b1cc..00000000 --- a/plasma/servicejob.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2008 Aaron Seigo - * - * 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 - -#include - -namespace Plasma -{ - -ServiceJobPrivate::ServiceJobPrivate(ServiceJob *owner, const QString &dest, - const QString &op, const QMap ¶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 ¶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 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" - diff --git a/plasma/servicejob.h b/plasma/servicejob.h deleted file mode 100644 index 2737c9f6..00000000 --- a/plasma/servicejob.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2008 Aaron Seigo - * - * 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 - -#include -#include - -#include - -namespace Plasma -{ - -class ServiceJobPrivate; - -/** - * @class ServiceJob plasma/servicejob.h - * - * @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 ¶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 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 - diff --git a/plasma/wallpaper.cpp b/plasma/wallpaper.cpp index d458891a..7ed5bbbb 100644 --- a/plasma/wallpaper.cpp +++ b/plasma/wallpaper.cpp @@ -21,7 +21,6 @@ #include "wallpaper.h" #include "plasma/plasma.h" #include "plasma/package.h" -#include "plasma/private/dataengineconsumer_p.h" #include "plasma/private/packages_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 { return d->needsConfig; diff --git a/plasma/wallpaper.h b/plasma/wallpaper.h index 2e418f5b..61ad1652 100644 --- a/plasma/wallpaper.h +++ b/plasma/wallpaper.h @@ -31,7 +31,6 @@ namespace Plasma { -class DataEngine; class WallpaperPrivate; class Package; @@ -279,27 +278,6 @@ class PLASMA_EXPORT Wallpaper : public QObject */ 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 not 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, * otherwise, false diff --git a/plasma/widgets/iconwidget.h b/plasma/widgets/iconwidget.h index f0d833da..9cf8cf0b 100644 --- a/plasma/widgets/iconwidget.h +++ b/plasma/widgets/iconwidget.h @@ -29,7 +29,6 @@ #include #include -#include #include #include diff --git a/plasma/widgets/label.cpp b/plasma/widgets/label.cpp index 63e225c6..ec01ee4d 100644 --- a/plasma/widgets/label.cpp +++ b/plasma/widgets/label.cpp @@ -212,20 +212,6 @@ QLabel *Label::nativeWidget() const return static_cast(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) { if (d->textSelectable || d->hasLinks){ diff --git a/plasma/widgets/label.h b/plasma/widgets/label.h index 7cae7222..25bbd658 100644 --- a/plasma/widgets/label.h +++ b/plasma/widgets/label.h @@ -23,7 +23,6 @@ #include #include -#include #include @@ -157,9 +156,6 @@ Q_SIGNALS: void linkActivated(const QString &link); void linkHovered(const QString &link); -public Q_SLOTS: - void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); - protected: void resizeEvent(QGraphicsSceneResizeEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/plasma/widgets/meter.cpp b/plasma/widgets/meter.cpp index bdbd2f6b..c078f953 100644 --- a/plasma/widgets/meter.cpp +++ b/plasma/widgets/meter.cpp @@ -399,21 +399,6 @@ QRectF Meter::labelRect(int index) const 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) { if (d->svg == svg) { diff --git a/plasma/widgets/meter.h b/plasma/widgets/meter.h index 4bd3da65..99c023ab 100644 --- a/plasma/widgets/meter.h +++ b/plasma/widgets/meter.h @@ -21,7 +21,6 @@ #define PLASMA_METER_H #include -#include #include namespace Plasma @@ -181,11 +180,6 @@ public: QRectF labelRect(int index) const; 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 */ diff --git a/plasma/widgets/textbrowser.cpp b/plasma/widgets/textbrowser.cpp index c1a64bc5..5d536ead 100644 --- a/plasma/widgets/textbrowser.cpp +++ b/plasma/widgets/textbrowser.cpp @@ -140,20 +140,6 @@ void TextBrowser::append(const QString &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) { QMenu *popup = nativeWidget()->createStandardContextMenu(event->screenPos()); diff --git a/plasma/widgets/textbrowser.h b/plasma/widgets/textbrowser.h index 69076c11..70d5ece6 100644 --- a/plasma/widgets/textbrowser.h +++ b/plasma/widgets/textbrowser.h @@ -24,7 +24,6 @@ #include #include -#include namespace Plasma { @@ -97,8 +96,6 @@ public Q_SLOTS: */ void append(const QString &text); - void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); - Q_SIGNALS: void textChanged(); diff --git a/plasma/widgets/textedit.cpp b/plasma/widgets/textedit.cpp index ee73b801..4dfaaf11 100644 --- a/plasma/widgets/textedit.cpp +++ b/plasma/widgets/textedit.cpp @@ -123,20 +123,6 @@ void TextEdit::append(const QString &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) { QMenu *popup = nativeWidget()->mousePopupMenu(); diff --git a/plasma/widgets/textedit.h b/plasma/widgets/textedit.h index c62fba32..b5bf015c 100644 --- a/plasma/widgets/textedit.h +++ b/plasma/widgets/textedit.h @@ -25,7 +25,6 @@ class KTextEdit; #include -#include namespace Plasma { @@ -107,8 +106,6 @@ public Q_SLOTS: */ void append(const QString &text); - void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data); - Q_SIGNALS: void textChanged();