aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlextensionplugin.cpp12
-rw-r--r--src/qml/qml/qqmllist.cpp43
-rw-r--r--src/qml/qml/qqmllist.h10
-rw-r--r--src/qml/qml/qqmlopenmetaobject.cpp17
-rw-r--r--src/qml/qml/qqmlopenmetaobject_p.h4
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp33
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h1
-rw-r--r--src/qml/qml/qqmlvme.cpp11
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h2
-rw-r--r--src/qml/qml/v8/qv8contextwrapper.cpp1
10 files changed, 116 insertions, 18 deletions
diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp
index 36abc3a9e4..2f0e804019 100644
--- a/src/qml/qml/qqmlextensionplugin.cpp
+++ b/src/qml/qml/qqmlextensionplugin.cpp
@@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE
To make this class available as a QML type, create a plugin that registers
this type with a specific \l {QML Modules}{module} using qmlRegisterType(). For this example the plugin
- module will be named \c com.nokia.TimeExample (as defined in the project
+ module will be named \c TimeExample (as defined in the project
file further below).
\snippet examples/qml/plugins/plugin.cpp plugin
@@ -93,27 +93,27 @@ QT_BEGIN_NAMESPACE
ensures the module is imported correctly by any QML components that use this plugin.
The project file defines the project as a plugin library and specifies
- it should be built into the \c com/nokia/TimeExample directory:
+ it should be built into the \c imports/TimeExample directory:
\code
TEMPLATE = lib
CONFIG += qt plugin
QT += qml
- DESTDIR = com/nokia/TimeExample
+ DESTDIR = imports/TimeExample
TARGET = qmlqtimeexampleplugin
...
\endcode
- Finally, a \l{Module Definition qmldir Files}{qmldir file} is required in the \c com/nokia/TimeExample directory
+ Finally, a \l{Module Definition qmldir Files}{qmldir file} is required in the \c imports/TimeExample directory
that describes the plugin. This directory includes a \c Clock.qml file that
should be bundled with the plugin, so it needs to be specified in the \c qmldir
file:
- \quotefile examples/qml/plugins/com/nokia/TimeExample/qmldir
+ \quotefile examples/qml/plugins/imports/TimeExample/qmldir
Once the project is built and installed, the new \c Time element can be
- used by any QML component that imports the \c com.nokia.TimeExample module:
+ used by any QML component that imports the \c TimeExample module:
\snippet examples/qml/plugins/plugins.qml 0
diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp
index 2aef3f2cd7..e90633ac1a 100644
--- a/src/qml/qml/qqmllist.cpp
+++ b/src/qml/qml/qqmllist.cpp
@@ -254,6 +254,32 @@ bool QQmlListReference::canCount() const
}
/*!
+ Return true if at(), count(), append() and clear() are implemented, so you can manipulate
+ the list.
+
+\sa isReadable(), at(), count(), append(), clear()
+*/
+bool QQmlListReference::isManipulable() const
+{
+ return (isValid()
+ && d->property.append
+ && d->property.count
+ && d->property.at
+ && d->property.clear);
+}
+
+
+/*!
+ Return true if at() and count() are implemented, so you can access the elements.
+
+\sa isManipulable(), at(), count()
+*/
+bool QQmlListReference::isReadable() const
+{
+ return (isValid() && d->property.count && d->property.at);
+}
+
+/*!
Appends \a object to the list. Returns true if the operation succeeded, otherwise false.
\sa canAppend()
@@ -366,16 +392,25 @@ can very useful while prototyping.
*/
/*!
+\fn QQmlListProperty::QQmlListProperty(QObject *object, void *data,
+ CountFunction count, AtFunction at)
+
+Construct a readonly QQmlListProperty from a set of operation functions. An opaque \a data handle
+may be passed which can be accessed from within the operation functions. The list property
+remains valid while \a object exists.
+*/
+
+/*!
\fn QQmlListProperty::QQmlListProperty(QObject *object, void *data, AppendFunction append,
- CountFunction count = 0, AtFunction at = 0,
- ClearFunction clear = 0)
+ CountFunction count, AtFunction at,
+ ClearFunction clear)
Construct a QQmlListProperty from a set of operation functions. An opaque \a data handle
may be passed which can be accessed from within the operation functions. The list property
remains valid while \a object exists.
-The \a append operation is compulsory and must be provided, while the \a count, \a at and
-\a clear methods are optional.
+You can pass a null pointer, but than the list will be not designable or changeable by the debugger.
+So provide all function, except it is not possible.
*/
/*!
diff --git a/src/qml/qml/qqmllist.h b/src/qml/qml/qqmllist.h
index bc2feaf22f..e772022636 100644
--- a/src/qml/qml/qqmllist.h
+++ b/src/qml/qml/qqmllist.h
@@ -69,10 +69,11 @@ public:
QQmlListProperty(QObject *o, QList<T *> &list)
: object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at),
clear(qlist_clear), dummy1(0), dummy2(0) {}
- QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0,
- ClearFunction r = 0)
+ QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t,
+ ClearFunction r )
: object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {}
-
+ QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction t)
+ : object(o), data(d), append(0), count(c), at(t), clear(0), dummy1(0), dummy2(0) {}
bool operator==(const QQmlListProperty &o) const {
return object == o.object &&
data == o.data &&
@@ -132,6 +133,9 @@ public:
bool canClear() const;
bool canCount() const;
+ bool isManipulable() const;
+ bool isReadable() const;
+
bool append(QObject *) const;
QObject *at(int) const;
bool clear() const;
diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp
index a92d822774..5928a6dfb7 100644
--- a/src/qml/qml/qqmlopenmetaobject.cpp
+++ b/src/qml/qml/qqmlopenmetaobject.cpp
@@ -96,6 +96,23 @@ int QQmlOpenMetaObjectType::signalOffset() const
return d->signalOffset;
}
+int QQmlOpenMetaObjectType::propertyCount() const
+{
+ return d->names.count();
+}
+
+QByteArray QQmlOpenMetaObjectType::propertyName(int idx) const
+{
+ Q_ASSERT(idx >= 0 && idx < d->names.count());
+
+ return d->mob.property(idx).name();
+}
+
+QMetaObject *QQmlOpenMetaObjectType::metaObject() const
+{
+ return d->mem;
+}
+
int QQmlOpenMetaObjectType::createProperty(const QByteArray &name)
{
int id = d->mob.propertyCount();
diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h
index 1ca53df772..d037776150 100644
--- a/src/qml/qml/qqmlopenmetaobject_p.h
+++ b/src/qml/qml/qqmlopenmetaobject_p.h
@@ -69,6 +69,10 @@ public:
int propertyOffset() const;
int signalOffset() const;
+ int propertyCount() const;
+ QByteArray propertyName(int) const;
+ QMetaObject *metaObject() const;
+
protected:
virtual void propertyCreated(int, QMetaPropertyBuilder &);
virtual void clear();
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 431a5be01b..c1c4a6c03d 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -849,6 +849,39 @@ void QQmlPropertyCache::update(QQmlEngine *engine, const QMetaObject *metaObject
}
/*! \internal
+ invalidates and updates the PropertyCache if the QMetaObject has changed.
+ This function is used in the tooling to update dynamic properties.
+*/
+void QQmlPropertyCache::invalidate(QQmlEngine *engine, const QMetaObject *metaObject)
+{
+ stringCache.clear();
+ propertyIndexCache.clear();
+ methodIndexCache.clear();
+ signalHandlerIndexCache.clear();
+
+ _hasPropertyOverrides = false;
+ argumentsCache = 0;
+
+ int pc = metaObject->propertyCount();
+ int mc = metaObject->methodCount();
+ int sc = metaObjectSignalCount(metaObject);
+ int reserve = pc + mc + sc;
+
+ if (parent()) {
+ propertyIndexCacheStart = parent()->propertyIndexCache.count() + parent()->propertyIndexCacheStart;
+ methodIndexCacheStart = parent()->methodIndexCache.count() + parent()->methodIndexCacheStart;
+ signalHandlerIndexCacheStart = parent()->signalHandlerIndexCache.count() + parent()->signalHandlerIndexCacheStart;
+ stringCache.linkAndReserve(parent()->stringCache, reserve);
+ append(engine, metaObject, -1);
+ } else {
+ propertyIndexCacheStart = 0;
+ methodIndexCacheStart = 0;
+ signalHandlerIndexCacheStart = 0;
+ update(engine, metaObject);
+ }
+}
+
+/*! \internal
\a index MUST be in the signal index range (see QObjectPrivate::signalIndex()).
This is different from QMetaMethod::methodIndex().
*/
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 4310e4ea40..14be99045f 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -247,6 +247,7 @@ public:
virtual ~QQmlPropertyCache();
void update(QQmlEngine *, const QMetaObject *);
+ void invalidate(QQmlEngine *, const QMetaObject *);
QQmlPropertyCache *copy();
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index 045869e15d..12de9ffebd 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -941,7 +941,10 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QObject *assign = objects.pop();
const List &list = lists.top();
- list.qListProperty.append((QQmlListProperty<void>*)&list.qListProperty, assign);
+ if (list.qListProperty.append)
+ list.qListProperty.append((QQmlListProperty<void>*)&list.qListProperty, assign);
+ else
+ VME_EXCEPTION(tr("Cannot assign object to read only list"), -1);
QML_END_INSTR(StoreObjectQList)
QML_BEGIN_INSTR(AssignObjectList)
@@ -959,8 +962,10 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
if (!ptr)
VME_EXCEPTION(tr("Cannot assign object to list"), instr.line);
-
- list.qListProperty.append((QQmlListProperty<void>*)&list.qListProperty, ptr);
+ if (list.qListProperty.append)
+ list.qListProperty.append((QQmlListProperty<void>*)&list.qListProperty, ptr);
+ else
+ VME_EXCEPTION(tr("Cannot assign object to read only list"), -1);
QML_END_INSTR(AssignObjectList)
QML_BEGIN_INSTR(StoreInterface)
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index c858370d27..c46989eb25 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -157,7 +157,7 @@ class QV8QObjectWrapper;
class QQmlVMEVariant;
class QQmlRefCount;
class QQmlVMEMetaObjectEndpoint;
-class Q_AUTOTEST_EXPORT QQmlVMEMetaObject : public QAbstractDynamicMetaObject,
+class Q_QML_PRIVATE_EXPORT QQmlVMEMetaObject : public QAbstractDynamicMetaObject,
public QV8GCCallback::Node
{
public:
diff --git a/src/qml/qml/v8/qv8contextwrapper.cpp b/src/qml/qml/v8/qv8contextwrapper.cpp
index b2c60fe7a8..9f18afc5cb 100644
--- a/src/qml/qml/v8/qv8contextwrapper.cpp
+++ b/src/qml/qml/v8/qv8contextwrapper.cpp
@@ -309,7 +309,6 @@ v8::Handle<v8::Value> QV8ContextWrapper::Getter(v8::Local<v8::String> property,
const QVariant &value = cp->propertyValues.at(propertyIdx);
if (value.userType() == qMetaTypeId<QList<QObject*> >()) {
QQmlListProperty<QObject> prop(context->asQQmlContext(), (void*) qintptr(propertyIdx),
- 0,
QQmlContextPrivate::context_count,
QQmlContextPrivate::context_at);
return engine->listWrapper()->newList(prop, qMetaTypeId<QQmlListProperty<QObject> >());