remove the QVariant workaround since the QScriptEngine::newVariant() should be fixed now in qt.

it seems to work for now, will keep the js scriptengine unchanged for a while to check for eventual problems.
if this work out will make the merge with the qml engine way easier

svn path=/trunk/KDE/kdebase/runtime/; revision=1185556
This commit is contained in:
Marco Martin 2010-10-13 18:08:07 +00:00
parent ac8de83bbd
commit 9de619ed86
7 changed files with 5 additions and 109 deletions

View File

@ -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})

View File

@ -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)

View File

@ -28,8 +28,6 @@
#include <Plasma/Service>
#include <Plasma/ServiceJob>
#include "variant.h"
using namespace Plasma;
Q_DECLARE_METATYPE(Service*)

View File

@ -25,8 +25,6 @@
#include <Plasma/Extender>
#include <Plasma/VideoWidget>
#include "variant.h"
//Q_DECLARE_METATYPE(SimpleJavaScriptApplet*)
Q_DECLARE_METATYPE(QGraphicsWidget*)
Q_DECLARE_METATYPE(QGraphicsLayout*)

View File

@ -24,7 +24,6 @@
#include <KSharedConfig>
#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;

View File

@ -1,70 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* 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 <QColor>
#include <QDate>
#include <QDateTime>
#include <QScriptEngine>
#include <QScriptValue>
#include <QVariant>
#include <KUrl>
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<KUrl>().prettyUrl());
} else if (var.typeName() == QLatin1String("QColor")) {
return QScriptValue(engine, var.value<QColor>().name());
} else if (var.typeName() == QLatin1String("QUrl")) {
return QScriptValue(engine, var.value<QUrl>().toString());
}
break;
}
return qScriptValueFromValue(engine, var);
}

View File

@ -1,24 +0,0 @@
/*
* Copyright 2007 Richard J. Moore <rich@kde.org>
*
* 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