Qt 4.8
qdeclarativeproperty.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qdeclarativeproperty.h"
43 #include "private/qdeclarativeproperty_p.h"
44 
45 #include "qdeclarative.h"
46 #include "private/qdeclarativebinding_p.h"
47 #include "qdeclarativecontext.h"
48 #include "private/qdeclarativecontext_p.h"
49 #include "private/qdeclarativeboundsignal_p.h"
50 #include "qdeclarativeengine.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"
57 
58 #include <QStringList>
59 #include <QtCore/qdebug.h>
60 
61 #include <math.h>
62 
64 
112 : d(0)
113 {
114 }
115 
118 {
119  if (d)
120  d->release();
121  d = 0;
122 }
123 
130 {
131  d->initDefault(obj);
132 }
133 
142 {
143  d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
144  d->engine = ctxt?ctxt->engine():0;
145  d->initDefault(obj);
146 }
147 
156 {
157  d->context = 0;
158  d->engine = engine;
159  d->initDefault(obj);
160 }
161 
166 {
167  if (!obj)
168  return;
169 
171  core.load(p);
172  if (core.isValid())
173  object = obj;
174 }
175 
181 {
182  d->initProperty(obj, name);
183  if (!isValid()) d->object = 0;
184 }
185 
195 {
196  d->context = ctxt?QDeclarativeContextData::get(ctxt):0;
197  d->engine = ctxt?ctxt->engine():0;
198  d->initProperty(obj, name);
199  if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
200 }
201 
209 {
210  d->context = 0;
211  d->engine = engine;
212  d->initProperty(obj, name);
213  if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; }
214 }
215 
217 
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;
276  valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(vtProp);
277  valueType.valueTypeCoreIdx = idx;
278  valueType.valueTypePropType = vtProp.userType();
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 }
323 
328 {
329  d = other.d;
330  if (d)
331  d->addref();
332 }
333 
365 {
366  return d ? d->propertyTypeCategory() : InvalidCategory;
367 }
368 
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)
384  else if (core.flags & QDeclarativePropertyCache::Data::IsQList)
386  else
388  } else {
390  }
391 }
392 
398 {
399  if (!d)
400  return 0;
401  if (d->isValueType()) {
402 
404  QDeclarativeValueType *valueType = 0;
405  if (ep) valueType = ep->valueTypes[d->core.propType];
407  Q_ASSERT(valueType);
408 
409  const char *rv = valueType->metaObject()->property(d->valueType.valueTypeCoreIdx).typeName();
410 
411  if (!ep) delete valueType;
412 
413  return rv;
414  } else if (d->object && type() & Property && d->core.isValid()) {
416  } else {
417  return 0;
418  }
419 }
420 
426 {
427  if (!d || !other.d)
428  return false;
429  // category is intentially omitted here as it is generated
430  // from the other members
431  return d->object == other.d->object &&
432  d->core == other.d->core &&
433  d->valueType == other.d->valueType;
434 }
435 
441 {
442  return d ? d->propertyType() : int(QVariant::Invalid);
443 }
444 
446 {
447  return valueType.valueTypeCoreIdx != -1;
448 }
449 
451 {
452  uint type = this->type();
453  if (isValueType()) {
454  return valueType.valueTypePropType;
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 }
464 
466 {
469  else if (core.isValid())
471  else
473 }
474 
479 {
480  return d ? d->type() : Invalid;
481 }
482 
487 {
488  return type() & Property;
489 }
490 
495 {
496  return type() & SignalProperty;
497 }
498 
503 {
504  return d ? d->object : 0;
505 }
506 
511 {
512  if (d)
513  d->release();
514  d = other.d;
515  if (d)
516  d->addref();
517 
518  return *this;
519 }
520 
525 {
526  if (!d)
527  return false;
528  if (!d->object)
529  return false;
531  return true;
532  else if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction) //signal handler
533  return false;
534  else if (d->core.isValid()) //normal property
536  else
537  return false;
538 }
539 
544 {
545  if (!d)
546  return false;
547  if (type() & Property && d->core.isValid() && d->object)
549  else
550  return false;
551 }
552 
557 {
558  if (!d)
559  return false;
560  if (type() & Property && d->core.isValid() && d->object)
562  else
563  return false;
564 }
565 
571 {
572  if (!d)
573  return false;
574  return type() != Invalid;
575 }
576 
581 {
582  if (!d)
583  return QString();
584  if (!d->isNameCached) {
585  // ###
586  if (!d->object) {
587  } else if (d->isValueType()) {
588  QString rv = d->core.name(d->object) + QLatin1Char('.');
589 
591  QDeclarativeValueType *valueType = 0;
592  if (ep) valueType = ep->valueTypes[d->core.propType];
594  Q_ASSERT(valueType);
595 
597 
598  if (!ep) delete valueType;
599 
600  d->nameCache = rv;
601  } else if (type() & SignalProperty) {
602  QString name = QLatin1String("on") + d->core.name(d->object);
603  name[2] = name.at(2).toUpper();
604  d->nameCache = name;
605  } else {
606  d->nameCache = d->core.name(d->object);
607  }
608  d->isNameCached = true;
609  }
610 
611  return d->nameCache;
612 }
613 
619 {
620  if (!d)
621  return QMetaProperty();
622  if (type() & Property && d->core.isValid() && d->object)
623  return d->object->metaObject()->property(d->core.coreIndex);
624  else
625  return QMetaProperty();
626 }
627 
633 {
634  if (!d)
635  return QMetaMethod();
636  if (type() & SignalProperty && d->object)
637  return d->object->metaObject()->method(d->core.coreIndex);
638  else
639  return QMetaMethod();
640 }
641 
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 }
654 
670  QDeclarativeAbstractBinding *newBinding,
671  WriteFlags flags)
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 }
682 
684 QDeclarativePropertyPrivate::binding(QObject *object, int coreIndex, int valueTypeIndex)
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 
708  QDeclarativeAbstractBinding *binding = data->bindings;
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 }
721 
723  QObject **targetObject, int *targetBindingIndex)
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 }
756 
758 QDeclarativePropertyPrivate::setBinding(QObject *object, int coreIndex, int valueTypeIndex,
759  QDeclarativeAbstractBinding *newBinding, WriteFlags flags)
760 {
761  QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding);
762  QDeclarativeAbstractBinding *binding = 0;
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 }
810 
812 QDeclarativePropertyPrivate::setBindingNoEnable(QObject *object, int coreIndex, int valueTypeIndex,
813  QDeclarativeAbstractBinding *newBinding)
814 {
815  QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding);
816  QDeclarativeAbstractBinding *binding = 0;
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 }
860 
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 }
883 
893  QDeclarativeExpression *expr)
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 }
917 
922 {
923  if (!d)
924  return QVariant();
925  if (!d->object)
926  return QVariant();
927 
928  if (type() & SignalProperty) {
929 
930  return QVariant();
931 
932  } else if (type() & Property) {
933 
934  return d->readValueProperty();
935 
936  }
937  return QVariant();
938 }
939 
948 {
949  QDeclarativeProperty p(object, name);
950  return p.read();
951 }
952 
964 {
965  QDeclarativeProperty p(object, name, ctxt);
966  return p.read();
967 }
968 
981 {
982  QDeclarativeProperty p(object, name, engine);
983  return p.read();
984 }
985 
987 {
988  if (isValueType()) {
989 
991  QDeclarativeValueType *valueType = 0;
992  if (ep) valueType = ep->valueTypes[core.propType];
993  else valueType = QDeclarativeValueTypeFactory::valueType(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 
1004  } else if (core.flags & QDeclarativePropertyCache::Data::IsQList) {
1005 
1007  void *args[] = { &prop, 0 };
1008  QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
1009  return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine));
1010 
1011  } else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
1012 
1013  QObject *rv = 0;
1014  void *args[] = { &rv, 0 };
1015  QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
1016  return QVariant::fromValue(rv);
1017 
1018  } else {
1019 
1020  return object->metaObject()->property(core.coreIndex).read(object.data());
1021 
1022  }
1023 }
1024 
1025 //writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC!
1026 bool QDeclarativePropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags)
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 }
1062 
1063 bool QDeclarativePropertyPrivate::writeValueProperty(const QVariant &value, WriteFlags flags)
1064 {
1065  // Remove any existing bindings on this property
1066  if (!(flags & DontRemoveBinding) &&
1067  (type() & QDeclarativeProperty::Property) && object) {
1068  QDeclarativeAbstractBinding *binding = setBinding(object, core.coreIndex,
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 {
1081  writeBack = QDeclarativeValueTypeFactory::valueType(core.propType);
1082  }
1083 
1084  writeBack->read(object, core.coreIndex);
1085 
1087  data.flags = valueType.flags;
1088  data.coreIndex = valueType.valueTypeCoreIdx;
1089  data.propType = valueType.valueTypePropType;
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 }
1103 
1105  const QVariant &value, QDeclarativeContextData *context,
1106  WriteFlags flags)
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 }
1256 
1258 {
1259  if (engine) {
1260  return engine->rawMetaObjectForType(userType);
1261  } else {
1263  return type?type->baseMetaObject():0;
1264  }
1265 }
1266 
1272 bool QDeclarativeProperty::write(const QVariant &value) const
1273 {
1274  return QDeclarativePropertyPrivate::write(*this, value, 0);
1275 }
1276 
1286 bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value)
1287 {
1288  QDeclarativeProperty p(object, name);
1289  return p.write(value);
1290 }
1291 
1303  const QString &name,
1304  const QVariant &value,
1305  QDeclarativeContext *ctxt)
1306 {
1307  QDeclarativeProperty p(object, name, ctxt);
1308  return p.write(value);
1309 }
1310 
1322 bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value,
1323  QDeclarativeEngine *engine)
1324 {
1325  QDeclarativeProperty p(object, name, engine);
1326  return p.write(value);
1327 }
1328 
1335 {
1336  if (isResettable()) {
1337  void *args[] = { 0 };
1339  return true;
1340  } else {
1341  return false;
1342  }
1343 }
1344 
1346  const QVariant &value, WriteFlags flags)
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 }
1356 
1361 {
1362  if (type() & Property && d->object) {
1364  }
1365  return false;
1366 }
1367 
1376 {
1377  return type() & Property && !property().isConstant();
1378 }
1379 
1389 {
1390  if (!(type() & Property) || !d->object)
1391  return false;
1392 
1394  if (prop.hasNotifySignal()) {
1396  } else {
1397  return false;
1398  }
1399 }
1400 
1409 bool QDeclarativeProperty::connectNotifySignal(QObject *dest, const char *slot) const
1410 {
1411  if (!(type() & Property) || !d->object)
1412  return false;
1413 
1415  if (prop.hasNotifySignal()) {
1416  QByteArray signal(QByteArray("2") + prop.notifySignal().signature());
1417  return QObject::connect(d->object, signal.constData(), dest, slot);
1418  } else {
1419  return false;
1420  }
1421 }
1422 
1427 {
1428  return d ? d->core.coreIndex : -1;
1429 }
1430 
1432 {
1433  return that.d ? that.d->valueType.valueTypeCoreIdx : -1;
1434 }
1435 
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 }
1449 
1453 };
1454 
1457 };
1458 
1460  const QMetaObject *subObject, int subIndex)
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 }
1476 
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 }
1487 
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 }
1505 
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 }
1521 
1526 {
1527  return lhs == rhs || (1 && lhs && rhs && lhs->d.stringdata == rhs->d.stringdata);
1528 }
1529 
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 }
1546 
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 }
1578 
1579 static inline int QMetaObject_methods(const QMetaObject *metaObject)
1580 {
1581  struct Private
1582  {
1583  int revision;
1584  int className;
1585  int classInfoCount, classInfoData;
1586  int methodCount, methodData;
1587  int propertyCount, propertyData;
1588  };
1589 
1590  return reinterpret_cast<const Private *>(metaObject->d.data)->methodCount;
1591 }
1592 
1593 static inline int QMetaObject_properties(const QMetaObject *metaObject)
1594 {
1595  struct Private
1596  {
1597  int revision;
1598  int className;
1599  int classInfoCount, classInfoData;
1600  int methodCount, methodData;
1601  int propertyCount, propertyData;
1602  };
1603 
1604  return reinterpret_cast<const Private *>(metaObject->d.data)->propertyCount;
1605 }
1606 
1607 static inline void flush_vme_signal(const QObject *object, int index)
1608 {
1609  QDeclarativeData *data = static_cast<QDeclarativeData *>(QObjectPrivate::get(const_cast<QObject *>(object))->declarativeData);
1610  if (data && data->propertyCache) {
1611  QDeclarativePropertyCache::Data *property = data->propertyCache->method(index);
1612 
1614  const QMetaObject *metaObject = object->metaObject();
1615  int methodOffset = metaObject->methodOffset();
1616 
1617  while (methodOffset > index) {
1618  metaObject = metaObject->d.superdata;
1619  methodOffset -= QMetaObject_methods(metaObject);
1620  }
1621 
1623  static_cast<QDeclarativeVMEMetaObject *>(const_cast<QMetaObject *>(metaObject));
1624 
1625  vme->connectAliasSignal(index);
1626  }
1627  }
1628 }
1629 
1637 bool QDeclarativePropertyPrivate::connect(QObject *sender, int signal_index,
1638  const QObject *receiver, int method_index,
1639  int type, int *types)
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 }
1657 
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 }
1672 
QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const
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)
double d
Definition: qnumeric_p.h:62
QObject *(* QDeclarativeAttachedPropertiesFunc)(QObject *)
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
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.
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
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
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int keysToValue(const char *keys) const
Returns the value derived from combining together the values of the keys using the OR operator...
static void signalSignature(const QMetaMethod &signal, QVarLengthArray< char > *result)
Definition: qobject_p.h:255
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QDeclarativeEngine * engine
int notifySignalIndex() const
Returns the index of the property change notifying signal if one was specified, otherwise returns -1...
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 **)
QDeclarativePropertyCache::Data core
static QDeclarativeBoundSignal * cast(QObject *)
static QDeclarativeValueType * valueType(int)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition: qurl.cpp:4317
static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &)
Return the signal corresponding to name.
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 ...
Definition: qvariant.cpp:2270
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.
Definition: qobject.h:128
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 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
Definition: qlocale_icu.cpp:69
static int valueTypeCoreIndex(const QDeclarativeProperty &that)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QMetaObject * baseMetaObject() const
quint16 u
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.
Definition: qlist.h:891
Type type() const
Returns the type of the property.
QDeclarativePropertyCache::Data core
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
bool reset() const
Resets the property and returns true if the property is resettable.
The QString class provides a Unicode character string.
Definition: qstring.h:83
const char * stringdata
Definition: qobjectdefs.h:470
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
const char * scope() const
Returns the scope this enumerator was declared in.
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)
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
const char * name() const
Returns the name of the enumerator (without the scope).
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 char * className
Definition: qwizard.cpp:137
static const QMetaObject * metaObjectForProperty(const QMetaObject *, int)
Return metaObject&#39;s [super] meta object that provides data for property.
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)
QDeclarativeExpression * setExpression(QDeclarativeExpression *)
Sets the signal expression to e.
QObject * object() const
Returns the QDeclarativeProperty&#39;s QObject.
void * data()
Definition: qvariant.cpp:3077
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QDeclarativeListReference init(const QDeclarativeListProperty< QObject > &, int, QDeclarativeEngine *)
bool isEnumType() const
Returns true if the property&#39;s type is an enumeration value; otherwise returns false.
int methodOffset() const
Returns the method offset for this class; i.e.
int userType() const
Returns this property&#39;s user type.
bool isFlagType() const
Returns true if the property&#39;s type is an enumeration value that is used as a flag; otherwise returns...
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...
Definition: qobject.cpp:2580
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)
QMetaMethod notifySignal() const
Returns the QMetaMethod instance of the property change notifying signal if one was specified...
PropertyTypeCategory propertyTypeCategory() const
Returns the property category.
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
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.
Definition: qstring.cpp:4302
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)
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
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...
Definition: qchar.cpp:1287
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
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
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 connectNotifySignal(QObject *dest, const char *slot) const
Connects the property&#39;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.
Definition: qvariant.h:336
const uint * data
Definition: qobjectdefs.h:471
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
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...
Definition: qvariant.cpp:2528
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
Definition: qobject_p.h:214
int count() const
Definition: qstring.h:103
void connectNotify(const char *signal)
Definition: qobject_p.h:245
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.
Definition: qchar.h:273
bool convert(Type t)
Casts the variant to the requested type, t.
Definition: qvariant.cpp:2959
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().
Definition: qbytearray.h:356
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
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
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.
const char * name() const
Returns this property&#39;s name.
static const struct @32 types[]
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
Definition: qvariant.cpp:3065
static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *)
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
QDeclarativePropertyPrivate * d
const QMetaObject * superdata
Definition: qobjectdefs.h:469
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...
bool isDesignable(const QObject *obj=0) const
Returns true if this property is designable for the given object; otherwise returns false...
if(void) toggleToolbarShown
struct QMetaObject::@38 d
QVariant read(const QObject *obj) const
Reads the property&#39;s value from the given object.
bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const
static StringConverter customStringConverter(int)
Return the custom string converter for type, previously installed through registerCustomStringConvert...
bool isWritable() const
Returns true if the property is writable, otherwise false.
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
Type
This enum specifies a type of QML property.
int keyToValue(const char *key) const
Returns the integer value of the given enumeration key, or -1 if key is not defined.
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 ...
Definition: qvariant.cpp:2710
QMetaEnum enumerator() const
Returns the enumerator if this property&#39;s type is an enumerator type; otherwise the returned value is...
PropertyTypeCategory
This enum specifies a category of QML property.
QDeclarativeProperty()
Create an invalid QDeclarativeProperty.
QDeclarativeEngine * engine() const
Return the context&#39;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)
Definition: qglobal.h:2043
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
Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
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...
Definition: qstring.cpp:6526
static void findAliasTarget(QObject *, int, QObject **, int *)
bool operator==(const QDeclarativeProperty &) const
Returns true if other and this QDeclarativeProperty represent the same property.
int propertyOffset() const
Returns the property offset for this class; i.e.
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
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.
bool hasNotifySignal() const
Returns true if this property has a corresponding change notify signal; otherwise returns false...
static void flush_vme_signal(const QObject *object, int index)
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...
Definition: qchar.cpp:1239
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
const char * typeName() const
Returns the name of this property&#39;s type.
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
bool isConstant() const
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)
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
static bool equal(const QChar *a, int l, const char *b)
Definition: qurl.cpp:3270
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(* StringConverter)(const QString &)
QVariant read() const
Returns the property value.
static QMetaProperty defaultProperty(const QMetaObject *)
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)