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

#include <qdeclarativegesturearea_p.h>

Inheritance diagram for QDeclarativeGestureAreaParser:
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 88 of file qdeclarativegesturearea_p.h.

Functions

◆ compile()

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

Implements QDeclarativeCustomParser.

Definition at line 163 of file qdeclarativegesturearea.cpp.

164 {
165  QByteArray rv;
167 
168  for(int ii = 0; ii < props.count(); ++ii)
169  {
170  QString propName = QString::fromUtf8(props.at(ii).name());
172 
173  if (propName == QLatin1String("onTap")) {
174  type = Qt::TapGesture;
175  } else if (propName == QLatin1String("onTapAndHold")) {
176  type = Qt::TapAndHoldGesture;
177  } else if (propName == QLatin1String("onPan")) {
178  type = Qt::PanGesture;
179  } else if (propName == QLatin1String("onPinch")) {
180  type = Qt::PinchGesture;
181  } else if (propName == QLatin1String("onSwipe")) {
182  type = Qt::SwipeGesture;
183  } else if (propName == QLatin1String("onGesture")) {
184  type = Qt::CustomGesture;
185  } else {
186  error(props.at(ii), QDeclarativeGestureArea::tr("Cannot assign to non-existent property \"%1\"").arg(propName));
187  return QByteArray();
188  }
189 
190  QList<QVariant> values = props.at(ii).assignedValues();
191 
192  for (int i = 0; i < values.count(); ++i) {
193  const QVariant &value = values.at(i);
194 
195  if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
196  error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: nested objects not allowed"));
197  return QByteArray();
198  } else if (value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
199  error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: syntax error"));
200  return QByteArray();
201  } else {
203  if (v.isScript()) {
204  ds << propName;
205  ds << int(type);
206  ds << v.asScript();
207  } else {
208  error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: script expected"));
209  return QByteArray();
210  }
211  }
212  }
213  }
214 
215  return rv;
216 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
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)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
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
quint16 values[128]
GestureType
Definition: qnamespace.h:1759
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 QDeclarativeGestureAreaParser::setCustomData ( QObject object,
const QByteArray data 
)
virtual

Implements QDeclarativeCustomParser.

Definition at line 218 of file qdeclarativegesturearea.cpp.

220 {
222  ga->d_func()->data = data;
223 }
QVariant data(int key) const
Returns this item&#39;s custom data for the key key as a QVariant.
static const char * data(const QByteArray &arr)
QDeclarativeParser::Object * object

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