Qt 4.8
Public Types | Public Functions | Protected Functions | Properties | List of all members
QDeclarativeTypeNameScriptClass Class Reference

#include <qdeclarativetypenamescriptclass_p.h>

Inheritance diagram for QDeclarativeTypeNameScriptClass:
QScriptDeclarativeClass

Public Types

enum  TypeNameMode { IncludeEnums, ExcludeEnums }
 
- Public Types inherited from QScriptDeclarativeClass
typedef void * Identifier
 

Public Functions

QScriptValue newObject (QObject *, QDeclarativeType *, TypeNameMode=IncludeEnums)
 
QScriptValue newObject (QObject *, QDeclarativeTypeNameCache *, TypeNameMode=IncludeEnums)
 
 QDeclarativeTypeNameScriptClass (QDeclarativeEngine *)
 
 ~QDeclarativeTypeNameScriptClass ()
 
- Public Functions inherited from QScriptDeclarativeClass
virtual Value call (Object *, QScriptContext *)
 
virtual bool compare (Object *, Object *)
 
QScriptContextcontext () const
 
PersistentIdentifier createPersistentIdentifier (const QString &)
 
PersistentIdentifier createPersistentIdentifier (const Identifier &)
 
QScriptEngineengine () const
 
virtual bool isQObject () const
 
virtual QScriptValue::PropertyFlags propertyFlags (Object *, const Identifier &)
 
virtual QStringList propertyNames (Object *)
 
 QScriptDeclarativeClass (QScriptEngine *engine)
 
void setSupportsCall (bool)
 
bool startsWithUpper (const Identifier &)
 
bool supportsCall () const
 
quint32 toArrayIndex (const Identifier &, bool *ok)
 
virtual QObjecttoQObject (Object *, bool *ok=0)
 
QString toString (const Identifier &)
 
virtual QVariant toVariant (Object *, bool *ok=0)
 
virtual ~QScriptDeclarativeClass ()
 

Protected Functions

virtual Value property (Object *, const Identifier &)
 
virtual QScriptClass::QueryFlags queryProperty (Object *, const Identifier &, QScriptClass::QueryFlags flags)
 
virtual void setProperty (Object *, const Identifier &name, const QScriptValue &)
 

Properties

QDeclarativeEngineengine
 
quint32 enumValue
 
QObjectobject
 
QDeclarativeTypetype
 

Additional Inherited Members

- Static Public Functions inherited from QScriptDeclarativeClass
static QScriptValue function (const QScriptValue &, const Identifier &)
 
static Value functionValue (const QScriptValue &, const Identifier &)
 
static QScriptValue newObject (QScriptEngine *, QScriptDeclarativeClass *, Object *)
 
static Value newObjectValue (QScriptEngine *, QScriptDeclarativeClass *, Object *)
 
static QScriptValue newStaticScopeObject (QScriptEngine *, int propertyCount, const QString *names, const QScriptValue *values, const QScriptValue::PropertyFlags *flags)
 Creates a scope object with a fixed set of undeletable properties. More...
 
static QScriptValue newStaticScopeObject (QScriptEngine *)
 Creates a static scope object that's initially empty, but to which new properties can be added. More...
 
static Objectobject (const QScriptValue &)
 
static QScriptValue property (const QScriptValue &, const Identifier &)
 
static Value propertyValue (const QScriptValue &, const Identifier &)
 
static QScriptContextpushCleanContext (QScriptEngine *)
 Enters a new execution context and returns the associated QScriptContext object. More...
 
static QScriptValue scopeChainValue (QScriptContext *, int index)
 
static QScriptDeclarativeClassscriptClass (const QScriptValue &)
 
- Protected Variables inherited from QScriptDeclarativeClass
QScopedPointer< QScriptDeclarativeClassPrivated_ptr
 

Detailed Description

Definition at line 65 of file qdeclarativetypenamescriptclass_p.h.

Enumerations

◆ TypeNameMode

Constructors and Destructors

◆ QDeclarativeTypeNameScriptClass()

QDeclarativeTypeNameScriptClass::QDeclarativeTypeNameScriptClass ( QDeclarativeEngine bindEngine)

Definition at line 64 of file qdeclarativetypenamescriptclass.cpp.

66  engine(bindEngine), object(0), type(0)
67 {
68 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
QScriptEngine * engine() const
QScriptDeclarativeClass(QScriptEngine *engine)

◆ ~QDeclarativeTypeNameScriptClass()

QDeclarativeTypeNameScriptClass::~QDeclarativeTypeNameScriptClass ( )

Definition at line 70 of file qdeclarativetypenamescriptclass.cpp.

71 {
72 }

Functions

◆ newObject() [1/2]

QScriptValue QDeclarativeTypeNameScriptClass::newObject ( QObject object,
QDeclarativeType type,
TypeNameMode  mode = IncludeEnums 
)

Definition at line 74 of file qdeclarativetypenamescriptclass.cpp.

Referenced by property(), QDeclarativeContextScriptClass::property(), and QDeclarativeObjectScriptClass::property().

75 {
77 
78  return QScriptDeclarativeClass::newObject(scriptEngine, this, new TypeNameData(object, type, mode));
79 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *)
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptEngine * engine() const

◆ newObject() [2/2]

QScriptValue QDeclarativeTypeNameScriptClass::newObject ( QObject object,
QDeclarativeTypeNameCache ns,
TypeNameMode  mode = IncludeEnums 
)

Definition at line 81 of file qdeclarativetypenamescriptclass.cpp.

82 {
84 
85  return QScriptDeclarativeClass::newObject(scriptEngine, this, new TypeNameData(object, ns, mode));
86 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *)
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptEngine * engine() const

◆ property()

QDeclarativeTypeNameScriptClass::Value QDeclarativeTypeNameScriptClass::property ( Object obj,
const Identifier name 
)
protectedvirtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 142 of file qdeclarativetypenamescriptclass.cpp.

143 {
146  if (type) {
147  return Value(scriptEngine, newObject(((TypeNameData *)obj)->object, type, ((TypeNameData *)obj)->mode));
148  } else if (object) {
149  return ep->objectClass->property(object, name);
150  } else {
151  return Value(scriptEngine, enumValue);
152  }
153 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptValue newObject(QObject *, QDeclarativeType *, TypeNameMode=IncludeEnums)
const char * name
QScriptEngine * engine() const
QDeclarativeObjectScriptClass * objectClass
Value property(QObject *, const Identifier &)

◆ queryProperty()

QScriptClass::QueryFlags QDeclarativeTypeNameScriptClass::queryProperty ( Object obj,
const Identifier name,
QScriptClass::QueryFlags  flags 
)
protectedvirtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 89 of file qdeclarativetypenamescriptclass.cpp.

91 {
92  Q_UNUSED(flags);
93 
94  TypeNameData *data = (TypeNameData *)obj;
95 
96  object = 0;
97  type = 0;
99 
100  if (data->typeNamespace) {
101 
103  if (d && d->type) {
104  type = d->type;
106  } else {
107  return 0;
108  }
109 
110  } else if (data->type) {
111 
112  if (startsWithUpper(name)) {
113  QString strName = toString(name);
114  // Must be an enum
115  if (data->mode == IncludeEnums) {
116  // ### Optimize
117  QByteArray enumName = strName.toUtf8();
118  const QMetaObject *metaObject = data->type->baseMetaObject();
119  for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) {
120  QMetaEnum e = metaObject->enumerator(ii);
121  int value = e.keyToValue(enumName.constData());
122  if (value != -1) {
123  enumValue = value;
125  }
126  }
127  }
128  return 0;
129  } else if (data->object) {
130  // Must be an attached property
132  if (!object) return 0;
133  return ep->objectClass->queryProperty(object, name, flags, 0);
134  }
135 
136  }
137 
138  return 0;
139 }
double d
Definition: qnumeric_p.h:62
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
bool startsWithUpper(const Identifier &)
QScriptClass::QueryFlags queryProperty(QObject *, const Identifier &, QScriptClass::QueryFlags flags, QDeclarativeContextData *evalContext, QueryHints hints=0)
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
const QMetaObject * baseMetaObject() const
int attachedPropertiesId() const
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QDeclarativeTypeNameScriptClass::TypeNameMode mode
Q_DECLARATIVE_EXPORT QObject * qmlAttachedPropertiesObjectById(int, const QObject *, bool create=true)
const char * name
QScriptEngine * engine() const
static const char * data(const QByteArray &arr)
int enumeratorCount() const
Returns the number of enumerators in this class.
QDeclarativeTypeNameCache * typeNamespace
QDeclarativeObjectScriptClass * objectClass
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QMetaEnum enumerator(int index) const
Returns the meta-data for the enumerator with the given index.
int keyToValue(const char *key) const
Returns the integer value of the given enumeration key, or -1 if key is not defined.
Data * data(const QString &) const
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QString toString(const Identifier &)

◆ setProperty()

void QDeclarativeTypeNameScriptClass::setProperty ( Object ,
const Identifier name,
const QScriptValue v 
)
protectedvirtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 155 of file qdeclarativetypenamescriptclass.cpp.

156 {
157  Q_ASSERT(object);
158  Q_ASSERT(!type);
159 
161  ep->objectClass->setProperty(object, n, v, context());
162 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QScriptEngine * engine() const
QDeclarativeObjectScriptClass * objectClass
void setProperty(QObject *, const Identifier &name, const QScriptValue &, QScriptContext *context, QDeclarativeContextData *evalContext=0)
QScriptContext * context() const

Properties

◆ engine

QDeclarativeEngine* QDeclarativeTypeNameScriptClass::engine
private

Definition at line 83 of file qdeclarativetypenamescriptclass_p.h.

◆ enumValue

quint32 QDeclarativeTypeNameScriptClass::enumValue
private

Definition at line 86 of file qdeclarativetypenamescriptclass_p.h.

Referenced by property(), and queryProperty().

◆ object

QObject* QDeclarativeTypeNameScriptClass::object
private

Definition at line 84 of file qdeclarativetypenamescriptclass_p.h.

◆ type

QDeclarativeType* QDeclarativeTypeNameScriptClass::type
private

Definition at line 85 of file qdeclarativetypenamescriptclass_p.h.

Referenced by property(), queryProperty(), and setProperty().


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