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

Plasma

bind_dataengine.h

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2007 Richard J. Moore <rich@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 version 2 as
00006  *   published by the Free Software Foundation
00007  *
00008  *   This program is distributed in the hope that it will be useful,
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *   GNU General Public License for more details
00012  *
00013  *   You should have received a copy of the GNU Library General Public
00014  *   License along with this program; if not, write to the
00015  *   Free Software Foundation, Inc.,
00016  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017  */
00018 
00019 #ifndef BIND_DATAENGINE_H
00020 #define BIND_DATAENGINE_H
00021 
00022 #include <QtScript/QtScript>
00023 #include <KDebug>
00024 
00025 #include <Plasma/DataEngine>
00026 #include <Plasma/Service>
00027 #include <Plasma/ServiceJob>
00028 
00029 using namespace Plasma;
00030 
00031 Q_DECLARE_METATYPE(DataEngine*)
00032 Q_DECLARE_METATYPE(Service*)
00033 Q_DECLARE_METATYPE(ServiceJob*)
00034 Q_DECLARE_METATYPE(QVariant)
00035 Q_DECLARE_METATYPE(DataEngine::Dict)
00036 Q_DECLARE_METATYPE(DataEngine::Data)
00037 
00038 
00039 template <class M>
00040 QScriptValue qScriptValueFromMap(QScriptEngine *eng, const M &map)
00041 {
00042     kDebug() << "qScriptValueFromMap called";
00043 
00044     QScriptValue obj = eng->newObject();
00045     typename M::const_iterator begin = map.constBegin();
00046     typename M::const_iterator end = map.constEnd();
00047     typename M::const_iterator it;
00048     for (it = begin; it != end; ++it)
00049         obj.setProperty(it.key(), qScriptValueFromValue(eng, it.value()));
00050     return obj;
00051 }
00052 
00053 template <class M>
00054 void qScriptValueToMap(const QScriptValue &value, M &map)
00055 {
00056     QScriptValueIterator it(value);
00057     while (it.hasNext()) {
00058         it.next();
00059         map[it.name()] = qscriptvalue_cast<typename M::mapped_type>(it.value());
00060     }
00061 }
00062 
00063 template<typename T>
00064 int qScriptRegisterMapMetaType(
00065     QScriptEngine *engine,
00066     const QScriptValue &prototype = QScriptValue()
00067 #ifndef qdoc
00068     , T * /* dummy */ = 0
00069 #endif
00070 )
00071 {
00072     return qScriptRegisterMetaType<T>(engine, qScriptValueFromMap,
00073                                       qScriptValueToMap, prototype);
00074 }
00075 
00076 #endif // BIND_DATAENGINE_H
00077 

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