summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-04 05:50:05 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-04 05:50:05 (GMT)
commit9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6 (patch)
tree8f44e4adbf0de9308669820b80697e7ed372608d /src/declarative/qml
parent48ea5a5c74620f9811debc6bf1e49bf095d30722 (diff)
parent0ced984d3e2cb2a7a1a219ae7a9b09ff4e15a55c (diff)
downloadQt-9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6.zip
Qt-9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6.tar.gz
Qt-9cfd793625e6582d2fe3eaff7d5dfac3a3fcdff6.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlcontextscriptclass.cpp1
-rw-r--r--src/declarative/qml/qmlengine.cpp20
-rw-r--r--src/declarative/qml/qmlengine_p.h1
-rw-r--r--src/declarative/qml/qmlglobalscriptclass.cpp19
-rw-r--r--src/declarative/qml/qmllistscriptclass.cpp15
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp3
6 files changed, 45 insertions, 14 deletions
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp
index 4615764..fda284a 100644
--- a/src/declarative/qml/qmlcontextscriptclass.cpp
+++ b/src/declarative/qml/qmlcontextscriptclass.cpp
@@ -219,6 +219,7 @@ QScriptValue QmlContextScriptClass::property(Object *object, const Identifier &n
void QmlContextScriptClass::setProperty(Object *object, const Identifier &name,
const QScriptValue &value)
{
+ Q_UNUSED(object);
Q_ASSERT(lastScopeObject || lastDefaultObject != -1);
QmlContext *bindContext = lastContext;
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index c562e02..2926791 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -147,6 +147,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
qtObject.setProperty(QLatin1String("tint"), scriptEngine.newFunction(QmlEnginePrivate::tint, 2));
//misc methods
+ qtObject.setProperty(QLatin1String("closestAngle"), scriptEngine.newFunction(QmlEnginePrivate::closestAngle, 2));
qtObject.setProperty(QLatin1String("playSound"), scriptEngine.newFunction(QmlEnginePrivate::playSound, 1));
qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1));
@@ -810,6 +811,25 @@ QScriptValue QmlEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngin
return e->newVariant(QVariant(ret));
}
+QScriptValue QmlEnginePrivate::closestAngle(QScriptContext *ctxt, QScriptEngine *e)
+{
+ if(ctxt->argumentCount() < 2)
+ return e->newVariant(QVariant(0.0));
+ qreal a = ctxt->argument(0).toNumber();
+ qreal b = ctxt->argument(1).toNumber();
+ qreal ret = b;
+ qreal diff = b-a;
+ while(diff > 180.0){
+ ret -= 360.0;
+ diff -= 360.0;
+ }
+ while(diff < -180.0){
+ ret += 360.0;
+ diff += 360.0;
+ }
+ return e->newVariant(QVariant(ret));
+}
+
QScriptValue QmlEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 2)
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index b050ef6..3c60b5c 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -269,6 +269,7 @@ public:
static QScriptValue darker(QScriptContext*, QScriptEngine*);
static QScriptValue tint(QScriptContext*, QScriptEngine*);
+ static QScriptValue closestAngle(QScriptContext*, QScriptEngine*);
static QScriptValue playSound(QScriptContext*, QScriptEngine*);
static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*);
diff --git a/src/declarative/qml/qmlglobalscriptclass.cpp b/src/declarative/qml/qmlglobalscriptclass.cpp
index a9c5d3d..fd270e3 100644
--- a/src/declarative/qml/qmlglobalscriptclass.cpp
+++ b/src/declarative/qml/qmlglobalscriptclass.cpp
@@ -70,10 +70,10 @@ QmlGlobalScriptClass::queryProperty(const QScriptValue &object,
const QScriptString &name,
QueryFlags flags, uint *id)
{
- Q_UNUSED(object)
- Q_UNUSED(name)
- Q_UNUSED(flags)
- Q_UNUSED(id)
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ Q_UNUSED(flags);
+ Q_UNUSED(id);
return HandlesReadAccess | HandlesWriteAccess;
}
@@ -82,9 +82,9 @@ QmlGlobalScriptClass::property(const QScriptValue &object,
const QScriptString &name,
uint id)
{
- Q_UNUSED(object)
- Q_UNUSED(name)
- Q_UNUSED(id)
+ Q_UNUSED(object);
+ Q_UNUSED(name);
+ Q_UNUSED(id);
return engine()->undefinedValue();
}
@@ -92,8 +92,9 @@ void QmlGlobalScriptClass::setProperty(QScriptValue &object,
const QScriptString &name,
uint id, const QScriptValue &value)
{
- Q_UNUSED(object)
- Q_UNUSED(value)
+ Q_UNUSED(object);
+ Q_UNUSED(id);
+ Q_UNUSED(value);
QString error = QLatin1String("Invalid write to global property \"") +
name.toString() + QLatin1String("\"");
engine()->currentContext()->throwError(error);
diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp
index f067db6..a180e49 100644
--- a/src/declarative/qml/qmllistscriptclass.cpp
+++ b/src/declarative/qml/qmllistscriptclass.cpp
@@ -54,6 +54,7 @@ QmlListScriptClass::QmlListScriptClass(QmlEngine *e)
: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(e)), engine(e)
{
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
+ Q_UNUSED(scriptEngine);
m_lengthId = createPersistentIdentifier(QLatin1String("length"));
}
@@ -81,6 +82,8 @@ QScriptClass::QueryFlags
QmlListScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags flags)
{
+ Q_UNUSED(object);
+ Q_UNUSED(flags);
if (name == m_lengthId.identifier)
return QScriptClass::HandlesReadAccess;
@@ -115,9 +118,11 @@ QScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name)
if (data->type == QListPtr) {
const QList<QObject *> &qlist = *((QList<QObject *>*)list);
- if (name == m_lengthId.identifier)
- return qlist.count();
- else if (lastIndex < qlist.count())
+ quint32 count = qlist.count();
+
+ if (name == m_lengthId.identifier)
+ return count;
+ else if (lastIndex < count)
return enginePriv->objectClass->newQObject(qlist.at(lastIndex));
else
return scriptEngine->undefinedValue();
@@ -126,9 +131,9 @@ QScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name)
Q_ASSERT(data->type == QmlListPtr);
const QmlList<QObject *> &qmllist = *((QmlList<QObject *>*)list);
- int count = qmllist.count();
+ quint32 count = qmllist.count();
- if (name == m_lengthId.identifier)
+ if (name == m_lengthId.identifier)
return count;
else if (lastIndex < count)
return enginePriv->objectClass->newQObject(qmllist.at(lastIndex));
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 28878b8..4ad9aac 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -534,6 +534,9 @@ QmlAbstractBinding *QmlMetaProperty::binding() const
Ownership of \a newBinding transfers to QML. Ownership of the return value
is assumed by the caller.
+
+ \a flags is passed through to the binding and is used for the initial update (when
+ the binding sets the intial value, it will use these flags for the write).
*/
QmlAbstractBinding *
QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding, QmlMetaProperty::WriteFlags flags) const