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

libplasma

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 <KDE/KGenericFactory>
00028 #include <KDE/KService>
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 
00056 class PLASMA_EXPORT DataEngine : public QObject
00057 {
00058     friend class DataEnginePrivate;
00059     friend class DataEngineScript;
00060     friend class DataEngineManager;
00061     friend class NullEngine;
00062 
00063     Q_OBJECT
00064     Q_PROPERTY( QStringList sources READ sources )
00065     Q_PROPERTY( bool valid READ isValid )
00066     Q_PROPERTY( QString icon READ icon WRITE setIcon )
00067 
00068     public:
00069         typedef QHash<QString, DataEngine*> Dict;
00070         typedef QHash<QString, QVariant> Data;
00071         typedef QHashIterator<QString, QVariant> DataIterator;
00072         typedef QHash<QString, DataContainer*> SourceDict;
00073 
00080         explicit DataEngine(QObject* parent = 0, KService::Ptr service = KService::Ptr(0));
00081         DataEngine(QObject* parent, const QVariantList& args);
00082         ~DataEngine();
00083 
00090         virtual void init();
00091 
00098         virtual QStringList sources() const;
00099 
00106         virtual Service* serviceForSource(const QString &source);
00107 
00111         QString name() const;
00112 
00134         Q_INVOKABLE void connectSource(const QString& source, QObject* visualization,
00135                                        uint pollingInterval = 0,
00136                                        Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00137 
00165         Q_INVOKABLE void connectAllSources(QObject* visualization, uint pollingInterval = 0,
00166                                            Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00167 
00174         Q_INVOKABLE void disconnectSource(const QString& source, QObject* visualization) const;
00175 
00186         Q_INVOKABLE DataContainer* containerForSource(const QString &source);
00187 
00198         Q_INVOKABLE DataEngine::Data query(const QString& source) const;
00199 
00203         bool isValid() const;
00204 
00209         bool isEmpty() const;
00210 
00217         uint maxSourceCount() const;
00218 
00223         QString icon() const;
00224 
00230         const Package* package() const;
00231 
00232     Q_SIGNALS:
00237         void sourceAdded(const QString& source);
00238 
00243         void sourceRemoved(const QString& source);
00244 
00245     protected:
00266         virtual bool sourceRequestEvent(const QString &source);
00267 
00278         virtual bool updateSourceEvent(const QString& source);
00279 
00287         void setData(const QString &source, const QVariant &value);
00288 
00297         void setData(const QString& source, const QString& key, const QVariant& value);
00298 
00306         void setData(const QString &source, const Data &data);
00307 
00313         void removeAllData(const QString& source);
00314 
00321         void removeData(const QString& source, const QString& key);
00322 
00328         void addSource(DataContainer* source);
00329 
00337         void setMaxSourceCount(uint limit);
00338 
00350         void setMinimumPollingInterval(int minimumMs);
00351 
00355         int minimumPollingInterval() const;
00356 
00365         void setPollingInterval(uint frequency);
00366 
00379         void removeAllSources();
00380 
00388         void setValid(bool valid);
00389 
00393         SourceDict containerDict() const;
00394 
00398         void timerEvent(QTimerEvent *event);
00399 
00403         void setName(const QString &name);
00404 
00408         void setIcon(const QString& icon);
00409 
00410     protected Q_SLOTS:
00416         void scheduleSourcesUpdated();
00417 
00422         void removeSource(const QString& source);
00423 
00424     private:
00425         Q_PRIVATE_SLOT(d, void internalUpdateSource(DataContainer* source))
00426 
00427         DataEnginePrivate* const d;
00428 };
00429 
00430 } // Plasma namespace
00431 
00432 #define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
00433 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00434 K_EXPORT_PLUGIN(factory("plasma_engine_" #libname)) \
00435 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00436 
00437 #endif // multiple inclusion guard
00438 

libplasma

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

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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