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

#include <qdeclarativelistscriptclass_p.h>

Inheritance diagram for QDeclarativeListScriptClass:
QScriptDeclarativeClass

Public Functions

QScriptValue newList (QObject *, int, int)
 
QScriptValue newList (const QDeclarativeListProperty< QObject > &, int)
 
 QDeclarativeListScriptClass (QDeclarativeEngine *)
 
 ~QDeclarativeListScriptClass ()
 
- 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)
 
virtual void setProperty (Object *, const Identifier &name, const QScriptValue &)
 
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 ~QScriptDeclarativeClass ()
 

Protected Functions

virtual Value property (Object *, const Identifier &)
 
virtual QScriptClass::QueryFlags queryProperty (Object *, const Identifier &, QScriptClass::QueryFlags flags)
 
virtual QVariant toVariant (Object *, bool *ok)
 

Properties

QDeclarativeEngineengine
 
quint32 lastIndex
 
PersistentIdentifier m_lengthId
 

Additional Inherited Members

- Public Types inherited from QScriptDeclarativeClass
typedef void * Identifier
 
- 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 62 of file qdeclarativelistscriptclass_p.h.

Constructors and Destructors

◆ QDeclarativeListScriptClass()

QDeclarativeListScriptClass::QDeclarativeListScriptClass ( QDeclarativeEngine e)

Definition at line 56 of file qdeclarativelistscriptclass.cpp.

58 {
60  Q_UNUSED(scriptEngine);
61 
63 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
PersistentIdentifier createPersistentIdentifier(const QString &)
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptEngine * engine() const
QScriptDeclarativeClass(QScriptEngine *engine)
#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

◆ ~QDeclarativeListScriptClass()

QDeclarativeListScriptClass::~QDeclarativeListScriptClass ( )

Definition at line 65 of file qdeclarativelistscriptclass.cpp.

66 {
67 }

Functions

◆ newList() [1/2]

QScriptValue QDeclarativeListScriptClass::newList ( QObject object,
int  propId,
int  propType 
)

Definition at line 69 of file qdeclarativelistscriptclass.cpp.

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

70 {
72 
73  if (!object || propId == -1)
74  return scriptEngine->nullValue();
75 
76  ListData *data = new ListData;
77  data->object = object;
78  data->propertyType = propType;
79  void *args[] = { &data->property, 0 };
80  QMetaObject::metacall(object, QMetaObject::ReadProperty, propId, args);
81 
82  return newObject(scriptEngine, this, data);
83 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *)
static int metacall(QObject *, Call, int, void **)
static Object * object(const QScriptValue &)
QDeclarativeGuard< QObject > object
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptEngine * engine() const
static const char * data(const QByteArray &arr)
QDeclarativeListProperty< QObject > property
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ newList() [2/2]

QScriptValue QDeclarativeListScriptClass::newList ( const QDeclarativeListProperty< QObject > &  prop,
int  propType 
)

Definition at line 85 of file qdeclarativelistscriptclass.cpp.

86 {
88 
89  ListData *data = new ListData;
90  data->object = prop.object;
91  data->property = prop;
92  data->propertyType = propType;
93 
94  return newObject(scriptEngine, this, data);
95 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *)
QDeclarativeGuard< QObject > object
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptEngine * engine() const
static const char * data(const QByteArray &arr)
QDeclarativeListProperty< QObject > property

◆ property()

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

Reimplemented from QScriptDeclarativeClass.

Definition at line 117 of file qdeclarativelistscriptclass.cpp.

118 {
121 
122  ListData *data = (ListData *)obj;
123  if (!data->object)
124  return Value();
125 
126  quint32 count = data->property.count?data->property.count(&data->property):0;
127 
128  if (name == m_lengthId.identifier)
129  return Value(scriptEngine, count);
130  else if (lastIndex < count && data->property.at)
131  return Value(scriptEngine, enginePriv->objectClass->newQObject(data->property.at(&data->property, lastIndex)));
132  else
133  return Value();
134 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QDeclarativeGuard< QObject > object
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
The QScriptEngine class provides an environment for evaluating Qt Script code.
const char * name
QScriptEngine * engine() const
static const char * data(const QByteArray &arr)
QDeclarativeListProperty< QObject > property
QDeclarativeObjectScriptClass * objectClass
unsigned int quint32
Definition: qglobal.h:938
virtual Value property(Object *, const Identifier &)

◆ queryProperty()

QScriptClass::QueryFlags QDeclarativeListScriptClass::queryProperty ( Object object,
const Identifier name,
QScriptClass::QueryFlags  flags 
)
protectedvirtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 98 of file qdeclarativelistscriptclass.cpp.

100 {
101  Q_UNUSED(object);
102  Q_UNUSED(flags);
103  if (name == m_lengthId.identifier)
105 
106  bool ok = false;
107  quint32 idx = toArrayIndex(name, &ok);
108 
109  if (ok) {
110  lastIndex = idx;
112  } else {
113  return 0;
114  }
115 }
const char * name
quint32 toArrayIndex(const Identifier &, bool *ok)
unsigned int quint32
Definition: qglobal.h:938
#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

◆ toVariant()

QVariant QDeclarativeListScriptClass::toVariant ( Object obj,
bool *  ok 
)
protectedvirtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 136 of file qdeclarativelistscriptclass.cpp.

137 {
138  ListData *data = (ListData *)obj;
139 
140  if (!data->object) {
141  if (ok) *ok = false;
142  return QVariant();
143  }
144 
146 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeGuard< QObject > object
static QDeclarativeListReference init(const QDeclarativeListProperty< QObject > &, int, QDeclarativeEngine *)
QScriptEngine * engine() const
static const char * data(const QByteArray &arr)
QDeclarativeListProperty< QObject > property
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336

Properties

◆ engine

QDeclarativeEngine* QDeclarativeListScriptClass::engine
private

Definition at line 79 of file qdeclarativelistscriptclass_p.h.

◆ lastIndex

quint32 QDeclarativeListScriptClass::lastIndex
private

Definition at line 81 of file qdeclarativelistscriptclass_p.h.

Referenced by property(), and queryProperty().

◆ m_lengthId

PersistentIdentifier QDeclarativeListScriptClass::m_lengthId
private

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