• Skip to content
  • Skip to link menu
KDE 4.3 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 
00033 namespace Plasma
00034 {
00035 
00036 class DataContainer;
00037 class DataEngineScript;
00038 class Package;
00039 class Service;
00040 class DataEnginePrivate;
00041 
00057 class PLASMA_EXPORT DataEngine : public QObject
00058 {
00059     Q_OBJECT
00060     Q_PROPERTY(QStringList sources READ sources)
00061     Q_PROPERTY(bool valid READ isValid)
00062     Q_PROPERTY(QString icon READ icon WRITE setIcon)
00063 
00064     public:
00065         typedef QHash<QString, DataEngine*> Dict;
00066         typedef QHash<QString, QVariant> Data;
00067         typedef QHashIterator<QString, QVariant> DataIterator;
00068         typedef QHash<QString, DataContainer*> SourceDict;
00069 
00076         explicit DataEngine(QObject *parent = 0, KService::Ptr service = KService::Ptr(0));
00077         DataEngine(QObject *parent, const QVariantList &args);
00078         ~DataEngine();
00079 
00086         virtual void init();
00087 
00094         Q_INVOKABLE virtual QStringList sources() const;
00095 
00102         Q_INVOKABLE virtual Service *serviceForSource(const QString &source);
00103 
00107         Q_INVOKABLE QString name() const;
00108 
00130         Q_INVOKABLE void connectSource(
00131             const QString &source, QObject *visualization,
00132             uint pollingInterval = 0,
00133             Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00134 
00162         Q_INVOKABLE void connectAllSources(QObject *visualization, uint pollingInterval = 0,
00163                                            Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00164 
00171         Q_INVOKABLE void disconnectSource(const QString &source, QObject *visualization) const;
00172 
00183         Q_INVOKABLE DataContainer *containerForSource(const QString &source);
00184 
00195         Q_INVOKABLE DataEngine::Data query(const QString &source) const;
00196 
00200         bool isValid() const;
00201 
00206         bool isEmpty() const;
00207 
00214         uint maxSourceCount() const;
00215 
00220         QString icon() const;
00221 
00227         const Package *package() const;
00228 
00232         QString pluginName() const;
00233 
00234 
00235     Q_SIGNALS:
00246         void sourceAdded(const QString &source);
00247 
00258         void sourceRemoved(const QString &source);
00259 
00260     protected:
00281         virtual bool sourceRequestEvent(const QString &source);
00282 
00293         virtual bool updateSourceEvent(const QString &source);
00294 
00302         void setData(const QString &source, const QVariant &value);
00303 
00312         void setData(const QString &source, const QString &key, const QVariant &value);
00313 
00321         void setData(const QString &source, const Data &data);
00322 
00328         void removeAllData(const QString &source);
00329 
00336         void removeData(const QString &source, const QString &key);
00337 
00345         void addSource(DataContainer *source);
00346 
00354         void setMaxSourceCount(uint limit);
00355 
00367         void setMinimumPollingInterval(int minimumMs);
00368 
00372         int minimumPollingInterval() const;
00373 
00382         void setPollingInterval(uint frequency);
00383 
00396         void removeAllSources();
00397 
00405         void setValid(bool valid);
00406 
00410         SourceDict containerDict() const;
00411 
00415         void timerEvent(QTimerEvent *event);
00416 
00420         void setName(const QString &name);
00421 
00425         void setIcon(const QString &icon);
00426 
00427     protected Q_SLOTS:
00433         void scheduleSourcesUpdated();
00434 
00439         void removeSource(const QString &source);
00440 
00444         void updateAllSources();
00445 
00446     private:
00447         friend class DataEnginePrivate;
00448         friend class DataEngineScript;
00449         friend class DataEngineManager;
00450         friend class NullEngine;
00451 
00452         Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer *source))
00453 
00454         DataEnginePrivate *const d;
00455 };
00456 
00457 } // Plasma namespace
00458 
00462 #define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
00463 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00464 K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
00465 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00466 
00467 #endif // multiple inclusion guard
00468 

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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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