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

#include <qdeclarativeconnections_p.h>

Inheritance diagram for QDeclarativeConnectionsParser:
QDeclarativeCustomParser

Public Functions

virtual QByteArray compile (const QList< QDeclarativeCustomParserProperty > &)
 
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 89 of file qdeclarativeconnections_p.h.

Functions

◆ compile()

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

Implements QDeclarativeCustomParser.

Definition at line 207 of file qdeclarativeconnections.cpp.

208 {
209  QByteArray rv;
211 
212  for(int ii = 0; ii < props.count(); ++ii)
213  {
214  QString propName = QString::fromUtf8(props.at(ii).name());
215  if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) {
216  error(props.at(ii), QDeclarativeConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
217  return QByteArray();
218  }
219 
220  QList<QVariant> values = props.at(ii).assignedValues();
221 
222  for (int i = 0; i < values.count(); ++i) {
223  const QVariant &value = values.at(i);
224 
225  if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
226  error(props.at(ii), QDeclarativeConnections::tr("Connections: nested objects not allowed"));
227  return QByteArray();
228  } else if (value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
229  error(props.at(ii), QDeclarativeConnections::tr("Connections: syntax error"));
230  return QByteArray();
231  } else {
233  if (v.isScript()) {
234  ds << propName;
235  ds << v.asScript();
236  } else {
237  error(props.at(ii), QDeclarativeConnections::tr("Connections: script expected"));
238  return QByteArray();
239  }
240  }
241  }
242  }
243 
244  return rv;
245 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
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
The QString class provides a Unicode character string.
Definition: qstring.h:83
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
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
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
quint16 values[128]
bool isUpper() const
Returns true if the character is an uppercase letter, i.
Definition: qchar.h:273
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71

◆ setCustomData()

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

Implements QDeclarativeCustomParser.

Definition at line 247 of file qdeclarativeconnections.cpp.

249 {
251  static_cast<QDeclarativeConnectionsPrivate *>(QObjectPrivate::get(object));
252  p->data = data;
253 }
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: