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

#include <qdeclarativevaluetypescriptclass_p.h>

Inheritance diagram for QDeclarativeValueTypeScriptClass:
QScriptDeclarativeClass

Public Functions

QScriptValue newObject (QObject *object, int coreIndex, QDeclarativeValueType *)
 
QScriptValue newObject (const QVariant &, QDeclarativeValueType *)
 
virtual Value property (Object *, const Identifier &)
 
 QDeclarativeValueTypeScriptClass (QDeclarativeEngine *)
 
virtual QScriptClass::QueryFlags queryProperty (Object *, const Identifier &, QScriptClass::QueryFlags flags)
 
virtual void setProperty (Object *, const Identifier &name, const QScriptValue &)
 
virtual QVariant toVariant (Object *, bool *ok=0)
 
QVariant toVariant (const QScriptValue &)
 
 ~QDeclarativeValueTypeScriptClass ()
 
- 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 ~QScriptDeclarativeClass ()
 

Properties

QDeclarativeEngineengine
 
int m_lastIndex
 

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 63 of file qdeclarativevaluetypescriptclass_p.h.

Constructors and Destructors

◆ QDeclarativeValueTypeScriptClass()

QDeclarativeValueTypeScriptClass::QDeclarativeValueTypeScriptClass ( QDeclarativeEngine bindEngine)

Definition at line 71 of file qdeclarativevaluetypescriptclass.cpp.

73 {
74 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
QScriptEngine * engine() const
QScriptDeclarativeClass(QScriptEngine *engine)

◆ ~QDeclarativeValueTypeScriptClass()

QDeclarativeValueTypeScriptClass::~QDeclarativeValueTypeScriptClass ( )

Definition at line 76 of file qdeclarativevaluetypescriptclass.cpp.

77 {
78 }

Functions

◆ newObject() [1/2]

QScriptValue QDeclarativeValueTypeScriptClass::newObject ( QObject object,
int  coreIndex,
QDeclarativeValueType type 
)

Definition at line 80 of file qdeclarativevaluetypescriptclass.cpp.

Referenced by QDeclarativeObjectScriptClass::property().

81 {
83  ref->type = type;
84  ref->object = object;
85  ref->property = coreIndex;
87  return QScriptDeclarativeClass::newObject(scriptEngine, this, ref);
88 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
int type
Definition: qmetatype.cpp:239
static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *)
static Object * object(const QScriptValue &)
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptEngine * engine() const

◆ newObject() [2/2]

QScriptValue QDeclarativeValueTypeScriptClass::newObject ( const QVariant v,
QDeclarativeValueType type 
)

Definition at line 90 of file qdeclarativevaluetypescriptclass.cpp.

91 {
93  copy->type = type;
94  copy->value = v;
96  return QScriptDeclarativeClass::newObject(scriptEngine, this, copy);
97 }
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
int type
Definition: qmetatype.cpp:239
static QScriptValue newObject(QScriptEngine *, QScriptDeclarativeClass *, Object *)
The QScriptEngine class provides an environment for evaluating Qt Script code.
QScriptEngine * engine() const

◆ property()

QDeclarativeValueTypeScriptClass::Value QDeclarativeValueTypeScriptClass::property ( Object obj,
const Identifier  
)
virtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 133 of file qdeclarativevaluetypescriptclass.cpp.

134 {
136 
137  QVariant rv;
140 
142  ref->type->read(ref->object, ref->property);
143  rv = p.read(ref->type);
144  } else {
145  QDeclarativeValueTypeCopy *copy = static_cast<QDeclarativeValueTypeCopy *>(obj);
146 
148  copy->type->setValue(copy->value);
149  rv = p.read(copy->type);
150  }
151 
153  return Value(scriptEngine, static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv));
154 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static QScriptEngine * getScriptEngine(QDeclarativeEngine *e)
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
The QScriptEngine class provides an environment for evaluating Qt Script code.
virtual void setValue(QVariant)=0
QScriptEngine * engine() const
QVariant read(const QObject *obj) const
Reads the property&#39;s value from the given object.
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
virtual void read(QObject *, int)=0

◆ queryProperty()

QScriptClass::QueryFlags QDeclarativeValueTypeScriptClass::queryProperty ( Object obj,
const Identifier name,
QScriptClass::QueryFlags  flags 
)
virtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 100 of file qdeclarativevaluetypescriptclass.cpp.

102 {
104 
105  m_lastIndex = -1;
106 
107  QByteArray propName = toString(name).toUtf8();
108 
109  m_lastIndex = o->type->metaObject()->indexOfProperty(propName.constData());
110  if (m_lastIndex == -1)
111  return 0;
112 
113  QScriptClass::QueryFlags rv = 0;
114 
117 
118  if (!ref->object)
119  return 0;
120 
122 
124  if (prop.isWritable())
126  } else {
128  }
129 
130  return rv;
131 }
bool isWritable() const
Returns true if this property is writable; otherwise returns false.
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
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
const char * name
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
QString toString(const Identifier &)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.

◆ setProperty()

void QDeclarativeValueTypeScriptClass::setProperty ( Object obj,
const Identifier name,
const QScriptValue value 
)
virtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 156 of file qdeclarativevaluetypescriptclass.cpp.

158 {
160 
162 
165 
166  ref->type->read(ref->object, ref->property);
168 
169  QDeclarativeBinding *newBinding = 0;
170  if (value.isFunction() && !value.isRegExp()) {
172 
175  cacheData.propType = ref->object->metaObject()->property(ref->property).userType();
176  cacheData.coreIndex = ref->property;
177 
179  valueTypeData.valueTypeCoreIdx = m_lastIndex;
180  valueTypeData.valueTypePropType = p.userType();
181 
182  newBinding = new QDeclarativeBinding(value, ref->object, ctxt);
183  QScriptContextInfo ctxtInfo(context());
184  newBinding->setSourceLocation(ctxtInfo.fileName(), ctxtInfo.functionStartLineNumber());
185  QDeclarativeProperty prop = QDeclarativePropertyPrivate::restore(cacheData, valueTypeData, ref->object, ctxt);
186  newBinding->setTarget(prop);
187  if (newBinding->expression().contains(QLatin1String("this")))
189  }
190 
191  QDeclarativeAbstractBinding *delBinding =
193  if (delBinding)
194  delBinding->destroy();
195 
196  if (p.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double)
197  v = v.toInt();
198  p.write(ref->type, v);
199  ref->type->write(ref->object, ref->property, 0);
200 
201  } else {
202  QDeclarativeValueTypeCopy *copy = static_cast<QDeclarativeValueTypeCopy *>(obj);
203  copy->type->setValue(copy->value);
205  p.write(copy->type, v);
206  copy->value = copy->type->value();
207  }
208 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
virtual QVariant value()=0
bool isFunction() const
Returns true if this QScriptValue is a function; otherwise returns false.
void setTarget(const QDeclarativeProperty &)
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual void write(QObject *, int, QDeclarativePropertyPrivate::WriteFlags flags)=0
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QVariant scriptValueToVariant(const QScriptValue &, int hint=QVariant::Invalid)
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
bool isEnumType() const
Returns true if the property&#39;s type is an enumeration value; otherwise returns false.
int userType() const
Returns this property&#39;s user type.
virtual void setValue(QVariant)=0
QScriptEngine * engine() const
Type
These are the built-in types supported by QMetaType:
Definition: qmetatype.h:64
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
void setEvaluateFlags(EvaluateFlags flags)
The QScriptContextInfo class provides additional information about a QScriptContext.
bool isRegExp() const
Returns true if this QScriptValue is an object of the RegExp class; otherwise returns false...
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *)
virtual QString expression() const
void setSourceLocation(const QString &fileName, int line)
Set the location of this expression to line of url.
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
The QMetaProperty class provides meta-data about a property.
Definition: qmetaobject.h:176
bool write(QObject *obj, const QVariant &value) const
Writes value as the property&#39;s value to the given object.
QScriptContext * context() const
QDeclarativeContextData * getContext(QScriptContext *)
Returns the QDeclarativeContext for the executing QScript ctxt.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QMetaProperty property(int index) const
Returns the meta-data for the property with the given index.
EvaluateFlags evaluateFlags() const
virtual void read(QObject *, int)=0

◆ toVariant() [1/2]

QVariant QDeclarativeValueTypeScriptClass::toVariant ( Object obj,
bool *  ok = 0 
)
virtual

Reimplemented from QScriptDeclarativeClass.

Definition at line 210 of file qdeclarativevaluetypescriptclass.cpp.

Referenced by toVariant().

211 {
213 
216 
217  if (ok) *ok = true;
218 
219  if (ref->object) {
220  ref->type->read(ref->object, ref->property);
221  return ref->type->value();
222  }
223  } else {
224  QDeclarativeValueTypeCopy *copy = static_cast<QDeclarativeValueTypeCopy *>(obj);
225 
226  if (ok) *ok = true;
227 
228  return copy->value;
229  }
230 
231  return QVariant();
232 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual QVariant value()=0
virtual void read(QObject *, int)=0

◆ toVariant() [2/2]

QVariant QDeclarativeValueTypeScriptClass::toVariant ( const QScriptValue value)

Definition at line 234 of file qdeclarativevaluetypescriptclass.cpp.

235 {
236  Q_ASSERT(scriptClass(value) == this);
237 
238  return toVariant(object(value), 0);
239 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual QVariant toVariant(Object *, bool *ok=0)
static QScriptDeclarativeClass * scriptClass(const QScriptValue &)

Properties

◆ engine

QDeclarativeEngine* QDeclarativeValueTypeScriptClass::engine
private

Definition at line 80 of file qdeclarativevaluetypescriptclass_p.h.

◆ m_lastIndex

int QDeclarativeValueTypeScriptClass::m_lastIndex
private

Definition at line 81 of file qdeclarativevaluetypescriptclass_p.h.

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


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