• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaCore

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • core
dataenginebindings.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2007 Richard J. Moore <rich@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License version 2 as
6  * published by the Free Software Foundation
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this program; if not, write to the
15  * Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include "dataenginebindings_p.h"
20 
21 typedef Plasma::Service *ServicePtr;
22 QScriptValue qScriptValueFromService(QScriptEngine *engine, const ServicePtr &service)
23 {
24  return engine->newQObject(const_cast<Plasma::Service *>(service), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
25 }
26 
27 void serviceFromQScriptValue(const QScriptValue &scriptValue, ServicePtr &service)
28 {
29  QObject *obj = scriptValue.toQObject();
30  service = static_cast<Plasma::Service *>(obj);
31 }
32 
33 typedef Plasma::DataEngine *DataEnginePtr;
34 QScriptValue qScriptValueFromDataEngine(QScriptEngine *engine, const DataEnginePtr &dataEngine)
35 {
36  return engine->newQObject(const_cast<Plasma::DataEngine *>(dataEngine), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
37 }
38 
39 void dataEngineFromQScriptValue(const QScriptValue &scriptValue, DataEnginePtr &dataEngine)
40 {
41  QObject *obj = scriptValue.toQObject();
42  dataEngine = static_cast<Plasma::DataEngine *>(obj);
43 }
44 
45 typedef Plasma::ServiceJob *ServiceJobPtr;
46 QScriptValue qScriptValueFromServiceJob(QScriptEngine *engine, const ServiceJobPtr &serviceJob)
47 {
48  return engine->newQObject(const_cast<Plasma::ServiceJob *>(serviceJob), QScriptEngine::AutoOwnership, QScriptEngine::PreferExistingWrapperObject);
49 }
50 
51 void serviceJobFromQScriptValue(const QScriptValue &scriptValue, ServiceJobPtr &serviceJob)
52 {
53  QObject *obj = scriptValue.toQObject();
54  serviceJob = static_cast<Plasma::ServiceJob *>(obj);
55 }
56 
57 void registerDataEngineMetaTypes(QScriptEngine *engine)
58 {
59  qRegisterMetaType<Plasma::DataEngine::Data>("Plasma::DataEngine::Data");
60  qRegisterMetaType<Plasma::DataEngine::Data>("DataEngine::Data");
61  qScriptRegisterMapMetaType<Plasma::DataEngine::Data>(engine);
62  qScriptRegisterMetaType<Plasma::Service *>(engine, qScriptValueFromService, serviceFromQScriptValue);
63  qScriptRegisterMetaType<Plasma::DataEngine *>(engine, qScriptValueFromDataEngine, dataEngineFromQScriptValue);
64  qScriptRegisterMetaType<Plasma::ServiceJob *>(engine, qScriptValueFromServiceJob, serviceJobFromQScriptValue);
65 }
66 
QScriptValue
ServiceJobPtr
Plasma::ServiceJob * ServiceJobPtr
Definition: dataenginebindings.cpp:45
dataEngineFromQScriptValue
void dataEngineFromQScriptValue(const QScriptValue &scriptValue, DataEnginePtr &dataEngine)
Definition: dataenginebindings.cpp:39
serviceJobFromQScriptValue
void serviceJobFromQScriptValue(const QScriptValue &scriptValue, ServiceJobPtr &serviceJob)
Definition: dataenginebindings.cpp:51
QScriptEngine
DataEnginePtr
Plasma::DataEngine * DataEnginePtr
Definition: dataenginebindings.cpp:33
QObject
qScriptValueFromService
QScriptValue qScriptValueFromService(QScriptEngine *engine, const ServicePtr &service)
Definition: dataenginebindings.cpp:22
ServicePtr
Plasma::Service * ServicePtr
Definition: dataenginebindings.cpp:21
dataenginebindings_p.h
serviceFromQScriptValue
void serviceFromQScriptValue(const QScriptValue &scriptValue, ServicePtr &service)
Definition: dataenginebindings.cpp:27
QScriptEngine::newQObject
QScriptValue newQObject(QObject *object, ValueOwnership ownership, const QObjectWrapOptions &options)
qScriptValueFromServiceJob
QScriptValue qScriptValueFromServiceJob(QScriptEngine *engine, const ServiceJobPtr &serviceJob)
Definition: dataenginebindings.cpp:46
qScriptValueFromDataEngine
QScriptValue qScriptValueFromDataEngine(QScriptEngine *engine, const DataEnginePtr &dataEngine)
Definition: dataenginebindings.cpp:34
registerDataEngineMetaTypes
void registerDataEngineMetaTypes(QScriptEngine *engine)
Definition: dataenginebindings.cpp:57
QScriptValue::toQObject
QObject * toQObject() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaCore

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

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal