summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-08-27 08:21:33 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-08-27 08:21:33 (GMT)
commit1651d5d9109d60f9f6a63e18e31b59b90aeda6f8 (patch)
tree5b921d91446efa24c5121dc4322b0b9e82c4cb19 /src/declarative
parentdd60bef7c93a09a92228574bade084d520e711f9 (diff)
parentf73d25d19a8978be3735f696f5f3bf6fe5ca68ee (diff)
downloadQt-1651d5d9109d60f9f6a63e18e31b59b90aeda6f8.zip
Qt-1651d5d9109d60f9f6a63e18e31b59b90aeda6f8.tar.gz
Qt-1651d5d9109d60f9f6a63e18e31b59b90aeda6f8.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfxgridview.cpp5
-rw-r--r--src/declarative/fx/qfxlistview.cpp6
-rw-r--r--src/declarative/qml/qmlengine.cpp66
-rw-r--r--src/declarative/qml/qmlengine_p.h5
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp2
5 files changed, 76 insertions, 8 deletions
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index b429895..bf6e863 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -1254,6 +1254,7 @@ void QFxGridView::itemsInserted(int modelIndex, int count)
void QFxGridView::itemsRemoved(int modelIndex, int count)
{
Q_D(QFxGridView);
+ bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
int index = d->mapFromModel(modelIndex);
if (index == -1) {
if (modelIndex + count - 1 < d->visibleIndex) {
@@ -1269,7 +1270,7 @@ void QFxGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
d->releaseItem(d->currentItem);
d->currentItem = 0;
@@ -1311,7 +1312,7 @@ void QFxGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
d->releaseItem(d->currentItem);
d->currentItem = 0;
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 0dfdce8..c1e03dd 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -1522,6 +1522,7 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
{
Q_D(QFxListView);
d->updateUnrequestedIndexes();
+ bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
if (!d->mapRangeFromModel(modelIndex, count)) {
if (modelIndex + count - 1 < d->visibleIndex) {
// Items removed before our visible items.
@@ -1536,7 +1537,7 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
d->releaseItem(d->currentItem);
d->currentItem = 0;
@@ -1579,8 +1580,9 @@ void QFxListView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
- } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
+ } else if (currentRemoved) {
// current item has been removed.
+ d->currentItem->attached->setIsCurrentItem(false);
d->releaseItem(d->currentItem);
d->currentItem = 0;
d->currentIndex = -1;
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index cf90fe7..de88241 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -72,6 +72,7 @@
#include <QtCore/qthread.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
+#include <QtGui/qcolor.h>
#include <QtGui/qvector3d.h>
#include <qmlcomponent.h>
#include "private/qmlcomponentjs_p.h"
@@ -116,6 +117,12 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
desktopObject.setProperty(QLatin1String("openUrl"),scriptEngine.newFunction(desktopOpenUrl, 1));
qtObject.setProperty(QLatin1String("DesktopServices"), desktopObject);
scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject);
+ qtObject.setProperty(QLatin1String("rgba"), scriptEngine.newFunction(QmlEnginePrivate::rgba, 4));
+ qtObject.setProperty(QLatin1String("hsla"), scriptEngine.newFunction(QmlEnginePrivate::hsla, 4));
+ qtObject.setProperty(QLatin1String("rect"), scriptEngine.newFunction(QmlEnginePrivate::rect, 4));
+ qtObject.setProperty(QLatin1String("point"), scriptEngine.newFunction(QmlEnginePrivate::point, 2));
+ qtObject.setProperty(QLatin1String("size"), scriptEngine.newFunction(QmlEnginePrivate::size, 2));
+ qtObject.setProperty(QLatin1String("vector3d"), scriptEngine.newFunction(QmlEnginePrivate::vector, 3));
}
QmlEnginePrivate::~QmlEnginePrivate()
@@ -172,7 +179,7 @@ void QmlEnginePrivate::init()
scriptEngine.globalObject().setProperty(QLatin1String("createComponent"),
scriptEngine.newFunction(QmlEnginePrivate::createComponent, 1));
scriptEngine.globalObject().setProperty(QLatin1String("vector"),
- scriptEngine.newFunction(QmlEnginePrivate::vector, 1));
+ scriptEngine.newFunction(QmlEnginePrivate::vector, 3));
if (QCoreApplication::instance()->thread() == q->thread() &&
QmlEngineDebugServer::isDebuggingEnabled()) {
@@ -710,7 +717,7 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi
QVector3D as usual.
This function takes three numeric components and combines them into a
- QMLJS string that can be used with any property that takes a
+ QVector3D value that can be used with any property that takes a
QVector3D argument. The following QML code:
\code
@@ -741,6 +748,59 @@ QScriptValue QmlEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engin
return engine->newVariant(qVariantFromValue(QVector3D(x, y, z)));
}
+QScriptValue QmlEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount < 3)
+ return engine->nullValue();
+ qsreal r = ctxt->argument(0).toNumber();
+ qsreal g = ctxt->argument(1).toNumber();
+ qsreal b = ctxt->argument(2).toNumber();
+ qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
+ return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a)));
+}
+
+QScriptValue QmlEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount < 3)
+ return engine->nullValue();
+ qsreal h = ctxt->argument(0).toNumber();
+ qsreal s = ctxt->argument(1).toNumber();
+ qsreal l = ctxt->argument(2).toNumber();
+ qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
+ return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a)));
+}
+
+QScriptValue QmlEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() < 4)
+ return engine->nullValue();
+ qsreal x = ctxt->argument(0).toNumber();
+ qsreal y = ctxt->argument(1).toNumber();
+ qsreal w = ctxt->argument(2).toNumber();
+ qsreal h = ctxt->argument(3).toNumber();
+ return qScriptValueFromValue(engine, qVariantFromValue(QRectF(x, y, w, h)));
+}
+
+QScriptValue QmlEnginePrivate::point(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() < 2)
+ return engine->nullValue();
+ qsreal x = ctxt->argument(0).toNumber();
+ qsreal y = ctxt->argument(1).toNumber();
+ return qScriptValueFromValue(engine, qVariantFromValue(QPointF(x, y)));
+}
+
+QScriptValue QmlEnginePrivate::size(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if(ctxt->argumentCount() < 2)
+ return engine->nullValue();
+ qsreal w = ctxt->argument(0).toNumber();
+ qsreal h = ctxt->argument(1).toNumber();
+ return qScriptValueFromValue(engine, qVariantFromValue(QSizeF(w, h)));
+}
+
QmlScriptClass::QmlScriptClass(QmlEngine *bindengine)
: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)),
engine(bindengine)
@@ -983,7 +1043,7 @@ QScriptValue QmlObjectToString(QScriptContext *context, QScriptEngine *engine)
ret += QString::number((quintptr)obj,16);
ret += QLatin1String(")");
}else{
- ret += "null";
+ ret += QLatin1String("null");
}
return engine->newVariant(ret);
}
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 53b2967..c2de72b 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -214,6 +214,11 @@ public:
static QScriptValue createComponent(QScriptContext*, QScriptEngine*);
static QScriptValue createQmlObject(QScriptContext*, QScriptEngine*);
static QScriptValue vector(QScriptContext*, QScriptEngine*);
+ static QScriptValue rgba(QScriptContext*, QScriptEngine*);
+ static QScriptValue hsla(QScriptContext*, QScriptEngine*);
+ static QScriptValue point(QScriptContext*, QScriptEngine*);
+ static QScriptValue size(QScriptContext*, QScriptEngine*);
+ static QScriptValue rect(QScriptContext*, QScriptEngine*);
static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; }
static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); }
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index cc5e4ee..1e8ce91 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -532,7 +532,7 @@ QmlAbstractBinding *QmlMetaProperty::binding() const
QmlAbstractBinding *binding = data->bindings;
while (binding) {
// ### This wont work for value types
- if (binding->propertyIndex() == d->coreIdx)
+ if (binding->propertyIndex() == d->coreIdx) //### should we check for enabled?
return binding;
binding = binding->m_nextBinding;
}