• Skip to content
  • Skip to link menu
KDE 4.1 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.h>
00026 
00027 using namespace Plasma;
00028 
00029 Q_DECLARE_METATYPE(DataEngine*)
00030 Q_DECLARE_METATYPE(QVariant)
00031 Q_DECLARE_METATYPE(DataEngine::Dict)
00032 Q_DECLARE_METATYPE(DataEngine::Data)
00033 
00034 template <class M>
00035 QScriptValue qScriptValueFromMap(QScriptEngine *eng, const M &map)
00036 {
00037     kDebug() << "qScriptValueFromMap called";
00038 
00039     QScriptValue obj = eng->newObject();
00040     typename M::const_iterator begin = map.begin();
00041     typename M::const_iterator end = map.end();
00042     typename M::const_iterator it;
00043     for (it = begin; it != end; ++it)
00044         obj.setProperty(it.key(), qScriptValueFromValue(eng, it.value()));
00045     return obj;
00046 }
00047 
00048 template <class M>
00049 void qScriptValueToMap(const QScriptValue &value, M &map)
00050 {
00051     QScriptValueIterator it(value);
00052     while (it.hasNext()) {
00053         it.next();
00054         map[it.name()] = qscriptvalue_cast<typename M::mapped_type>(it.value());
00055     }
00056 }
00057 
00058 template<typename T>
00059 int qScriptRegisterMapMetaType(
00060     QScriptEngine *engine,
00061     const QScriptValue &prototype = QScriptValue()
00062 #ifndef qdoc
00063     , T * /* dummy */ = 0
00064 #endif
00065 )
00066 {
00067     return qScriptRegisterMetaType<T>(engine, qScriptValueFromMap,
00068                                       qScriptValueToMap, prototype);
00069 }
00070 
00071 #endif // BIND_DATAENGINE_H
00072 

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