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

Plasma

plasmajs.cpp

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 #include "plasmajs.h"
00023 #include "plasmawebapplet.h"
00024 
00025 #include <Plasma/DataEngineManager>
00026 #include <Plasma/DataEngine>
00027 
00028 using namespace Plasma;
00029 
00030 PlasmaJs::PlasmaJs(QObject *parent)
00031     : QObject(parent)
00032 {
00033 }
00034 
00035 QStringList PlasmaJs::knownEngines()
00036 {
00037     return DataEngineManager::listAllEngines();
00038 }
00039 
00040 ConfigGroupWrapper::ConfigGroupWrapper(const KConfigGroup &config)
00041 : m_config(config)
00042 {
00043 }
00044 
00045 void ConfigGroupWrapper::setConfig(const KConfigGroup &config)
00046 {
00047     //kDebug() << config.config()->name() << config.name();
00048     m_config = config;
00049 }
00050 
00051 QVariant ConfigGroupWrapper::readEntry(const QString &key, const QVariant &aDefault) const
00052 {
00053     // Should KConfig do this?
00054     // There is readEntry(key, QVariant) but it does not seem to work
00055     // (if writeEntry was not QVariant??)
00056     // kDebug() << aDefault.typeName();
00057     if (aDefault.type() == QVariant::Int) {
00058         return m_config.readEntry(key, aDefault.toInt());
00059     } else if (aDefault.type() == QVariant::Double) {
00060         return m_config.readEntry(key, aDefault.toDouble());
00061     } else if (aDefault.type() == QVariant::Bool) {
00062         return m_config.readEntry(key, aDefault.toBool());
00063     } else {
00064         return m_config.readEntry(key, aDefault.toString());
00065     }
00066 }
00067 
00068 void ConfigGroupWrapper::writeEntry(const QString &key, const QVariant& value)
00069 {
00070     m_config.writeEntry(key, value);
00071 }
00072 
00073 DataEngineDataWrapper::DataEngineDataWrapper(const DataEngine::Data &data)
00074     : m_data(data)
00075 {
00076 }
00077 
00078 int DataEngineDataWrapper::size() const
00079 {
00080     return m_data.count();
00081 }
00082 
00083 void DataEngineDataWrapper::setData(const Plasma::DataEngine::Data &data)
00084 {
00085     m_data = data;
00086 }
00087 
00088 QVariant DataEngineDataWrapper::value(const QString &key) const
00089 {
00090     return m_data[key];
00091 }
00092 
00093 bool DataEngineDataWrapper::contains(const QString &key) const
00094 {
00095     return m_data.keys().contains(key);
00096 }
00097 
00098 QStringList DataEngineDataWrapper::keys() const
00099 {
00100     return m_data.keys();
00101 }
00102 
00103 QString DataEngineDataWrapper::key(int i) const
00104 {
00105     return m_data.keys().at(i);
00106 }
00107 
00108 DataEngineWrapper::DataEngineWrapper(Plasma::DataEngine *engine, QObject *applet)
00109     : QObject(engine), m_engine(engine), m_applet(applet)
00110 {
00111 }
00112 
00113 QStringList DataEngineWrapper::sources() const
00114 {
00115     return m_engine->sources();
00116 }
00117 
00118 QString DataEngineWrapper::engineName() const
00119 {
00120     return m_engine->name();
00121 }
00122 
00123 bool DataEngineWrapper::isValid() const
00124 {
00125     return m_engine->isValid();
00126 }
00127 
00128 QString DataEngineWrapper::icon() const
00129 {
00130     return m_engine->icon();
00131 }
00132 
00133 QObject * DataEngineWrapper::query(const QString &str) const
00134 {
00135     DataEngine::Data data = m_engine->query(str);
00136     return new DataEngineDataWrapper(data);
00137 }
00138 
00139 DataEngineWrapper::~DataEngineWrapper()
00140 {
00141 }
00142 
00143 void DataEngineWrapper::connectSource(const QString& source,
00144                                       uint pollingInterval, uint intervalAlignment)
00145 {
00146     if (m_applet) {
00147         m_engine->connectSource(source, m_applet, pollingInterval,
00148                                 (Plasma::IntervalAlignment)intervalAlignment);
00149     }
00150 }
00151 
00152 #include "plasmajs.moc"

Plasma

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

API Reference

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