• Skip to content
  • Skip to link menu
KDE 4.7 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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     Q_PROPERTY(QString name READ name)
00065 
00066     public:
00067         typedef QHash<QString, DataEngine*> Dict;
00068         typedef QHash<QString, QVariant> Data;
00069         typedef QHashIterator<QString, QVariant> DataIterator;
00070         typedef QHash<QString, DataContainer*> SourceDict;
00071 
00078         explicit DataEngine(QObject *parent = 0, KService::Ptr service = KService::Ptr(0));
00079         DataEngine(QObject *parent, const QVariantList &args);
00080         ~DataEngine();
00081 
00091         virtual void init();
00092 
00099         virtual QStringList sources() const;
00100 
00107         Q_INVOKABLE virtual Service *serviceForSource(const QString &source);
00108 
00112         QString name() const;
00113 
00135         Q_INVOKABLE void connectSource(
00136             const QString &source, QObject *visualization,
00137             uint pollingInterval = 0,
00138             Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00139 
00167         Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0,
00168                                            Plasma::IntervalAlignment intervalAlignment =
00169 NoAlignment) const;
00170 
00177         Q_INVOKABLE void disconnectSource(const QString &source, QObject *visualization) const;
00178 
00189         Q_INVOKABLE DataContainer *containerForSource(const QString &source);
00190 
00201         Q_INVOKABLE DataEngine::Data query(const QString &source) const;
00202 
00208         bool isValid() const;
00209 
00216         bool isEmpty() const;
00217 
00224         uint maxSourceCount() const;
00225 
00230         QString icon() const;
00231 
00237         const Package *package() const;
00238 
00242         QString pluginName() const;
00243 
00255         Q_INVOKABLE Service* createDefaultService(QObject *parent = 0);
00256 
00257     Q_SIGNALS:
00268         void sourceAdded(const QString &source);
00269 
00280         void sourceRemoved(const QString &source);
00281 
00282     protected:
00303         virtual bool sourceRequestEvent(const QString &source);
00304 
00315         virtual bool updateSourceEvent(const QString &source);
00316 
00324         void setData(const QString &source, const QVariant &value);
00325 
00334         void setData(const QString &source, const QString &key, const QVariant &value);
00335 
00343         void setData(const QString &source, const Data &data);
00344 
00350         void removeAllData(const QString &source);
00351 
00358         void removeData(const QString &source, const QString &key);
00359 
00367         void addSource(DataContainer *source);
00368 
00376         void setMaxSourceCount(uint limit);
00377 
00391         void setMinimumPollingInterval(int minimumMs);
00392 
00396         int minimumPollingInterval() const;
00397 
00406         void setPollingInterval(uint frequency);
00407 
00411         void removeAllSources();
00412 
00420         void setValid(bool valid);
00421 
00425         SourceDict containerDict() const;
00426 
00430         void timerEvent(QTimerEvent *event);
00431 
00435         void setName(const QString &name);
00436 
00440         void setIcon(const QString &icon);
00441 
00456         void setDefaultService(const QString &serviceName);
00457 
00466         void setStorageEnabled(const QString &source, bool store);
00467 
00468     protected Q_SLOTS:
00474         void scheduleSourcesUpdated();
00475 
00480         void removeSource(const QString &source);
00481 
00485         void updateAllSources();
00486 
00497         void forceImmediateUpdateOfAllVisualizations();
00498 
00499     private:
00500         friend class DataEnginePrivate;
00501         friend class DataEngineScript;
00502         friend class DataEngineManager;
00503         friend class PlasmoidServiceJob;
00504         friend class NullEngine;
00505 
00506         Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source))
00507         Q_PRIVATE_SLOT(d, void sourceDestroyed(QObject *object))
00508 
00509         DataEnginePrivate *const d;
00510 };
00511 
00512 } // Plasma namespace
00513 
00517 #define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
00518 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00519 K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
00520 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00521 
00522 Q_DECLARE_METATYPE(Plasma::DataEngine*)
00523 
00524 #endif // multiple inclusion guard

Plasma

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • 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
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.5
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