43 #include "private/qdeclarativeproperty_p.h" 46 #include "private/qdeclarativebinding_p.h" 48 #include "private/qdeclarativecontext_p.h" 49 #include "private/qdeclarativeboundsignal_p.h" 51 #include "private/qdeclarativeengine_p.h" 52 #include "private/qdeclarativedata_p.h" 53 #include "private/qdeclarativestringconverters_p.h" 54 #include "private/qdeclarativelist_p.h" 55 #include "private/qdeclarativecompiler_p.h" 56 #include "private/qdeclarativevmemetaobject_p.h" 58 #include <QStringList> 59 #include <QtCore/qdebug.h> 230 for (
int ii = 0; ii < path.
count() - 1; ++ii) {
239 if (!currentObject)
return;
242 if ((ii + 1) == path.
count())
return;
244 ++ii;
data =
data->typeNamespace->data(path.
at(ii));
251 if (!currentObject)
return;
267 if (!typeObject)
return;
270 if (idx == -1)
return;
274 object = currentObject;
277 valueType.valueTypeCoreIdx = idx;
278 valueType.valueTypePropType = vtProp.
userType();
285 void *args[] = { ¤tObject, 0 };
287 if (!currentObject)
return;
296 if (terminal.
count() >= 3 &&
302 signalName[0] = signalName.
at(0).
toLower();
306 object = currentObject;
317 object = currentObject;
319 nameCache = terminal;
411 if (!ep)
delete valueType;
447 return valueType.valueTypeCoreIdx != -1;
454 return valueType.valueTypePropType;
457 return qMetaTypeId<QVariant>();
459 return core.propType;
469 else if (core.isValid())
598 if (!ep)
delete valueType;
696 QObject *aObject = 0;
int aCoreIndex = -1;
int aValueTypeIndex = -1;
697 if (!vme->
aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex) || aCoreIndex == -1)
701 Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
702 return binding(aObject, aCoreIndex, (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex);
712 if (binding && valueTypeIndex != -1) {
714 int index = coreIndex | (valueTypeIndex << 24);
723 QObject **targetObject,
int *targetBindingIndex)
725 int coreIndex = bindingIndex & 0xFFFFFF;
726 int valueTypeIndex = bindingIndex >> 24;
727 if (valueTypeIndex == 0) valueTypeIndex = -1;
736 QObject *aObject = 0;
int aCoreIndex = -1;
int aValueTypeIndex = -1;
737 if (vme->
aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
739 Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
741 int aBindingIndex = aCoreIndex;
742 if (aValueTypeIndex != -1)
743 aBindingIndex |= aValueTypeIndex << 24;
744 else if (valueTypeIndex != -1)
745 aBindingIndex |= valueTypeIndex << 24;
747 findAliasTarget(aObject, aBindingIndex, targetObject, targetBindingIndex);
754 *targetBindingIndex = bindingIndex;
771 QObject *aObject = 0;
int aCoreIndex = -1;
int aValueTypeIndex = -1;
772 if (!vme->
aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
773 if (newBinding) newBinding->
destroy();
778 Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
779 return setBinding(aObject, aCoreIndex, (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex,
791 int index = coreIndex;
792 if (valueTypeIndex != -1)
793 index |= (valueTypeIndex << 24);
796 binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
825 QObject *aObject = 0;
int aCoreIndex = -1;
int aValueTypeIndex = -1;
826 if (!vme->
aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
827 if (newBinding) newBinding->
destroy();
832 Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
833 return setBindingNoEnable(aObject, aCoreIndex, (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex,
845 int index = coreIndex;
846 if (valueTypeIndex != -1)
847 index |= (valueTypeIndex << 24);
850 binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
873 for (
int ii = 0; ii < children.
count(); ++ii) {
877 if (signal && signal->
index() == that.
index())
902 for (
int ii = 0; ii < children.
count(); ++ii) {
906 if (signal && signal->
index() == that.
index())
992 if (ep) valueType = ep->
valueTypes[core.propType];
996 valueType->
read(
object, core.coreIndex);
1001 if (!ep)
delete valueType;
1007 void *args[] = { &prop, 0 };
1014 void *args[] = { &rv, 0 };
1020 return object->metaObject()->property(core.coreIndex).read(
object.
data());
1036 || v.
userType() == QVariant::CString
1045 if ((enumMetaTypeId == 0) || (v.
userType() != enumMetaTypeId) || !v.
constData())
1058 void *argv[] = { v.
data(), &v, &
status, &flags };
1066 if (!(flags & DontRemoveBinding) &&
1069 valueType.valueTypeCoreIdx, 0, flags);
1070 if (binding) binding->
destroy();
1074 if (isValueType()) {
1084 writeBack->
read(
object, core.coreIndex);
1087 data.
flags = valueType.flags;
1088 data.
coreIndex = valueType.valueTypeCoreIdx;
1089 data.
propType = valueType.valueTypePropType;
1090 rv =
write(writeBack, data, value, context, flags);
1092 writeBack->
write(
object, core.coreIndex, flags);
1093 if (!ep)
delete writeBack;
1097 rv =
write(
object, core, value, context, flags);
1108 int coreIdx =
property.coreIndex;
1117 double fractional = modf(value.
toDouble(), &integral);
1121 return writeEnumProperty(prop, coreIdx,
object, v, flags);
1125 int variantType = value.
userType();
1150 void *argv[] = { &
u, 0, &
status, &flags };
1153 }
else if (variantType == propertyType) {
1158 }
else if (qMetaTypeId<QVariant>() == propertyType) {
1160 void *
a[] = { (
void *)&value, 0, &status, &flags };
1171 const QMetaObject *propMo = rawMetaObjectForType(enginePriv, propertyType);
1175 if (canConvert(valMo, propMo)) {
1176 void *args[] = { &o, 0, &
status, &flags };
1179 }
else if (!o && canConvert(propMo, valMo)) {
1183 void *args[] = { &o, 0, &
status, &flags };
1197 if (!type)
return false;
1200 if (!listType)
return false;
1203 void *args[] = { &prop, 0 };
1206 if (!prop.clear)
return false;
1210 if (value.
userType() == qMetaTypeId<QList<QObject *> >()) {
1213 for (
int ii = 0; ii < list.
count(); ++ii) {
1215 if (o && !canConvert(o->
metaObject(), listType))
1217 prop.append(&prop, (
void *)o);
1221 if (o && !canConvert(o->
metaObject(), listType))
1223 prop.append(&prop, (
void *)o);
1227 Q_ASSERT(variantType != propertyType);
1289 return p.
write(value);
1308 return p.
write(value);
1326 return p.
write(value);
1337 void *args[] = { 0 };
1346 const QVariant &value, WriteFlags flags)
1465 memset(&sd, 0,
sizeof(sd));
1472 QByteArray rv((
const char *)&sd,
sizeof(sd));
1480 memset(&sd, 0,
sizeof(sd));
1484 QByteArray rv((
const char *)&sd,
sizeof(sd));
1502 return restore(sd->
core, data,
object, ctxt);
1539 if (
equal(from, to))
1554 for (
int ii = methods - 1; ii >= 2; --ii) {
1557 int idx = methodName.
indexOf(
'(');
1558 methodName = methodName.
left(idx);
1560 if (methodName == name)
1585 int classInfoCount, classInfoData;
1586 int methodCount, methodData;
1587 int propertyCount, propertyData;
1590 return reinterpret_cast<const Private *
>(metaObject->
d.
data)->methodCount;
1599 int classInfoCount, classInfoData;
1600 int methodCount, methodData;
1601 int propertyCount, propertyData;
1604 return reinterpret_cast<const Private *
>(metaObject->
d.
data)->propertyCount;
1614 const QMetaObject *metaObject =
object->metaObject();
1617 while (methodOffset > index) {
1638 const QObject *receiver,
int method_index,
1665 while (propertyOffset > property) {
QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const
The QVariant class acts like a union for the most common Qt data types.
QUrl resolvedUrl(const QUrl &)
QObject *(* QDeclarativeAttachedPropertiesFunc)(QObject *)
const T * constData() const
QDeclarativePropertyCache * propertyCache
static QDeclarativeData * get(const QObject *object, bool create=false)
QDeclarativeProperty::Type type() const
bool isResettable() const
Returns true if the property is resettable, otherwise false.
#define QT_END_NAMESPACE
This macro expands to.
static void signalSignature(const QMetaMethod &signal, QVarLengthArray< char > *result)
const QChar at(int i) const
Returns the character at the given index position in the string.
QDeclarativeEngine * engine
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
QDeclarativePropertyCache::Data core
static QDeclarativeBoundSignal * cast(QObject *)
static QDeclarativeValueType * valueType(int)
The QByteArray class provides an array of bytes.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &)
Return the signal corresponding to name.
int propertyIndex() const
void addToObject(QObject *, int)
Add this binding to object.
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
bool isDesignable() const
Returns true if the property is designable, otherwise false.
QDeclarativeAbstractBinding * bindings
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
static bool connect(QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Connect sender signal_index to receiver method_index with the specified type and types.
static LibLoadStatus status
static int valueTypeCoreIndex(const QDeclarativeProperty &that)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QMetaObject * baseMetaObject() const
virtual Type bindingType() const
long ASN1_INTEGER_get ASN1_INTEGER * a
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags flags)=0
int count(const T &t) const
Returns the number of occurrences of value in the list.
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
The QUrl class provides a convenient interface for working with URLs.
bool reset() const
Resets the property and returns true if the property is resettable.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
bool isValid() const
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false.
QDeclarativeContextData * context
bool hasBindingBit(int) const
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static QObjectPrivate * get(QObject *o)
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
static const QMetaObject * metaObjectForProperty(const QMetaObject *, int)
Return metaObject's [super] meta object that provides data for property.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Q_DECLARATIVE_EXPORT QObject * qmlAttachedPropertiesObjectById(int, const QObject *, bool create=true)
QDeclarativeExpression * setExpression(QDeclarativeExpression *)
Sets the signal expression to e.
QObject * object() const
Returns the QDeclarativeProperty's QObject.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QVariant readValueProperty()
static QDeclarativeListReference init(const QDeclarativeListProperty< QObject > &, int, QDeclarativeEngine *)
int index() const
Return the Qt metaobject index of the property.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
QMetaMethod method() const
Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMet...
static int QMetaObject_methods(const QMetaObject *metaObject)
PropertyTypeCategory propertyTypeCategory() const
Returns the property category.
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
Data * property(const QScriptDeclarativeClass::Identifier &id) const
QDeclarativeProperty & operator=(const QDeclarativeProperty &)
Assign other to this QDeclarativeProperty.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
QVariant Q_DECLARATIVE_PRIVATE_EXPORT variantFromString(const QString &)
bool needsNotifySignal() const
Returns true if the property needs a change notifier signal for bindings to remain upto date...
static const char * data(const QByteArray &arr)
Type
This enum type defines the types of variable that a QVariant can contain.
static QDeclarativeExpression * signalExpression(const QDeclarativeProperty &that)
Returns the expression associated with this signal property, or 0 if no signal expression exists...
bool hasNotifySignal() const
Returns true if the property has a change notifier signal, otherwise false.
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
void load(const QMetaProperty &, QDeclarativeEngine *engine=0)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
bool connectNotifySignal(QObject *dest, const char *slot) const
Connects the property's change notifier signal to the specified slot of the dest object and returns t...
QDeclarativeAbstractBinding * m_nextBinding
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
static int bindingIndex(const QDeclarativeProperty &that)
Returns the "property index" for use in bindings.
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
QAbstractDeclarativeData * declarativeData
void connectNotify(const char *signal)
QDeclarativeExpression * expression() const
Returns the signal expression.
static QByteArray saveValueType(const QMetaObject *, int, const QMetaObject *, int)
bool isUpper() const
Returns true if the character is an uppercase letter, i.
bool convert(Type t)
Casts the variant to the requested type, t.
void initDefault(QObject *obj)
Initialize from the default property of obj.
QMetaProperty property() const
Returns the Qt property associated with this QML property.
int length() const
Same as size().
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
int userType() const
Returns the storage type of the value stored in the variant.
int propertyType() const
Returns the QVariant type of the property, or QVariant::Invalid if the property has no QVariant type...
void removeFromObject()
Remove the binding from the object.
static bool isValueType(int)
static QDeclarativeAbstractBinding * setBindingNoEnable(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *)
The QDeclarativeEngine class provides an environment for instantiating QML components.
void initProperty(QObject *obj, const QString &name)
QDeclarativeValueTypeFactory valueTypes
bool isSignalProperty() const
Returns true if this QDeclarativeProperty represents a QML signal property.
const void * constData() const
static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *)
T & last()
Returns a reference to the last item in the list.
QDeclarativePropertyPrivate * d
static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
static QByteArray methodName(const char *signature, int nameLength)
Makes a deep copy of the first nameLength characters of the given method signature and returns the co...
if(void) toggleToolbarShown
bool isWritable() const
Returns true if the property is writable, otherwise false.
const QObjectList & children() const
Returns a list of child objects.
T qvariant_cast(const QVariant &)
Type
This enum specifies a type of QML property.
The QDeclarativeContext class defines a context within a QML engine.
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
PropertyTypeCategory
This enum specifies a category of QML property.
QDeclarativeProperty()
Create an invalid QDeclarativeProperty.
QDeclarativeEngine * engine() const
Return the context's QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
QDeclarativeGuard< QObject > object
QObject * toQObject(const QVariant &, bool *ok=0) const
static bool canConvert(const QMetaObject *from, const QMetaObject *to)
Returns true if from inherits to.
bool writeValueProperty(const QVariant &, WriteFlags)
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
const char * propertyTypeName() const
Returns the type name of the property, or 0 if the property has no type name.
bool write(const QVariant &) const
Sets the property value to value and returns true.
static QDeclarativeExpression * setSignalExpression(const QDeclarativeProperty &that, QDeclarativeExpression *)
Set the signal expression associated with this signal property to expr.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
static void findAliasTarget(QObject *, int, QObject **, int *)
bool operator==(const QDeclarativeProperty &) const
Returns true if other and this QDeclarativeProperty represent the same property.
static int QMetaObject_properties(const QMetaObject *metaObject)
Data * data(const QString &) const
The QDeclarativeExpression class evaluates JavaScript in a QML context.
QString name() const
Return the name of this QML property.
static void flush_vme_signal(const QObject *object, int index)
QDeclarativeEngine * engine
QDeclarativePropertyCache::ValueTypeData valueType
const QMetaObject * rawMetaObjectForType(int) const
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static const QMetaObject * rawMetaObjectForType(QDeclarativeEnginePrivate *, int)
friend class QDeclarativePropertyPrivate
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
static QByteArray saveProperty(const QMetaObject *, int)
static bool equal(const QChar *a, int l, const char *b)
static bool equal(const QMetaObject *, const QMetaObject *)
Returns true if lhs and rhs refer to the same metaobject data.
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
bool isProperty() const
Returns true if this QDeclarativeProperty represents a regular Qt property.
QVariant read() const
Returns the property value.
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)
static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine=0)
virtual void read(QObject *, int)=0
QDeclarativePropertyCache::ValueTypeData valueType
static QDeclarativeContextData * get(QDeclarativeContext *context)