Plasma
plasmajs.h
Go to the documentation of this file.00001 /* 00002 Copyright (c) 2007 Zack Rusin <zack@kde.org> 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 00011 The above copyright notice and this permission notice shall be included in 00012 all copies or substantial portions of the Software. 00013 00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 THE SOFTWARE. 00021 */ 00022 #ifndef PLASMAJS_H 00023 #define PLASMAJS_H 00024 00025 #include <QObject> 00026 #include <KConfigGroup> 00027 #include <Plasma/DataEngine> 00028 00029 class PlasmaJs : public QObject 00030 { 00031 Q_OBJECT 00032 public: 00033 PlasmaJs(QObject *parent=0); 00034 00035 public Q_SLOTS: 00036 QStringList knownEngines(); 00037 }; 00038 00039 class DataEngineDataWrapper : public QObject 00040 { 00041 Q_OBJECT 00042 Q_PROPERTY(int size READ size) 00043 public: 00044 DataEngineDataWrapper(const Plasma::DataEngine::Data &data = Plasma::DataEngine::Data()); 00045 00046 int size() const; 00047 void setData(const Plasma::DataEngine::Data &data); 00048 00049 public Q_SLOTS: 00050 bool contains(const QString &key) const; 00051 QVariant value(const QString &key) const; 00052 QStringList keys() const; 00053 QString key(int i) const; 00054 00055 private: 00056 Plasma::DataEngine::Data m_data; 00057 }; 00058 00059 class DataEngineWrapper : public QObject 00060 { 00061 Q_OBJECT 00062 Q_PROPERTY(QStringList sources READ sources) 00063 Q_PROPERTY(bool valid READ isValid) 00064 Q_PROPERTY(QString icon READ icon) 00065 Q_PROPERTY(QString engineName READ engineName) 00066 public: 00067 DataEngineWrapper(Plasma::DataEngine *engine, QObject *applet = 0); 00068 ~DataEngineWrapper(); 00069 00070 QStringList sources() const; 00071 QString engineName() const; 00072 bool isValid() const; 00073 QString icon() const; 00074 00075 public Q_SLOTS: 00076 QObject *query(const QString &str) const; 00077 void connectSource(const QString& source, 00078 uint pollingInterval = 0, uint intervalAlignment = 0); 00079 00080 private: 00081 Plasma::DataEngine *m_engine; 00082 QObject *m_applet; 00083 }; 00084 00085 class ConfigGroupWrapper : public QObject 00086 { 00087 Q_OBJECT 00088 public: 00089 ConfigGroupWrapper(const KConfigGroup &config = KConfigGroup()); 00090 00091 void setConfig(const KConfigGroup &config); 00092 00093 public Q_SLOTS: 00094 QVariant readEntry(const QString &key, const QVariant &aDefault) const; 00095 void writeEntry(const QString &key, const QVariant& value); 00096 00097 private: 00098 KConfigGroup m_config; 00099 }; 00100 00101 #endif