• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

dataengine.h

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #ifndef PLASMA_DATAENGINE_H
00021 #define PLASMA_DATAENGINE_H
00022 
00023 #include <QtCore/QHash>
00024 #include <QtCore/QObject>
00025 #include <QtCore/QStringList>
00026 
00027 #include <kgenericfactory.h>
00028 #include <kservice.h>
00029 
00030 #include <plasma/version.h>
00031 #include <plasma/plasma.h>
00032 #include <plasma/service.h>
00033 
00034 namespace Plasma
00035 {
00036 
00037 class DataContainer;
00038 class DataEngineScript;
00039 class Package;
00040 class Service;
00041 class DataEnginePrivate;
00042 
00058 class PLASMA_EXPORT DataEngine : public QObject
00059 {
00060     Q_OBJECT
00061     Q_PROPERTY(QStringList sources READ sources)
00062     Q_PROPERTY(bool valid READ isValid)
00063     Q_PROPERTY(QString icon READ icon WRITE setIcon)
00064 
00065     public:
00066         typedef QHash<QString, DataEngine*> Dict;
00067         typedef QHash<QString, QVariant> Data;
00068         typedef QHashIterator<QString, QVariant> DataIterator;
00069         typedef QHash<QString, DataContainer*> SourceDict;
00070 
00077         explicit DataEngine(QObject *parent = 0, KService::Ptr service = KService::Ptr(0));
00078         DataEngine(QObject *parent, const QVariantList &args);
00079         ~DataEngine();
00080 
00087         virtual void init();
00088 
00095         Q_INVOKABLE virtual QStringList sources() const;
00096 
00103         Q_INVOKABLE virtual Service *serviceForSource(const QString &source);
00104 
00108         Q_INVOKABLE QString name() const;
00109 
00131         Q_INVOKABLE void connectSource(
00132             const QString &source, QObject *visualization,
00133             uint pollingInterval = 0,
00134             Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00135 
00163         Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0,
00164                                            Plasma::IntervalAlignment intervalAlignment =
00165 NoAlignment) const;
00166 
00173         Q_INVOKABLE void disconnectSource(const QString &source, QObject *visualization) const;
00174 
00185         Q_INVOKABLE DataContainer *containerForSource(const QString &source);
00186 
00197         Q_INVOKABLE DataEngine::Data query(const QString &source) const;
00198 
00202         bool isValid() const;
00203 
00208         bool isEmpty() const;
00209 
00216         uint maxSourceCount() const;
00217 
00222         QString icon() const;
00223 
00229         const Package *package() const;
00230 
00234         QString pluginName() const;
00235 
00236     Q_SIGNALS:
00247         void sourceAdded(const QString &source);
00248 
00259         void sourceRemoved(const QString &source);
00260 
00261     protected:
00282         virtual bool sourceRequestEvent(const QString &source);
00283 
00294         virtual bool updateSourceEvent(const QString &source);
00295 
00303         void setData(const QString &source, const QVariant &value);
00304 
00313         void setData(const QString &source, const QString &key, const QVariant &value);
00314 
00322         void setData(const QString &source, const Data &data);
00323 
00329         void removeAllData(const QString &source);
00330 
00337         void removeData(const QString &source, const QString &key);
00338 
00346         void addSource(DataContainer *source);
00347 
00355         void setMaxSourceCount(uint limit);
00356 
00368         void setMinimumPollingInterval(int minimumMs);
00369 
00373         int minimumPollingInterval() const;
00374 
00383         void setPollingInterval(uint frequency);
00384 
00397         void removeAllSources();
00398 
00406         void setValid(bool valid);
00407 
00411         SourceDict containerDict() const;
00412 
00416         void timerEvent(QTimerEvent *event);
00417 
00421         void setName(const QString &name);
00422 
00426         void setIcon(const QString &icon);
00427 
00428     protected Q_SLOTS:
00434         void scheduleSourcesUpdated();
00435 
00440         void removeSource(const QString &source);
00441 
00445         void updateAllSources();
00446 
00457         void forceImmediateUpdateOfAllVisualizations();
00458 
00459     private:
00460         friend class DataEnginePrivate;
00461         friend class DataEngineScript;
00462         friend class DataEngineManager;
00463         friend class PlasmoidServiceJob;
00464         friend class NullEngine;
00465 
00466         Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source))
00467 
00468         DataEnginePrivate *const d;
00469 };
00470 
00471 } // Plasma namespace
00472 
00476 #define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
00477 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00478 K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
00479 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00480 
00481 #endif // multiple inclusion guard
00482 

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  •     Sodep
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal