Qt 4.8
Public Functions | Properties | Friends | List of all members
QDeclarativeDomDynamicProperty Class Reference

#include <qdeclarativedom_p.h>

Public Functions

QDeclarativeDomProperty defaultValue () const
 Returns the default value as a QDeclarativeDomProperty. More...
 
bool isAlias () const
 Returns true if this dynamic property is an alias for another property, false otherwise. More...
 
bool isDefaultProperty () const
 Return true if this property is used as a default property in the QML document. More...
 
bool isValid () const
 
int length () const
 Returns the length in the input data from where the property ID started upto the end of it, or 0 if the property is invalid. More...
 
QDeclarativeDomDynamicPropertyoperator= (const QDeclarativeDomDynamicProperty &)
 Assign other to this QDeclarativeDomDynamicProperty. More...
 
int position () const
 Returns the position in the input data where the property ID startd, or 0 if the property is invalid. More...
 
QByteArray propertyName () const
 Return the name of this dynamic property. More...
 
int propertyType () const
 Returns the type of the dynamic property. More...
 
QByteArray propertyTypeName () const
 
 QDeclarativeDomDynamicProperty ()
 Construct an invalid QDeclarativeDomDynamicProperty. More...
 
 QDeclarativeDomDynamicProperty (const QDeclarativeDomDynamicProperty &)
 Create a copy of other QDeclarativeDomDynamicProperty. More...
 
 ~QDeclarativeDomDynamicProperty ()
 Destroy the QDeclarativeDomDynamicProperty. More...
 

Properties

QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivated
 

Friends

class QDeclarativeDomObject
 

Detailed Description

Definition at line 128 of file qdeclarativedom_p.h.

Constructors and Destructors

◆ QDeclarativeDomDynamicProperty() [1/2]

QDeclarativeDomDynamicProperty::QDeclarativeDomDynamicProperty ( )

Construct an invalid QDeclarativeDomDynamicProperty.

Definition at line 405 of file qdeclarativedom.cpp.

405  :
407 {
408 }
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ QDeclarativeDomDynamicProperty() [2/2]

QDeclarativeDomDynamicProperty::QDeclarativeDomDynamicProperty ( const QDeclarativeDomDynamicProperty other)

Create a copy of other QDeclarativeDomDynamicProperty.

Definition at line 413 of file qdeclarativedom.cpp.

413  :
414  d(other.d)
415 {
416 }
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ ~QDeclarativeDomDynamicProperty()

QDeclarativeDomDynamicProperty::~QDeclarativeDomDynamicProperty ( )

Destroy the QDeclarativeDomDynamicProperty.

Definition at line 421 of file qdeclarativedom.cpp.

422 {
423 }

Functions

◆ defaultValue()

QDeclarativeDomProperty QDeclarativeDomDynamicProperty::defaultValue ( ) const

Returns the default value as a QDeclarativeDomProperty.

Definition at line 540 of file qdeclarativedom.cpp.

541 {
543 
544  if (isValid() && d->property.defaultValue) {
546  rp.d->propertyName = propertyName();
547  rp.d->property->addref();
548  }
549 
550  return rp;
551 }
The QDeclarativeDomProperty class represents one property assignment in the QML DOM tree...
QByteArray propertyName() const
Return the name of this dynamic property.
QDeclarativeParser::Object::DynamicProperty property
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d
QDeclarativeParser::Property * property

◆ isAlias()

bool QDeclarativeDomDynamicProperty::isAlias ( ) const

Returns true if this dynamic property is an alias for another property, false otherwise.

Definition at line 557 of file qdeclarativedom.cpp.

558 {
559  if (isValid())
561  else
562  return false;
563 }
QDeclarativeParser::Object::DynamicProperty property
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ isDefaultProperty()

bool QDeclarativeDomDynamicProperty::isDefaultProperty ( ) const

Return true if this property is used as a default property in the QML document.

<Text text="hello"/>
<Text>hello</Text>

The above two examples return the same DOM tree, except that the second has the default property flag set on the text property. Observe that whether or not a property has isDefaultProperty set is determined by how the property is used, and not only by whether the property is the types default property.

Definition at line 529 of file qdeclarativedom.cpp.

530 {
531  if (isValid())
532  return d->property.isDefaultProperty;
533  else
534  return false;
535 }
QDeclarativeParser::Object::DynamicProperty property
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ isValid()

bool QDeclarativeDomDynamicProperty::isValid ( ) const

Definition at line 434 of file qdeclarativedom.cpp.

Referenced by defaultValue(), isAlias(), isDefaultProperty(), length(), position(), propertyName(), propertyType(), and propertyTypeName().

435 {
436  return d && d->valid;
437 }
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ length()

int QDeclarativeDomDynamicProperty::length ( ) const

Returns the length in the input data from where the property ID started upto the end of it, or 0 if the property is invalid.

Definition at line 581 of file qdeclarativedom.cpp.

582 {
583  if (isValid())
584  return d->property.location.range.length;
585  else
586  return -1;
587 }
QDeclarativeParser::Object::DynamicProperty property
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ operator=()

QDeclarativeDomDynamicProperty & QDeclarativeDomDynamicProperty::operator= ( const QDeclarativeDomDynamicProperty other)

Assign other to this QDeclarativeDomDynamicProperty.

Definition at line 428 of file qdeclarativedom.cpp.

429 {
430  d = other.d;
431  return *this;
432 }
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ position()

int QDeclarativeDomDynamicProperty::position ( ) const

Returns the position in the input data where the property ID startd, or 0 if the property is invalid.

Definition at line 569 of file qdeclarativedom.cpp.

570 {
571  if (isValid()) {
572  return d->property.location.range.offset;
573  } else
574  return -1;
575 }
QDeclarativeParser::Object::DynamicProperty property
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ propertyName()

QByteArray QDeclarativeDomDynamicProperty::propertyName ( ) const

Return the name of this dynamic property.

property int count: 10;
}

As illustrated above, a dynamic property name can have a name and a default value ("10").

Definition at line 451 of file qdeclarativedom.cpp.

Referenced by defaultValue().

452 {
453  if (isValid())
454  return d->property.name;
455  else
456  return QByteArray();
457 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QDeclarativeParser::Object::DynamicProperty property
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ propertyType()

int QDeclarativeDomDynamicProperty::propertyType ( ) const

Returns the type of the dynamic property.

Note that when the property is an alias property, this will return -1. Use QDeclarativeDomProperty::isAlias() to check if the property is an alias.

Definition at line 464 of file qdeclarativedom.cpp.

465 {
466  if (isValid()) {
467  switch (d->property.type) {
469  return QMetaType::type("bool");
470 
472  return QMetaType::type("QColor");
473 
475  return QMetaType::type("QTime");
476 
478  return QMetaType::type("QDate");
479 
481  return QMetaType::type("QDateTime");
482 
484  return QMetaType::type("int");
485 
487  return sizeof(qreal) == sizeof(double) ? QMetaType::type("double") : QMetaType::type("float");
488 
490  return QMetaType::type("QString");
491 
493  return QMetaType::type("QUrl");
494 
496  return QMetaType::type("QVariant");
497 
498  default:
499  break;
500  }
501  }
502 
503  return -1;
504 }
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
QDeclarativeParser::Object::DynamicProperty property
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
The QMetaType class manages named types in the meta-object system.
Definition: qmetatype.h:62
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

◆ propertyTypeName()

QByteArray QDeclarativeDomDynamicProperty::propertyTypeName ( ) const

Definition at line 506 of file qdeclarativedom.cpp.

507 {
508  if (isValid())
509  return d->property.customType;
510 
511  return QByteArray();
512 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QDeclarativeParser::Object::DynamicProperty property
QSharedDataPointer< QDeclarativeDomDynamicPropertyPrivate > d

Friends and Related Functions

◆ QDeclarativeDomObject

Definition at line 151 of file qdeclarativedom_p.h.

Properties

◆ d

QSharedDataPointer<QDeclarativeDomDynamicPropertyPrivate> QDeclarativeDomDynamicProperty::d
private

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