diff --git a/scriptengines/javascript/CMakeLists.txt b/scriptengines/javascript/CMakeLists.txt index dff675c8c..fd7e66b4b 100644 --- a/scriptengines/javascript/CMakeLists.txt +++ b/scriptengines/javascript/CMakeLists.txt @@ -3,8 +3,9 @@ set(simple_javascript_engine_SRCS common/javascriptaddonpackagestructure.cpp common/scriptenvui.cpp + plasmoid/abstractjsappletscript.cpp plasmoid/appletauthorization.cpp - plasmoid/appletinterface.cpp + plasmoid/jsappletinterface.cpp plasmoid/simplejavascriptapplet.cpp plasmoid/themedsvg.cpp simplebindings/animationgroup.cpp @@ -33,7 +34,6 @@ set(simple_javascript_engine_SRCS simplebindings/timer.cpp simplebindings/uiloader.cpp simplebindings/url.cpp - simplebindings/variant.cpp ) include_directories(${PHONON_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/common) @@ -83,7 +83,6 @@ set(javascript_dataengine_engine_SRCS simplebindings/dataengine.cpp simplebindings/i18n.cpp simplebindings/qscriptnonguibookkeeping.cpp - simplebindings/variant.cpp ) kde4_add_plugin(plasma_dataenginescript_javascript ${javascript_dataengine_engine_SRCS}) diff --git a/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp b/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp index 5028fbd64..02944ce7a 100644 --- a/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp +++ b/scriptengines/javascript/plasmoid/simplejavascriptapplet.cpp @@ -63,7 +63,6 @@ #include "simplebindings/dataengine.h" #include "simplebindings/dataenginereceiver.h" #include "simplebindings/i18n.h" -#include "simplebindings/variant.h" #include "themedsvg.h" using namespace Plasma; @@ -523,7 +522,7 @@ void SimpleJavaScriptApplet::setupObjects() QScriptValue args = m_engine->newArray(); int i = 0; foreach (const QVariant &arg, applet()->startupArguments()) { - args.setProperty(i, ::variantToScriptValue(m_engine, arg)); + args.setProperty(i, m_engine->newVariant(arg)); ++i; } global.setProperty("startupArguments", args); @@ -852,12 +851,9 @@ QString SimpleJavaScriptApplet::filePath(const QString &type, const QString &fil return package()->filePath(type.toLocal8Bit().constData(), file); } -/* - * Workaround the fact that QtScripts handling of variants seems a bit broken. - */ QScriptValue SimpleJavaScriptApplet::variantToScriptValue(QVariant var) { - return ::variantToScriptValue(m_engine, var); + return m_engine->newVariant(var); } K_EXPORT_PLASMA_APPLETSCRIPTENGINE(qscriptapplet, SimpleJavaScriptApplet) diff --git a/scriptengines/javascript/simplebindings/dataengine.h b/scriptengines/javascript/simplebindings/dataengine.h index f371b40e8..198570666 100644 --- a/scriptengines/javascript/simplebindings/dataengine.h +++ b/scriptengines/javascript/simplebindings/dataengine.h @@ -28,8 +28,6 @@ #include #include -#include "variant.h" - using namespace Plasma; Q_DECLARE_METATYPE(Service*) diff --git a/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp b/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp index ed1711e61..1e35fea20 100644 --- a/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp +++ b/scriptengines/javascript/simplebindings/qscriptbookkeeping.cpp @@ -25,8 +25,6 @@ #include #include -#include "variant.h" - //Q_DECLARE_METATYPE(SimpleJavaScriptApplet*) Q_DECLARE_METATYPE(QGraphicsWidget*) Q_DECLARE_METATYPE(QGraphicsLayout*) diff --git a/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp b/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp index 712c3bd0b..18c8f8cc9 100644 --- a/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp +++ b/scriptengines/javascript/simplebindings/qscriptnonguibookkeeping.cpp @@ -24,7 +24,6 @@ #include #include "dataengine.h" -#include "variant.h" Q_DECLARE_METATYPE(KConfigGroup) Q_DECLARE_METATYPE(KJob *) @@ -76,7 +75,7 @@ QScriptValue qScriptValueFromKConfigGroup(QScriptEngine *engine, const KConfigGr //kDebug() << "setting" << it.key() << "to" << it.value(); QString prop = it.key(); prop.replace(' ', '_'); - obj.setProperty(prop, variantToScriptValue(engine, it.value())); + obj.setProperty(prop, it.value()); } return obj; diff --git a/scriptengines/javascript/simplebindings/variant.cpp b/scriptengines/javascript/simplebindings/variant.cpp deleted file mode 100644 index 6706bd0c2..000000000 --- a/scriptengines/javascript/simplebindings/variant.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2007 Richard J. Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include -#include - -#include - -QScriptValue variantToScriptValue(QScriptEngine *engine, QVariant var) -{ - if (var.isNull()) { - return engine->nullValue(); - } - - switch(var.type()) - { - case QVariant::Invalid: - return engine->nullValue(); - case QVariant::Bool: - return QScriptValue(engine, var.toBool()); - case QVariant::Date: - return engine->newDate(var.toDateTime()); - case QVariant::DateTime: - return engine->newDate(var.toDateTime()); - case QVariant::Double: - return QScriptValue(engine, var.toDouble()); - case QVariant::Int: - case QVariant::LongLong: - return QScriptValue(engine, var.toInt()); - case QVariant::String: - return QScriptValue(engine, var.toString()); - case QVariant::Time: { - QDateTime t(QDate::currentDate(), var.toTime()); - return engine->newDate(t); - } - case QVariant::UInt: - return QScriptValue(engine, var.toUInt()); - default: - if (var.typeName() == QLatin1String("KUrl")) { - return QScriptValue(engine, var.value().prettyUrl()); - } else if (var.typeName() == QLatin1String("QColor")) { - return QScriptValue(engine, var.value().name()); - } else if (var.typeName() == QLatin1String("QUrl")) { - return QScriptValue(engine, var.value().toString()); - } - break; - } - - return qScriptValueFromValue(engine, var); -} - diff --git a/scriptengines/javascript/simplebindings/variant.h b/scriptengines/javascript/simplebindings/variant.h deleted file mode 100644 index e80a5f8b8..000000000 --- a/scriptengines/javascript/simplebindings/variant.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2007 Richard J. Moore - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License version 2 as - * published by the Free Software Foundation - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef VARIANT_H -#define VARIANT_H - -QScriptValue variantToScriptValue(QScriptEngine *engine, QVariant var); - -#endif