Qt 4.8
Public Types | Public Functions | Static Public Functions | Public Variables | List of all members
QDeclarativePropertyPrivate Class Reference

#include <qdeclarativeproperty_p.h>

Inheritance diagram for QDeclarativePropertyPrivate:
QDeclarativeRefCount

Public Types

enum  WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02, RemoveBindingOnAliasWrite = 0x04 }
 

Public Functions

void initDefault (QObject *obj)
 Initialize from the default property of obj. More...
 
void initProperty (QObject *obj, const QString &name)
 
bool isValueType () const
 
int propertyType () const
 
QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory () const
 
 QDeclarativePropertyPrivate ()
 
QVariant readValueProperty ()
 
QDeclarativeProperty::Type type () const
 
bool writeValueProperty (const QVariant &, WriteFlags)
 
- Public Functions inherited from QDeclarativeRefCount
void addref ()
 
 QDeclarativeRefCount ()
 
void release ()
 
virtual ~QDeclarativeRefCount ()
 

Static Public Functions

static QDeclarativeAbstractBindingbinding (QObject *, int coreIndex, int valueTypeIndex)
 
static QDeclarativeAbstractBindingbinding (const QDeclarativeProperty &that)
 Returns the binding associated with this property, or 0 if no binding exists. More...
 
static int bindingIndex (const QDeclarativeProperty &that)
 Returns the "property index" for use in bindings. More...
 
static bool canConvert (const QMetaObject *from, const QMetaObject *to)
 Returns true if from inherits to. More...
 
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. More...
 
static bool equal (const QMetaObject *, const QMetaObject *)
 Returns true if lhs and rhs refer to the same metaobject data. More...
 
static void findAliasTarget (QObject *, int, QObject **, int *)
 
static QMetaMethod findSignalByName (const QMetaObject *mo, const QByteArray &)
 Return the signal corresponding to name. More...
 
static const QMetaObjectmetaObjectForProperty (const QMetaObject *, int)
 Return metaObject's [super] meta object that provides data for property. More...
 
static const QMetaObjectrawMetaObjectForType (QDeclarativeEnginePrivate *, int)
 
static QDeclarativeProperty restore (const QByteArray &, QObject *, QDeclarativeContextData *)
 
static QDeclarativeProperty restore (const QDeclarativePropertyCache::Data &, const QDeclarativePropertyCache::ValueTypeData &, QObject *, QDeclarativeContextData *)
 
static QByteArray saveProperty (const QMetaObject *, int)
 
static QByteArray saveValueType (const QMetaObject *, int, const QMetaObject *, int)
 
static QDeclarativeAbstractBindingsetBinding (QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
 
static QDeclarativeAbstractBindingsetBinding (const QDeclarativeProperty &that, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
 Set the binding associated with this property to newBinding. More...
 
static QDeclarativeAbstractBindingsetBindingNoEnable (QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *)
 
static QDeclarativeExpressionsetSignalExpression (const QDeclarativeProperty &that, QDeclarativeExpression *)
 Set the signal expression associated with this signal property to expr. More...
 
static QDeclarativeExpressionsignalExpression (const QDeclarativeProperty &that)
 Returns the expression associated with this signal property, or 0 if no signal expression exists. More...
 
static int valueTypeCoreIndex (const QDeclarativeProperty &that)
 
static bool write (QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)
 
static bool write (const QDeclarativeProperty &that, const QVariant &, WriteFlags)
 
static bool writeEnumProperty (const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
 

Public Variables

QDeclarativeContextDatacontext
 
QDeclarativePropertyCache::Data core
 
QDeclarativeEngineengine
 
bool isNameCached:1
 
QString nameCache
 
QDeclarativeGuard< QObjectobject
 
QDeclarativePropertyCache::ValueTypeData valueType
 

Detailed Description

Definition at line 68 of file qdeclarativeproperty_p.h.

Enumerations

◆ WriteFlag

Constructors and Destructors

◆ QDeclarativePropertyPrivate()

QDeclarativePropertyPrivate::QDeclarativePropertyPrivate ( )
inline

Definition at line 74 of file qdeclarativeproperty_p.h.

75  : context(0), engine(0), object(0), isNameCached(false) {}
QDeclarativeContextData * context
QDeclarativeGuard< QObject > object

Functions

◆ binding() [1/2]

QDeclarativeAbstractBinding * QDeclarativePropertyPrivate::binding ( QObject object,
int  coreIndex,
int  valueTypeIndex 
)
static

Definition at line 684 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeState::addEntriesToRevertList(), QDeclarativeState::apply(), QDeclarativePropertyChanges::changeExpression(), QDeclarativePropertyChanges::changeValue(), QDeclarativeEngineDebugService::propertyData(), QDeclarativeSimpleAction::QDeclarativeSimpleAction(), QDeclarativeState::removeAllEntriesFromRevertList(), QDeclarativeState::removeEntryFromRevertList(), QDeclarativeEngineDebugService::resetBinding(), and QDeclarativeAnchorChanges::saveOriginals().

685 {
687  if (!data)
688  return 0;
689 
690  QDeclarativePropertyCache::Data *propertyData =
691  data->propertyCache?data->propertyCache->property(coreIndex):0;
692  if (propertyData && propertyData->flags & QDeclarativePropertyCache::Data::IsAlias) {
693  const QDeclarativeVMEMetaObject *vme =
694  static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
695 
696  QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
697  if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex) || aCoreIndex == -1)
698  return 0;
699 
700  // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
701  Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
702  return binding(aObject, aCoreIndex, (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex);
703  }
704 
705  if (!data->hasBindingBit(coreIndex))
706  return 0;
707 
709  while (binding && binding->propertyIndex() != coreIndex)
710  binding = binding->m_nextBinding;
711 
712  if (binding && valueTypeIndex != -1) {
714  int index = coreIndex | (valueTypeIndex << 24);
715  binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
716  }
717  }
718 
719  return binding;
720 }
QDeclarativePropertyCache * propertyCache
static QDeclarativeData * get(const QObject *object, bool create=false)
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
QDeclarativeAbstractBinding * bindings
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool hasBindingBit(int) const
static const QMetaObject * metaObjectForProperty(const QMetaObject *, int)
Return metaObject&#39;s [super] meta object that provides data for property.
Data * property(const QScriptDeclarativeClass::Identifier &id) const
static const char * data(const QByteArray &arr)
QDeclarativeAbstractBinding * m_nextBinding
if(void) toggleToolbarShown
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
quint16 index
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ binding() [2/2]

QDeclarativeAbstractBinding * QDeclarativePropertyPrivate::binding ( const QDeclarativeProperty that)
static

Returns the binding associated with this property, or 0 if no binding exists.

Definition at line 647 of file qdeclarativeproperty.cpp.

648 {
649  if (!that.d || !that.isProperty() || !that.d->object)
650  return 0;
651 
652  return binding(that.d->object, that.d->core.coreIndex, that.d->valueType.valueTypeCoreIdx);
653 }
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
bool isProperty() const
Returns true if this QDeclarativeProperty represents a regular Qt property.
QDeclarativePropertyCache::ValueTypeData valueType

◆ bindingIndex()

int QDeclarativePropertyPrivate::bindingIndex ( const QDeclarativeProperty that)
static

Returns the "property index" for use in bindings.

The top 8 bits are the value type offset, and 0 otherwise. The bottom 24-bits are the regular property index.

Definition at line 1440 of file qdeclarativeproperty.cpp.

1441 {
1442  if (!that.d)
1443  return -1;
1444  int rv = that.d->core.coreIndex;
1445  if (rv != -1 && that.d->valueType.valueTypeCoreIdx != -1)
1446  rv = rv | (that.d->valueType.valueTypeCoreIdx << 24);
1447  return rv;
1448 }
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
QDeclarativePropertyCache::ValueTypeData valueType

◆ canConvert()

bool QDeclarativePropertyPrivate::canConvert ( const QMetaObject from,
const QMetaObject to 
)
static

Returns true if from inherits to.

Definition at line 1533 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeListReference::append(), and QDeclarativeBindingCompilerPrivate::compile().

1534 {
1535  if (from && to == &QObject::staticMetaObject)
1536  return true;
1537 
1538  while (from) {
1539  if (equal(from, to))
1540  return true;
1541  from = from->superClass();
1542  }
1543 
1544  return false;
1545 }
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
static bool equal(const QMetaObject *, const QMetaObject *)
Returns true if lhs and rhs refer to the same metaobject data.

◆ connect()

bool QDeclarativePropertyPrivate::connect ( QObject sender,
int  signal_index,
const QObject receiver,
int  method_index,
int  type = 0,
int *  types = 0 
)
static

Connect sender signal_index to receiver method_index with the specified type and types.

This behaves identically to QMetaObject::connect() except that it connects any lazy "proxy" signal connections set up by QML.

It is possible that this logic should be moved to QMetaObject::connect().

Definition at line 1637 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeNotifierEndpoint::connect(), QDeclarativeVMEMetaObject::connectAlias(), QDeclarativeProperty::connectNotifySignal(), QDeclarativeBoundSignal::init(), QDeclarativeProxyMetaObject::metaCall(), and QDeclarativeWatchProxy::QDeclarativeWatchProxy().

1640 {
1641  flush_vme_signal(sender, signal_index);
1642  flush_vme_signal(receiver, method_index);
1643 
1644  const bool result =
1645  QMetaObject::connect(sender, signal_index, receiver, method_index, type, types);
1646 
1647  // connectNotify() needs to be called after the actual connect, as otherwise QObject::receivers()
1648  // would return the wrong result inside connectNotify().
1649  const QMetaMethod signal = sender->metaObject()->method(signal_index);
1650  QObjectPrivate * const senderPriv = QObjectPrivate::get(sender);
1651  QVarLengthArray<char> signalSignature;
1652  QObjectPrivate::signalSignature(signal, &signalSignature);
1653  senderPriv->connectNotify(signalSignature.constData());
1654 
1655  return result;
1656 }
const T * constData() const
QDeclarativeProperty::Type type() const
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Definition: qobject.cpp:3194
static void signalSignature(const QMetaMethod &signal, QVarLengthArray< char > *result)
Definition: qobject_p.h:255
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
void connectNotify(const char *signal)
Definition: qobject_p.h:245
static const struct @32 types[]
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
static void flush_vme_signal(const QObject *object, int index)
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ equal()

bool QDeclarativePropertyPrivate::equal ( const QMetaObject lhs,
const QMetaObject rhs 
)
static

Returns true if lhs and rhs refer to the same metaobject data.

Definition at line 1525 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeCompiler::buildPropertyObjectAssignment(), and QDeclarativeCompiler::canCoerce().

1526 {
1527  return lhs == rhs || (1 && lhs && rhs && lhs->d.stringdata == rhs->d.stringdata);
1528 }
const char * stringdata
Definition: qobjectdefs.h:470
struct QMetaObject::@38 d

◆ findAliasTarget()

void QDeclarativePropertyPrivate::findAliasTarget ( QObject object,
int  bindingIndex,
QObject **  targetObject,
int *  targetBindingIndex 
)
static

Definition at line 722 of file qdeclarativeproperty.cpp.

724 {
725  int coreIndex = bindingIndex & 0xFFFFFF;
726  int valueTypeIndex = bindingIndex >> 24;
727  if (valueTypeIndex == 0) valueTypeIndex = -1;
728 
729  QDeclarativeData *data = QDeclarativeData::get(object, false);
730  if (data) {
731  QDeclarativePropertyCache::Data *propertyData =
732  data->propertyCache?data->propertyCache->property(coreIndex):0;
733  if (propertyData && propertyData->flags & QDeclarativePropertyCache::Data::IsAlias) {
734  const QDeclarativeVMEMetaObject *vme =
735  static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
736  QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
737  if (vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
738  // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
739  Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
740 
741  int aBindingIndex = aCoreIndex;
742  if (aValueTypeIndex != -1)
743  aBindingIndex |= aValueTypeIndex << 24;
744  else if (valueTypeIndex != -1)
745  aBindingIndex |= valueTypeIndex << 24;
746 
747  findAliasTarget(aObject, aBindingIndex, targetObject, targetBindingIndex);
748  return;
749  }
750  }
751  }
752 
753  *targetObject = object;
754  *targetBindingIndex = bindingIndex;
755 }
QDeclarativePropertyCache * propertyCache
static QDeclarativeData * get(const QObject *object, bool create=false)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static const QMetaObject * metaObjectForProperty(const QMetaObject *, int)
Return metaObject&#39;s [super] meta object that provides data for property.
Data * property(const QScriptDeclarativeClass::Identifier &id) const
static const char * data(const QByteArray &arr)
static int bindingIndex(const QDeclarativeProperty &that)
Returns the "property index" for use in bindings.
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
QDeclarativeGuard< QObject > object
static void findAliasTarget(QObject *, int, QObject **, int *)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ findSignalByName()

QMetaMethod QDeclarativePropertyPrivate::findSignalByName ( const QMetaObject mo,
const QByteArray name 
)
static

Return the signal corresponding to name.

Definition at line 1550 of file qdeclarativeproperty.cpp.

Referenced by hasValidSignal(), and QDeclarativeCompiler::indexOfSignal().

1551 {
1552  Q_ASSERT(mo);
1553  int methods = mo->methodCount();
1554  for (int ii = methods - 1; ii >= 2; --ii) { // >= 2 to block the destroyed signal
1555  QMetaMethod method = mo->method(ii);
1556  QByteArray methodName = method.signature();
1557  int idx = methodName.indexOf('(');
1558  methodName = methodName.left(idx);
1559 
1560  if (methodName == name)
1561  return method;
1562  }
1563 
1564  // If no signal is found, but the signal is of the form "onBlahChanged",
1565  // return the notify signal for the property "Blah"
1566  if (name.endsWith("Changed")) {
1567  QByteArray propName = name.mid(0, name.length() - 7);
1568  int propIdx = mo->indexOfProperty(propName.constData());
1569  if (propIdx >= 0) {
1570  QMetaProperty prop = mo->property(propIdx);
1571  if (prop.hasNotifySignal())
1572  return prop.notifySignal();
1573  }
1574  }
1575 
1576  return QMetaMethod();
1577 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
QMetaMethod notifySignal() const
Returns the QMetaMethod instance of the property change notifying signal if one was specified...
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
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...
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false...
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ initDefault()

void QDeclarativePropertyPrivate::initDefault ( QObject obj)

Initialize from the default property of obj.

Definition at line 165 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeProperty::QDeclarativeProperty().

166 {
167  if (!obj)
168  return;
169 
171  core.load(p);
172  if (core.isValid())
173  object = obj;
174 }
QDeclarativePropertyCache::Data core
void load(const QMetaProperty &, QDeclarativeEngine *engine=0)
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
static QMetaProperty defaultProperty(const QMetaObject *)

◆ initProperty()

void QDeclarativePropertyPrivate::initProperty ( QObject obj,
const QString name 
)

Definition at line 218 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeProperty::QDeclarativeProperty().

219 {
220  if (!obj) return;
221 
222  QDeclarativeTypeNameCache *typeNameCache = context?context->imports:0;
223 
224  QStringList path = name.split(QLatin1Char('.'));
225  if (path.isEmpty()) return;
226 
227  QObject *currentObject = obj;
228 
229  // Everything up to the last property must be an "object type" property
230  for (int ii = 0; ii < path.count() - 1; ++ii) {
231  const QString &pathName = path.at(ii);
232 
233  if (QDeclarativeTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
234  if (data->type) {
235  QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
236  if (!func) return; // Not an attachable type
237 
238  currentObject = qmlAttachedPropertiesObjectById(data->type->attachedPropertiesId(), currentObject);
239  if (!currentObject) return; // Something is broken with the attachable type
240  } else {
241  Q_ASSERT(data->typeNamespace);
242  if ((ii + 1) == path.count()) return; // No type following the namespace
243 
244  ++ii; data = data->typeNamespace->data(path.at(ii));
245  if (!data || !data->type) return; // Invalid type in namespace
246 
247  QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
248  if (!func) return; // Not an attachable type
249 
250  currentObject = qmlAttachedPropertiesObjectById(data->type->attachedPropertiesId(), currentObject);
251  if (!currentObject) return; // Something is broken with the attachable type
252  }
253  } else {
254 
257  QDeclarativePropertyCache::property(engine, obj, pathName, local);
258 
259  if (!property) return; // Not a property
261  return; // Not an object property
262 
263  if (ii == (path.count() - 2) && QDeclarativeValueTypeFactory::isValueType(property->propType)) {
264  // We're now at a value type property. We can use a global valuetypes array as we
265  // never actually use the objects, just look up their properties.
266  QObject *typeObject = (*qmlValueTypes())[property->propType];
267  if (!typeObject) return; // Not a value type
268 
269  int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
270  if (idx == -1) return; // Value type property does not exist
271 
272  QMetaProperty vtProp = typeObject->metaObject()->property(idx);
273 
274  object = currentObject;
275  core = *property;
279 
280  return;
281  } else {
283  return; // Not an object property
284 
285  void *args[] = { &currentObject, 0 };
286  QMetaObject::metacall(currentObject, QMetaObject::ReadProperty, property->coreIndex, args);
287  if (!currentObject) return; // No value
288 
289  }
290  }
291 
292  }
293 
294  const QString &terminal = path.last();
295 
296  if (terminal.count() >= 3 &&
297  terminal.at(0) == QLatin1Char('o') &&
298  terminal.at(1) == QLatin1Char('n') &&
299  terminal.at(2).isUpper()) {
300 
301  QString signalName = terminal.mid(2);
302  signalName[0] = signalName.at(0).toLower();
303 
304  QMetaMethod method = findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData());
305  if (method.signature()) {
306  object = currentObject;
307  core.load(method);
308  return;
309  }
310  }
311 
312  // Property
315  QDeclarativePropertyCache::property(engine, currentObject, terminal, local);
317  object = currentObject;
318  core = *property;
319  nameCache = terminal;
320  isNameCached = true;
321  }
322 }
QObject *(* QDeclarativeAttachedPropertiesFunc)(QObject *)
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
static int metacall(QObject *, Call, int, void **)
static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &)
Return the signal corresponding to name.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QDeclarativePropertyCache::Data core
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QDeclarativeContextData * context
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
QDeclarativeTypeNameCache * imports
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
Q_DECLARATIVE_EXPORT QObject * qmlAttachedPropertiesObjectById(int, const QObject *, bool create=true)
int userType() const
Returns this property&#39;s user type.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
Data * property(const QScriptDeclarativeClass::Identifier &id) const
static const char * data(const QByteArray &arr)
void load(const QMetaProperty &, QDeclarativeEngine *engine=0)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int count() const
Definition: qstring.h:103
bool isUpper() const
Returns true if the character is an uppercase letter, i.
Definition: qchar.h:273
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
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...
Definition: qstring.cpp:3706
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
const char * property
Definition: qwizard.cpp:138
if(void) toggleToolbarShown
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
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...
Definition: qstring.cpp:6526
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
Data * data(const QString &) const
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1239
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine=0)
QDeclarativePropertyCache::ValueTypeData valueType

◆ isValueType()

bool QDeclarativePropertyPrivate::isValueType ( ) const

Definition at line 445 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeProperty::name(), and QDeclarativeProperty::propertyTypeName().

446 {
447  return valueType.valueTypeCoreIdx != -1;
448 }
QDeclarativePropertyCache::ValueTypeData valueType

◆ metaObjectForProperty()

const QMetaObject * QDeclarativePropertyPrivate::metaObjectForProperty ( const QMetaObject metaObject,
int  property 
)
static

Return metaObject's [super] meta object that provides data for property.

Definition at line 1661 of file qdeclarativeproperty.cpp.

1662 {
1663  int propertyOffset = metaObject->propertyOffset();
1664 
1665  while (propertyOffset > property) {
1666  metaObject = metaObject->d.superdata;
1667  propertyOffset -= QMetaObject_properties(metaObject);
1668  }
1669 
1670  return metaObject;
1671 }
const QMetaObject * superdata
Definition: qobjectdefs.h:469
const char * property
Definition: qwizard.cpp:138
struct QMetaObject::@38 d
int propertyOffset() const
Returns the property offset for this class; i.e.
static int QMetaObject_properties(const QMetaObject *metaObject)

◆ propertyType()

int QDeclarativePropertyPrivate::propertyType ( ) const

Definition at line 450 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeProperty::propertyType().

451 {
452  uint type = this->type();
453  if (isValueType()) {
455  } else if (type & QDeclarativeProperty::Property) {
456  if (core.propType == (int)QVariant::LastType)
457  return qMetaTypeId<QVariant>();
458  else
459  return core.propType;
460  } else {
461  return QVariant::Invalid;
462  }
463 }
QDeclarativeProperty::Type type() const
QDeclarativePropertyCache::Data core
unsigned int uint
Definition: qglobal.h:996
QDeclarativePropertyCache::ValueTypeData valueType

◆ propertyTypeCategory()

QDeclarativeProperty::PropertyTypeCategory QDeclarativePropertyPrivate::propertyTypeCategory ( ) const

Definition at line 370 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeProperty::propertyTypeCategory().

371 {
372  uint type = this->type();
373 
374  if (isValueType()) {
376  } else if (type & QDeclarativeProperty::Property) {
377  int type = propertyType();
378  if (type == QVariant::Invalid)
386  else
388  } else {
390  }
391 }
QDeclarativeProperty::Type type() const
QDeclarativePropertyCache::Data core
unsigned int uint
Definition: qglobal.h:996

◆ rawMetaObjectForType()

const QMetaObject * QDeclarativePropertyPrivate::rawMetaObjectForType ( QDeclarativeEnginePrivate engine,
int  userType 
)
static

Definition at line 1257 of file qdeclarativeproperty.cpp.

1258 {
1259  if (engine) {
1260  return engine->rawMetaObjectForType(userType);
1261  } else {
1263  return type?type->baseMetaObject():0;
1264  }
1265 }
QDeclarativeProperty::Type type() const
static QDeclarativeType * qmlType(const QByteArray &, int, int)
Returns the type (if any) of URI-qualified named name in version specified by version_major and versi...
const QMetaObject * baseMetaObject() const
const QMetaObject * rawMetaObjectForType(int) const

◆ readValueProperty()

QVariant QDeclarativePropertyPrivate::readValueProperty ( )

Definition at line 986 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeProperty::read().

987 {
988  if (isValueType()) {
989 
992  if (ep) valueType = ep->valueTypes[core.propType];
994  Q_ASSERT(valueType);
995 
996  valueType->read(object, core.coreIndex);
997 
998  QVariant rv =
999  valueType->metaObject()->property(this->valueType.valueTypeCoreIdx).read(valueType);
1000 
1001  if (!ep) delete valueType;
1002  return rv;
1003 
1005 
1007  void *args[] = { &prop, 0 };
1010 
1012 
1013  QObject *rv = 0;
1014  void *args[] = { &rv, 0 };
1016  return QVariant::fromValue(rv);
1017 
1018  } else {
1019 
1020  return object->metaObject()->property(core.coreIndex).read(object.data());
1021 
1022  }
1023 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static int metacall(QObject *, Call, int, void **)
static QDeclarativeValueType * valueType(int)
QDeclarativePropertyCache::Data core
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QDeclarativeContextData * context
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static QDeclarativeListReference init(const QDeclarativeListProperty< QObject > &, int, QDeclarativeEngine *)
static const char * data(const QByteArray &arr)
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
QDeclarativeValueTypeFactory valueTypes
QVariant read(const QObject *obj) const
Reads the property&#39;s value from the given object.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
virtual void read(QObject *, int)=0
QDeclarativePropertyCache::ValueTypeData valueType

◆ restore() [1/2]

QDeclarativeProperty QDeclarativePropertyPrivate::restore ( const QByteArray data,
QObject object,
QDeclarativeContextData ctxt 
)
static

Definition at line 1489 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeValueTypeScriptClass::setProperty(), and QDeclarativeObjectScriptClass::setProperty().

1490 {
1491  QDeclarativeProperty prop;
1492 
1493  if (data.isEmpty())
1494  return prop;
1495 
1496  const SerializedData *sd = (const SerializedData *)data.constData();
1497  if (sd->isValueType) {
1498  const ValueTypeSerializedData *vt = (const ValueTypeSerializedData *)sd;
1499  return restore(vt->core, vt->valueType, object, ctxt);
1500  } else {
1502  return restore(sd->core, data, object, ctxt);
1503  }
1504 }
QDeclarativePropertyCache::Data core
static const char * data(const QByteArray &arr)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *)
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
QDeclarativePropertyCache::ValueTypeData valueType

◆ restore() [2/2]

QDeclarativeProperty QDeclarativePropertyPrivate::restore ( const QDeclarativePropertyCache::Data data,
const QDeclarativePropertyCache::ValueTypeData valueType,
QObject object,
QDeclarativeContextData ctxt 
)
static

Definition at line 1507 of file qdeclarativeproperty.cpp.

1508 {
1509  QDeclarativeProperty prop;
1510 
1511  prop.d = new QDeclarativePropertyPrivate;
1512  prop.d->object = object;
1513  prop.d->context = ctxt;
1514  prop.d->engine = ctxt->engine;
1515 
1516  prop.d->core = data;
1517  prop.d->valueType = valueType;
1518 
1519  return prop;
1520 }
QDeclarativeEngine * engine
QDeclarativePropertyCache::Data core
QDeclarativeContextData * context
static const char * data(const QByteArray &arr)
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
QDeclarativePropertyCache::ValueTypeData valueType

◆ saveProperty()

QByteArray QDeclarativePropertyPrivate::saveProperty ( const QMetaObject metaObject,
int  index 
)
static

Definition at line 1477 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeCompiler::genPropertyData().

1478 {
1479  SerializedData sd;
1480  memset(&sd, 0, sizeof(sd));
1481  sd.isValueType = false;
1482  sd.core.load(metaObject->property(index));
1483 
1484  QByteArray rv((const char *)&sd, sizeof(sd));
1485  return rv;
1486 }
QDeclarativePropertyCache::Data core
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void load(const QMetaProperty &, QDeclarativeEngine *engine=0)
quint16 index
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ saveValueType()

QByteArray QDeclarativePropertyPrivate::saveValueType ( const QMetaObject metaObject,
int  index,
const QMetaObject subObject,
int  subIndex 
)
static

Definition at line 1459 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeCompiler::genValueTypeData().

1461 {
1462  QMetaProperty subProp = subObject->property(subIndex);
1463 
1465  memset(&sd, 0, sizeof(sd));
1466  sd.isValueType = true;
1467  sd.core.load(metaObject->property(index));
1469  sd.valueType.valueTypeCoreIdx = subIndex;
1470  sd.valueType.valueTypePropType = subProp.userType();
1471 
1472  QByteArray rv((const char *)&sd, sizeof(sd));
1473 
1474  return rv;
1475 }
QDeclarativePropertyCache::Data core
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int userType() const
Returns this property&#39;s user type.
void load(const QMetaProperty &, QDeclarativeEngine *engine=0)
quint16 index
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
QDeclarativePropertyCache::ValueTypeData valueType
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
static Flags flagsForProperty(const QMetaProperty &, QDeclarativeEngine *engine=0)

◆ setBinding() [1/2]

QDeclarativeAbstractBinding * QDeclarativePropertyPrivate::setBinding ( QObject object,
int  coreIndex,
int  valueTypeIndex,
QDeclarativeAbstractBinding newBinding,
WriteFlags  flags = DontRemoveBinding 
)
static

Definition at line 758 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeState::addEntriesToRevertList(), QDeclarativeState::apply(), QDeclarativeTransitionManagerPrivate::applyBindings(), QDeclarativeTransitionManager::cancel(), QDeclarativePropertyChanges::changeExpression(), QDeclarativePropertyChanges::changeValue(), QDeclarativeAnchorChanges::clearBindings(), QDeclarativeAction::deleteFromBinding(), QDeclarativeAnchorChanges::execute(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeState::removeAllEntriesFromRevertList(), removeBindingOnProperty(), QDeclarativeState::removeEntryFromRevertList(), QDeclarativeEngineDebugService::resetBinding(), QDeclarativeAnchorChanges::reverse(), QDeclarativeEngineDebugService::setBinding(), setBinding(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), and QDeclarativeTransitionManager::transition().

760 {
761  QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding);
763 
764  if (data) {
765  QDeclarativePropertyCache::Data *propertyData =
766  data->propertyCache?data->propertyCache->property(coreIndex):0;
767  if (propertyData && propertyData->flags & QDeclarativePropertyCache::Data::IsAlias) {
768  const QDeclarativeVMEMetaObject *vme =
769  static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
770 
771  QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
772  if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
773  if (newBinding) newBinding->destroy();
774  return 0;
775  }
776 
777  // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
778  Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
779  return setBinding(aObject, aCoreIndex, (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex,
780  newBinding, flags);
781  }
782  }
783 
784  if (data && data->hasBindingBit(coreIndex)) {
785  binding = data->bindings;
786 
787  while (binding && binding->propertyIndex() != coreIndex)
788  binding = binding->m_nextBinding;
789  }
790 
791  int index = coreIndex;
792  if (valueTypeIndex != -1)
793  index |= (valueTypeIndex << 24);
794 
795  if (binding && valueTypeIndex != -1 && binding->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy)
796  binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
797 
798  if (binding) {
799  binding->removeFromObject();
800  binding->setEnabled(false, 0);
801  }
802 
803  if (newBinding) {
804  newBinding->addToObject(object, index);
805  newBinding->setEnabled(true, flags);
806  }
807 
808  return binding;
809 }
QDeclarativePropertyCache * propertyCache
static QDeclarativeData * get(const QObject *object, bool create=false)
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)
QDeclarativeAbstractBinding * bindings
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool hasBindingBit(int) const
static const QMetaObject * metaObjectForProperty(const QMetaObject *, int)
Return metaObject&#39;s [super] meta object that provides data for property.
Data * property(const QScriptDeclarativeClass::Identifier &id) const
static const char * data(const QByteArray &arr)
QDeclarativeAbstractBinding * m_nextBinding
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
void removeFromObject()
Remove the binding from the object.
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
quint16 index
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ setBinding() [2/2]

QDeclarativeAbstractBinding * QDeclarativePropertyPrivate::setBinding ( const QDeclarativeProperty that,
QDeclarativeAbstractBinding newBinding,
WriteFlags  flags = DontRemoveBinding 
)
static

Set the binding associated with this property to newBinding.

Returns the existing binding (if any), otherwise 0.

newBinding will be enabled, and the returned binding (if any) will be disabled.

Ownership of newBinding transfers to QML. Ownership of the return value is assumed by the caller.

flags is passed through to the binding and is used for the initial update (when the binding sets the initial value, it will use these flags for the write).

Definition at line 669 of file qdeclarativeproperty.cpp.

672 {
673  if (!that.d || !that.isProperty() || !that.d->object) {
674  if (newBinding)
675  newBinding->destroy();
676  return 0;
677  }
678 
679  return that.d->setBinding(that.d->object, that.d->core.coreIndex,
680  that.d->valueType.valueTypeCoreIdx, newBinding, flags);
681 }
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
QDeclarativePropertyCache::Data core
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
QDeclarativePropertyPrivate * d
QDeclarativeGuard< QObject > object
bool isProperty() const
Returns true if this QDeclarativeProperty represents a regular Qt property.
QDeclarativePropertyCache::ValueTypeData valueType

◆ setBindingNoEnable()

QDeclarativeAbstractBinding * QDeclarativePropertyPrivate::setBindingNoEnable ( QObject object,
int  coreIndex,
int  valueTypeIndex,
QDeclarativeAbstractBinding newBinding 
)
static

Definition at line 812 of file qdeclarativeproperty.cpp.

814 {
815  QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding);
817 
818  if (data) {
819  QDeclarativePropertyCache::Data *propertyData =
820  data->propertyCache?data->propertyCache->property(coreIndex):0;
821  if (propertyData && propertyData->flags & QDeclarativePropertyCache::Data::IsAlias) {
822  const QDeclarativeVMEMetaObject *vme =
823  static_cast<const QDeclarativeVMEMetaObject *>(metaObjectForProperty(object->metaObject(), coreIndex));
824 
825  QObject *aObject = 0; int aCoreIndex = -1; int aValueTypeIndex = -1;
826  if (!vme->aliasTarget(coreIndex, &aObject, &aCoreIndex, &aValueTypeIndex)) {
827  if (newBinding) newBinding->destroy();
828  return 0;
829  }
830 
831  // This will either be a value type sub-reference or an alias to a value-type sub-reference not both
832  Q_ASSERT(valueTypeIndex == -1 || aValueTypeIndex == -1);
833  return setBindingNoEnable(aObject, aCoreIndex, (valueTypeIndex == -1)?aValueTypeIndex:valueTypeIndex,
834  newBinding);
835  }
836  }
837 
838  if (data && data->hasBindingBit(coreIndex)) {
839  binding = data->bindings;
840 
841  while (binding && binding->propertyIndex() != coreIndex)
842  binding = binding->m_nextBinding;
843  }
844 
845  int index = coreIndex;
846  if (valueTypeIndex != -1)
847  index |= (valueTypeIndex << 24);
848 
849  if (binding && valueTypeIndex != -1 && binding->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy)
850  binding = static_cast<QDeclarativeValueTypeProxyBinding *>(binding)->binding(index);
851 
852  if (binding)
853  binding->removeFromObject();
854 
855  if (newBinding)
856  newBinding->addToObject(object, index);
857 
858  return binding;
859 }
QDeclarativePropertyCache * propertyCache
static QDeclarativeData * get(const QObject *object, bool create=false)
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)
QDeclarativeAbstractBinding * bindings
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool hasBindingBit(int) const
static const QMetaObject * metaObjectForProperty(const QMetaObject *, int)
Return metaObject&#39;s [super] meta object that provides data for property.
Data * property(const QScriptDeclarativeClass::Identifier &id) const
static const char * data(const QByteArray &arr)
QDeclarativeAbstractBinding * m_nextBinding
void removeFromObject()
Remove the binding from the object.
static QDeclarativeAbstractBinding * setBindingNoEnable(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *)
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
quint16 index
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ setSignalExpression()

QDeclarativeExpression * QDeclarativePropertyPrivate::setSignalExpression ( const QDeclarativeProperty that,
QDeclarativeExpression expr 
)
static

Set the signal expression associated with this signal property to expr.

Returns the existing signal expression (if any), otherwise 0.

Ownership of expr transfers to QML. Ownership of the return value is assumed by the caller.

Definition at line 892 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeReplaceSignalHandler::execute(), QDeclarativeEngineDebugService::resetBinding(), QDeclarativeReplaceSignalHandler::reverse(), QDeclarativeReplaceSignalHandler::rewind(), and QDeclarativeEngineDebugService::setBinding().

894 {
895  if (!(that.type() & QDeclarativeProperty::SignalProperty)) {
896  delete expr;
897  return 0;
898  }
899 
900  const QObjectList &children = that.d->object->children();
901 
902  for (int ii = 0; ii < children.count(); ++ii) {
903  QObject *child = children.at(ii);
904 
906  if (signal && signal->index() == that.index())
907  return signal->setExpression(expr);
908  }
909 
910  if (expr) {
911  QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(that.d->object, that.method(), that.d->object);
912  return signal->setExpression(expr);
913  } else {
914  return 0;
915  }
916 }
static QDeclarativeBoundSignal * cast(QObject *)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Type type() const
Returns the type of the property.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QDeclarativeExpression * setExpression(QDeclarativeExpression *)
Sets the signal expression to e.
int index() const
Return the Qt metaobject index of the property.
QMetaMethod method() const
Return the QMetaMethod for this property if it is a SignalProperty, otherwise returns an invalid QMet...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDeclarativePropertyPrivate * d
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
QDeclarativeGuard< QObject > object

◆ signalExpression()

QDeclarativeExpression * QDeclarativePropertyPrivate::signalExpression ( const QDeclarativeProperty that)
static

Returns the expression associated with this signal property, or 0 if no signal expression exists.

Definition at line 866 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeReplaceSignalHandler::saveCurrentValues().

867 {
869  return 0;
870 
871  const QObjectList &children = that.d->object->children();
872 
873  for (int ii = 0; ii < children.count(); ++ii) {
874  QObject *child = children.at(ii);
875 
877  if (signal && signal->index() == that.index())
878  return signal->expression();
879  }
880 
881  return 0;
882 }
static QDeclarativeBoundSignal * cast(QObject *)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Type type() const
Returns the type of the property.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int index() const
Return the Qt metaobject index of the property.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDeclarativeExpression * expression() const
Returns the signal expression.
QDeclarativePropertyPrivate * d
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
QDeclarativeGuard< QObject > object

◆ type()

QDeclarativeProperty::Type QDeclarativePropertyPrivate::type ( ) const

◆ valueTypeCoreIndex()

int QDeclarativePropertyPrivate::valueTypeCoreIndex ( const QDeclarativeProperty that)
static

Definition at line 1431 of file qdeclarativeproperty.cpp.

1432 {
1433  return that.d ? that.d->valueType.valueTypeCoreIdx : -1;
1434 }
QDeclarativePropertyPrivate * d
QDeclarativePropertyCache::ValueTypeData valueType

◆ write() [1/2]

bool QDeclarativePropertyPrivate::write ( QObject object,
const QDeclarativePropertyCache::Data property,
const QVariant value,
QDeclarativeContextData context,
WriteFlags  flags = 0 
)
static

Definition at line 1104 of file qdeclarativeproperty.cpp.

Referenced by QDeclarativeSpringAnimationPrivate::animate(), QSmoothedAnimation::init(), QDeclarativeObjectScriptClass::setProperty(), QDeclarativeAnimationPropertyUpdater::setValue(), QDeclarativeTransitionManager::transition(), QDeclarativePropertyAction::transition(), QDeclarativeBinding::update(), QSmoothedAnimation::updateCurrentTime(), QDeclarativeBehavior::write(), and QDeclarativeProperty::write().

1107 {
1108  int coreIdx = property.coreIndex;
1109  int status = -1; //for dbus
1110 
1112  QMetaProperty prop = object->metaObject()->property(property.coreIndex);
1113  QVariant v = value;
1114  // Enum values come through the script engine as doubles
1115  if (value.userType() == QVariant::Double) {
1116  double integral;
1117  double fractional = modf(value.toDouble(), &integral);
1118  if (qFuzzyIsNull(fractional))
1120  }
1121  return writeEnumProperty(prop, coreIdx, object, v, flags);
1122  }
1123 
1124  int propertyType = property.propType;
1125  int variantType = value.userType();
1126 
1128 
1129  if (propertyType == QVariant::Url) {
1130 
1131  QUrl u;
1132  bool found = false;
1133  if (variantType == QVariant::Url) {
1134  u = value.toUrl();
1135  found = true;
1136  } else if (variantType == QVariant::ByteArray) {
1137  u = QUrl(QString::fromUtf8(value.toByteArray()));
1138  found = true;
1139  } else if (variantType == QVariant::String) {
1140  u = QUrl(value.toString());
1141  found = true;
1142  }
1143 
1144  if (!found)
1145  return false;
1146 
1147  if (context && u.isRelative() && !u.isEmpty())
1148  u = context->resolvedUrl(u);
1149  int status = -1;
1150  void *argv[] = { &u, 0, &status, &flags };
1151  QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv);
1152 
1153  } else if (variantType == propertyType) {
1154 
1155  void *a[] = { (void *)value.constData(), 0, &status, &flags };
1157 
1158  } else if (qMetaTypeId<QVariant>() == propertyType) {
1159 
1160  void *a[] = { (void *)&value, 0, &status, &flags };
1162 
1164 
1165  const QMetaObject *valMo = rawMetaObjectForType(enginePriv, value.userType());
1166 
1167  if (!valMo)
1168  return false;
1169 
1170  QObject *o = *(QObject **)value.constData();
1171  const QMetaObject *propMo = rawMetaObjectForType(enginePriv, propertyType);
1172 
1173  if (o) valMo = o->metaObject();
1174 
1175  if (canConvert(valMo, propMo)) {
1176  void *args[] = { &o, 0, &status, &flags };
1178  args);
1179  } else if (!o && canConvert(propMo, valMo)) {
1180  // In the case of a null QObject, we assign the null if there is
1181  // any change that the null variant type could be up or down cast to
1182  // the property type.
1183  void *args[] = { &o, 0, &status, &flags };
1185  args);
1186  } else {
1187  return false;
1188  }
1189 
1190  } else if (property.flags & QDeclarativePropertyCache::Data::IsQList) {
1191 
1192  const QMetaObject *listType = 0;
1193  if (enginePriv) {
1194  listType = enginePriv->rawMetaObjectForType(enginePriv->listType(property.propType));
1195  } else {
1197  if (!type) return false;
1198  listType = type->baseMetaObject();
1199  }
1200  if (!listType) return false;
1201 
1203  void *args[] = { &prop, 0 };
1204  QMetaObject::metacall(object, QMetaObject::ReadProperty, coreIdx, args);
1205 
1206  if (!prop.clear) return false;
1207 
1208  prop.clear(&prop);
1209 
1210  if (value.userType() == qMetaTypeId<QList<QObject *> >()) {
1211  const QList<QObject *> &list = qvariant_cast<QList<QObject *> >(value);
1212 
1213  for (int ii = 0; ii < list.count(); ++ii) {
1214  QObject *o = list.at(ii);
1215  if (o && !canConvert(o->metaObject(), listType))
1216  o = 0;
1217  prop.append(&prop, (void *)o);
1218  }
1219  } else {
1220  QObject *o = enginePriv?enginePriv->toQObject(value):QDeclarativeMetaType::toQObject(value);
1221  if (o && !canConvert(o->metaObject(), listType))
1222  o = 0;
1223  prop.append(&prop, (void *)o);
1224  }
1225 
1226  } else {
1227  Q_ASSERT(variantType != propertyType);
1228 
1229  bool ok = false;
1230  QVariant v;
1231  if (variantType == QVariant::String)
1233  if (!ok) {
1234  v = value;
1235  if (v.convert((QVariant::Type)propertyType)) {
1236  ok = true;
1237  } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) {
1239  if (con) {
1240  v = con(value.toString());
1241  if (v.userType() == propertyType)
1242  ok = true;
1243  }
1244  }
1245  }
1246  if (ok) {
1247  void *a[] = { (void *)v.constData(), 0, &status, &flags};
1249  } else {
1250  return false;
1251  }
1252  }
1253 
1254  return true;
1255 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QUrl resolvedUrl(const QUrl &)
static QObject * toQObject(const QVariant &, bool *ok=0)
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QDeclarativeProperty::Type type() const
static int metacall(QObject *, Call, int, void **)
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition: qurl.cpp:4317
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
static QDeclarativeType * qmlType(const QByteArray &, int, int)
Returns the type (if any) of URI-qualified named name in version specified by version_major and versi...
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
const QMetaObject * baseMetaObject() const
quint16 u
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
QVariant Q_DECLARATIVE_PRIVATE_EXPORT variantFromString(const QString &)
unsigned int uint
Definition: qglobal.h:996
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
QUrl toUrl() const
Returns the variant as a QUrl if the variant has type() Url ; otherwise returns an invalid QUrl...
Definition: qvariant.cpp:2528
bool convert(Type t)
Casts the variant to the requested type, t.
Definition: qvariant.cpp:2959
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
const void * constData() const
Definition: qvariant.cpp:3065
static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
static StringConverter customStringConverter(int)
Return the custom string converter for type, previously installed through registerCustomStringConvert...
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
QObject * toQObject(const QVariant &, bool *ok=0) const
static bool canConvert(const QMetaObject *from, const QMetaObject *to)
Returns true if from inherits to.
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
const QMetaObject * rawMetaObjectForType(int) const
static const QMetaObject * rawMetaObjectForType(QDeclarativeEnginePrivate *, int)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QVariant(* StringConverter)(const QString &)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ write() [2/2]

bool QDeclarativePropertyPrivate::write ( const QDeclarativeProperty that,
const QVariant value,
WriteFlags  flags 
)
static

Definition at line 1345 of file qdeclarativeproperty.cpp.

1347 {
1348  if (!that.d)
1349  return false;
1350  if (that.d->object && that.type() & QDeclarativeProperty::Property &&
1351  that.d->core.isValid() && that.isWritable())
1352  return that.d->writeValueProperty(value, flags);
1353  else
1354  return false;
1355 }
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
QDeclarativePropertyPrivate * d
bool isWritable() const
Returns true if the property is writable, otherwise false.
QDeclarativeGuard< QObject > object
bool writeValueProperty(const QVariant &, WriteFlags)

◆ writeEnumProperty()

bool QDeclarativePropertyPrivate::writeEnumProperty ( const QMetaProperty prop,
int  idx,
QObject object,
const QVariant value,
int  flags 
)
static

Definition at line 1026 of file qdeclarativeproperty.cpp.

1027 {
1028  if (!object || !prop.isWritable())
1029  return false;
1030 
1031  QVariant v = value;
1032  if (prop.isEnumType()) {
1033  QMetaEnum menum = prop.enumerator();
1034  if (v.userType() == QVariant::String
1035 #ifdef QT3_SUPPORT
1036  || v.userType() == QVariant::CString
1037 #endif
1038  ) {
1039  if (prop.isFlagType())
1040  v = QVariant(menum.keysToValue(value.toByteArray()));
1041  else
1042  v = QVariant(menum.keyToValue(value.toByteArray()));
1043  } else if (v.userType() != QVariant::Int && v.userType() != QVariant::UInt) {
1044  int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope() + QByteArray("::") + menum.name()));
1045  if ((enumMetaTypeId == 0) || (v.userType() != enumMetaTypeId) || !v.constData())
1046  return false;
1047  v = QVariant(*reinterpret_cast<const int *>(v.constData()));
1048  }
1050  }
1051 
1052  // the status variable is changed by qt_metacall to indicate what it did
1053  // this feature is currently only used by QtDBus and should not be depended
1054  // upon. Don't change it without looking into QDBusAbstractInterface first
1055  // -1 (unchanged): normal qt_metacall, result stored in argv[0]
1056  // changed: result stored directly in value, return the value of status
1057  int status = -1;
1058  void *argv[] = { v.data(), &v, &status, &flags };
1060  return status;
1061 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
int keysToValue(const char *keys) const
Returns the value derived from combining together the values of the keys using the OR operator...
static int metacall(QObject *, Call, int, void **)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static LibLoadStatus status
Definition: qlocale_icu.cpp:69
const char * scope() const
Returns the scope this enumerator was declared in.
const char * name() const
Returns the name of the enumerator (without the scope).
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
void * data()
Definition: qvariant.cpp:3077
bool isEnumType() const
Returns true if the property&#39;s type is an enumeration value; otherwise returns false.
bool isFlagType() const
Returns true if the property&#39;s type is an enumeration value that is used as a flag; otherwise returns...
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
bool convert(Type t)
Casts the variant to the requested type, t.
Definition: qvariant.cpp:2959
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
const void * constData() const
Definition: qvariant.cpp:3065
int keyToValue(const char *key) const
Returns the integer value of the given enumeration key, or -1 if key is not defined.
QMetaEnum enumerator() const
Returns the enumerator if this property&#39;s type is an enumerator type; otherwise the returned value is...

◆ writeValueProperty()

bool QDeclarativePropertyPrivate::writeValueProperty ( const QVariant value,
WriteFlags  flags 
)

Definition at line 1063 of file qdeclarativeproperty.cpp.

Referenced by write().

1064 {
1065  // Remove any existing bindings on this property
1066  if (!(flags & DontRemoveBinding) &&
1067  (type() & QDeclarativeProperty::Property) && object) {
1069  valueType.valueTypeCoreIdx, 0, flags);
1070  if (binding) binding->destroy();
1071  }
1072 
1073  bool rv = false;
1074  if (isValueType()) {
1076 
1077  QDeclarativeValueType *writeBack = 0;
1078  if (ep) {
1079  writeBack = ep->valueTypes[core.propType];
1080  } else {
1082  }
1083 
1084  writeBack->read(object, core.coreIndex);
1085 
1087  data.flags = valueType.flags;
1090  rv = write(writeBack, data, value, context, flags);
1091 
1092  writeBack->write(object, core.coreIndex, flags);
1093  if (!ep) delete writeBack;
1094 
1095  } else {
1096 
1097  rv = write(object, core, value, context, flags);
1098 
1099  }
1100 
1101  return rv;
1102 }
QDeclarativeProperty::Type type() const
static QDeclarativeValueType * valueType(int)
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags flags)=0
QDeclarativePropertyCache::Data core
QDeclarativeContextData * context
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static const char * data(const QByteArray &arr)
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
QDeclarativeValueTypeFactory valueTypes
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)
virtual void read(QObject *, int)=0
QDeclarativePropertyCache::ValueTypeData valueType

Properties

◆ context

QDeclarativeContextData* QDeclarativePropertyPrivate::context

◆ core

QDeclarativePropertyCache::Data QDeclarativePropertyPrivate::core

◆ engine

QDeclarativeEngine* QDeclarativePropertyPrivate::engine

◆ isNameCached

bool QDeclarativePropertyPrivate::isNameCached

Definition at line 81 of file qdeclarativeproperty_p.h.

Referenced by QDeclarativeProperty::name().

◆ nameCache

QString QDeclarativePropertyPrivate::nameCache

Definition at line 83 of file qdeclarativeproperty_p.h.

Referenced by QDeclarativeProperty::name().

◆ object

QDeclarativeGuard<QObject> QDeclarativePropertyPrivate::object

◆ valueType

QDeclarativePropertyCache::ValueTypeData QDeclarativePropertyPrivate::valueType

The documentation for this class was generated from the following files: