Qt 4.8
Public Functions | List of all members
QDeclarativePropertyChangesParser Class Reference

#include <qdeclarativepropertychanges_p.h>

Inheritance diagram for QDeclarativePropertyChangesParser:
QDeclarativeCustomParser

Public Functions

virtual QByteArray compile (const QList< QDeclarativeCustomParserProperty > &)
 
void compileList (QList< QPair< QByteArray, QVariant > > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop)
 
 QDeclarativePropertyChangesParser ()
 
virtual void setCustomData (QObject *, const QByteArray &)
 
- Public Functions inherited from QDeclarativeCustomParser
void clearErrors ()
 
QList< QDeclarativeErrorerrors () const
 
Flags flags () const
 
 QDeclarativeCustomParser ()
 
 QDeclarativeCustomParser (Flags f)
 
virtual ~QDeclarativeCustomParser ()
 

Additional Inherited Members

- Public Types inherited from QDeclarativeCustomParser
enum  Flag { NoFlag = 0x00000000, AcceptsAttachedProperties = 0x00000001 }
 
- Protected Functions inherited from QDeclarativeCustomParser
void error (const QString &description)
 Reports an error with the given description. More...
 
void error (const QDeclarativeCustomParserProperty &, const QString &description)
 Reports an error in parsing prop, with the given description. More...
 
void error (const QDeclarativeCustomParserNode &, const QString &description)
 Reports an error in parsing node, with the given description. More...
 
int evaluateEnum (const QByteArray &) const
 If script is a simply enum expression (eg. More...
 
const QMetaObjectresolveType (const QByteArray &) const
 Resolves name to a type, or 0 if it is not a type. More...
 
QDeclarativeBinding::Identifier rewriteBinding (const QString &, const QByteArray &)
 Rewrites expression and returns an identifier that can be used to construct the binding later. More...
 

Detailed Description

Definition at line 93 of file qdeclarativepropertychanges_p.h.

Constructors and Destructors

◆ QDeclarativePropertyChangesParser()

QDeclarativePropertyChangesParser::QDeclarativePropertyChangesParser ( )
inline

Functions

◆ compile()

QByteArray QDeclarativePropertyChangesParser::compile ( const QList< QDeclarativeCustomParserProperty > &  props)
virtual

Implements QDeclarativeCustomParser.

Definition at line 278 of file qdeclarativepropertychanges.cpp.

279 {
281  for(int ii = 0; ii < props.count(); ++ii)
282  compileList(data, QByteArray(), props.at(ii));
283 
284  QByteArray rv;
286 
287  ds << data.count();
288  for(int ii = 0; ii < data.count(); ++ii) {
290  QVariant var;
291  bool isScript = v.isScript();
293  switch(v.type()) {
295  var = QVariant(v.asBoolean());
296  break;
298  var = QVariant(v.asNumber());
299  break;
301  var = QVariant(v.asString());
302  break;
305  var = QVariant(v.asScript());
306  {
307  // Pre-rewrite the expression
308  QString expression = v.asScript();
309  id = rewriteBinding(expression, data.at(ii).first); //### recreates the AST, which is slow
310  }
311  break;
312  }
313 
314  ds << QString::fromUtf8(data.at(ii).first) << isScript << var;
315  if (isScript)
316  ds << id;
317  }
318 
319  return rv;
320 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeBinding::Identifier rewriteBinding(const QString &, const QByteArray &)
Rewrites expression and returns an identifier that can be used to construct the binding later...
void compileList(QList< QPair< QByteArray, QVariant > > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
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
static const char * data(const QByteArray &arr)
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ compileList()

void QDeclarativePropertyChangesParser::compileList ( QList< QPair< QByteArray, QVariant > > &  list,
const QByteArray pre,
const QDeclarativeCustomParserProperty prop 
)

Definition at line 250 of file qdeclarativepropertychanges.cpp.

253 {
254  QByteArray propName = pre + prop.name();
255 
257  for (int ii = 0; ii < values.count(); ++ii) {
258  const QVariant &value = values.at(ii);
259 
260  if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
261  error(qvariant_cast<QDeclarativeCustomParserNode>(value),
262  QDeclarativePropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
263  continue;
264  } else if(value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
265 
268  QByteArray pre = propName + '.';
269  compileList(list, pre, prop);
270 
271  } else {
272  list << qMakePair(propName, value);
273  }
274  }
275 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void compileList(QList< QPair< QByteArray, QVariant > > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void error(const QString &description)
Reports an error with the given description.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
quint16 values[128]
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571

◆ setCustomData()

void QDeclarativePropertyChangesParser::setCustomData ( QObject object,
const QByteArray data 
)
virtual

Implements QDeclarativeCustomParser.

Definition at line 368 of file qdeclarativepropertychanges.cpp.

370 {
373  p->data = data;
374  p->decoded = false;
375 }
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
static const char * data(const QByteArray &arr)

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