• Skip to content
  • Skip to link menu
KDE 4.0 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 <kgenericfactory.h>
00028 
00029 #include <plasma/plasma_export.h>
00030 #include <plasma/plasma.h>
00031 
00032 namespace Plasma
00033 {
00034 
00035 class DataContainer;
00036 
00051 class PLASMA_EXPORT DataEngine : public QObject
00052 {
00053     Q_OBJECT
00054     Q_PROPERTY( QStringList sources READ sources )
00055     Q_PROPERTY( bool valid READ isValid )
00056     Q_PROPERTY( QString icon READ icon WRITE setIcon )
00057 
00058     public:
00059         typedef QHash<QString, DataEngine*> Dict;
00060         typedef QHash<QString, QVariant> Data;
00061         typedef QHashIterator<QString, QVariant> DataIterator;
00062         typedef QHash<QString, DataContainer*> SourceDict;
00063 
00069         explicit DataEngine(QObject* parent = 0);
00070         virtual ~DataEngine();
00071 
00078         virtual QStringList sources() const;
00079 
00100         Q_INVOKABLE void connectSource(const QString& source, QObject* visualization,
00101                                        uint updateInterval = 0,
00102                                        Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00103 
00125         Q_INVOKABLE void connectAllSources(QObject* viualization, uint updateInterval = 0,
00126                                            Plasma::IntervalAlignment intervalAlignment = NoAlignment) const;
00127 
00134         Q_INVOKABLE void disconnectSource(const QString& source, QObject* visualization) const;
00135 
00146         Q_INVOKABLE DataContainer* containerForSource(const QString &source);
00147 
00158         Q_INVOKABLE DataEngine::Data query(const QString& source) const;
00159 
00164         void ref();
00165 
00170         void deref();
00171 
00177         bool isUsed() const;
00178 
00182         bool isValid() const;
00183 
00188         bool isEmpty() const;
00189 
00193         void setIcon(const QString& icon);
00194 
00199         QString icon() const;
00200 
00201     Q_SIGNALS:
00206         void newSource(const QString& source);
00207 
00212         void sourceRemoved(const QString& source);
00213 
00214     protected:
00221         virtual void init();
00222 
00242         virtual bool sourceRequested(const QString &name);
00243 
00254         virtual bool updateSource(const QString& source);
00255 
00263         void setData(const QString &source, const QVariant &value);
00264 
00273         void setData(const QString& source, const QString& key, const QVariant& value);
00274 
00282         void setData(const QString &source, const Data &data);
00283 
00289         void clearData(const QString& source);
00290 
00297         void removeData(const QString& source, const QString& key);
00298 
00304         void addSource(DataContainer* source);
00305 
00313         void setSourceLimit(uint limit);
00314 
00326         void setMinimumUpdateInterval(int minimumMs);
00327 
00331         int minimumUpdateInterval() const;
00332 
00341         void setUpdateInterval(uint frequency);
00342 
00355         void clearSources();
00356 
00364         void setValid(bool valid);
00365 
00369         SourceDict sourceDict() const;
00370 
00374         void timerEvent(QTimerEvent *event);
00375 
00376     protected Q_SLOTS:
00382         void checkForUpdates();
00383 
00388         void removeSource(const QString& source);
00389 
00393         void startInit();
00394 
00398         void internalUpdateSource(DataContainer* source);
00399 
00400     private:
00401         class Private;
00402         Private* const d;
00403 };
00404 
00405 } // Plasma namespace
00406 
00407 #define K_EXPORT_PLASMA_DATAENGINE(libname, classname) \
00408 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00409 K_EXPORT_PLUGIN(factory("plasma_engine_" #libname))
00410 #endif // multiple inclusion guard
00411 

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
  • 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