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

The QDeclarativeDomProperty class represents one property assignment in the QML DOM tree. More...

#include <qdeclarativedom_p.h>

Public Functions

bool isDefaultProperty () const
 Return true if this property is used as a default property in the QML document. More...
 
bool isValid () const
 Returns true if this is a valid QDeclarativeDomProperty, false otherwise. More...
 
int length () const
 Returns the length in the input data from where the property ID started upto the end of it, or -1 if the property is invalid. More...
 
QDeclarativeDomPropertyoperator= (const QDeclarativeDomProperty &)
 Assign other to this QDeclarativeDomProperty. More...
 
int position () const
 Returns the position in the input data where the property ID startd, or -1 if the property is invalid. More...
 
QByteArray propertyName () const
 Return the name of this property. More...
 
QList< QByteArraypropertyNameParts () const
 Return the name of this property, split into multiple parts in the case of dot properties. More...
 
 QDeclarativeDomProperty ()
 Construct an invalid QDeclarativeDomProperty. More...
 
 QDeclarativeDomProperty (const QDeclarativeDomProperty &)
 Create a copy of other QDeclarativeDomProperty. More...
 
QDeclarativeDomValue value () const
 Returns the QDeclarativeDomValue that is assigned to this property, or an invalid QDeclarativeDomValue if no value is assigned. More...
 
 ~QDeclarativeDomProperty ()
 Destroy the QDeclarativeDomProperty. More...
 

Properties

QSharedDataPointer< QDeclarativeDomPropertyPrivated
 

Friends

class QDeclarativeDomDynamicProperty
 
class QDeclarativeDomObject
 

Detailed Description

The QDeclarativeDomProperty class represents one property assignment in the QML DOM tree.

Warning
This function is not part of the public interface.

Properties in QML can be assigned QML QDeclarativeDomValue{values}.

See also
QDeclarativeDomObject

Definition at line 101 of file qdeclarativedom_p.h.

Constructors and Destructors

◆ QDeclarativeDomProperty() [1/2]

QDeclarativeDomProperty::QDeclarativeDomProperty ( )

Construct an invalid QDeclarativeDomProperty.

Definition at line 253 of file qdeclarativedom.cpp.

255 {
256 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d

◆ QDeclarativeDomProperty() [2/2]

QDeclarativeDomProperty::QDeclarativeDomProperty ( const QDeclarativeDomProperty other)

Create a copy of other QDeclarativeDomProperty.

Definition at line 261 of file qdeclarativedom.cpp.

262 : d(other.d)
263 {
264 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d

◆ ~QDeclarativeDomProperty()

QDeclarativeDomProperty::~QDeclarativeDomProperty ( )

Destroy the QDeclarativeDomProperty.

Definition at line 269 of file qdeclarativedom.cpp.

270 {
271 }

Functions

◆ isDefaultProperty()

bool QDeclarativeDomProperty::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 354 of file qdeclarativedom.cpp.

355 {
356  return d->property && d->property->isDefault;
357 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d
QDeclarativeParser::Property * property

◆ isValid()

bool QDeclarativeDomProperty::isValid ( ) const

Returns true if this is a valid QDeclarativeDomProperty, false otherwise.

Definition at line 285 of file qdeclarativedom.cpp.

286 {
287  return d->property != 0;
288 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d
QDeclarativeParser::Property * property

◆ length()

int QDeclarativeDomProperty::length ( ) const

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

Definition at line 394 of file qdeclarativedom.cpp.

395 {
396  if (d && d->property)
397  return d->property->location.range.length;
398  else
399  return -1;
400 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d
QDeclarativeParser::Property * property

◆ operator=()

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

Assign other to this QDeclarativeDomProperty.

Definition at line 276 of file qdeclarativedom.cpp.

277 {
278  d = other.d;
279  return *this;
280 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d

◆ position()

int QDeclarativeDomProperty::position ( ) const

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

Definition at line 382 of file qdeclarativedom.cpp.

383 {
384  if (d && d->property) {
385  return d->property->location.range.offset;
386  } else
387  return -1;
388 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d
QDeclarativeParser::Property * property

◆ propertyName()

QByteArray QDeclarativeDomProperty::propertyName ( ) const

Return the name of this property.

x: 10
y: 10
font.bold: true
}

As illustrated above, a property name can be a simple string, such as "x" or "y", or a more complex "dot property", such as "font.bold". In both cases the full name is returned ("x", "y" and "font.bold") by this method.

For dot properties, a split version of the name can be accessed by calling QDeclarativeDomProperty::propertyNameParts().

See also
QDeclarativeDomProperty::propertyNameParts()

Definition at line 311 of file qdeclarativedom.cpp.

Referenced by QDeclarativeDomObject::property().

312 {
313  return d->propertyName;
314 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d

◆ propertyNameParts()

QList< QByteArray > QDeclarativeDomProperty::propertyNameParts ( ) const

Return the name of this property, split into multiple parts in the case of dot properties.

x: 10
y: 10
font.bold: true
}

For each of the properties shown above, this method would return ("x"), ("y") and ("font", "bold").

See also
QDeclarativeDomProperty::propertyName()

Definition at line 333 of file qdeclarativedom.cpp.

334 {
335  if (d->propertyName.isEmpty()) return QList<QByteArray>();
336  else return d->propertyName.split('.');
337 }
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421

◆ value()

QDeclarativeDomValue QDeclarativeDomProperty::value ( ) const

Returns the QDeclarativeDomValue that is assigned to this property, or an invalid QDeclarativeDomValue if no value is assigned.

Definition at line 363 of file qdeclarativedom.cpp.

364 {
366  if (d->property) {
367  rv.d->property = d->property;
368  if (d->property->values.count())
369  rv.d->value = d->property->values.at(0);
370  else
371  rv.d->value = d->property->onValues.at(0);
372  rv.d->property->addref();
373  rv.d->value->addref();
374  }
375  return rv;
376 }
The QDeclarativeDomValue class represents a generic Qml value.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
QSharedDataPointer< QDeclarativeDomPropertyPrivate > d
QDeclarativeParser::Property * property
QDeclarativeParser::Property * property
QDeclarativeParser::Value * value

Friends and Related Functions

◆ QDeclarativeDomDynamicProperty

Definition at line 123 of file qdeclarativedom_p.h.

◆ QDeclarativeDomObject

Definition at line 122 of file qdeclarativedom_p.h.

Properties

◆ d

QSharedDataPointer<QDeclarativeDomPropertyPrivate> QDeclarativeDomProperty::d
private

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