Qt 4.8
Classes | Public Functions | Static Public Functions | Public Variables | Static Public Variables | List of all members
QDeclarativeEnginePrivate Class Reference

#include <qdeclarativeengine_p.h>

Inheritance diagram for QDeclarativeEnginePrivate:
QObjectPrivate QObjectData

Classes

struct  CapturedProperty
 
struct  SimpleList
 

Public Functions

QDeclarativePropertyCachecache (QObject *obj)
 Returns a QDeclarativePropertyCache for obj if one is available. More...
 
QDeclarativePropertyCachecache (const QMetaObject *)
 Returns a QDeclarativePropertyCache for metaObject. More...
 
QDeclarativePropertyCachecache (QDeclarativeType *, int, QDeclarativeError &error)
 Returns a QDeclarativePropertyCache for type with minorVersion. More...
 
QDeclarativePropertyCachecreateCache (const QMetaObject *)
 
QDeclarativePropertyCachecreateCache (QDeclarativeType *, int, QDeclarativeError &error)
 
QNetworkAccessManagercreateNetworkAccessManager (QObject *parent) const
 
QDeclarativeContextDatagetContext (QScriptContext *)
 Returns the QDeclarativeContext for the executing QScript ctxt. More...
 
QImage getImageFromProvider (const QUrl &url, QSize *size, const QSize &req_size)
 
QDeclarativeImageProvider::ImageType getImageProviderType (const QUrl &url)
 
QNetworkAccessManagergetNetworkAccessManager () const
 
QPixmap getPixmapFromProvider (const QUrl &url, QSize *size, const QSize &req_size)
 
quint32 getUniqueId () const
 
QUrl getUrl (QScriptContext *)
 Returns the QUrl associated with the script ctxt for the case that there is no QDeclarativeContext. More...
 
QDeclarativeWorkerScriptEnginegetWorkerScriptEngine ()
 
void init ()
 
bool isList (int) const
 
bool isQObject (int)
 
int listType (int) const
 
const QMetaObjectmetaObjectForType (int) const
 
 QDeclarativeEnginePrivate (QDeclarativeEngine *)
 
const QMetaObjectrawMetaObjectForType (int) const
 
void registerCompositeType (QDeclarativeCompiledData *)
 
void registerFinalizedParserStatusObject (QObject *obj, int index)
 
QScriptValue scriptValueFromVariant (const QVariant &)
 
QVariant scriptValueToVariant (const QScriptValue &, int hint=QVariant::Invalid)
 
void sendQuit ()
 
QObjecttoQObject (const QVariant &, bool *ok=0) const
 
QDeclarativeMetaType::TypeCategory typeCategory (int) const
 
void warning (const QDeclarativeError &)
 
void warning (const QList< QDeclarativeError > &)
 
 ~QDeclarativeEnginePrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static QScriptValue atob (QScriptContext *, QScriptEngine *)
 
static QScriptValue btoa (QScriptContext *, QScriptEngine *)
 
static void clear (SimpleList< QDeclarativeAbstractBinding > &)
 
static void clear (SimpleList< QDeclarativeParserStatus > &)
 
static QScriptValue consoleLog (QScriptContext *, QScriptEngine *)
 
static QScriptValue createComponent (QScriptContext *, QScriptEngine *)
 
static QScriptValue createQmlObject (QScriptContext *, QScriptEngine *)
 
static QScriptValue darker (QScriptContext *, QScriptEngine *)
 
static void defineModule ()
 
static void defineModuleCompat ()
 
static QScriptValue desktopOpenUrl (QScriptContext *, QScriptEngine *)
 
static QScriptValue fontFamilies (QScriptContext *, QScriptEngine *)
 
static QScriptValue formatDate (QScriptContext *, QScriptEngine *)
 
static QScriptValue formatDateTime (QScriptContext *, QScriptEngine *)
 
static QScriptValue formatTime (QScriptContext *, QScriptEngine *)
 
static QDeclarativeEnginePrivateget (QDeclarativeEngine *e)
 
static QDeclarativeEnginePrivateget (QDeclarativeContext *c)
 
static QDeclarativeEnginePrivateget (QDeclarativeContextData *c)
 
static QDeclarativeEnginePrivateget (QScriptEngine *e)
 
static QDeclarativeEngineget (QDeclarativeEnginePrivate *p)
 
static QDeclarativeEnginegetEngine (QScriptEngine *e)
 
static QScriptEnginegetScriptEngine (QDeclarativeEngine *e)
 
static QScriptValue hsla (QScriptContext *, QScriptEngine *)
 
static QScriptValue isQtObject (QScriptContext *, QScriptEngine *)
 
static QScriptValue lighter (QScriptContext *, QScriptEngine *)
 
static QScriptValue md5 (QScriptContext *, QScriptEngine *)
 
static QScriptValue point (QScriptContext *, QScriptEngine *)
 
static QScriptValue qmlScriptObject (QObject *, QDeclarativeEngine *)
 Creates a QScriptValue allowing you to use object in QML script. More...
 
static QScriptValue quit (QScriptContext *, QScriptEngine *)
 
static QScriptValue rect (QScriptContext *, QScriptEngine *)
 
static QScriptValue rgba (QScriptContext *, QScriptEngine *)
 
static QScriptValue size (QScriptContext *, QScriptEngine *)
 
static QScriptValue tint (QScriptContext *, QScriptEngine *)
 
static QString urlToLocalFileOrQrc (const QUrl &url)
 
static QScriptValue vector3d (QScriptContext *, QScriptEngine *)
 
static void warning (QDeclarativeEngine *, const QDeclarativeError &)
 
static void warning (QDeclarativeEngine *, const QList< QDeclarativeError > &)
 
static void warning (QDeclarativeEnginePrivate *, const QDeclarativeError &)
 
static void warning (QDeclarativeEnginePrivate *, const QList< QDeclarativeError > &)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

QUrl baseUrl
 
QList< SimpleList< QDeclarativeAbstractBinding > > bindValues
 
QPODVector< CapturedProperty, 16 > capturedProperties
 
bool captureProperties
 
QDeclarativeCleanupcleanup
 
QDeclarativeComponentAttachedcomponentAttached
 
QDeclarativeContextScriptClasscontextClass
 
QDeclarativeDelayedErrorerroredBindings
 
QList< QPair< QDeclarativeGuard< QObject >, int > > finalizedParserStatus
 
QDeclarativeGlobalScriptClassglobalClass
 
QHash< QString, QSharedPointer< QDeclarativeImageProvider > > imageProviders
 
QDeclarativeImportDatabase importDatabase
 
bool inBeginCreate
 
int inProgressCreations
 
bool isDebugging
 
QDeclarativeListScriptClasslistClass
 
QHash< int, QDeclarativeCompiledData * > m_compositeTypes
 
QHash< int, int > m_qmlLists
 
QHash< QString, QScriptValuem_sharedScriptImports
 
QMutex mutex
 
QNetworkAccessManagernetworkAccessManager
 
QDeclarativeNetworkAccessManagerFactorynetworkAccessManagerFactory
 
QDeclarativeObjectScriptClassobjectClass
 
QString offlineStoragePath
 
bool outputWarningsToStdErr
 
QList< SimpleList< QDeclarativeParserStatus > > parserStatus
 
QHash< const QMetaObject *, QDeclarativePropertyCache * > propertyCache
 
QDeclarativeContextrootContext
 
QDeclarativeScriptEngine scriptEngine
 
QDeclarativeContextDatasharedContext
 
QObjectsharedScope
 
QDeclarativeTypeLoader typeLoader
 
QDeclarativeTypeNameScriptClasstypeNameClass
 
QHash< QPair< QDeclarativeType *, int >, QDeclarativePropertyCache * > typePropertyCache
 
quint32 uniqueId
 
QDeclarativeValueTypeScriptClassvalueTypeClass
 
QDeclarativeValueTypeFactory valueTypes
 
QDeclarativeWorkerScriptEngineworkerScriptEngine
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Static Public Variables

static bool qml_debugging_enabled = false
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 139 of file qdeclarativeengine_p.h.

Constructors and Destructors

◆ QDeclarativeEnginePrivate()

QDeclarativeEnginePrivate::QDeclarativeEnginePrivate ( QDeclarativeEngine e)

Definition at line 357 of file qdeclarativeengine.cpp.

358 : captureProperties(false), rootContext(0), isDebugging(false),
364 {
371  }
373 }
QDeclarativeCleanup * cleanup
QDeclarativeNetworkAccessManagerFactory * networkAccessManagerFactory
QDeclarativeGlobalScriptClass * globalClass
QDeclarativeTypeLoader typeLoader
QDeclarativeContext * rootContext
QDeclarativeScriptEngine scriptEngine
QDeclarativeWorkerScriptEngine * workerScriptEngine
QDeclarativeImportDatabase importDatabase
QDeclarativeValueTypeScriptClass * valueTypeClass
QDeclarativeContextData * sharedContext
static bool qt_QmlQtModule_registered
QDeclarativeObjectScriptClass * objectClass
QDeclarativeDelayedError * erroredBindings
QDeclarativeComponentAttached * componentAttached
QNetworkAccessManager * networkAccessManager
QDeclarativeContextScriptClass * contextClass

◆ ~QDeclarativeEnginePrivate()

QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate ( )

Definition at line 495 of file qdeclarativeengine.cpp.

496 {
498  Q_ASSERT(bindValues.isEmpty());
499  Q_ASSERT(parserStatus.isEmpty());
500 
501  while (cleanup) {
503  cleanup = c->next;
504  if (cleanup) cleanup->prev = &cleanup;
505  c->next = 0;
506  c->prev = 0;
507  c->clear();
508  }
509 
510  delete rootContext;
511  rootContext = 0;
512  delete contextClass;
513  contextClass = 0;
514  delete objectClass;
515  objectClass = 0;
516  delete valueTypeClass;
517  valueTypeClass = 0;
518  delete typeNameClass;
519  typeNameClass = 0;
520  delete listClass;
521  listClass = 0;
522  delete globalClass;
523  globalClass = 0;
524 
526  (*iter)->release();
528  (*iter)->release();
530  (*iter)->release();
531 
532 }
QDeclarativeCleanup * cleanup
QDeclarativeTypeNameScriptClass * typeNameClass
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
unsigned char c[8]
Definition: qnumeric_p.h:62
QDeclarativeGlobalScriptClass * globalClass
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QDeclarativeContext * rootContext
QDeclarativeCleanup ** prev
QHash< QPair< QDeclarativeType *, int >, QDeclarativePropertyCache * > typePropertyCache
QDeclarativeValueTypeScriptClass * valueTypeClass
QHash< int, QDeclarativeCompiledData * > m_compositeTypes
QList< SimpleList< QDeclarativeAbstractBinding > > bindValues
QDeclarativeObjectScriptClass * objectClass
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
virtual void clear()=0
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
QDeclarativeListScriptClass * listClass
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
The QDeclarativeCleanup provides a callback when a QDeclarativeEngine is deleted. ...
QDeclarativeCleanup * next
QHash< const QMetaObject *, QDeclarativePropertyCache * > propertyCache
QList< SimpleList< QDeclarativeParserStatus > > parserStatus
QDeclarativeContextScriptClass * contextClass

Functions

◆ atob()

QScriptValue QDeclarativeEnginePrivate::atob ( QScriptContext ctxt,
QScriptEngine  
)
static

Definition at line 1942 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1943 {
1944  if (ctxt->argumentCount() != 1)
1945  return ctxt->throwError(QLatin1String("Qt.atob(): Invalid arguments"));
1946 
1947  QByteArray data = ctxt->argument(0).toString().toUtf8();
1948 
1950 }
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
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
static QByteArray fromBase64(const QByteArray &base64)
Returns a decoded copy of the Base64 array base64.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ btoa()

QScriptValue QDeclarativeEnginePrivate::btoa ( QScriptContext ctxt,
QScriptEngine  
)
static

Definition at line 1927 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1928 {
1929  if (ctxt->argumentCount() != 1)
1930  return ctxt->throwError(QLatin1String("Qt.btoa(): Invalid arguments"));
1931 
1932  QByteArray data = ctxt->argument(0).toString().toUtf8();
1933 
1934  return QScriptValue(QLatin1String(data.toBase64()));
1935 }
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
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
QByteArray toBase64() const
Returns a copy of the byte array, encoded as Base64.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ cache() [1/3]

QDeclarativePropertyCache * QDeclarativeEnginePrivate::cache ( QObject obj)
inline

Returns a QDeclarativePropertyCache for obj if one is available.

If obj is null, being deleted or contains a dynamic meta object 0 is returned.

The returned cache is not referenced, so if it is to be stored, call addref().

Definition at line 340 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeCompiler::compile(), QDeclarativeCompiledData::TypeReference::createPropertyCache(), QDeclarativePropertyCache::property(), and QDeclarativeObjectScriptClass::propertyNames().

341 {
343  return 0;
344 
345  const QMetaObject *mo = obj->metaObject();
347  if (!rv) rv = createCache(mo);
348  return rv;
349 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
uint wasDeleted
Definition: qobject.h:98
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QMetaObject * metaObject
Definition: qobject.h:107
QHash< const QMetaObject *, QDeclarativePropertyCache * > propertyCache
QDeclarativePropertyCache * createCache(const QMetaObject *)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ cache() [2/3]

QDeclarativePropertyCache * QDeclarativeEnginePrivate::cache ( const QMetaObject metaObject)
inline

Returns a QDeclarativePropertyCache for metaObject.

As the cache is persisted for the life of the engine, metaObject must be a static "compile time" meta-object, or a meta-object that is otherwise known to exist for the lifetime of the QDeclarativeEngine.

The returned cache is not referenced, so if it is to be stored, call addref().

Definition at line 360 of file qdeclarativeengine_p.h.

361 {
362  Q_ASSERT(metaObject);
363 
365  if (!rv) rv = createCache(metaObject);
366  return rv;
367 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< const QMetaObject *, QDeclarativePropertyCache * > propertyCache
QDeclarativePropertyCache * createCache(const QMetaObject *)

◆ cache() [3/3]

QDeclarativePropertyCache * QDeclarativeEnginePrivate::cache ( QDeclarativeType type,
int  minorVersion,
QDeclarativeError error 
)
inline

Returns a QDeclarativePropertyCache for type with minorVersion.

The returned cache is not referenced, so if it is to be stored, call addref().

Definition at line 374 of file qdeclarativeengine_p.h.

375 {
376  Q_ASSERT(type);
377 
378  if (minorVersion == -1 || !type->containsRevisionedAttributes())
379  return cache(type->metaObject());
380 
381  QDeclarativePropertyCache *rv = typePropertyCache.value(qMakePair(type, minorVersion));
382  if (!rv) rv = createCache(type, minorVersion, error);
383  return rv;
384 }
QDeclarativePropertyCache * cache(QObject *obj)
Returns a QDeclarativePropertyCache for obj if one is available.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool containsRevisionedAttributes() const
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< QPair< QDeclarativeType *, int >, QDeclarativePropertyCache * > typePropertyCache
const QMetaObject * metaObject() const
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
QDeclarativePropertyCache * createCache(const QMetaObject *)

◆ clear() [1/2]

void QDeclarativeEnginePrivate::clear ( SimpleList< QDeclarativeAbstractBinding > &  bvs)
static

Definition at line 534 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeComponentPrivate::complete().

535 {
536  bvs.clear();
537 }

◆ clear() [2/2]

void QDeclarativeEnginePrivate::clear ( SimpleList< QDeclarativeParserStatus > &  pss)
static

Definition at line 539 of file qdeclarativeengine.cpp.

540 {
541  for (int ii = 0; ii < pss.count; ++ii) {
542  QDeclarativeParserStatus *ps = pss.at(ii);
543  if(ps)
544  ps->d = 0;
545  }
546  pss.clear();
547 }
QDeclarativeParserStatus ** d
The QDeclarativeParserStatus class provides updates on the QML parser state.

◆ consoleLog()

QScriptValue QDeclarativeEnginePrivate::consoleLog ( QScriptContext ctxt,
QScriptEngine e 
)
static

Definition at line 1952 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1953 {
1954  if(ctxt->argumentCount() < 1)
1955  return e->newVariant(QVariant(false));
1956 
1957  QByteArray msg;
1958 
1959  for (int i=0; i<ctxt->argumentCount(); ++i) {
1960  if (!msg.isEmpty()) msg += ' ';
1961  msg += ctxt->argument(i).toString().toLocal8Bit();
1962  // does not support firebug "%[a-z]" formatting, since firebug really
1963  // does just ignore the format letter, which makes it pointless.
1964  }
1965 
1966  qDebug("%s",msg.constData());
1967 
1968  return e->newVariant(QVariant(true));
1969 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
Q_CORE_EXPORT void qDebug(const char *,...)
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue newVariant(const QVariant &value)
Creates a QtScript object holding the given variant value.

◆ createCache() [1/2]

QDeclarativePropertyCache * QDeclarativeEnginePrivate::createCache ( const QMetaObject mo)

Definition at line 2352 of file qdeclarativeengine.cpp.

2353 {
2355 
2356  if (!mo->superClass()) {
2358  propertyCache.insert(mo, rv);
2359  return rv;
2360  } else {
2361  QDeclarativePropertyCache *super = cache(mo->superClass());
2362  QDeclarativePropertyCache *rv = super->copy();
2363  rv->append(q, mo);
2364  propertyCache.insert(mo, rv);
2365  return rv;
2366  }
2367 }
QDeclarativePropertyCache * cache(QObject *obj)
Returns a QDeclarativePropertyCache for obj if one is available.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
void append(QDeclarativeEngine *, const QMetaObject *, Data::Flag propertyFlags=Data::NoFlags, Data::Flag methodFlags=Data::NoFlags, Data::Flag signalFlags=Data::NoFlags)
The QDeclarativeEngine class provides an environment for instantiating QML components.
QHash< const QMetaObject *, QDeclarativePropertyCache * > propertyCache
QDeclarativePropertyCache * copy() const

◆ createCache() [2/2]

QDeclarativePropertyCache * QDeclarativeEnginePrivate::createCache ( QDeclarativeType type,
int  minorVersion,
QDeclarativeError error 
)

Definition at line 2369 of file qdeclarativeengine.cpp.

2371 {
2373 
2374  int maxMinorVersion = 0;
2375 
2376  const QMetaObject *metaObject = type->metaObject();
2377  while (metaObject) {
2378  QDeclarativeType *t = QDeclarativeMetaType::qmlType(metaObject, type->module(),
2379  type->majorVersion(), minorVersion);
2380  if (t) {
2381  maxMinorVersion = qMax(maxMinorVersion, t->minorVersion());
2382  types << t;
2383  } else {
2384  types << 0;
2385  }
2386 
2387  metaObject = metaObject->superClass();
2388  }
2389 
2390  if (QDeclarativePropertyCache *c = typePropertyCache.value(qMakePair(type, maxMinorVersion))) {
2391  c->addref();
2392  typePropertyCache.insert(qMakePair(type, minorVersion), c);
2393  return c;
2394  }
2395 
2396  QDeclarativePropertyCache *raw = cache(type->metaObject());
2397 
2398  bool hasCopied = false;
2399 
2400  for (int ii = 0; ii < types.count(); ++ii) {
2401  QDeclarativeType *currentType = types.at(ii);
2402  if (!currentType)
2403  continue;
2404 
2405  int rev = currentType->metaObjectRevision();
2406  int moIndex = types.count() - 1 - ii;
2407 
2408  if (raw->allowedRevisionCache[moIndex] != rev) {
2409  if (!hasCopied) {
2410  raw = raw->copy();
2411  hasCopied = true;
2412  }
2413  raw->allowedRevisionCache[moIndex] = rev;
2414  }
2415  }
2416 
2417  // Test revision compatibility - the basic rule is:
2418  // * Anything that is excluded, cannot overload something that is not excluded *
2419 
2420  // Signals override:
2421  // * other signals and methods of the same name.
2422  // * properties named on<Signal Name>
2423  // * automatic <property name>Changed notify signals
2424 
2425  // Methods override:
2426  // * other methods of the same name
2427 
2428  // Properties override:
2429  // * other elements of the same name
2430 
2431  bool overloadError = false;
2432  QString overloadName;
2433 
2434 #if 0
2436  !overloadError && iter != raw->stringCache.end();
2437  ++iter) {
2438 
2440  if (raw->isAllowedInRevision(d))
2441  continue; // Not excluded - no problems
2442 
2443  // check that a regular "name" overload isn't happening
2445  while (!overloadError && current) {
2446  current = d->overrideData(current);
2447  if (current && raw->isAllowedInRevision(current))
2448  overloadError = true;
2449  }
2450  }
2451 #endif
2452 
2453  if (overloadError) {
2454  if (hasCopied) raw->release();
2455 
2456  error.setDescription(QLatin1String("Type ") + QString::fromUtf8(type->qmlTypeName()) + QLatin1String(" ") + QString::number(type->majorVersion()) + QLatin1String(".") + QString::number(minorVersion) + QLatin1String(" contains an illegal property \"") + overloadName + QLatin1String("\". This is an error in the type's implementation."));
2457  return 0;
2458  }
2459 
2460  if (!hasCopied) raw->addref();
2461  typePropertyCache.insert(qMakePair(type, minorVersion), raw);
2462 
2463  if (minorVersion != maxMinorVersion) {
2464  raw->addref();
2465  typePropertyCache.insert(qMakePair(type, maxMinorVersion), raw);
2466  }
2467 
2468  return raw;
2469 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
double d
Definition: qnumeric_p.h:62
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
QByteArray module() const
unsigned char c[8]
Definition: qnumeric_p.h:62
void setDescription(const QString &)
Sets the error description.
QDeclarativePropertyCache * cache(QObject *obj)
Returns a QDeclarativePropertyCache for obj if one is available.
static QDeclarativeType * qmlType(const QByteArray &, int, int)
Returns the type (if any) of URI-qualified named name in version specified by version_major and versi...
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
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
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
QByteArray qmlTypeName() const
QHash< QPair< QDeclarativeType *, int >, QDeclarativePropertyCache * > typePropertyCache
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
const QMetaObject * metaObject() const
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
static const struct @32 types[]
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
QMetaObject * metaObject
Definition: qobject.h:107
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
QDeclarativePropertyCache * copy() const
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ createComponent()

QScriptValue QDeclarativeEnginePrivate::createComponent ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1346 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1347 {
1348  QDeclarativeEnginePrivate *activeEnginePriv =
1349  static_cast<QDeclarativeScriptEngine*>(engine)->p;
1350  QDeclarativeEngine* activeEngine = activeEnginePriv->q_func();
1351 
1352  if(ctxt->argumentCount() != 1) {
1353  return ctxt->throwError(QLatin1String("Qt.createComponent(): Invalid arguments"));
1354  } else {
1355 
1356  QString arg = ctxt->argument(0).toString();
1357  if (arg.isEmpty())
1358  return engine->nullValue();
1359  QUrl url = QDeclarativeScriptEngine::get(engine)->resolvedUrl(ctxt, QUrl(arg));
1360  QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
1361  QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine);
1364  return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId<QDeclarativeComponent*>());
1365  }
1366 }
static QDeclarativeComponentPrivate * get(QDeclarativeComponent *c)
static QDeclarativeData * get(const QObject *object, bool create=false)
unsigned char c[8]
Definition: qnumeric_p.h:62
QDeclarativeGuardedContextData creationContext
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QDeclarativeScriptEngine * get(QScriptEngine *e)
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
The QDeclarativeComponent class encapsulates a QML component definition.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
QUrl resolvedUrl(QScriptContext *context, const QUrl &url)
QDeclarativeObjectScriptClass * objectClass
The QDeclarativeEngine class provides an environment for instantiating QML components.
QDeclarativeContextData * getContext(QScriptContext *)
Returns the QDeclarativeContext for the executing QScript ctxt.
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ createNetworkAccessManager()

QNetworkAccessManager * QDeclarativeEnginePrivate::createNetworkAccessManager ( QObject parent) const

Definition at line 749 of file qdeclarativeengine.cpp.

Referenced by QDeclarativePixmapReader::networkAccessManager().

750 {
751  QMutexLocker locker(&mutex);
754  nam = networkAccessManagerFactory->create(parent);
755  } else {
756  nam = new QNetworkAccessManager(parent);
757  }
758 
759  return nam;
760 }
virtual QNetworkAccessManager * create(QObject *parent)=0
Creates and returns a network access manager with the specified parent.
QDeclarativeNetworkAccessManagerFactory * networkAccessManagerFactory
The QNetworkAccessManager class allows the application to send network requests and receive replies...
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

◆ createQmlObject()

QScriptValue QDeclarativeEnginePrivate::createQmlObject ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1393 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1394 {
1395  QDeclarativeEnginePrivate *activeEnginePriv =
1396  static_cast<QDeclarativeScriptEngine*>(engine)->p;
1397  QDeclarativeEngine* activeEngine = activeEnginePriv->q_func();
1398 
1399  if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3)
1400  return ctxt->throwError(QLatin1String("Qt.createQmlObject(): Invalid arguments"));
1401 
1402  QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
1403  Q_ASSERT(context);
1404 
1405  QString qml = ctxt->argument(0).toString();
1406  if (qml.isEmpty())
1407  return engine->nullValue();
1408 
1409  QUrl url;
1410  if(ctxt->argumentCount() > 2)
1411  url = QUrl(ctxt->argument(2).toString());
1412  else
1413  url = QUrl(QLatin1String("inline"));
1414 
1415  if (url.isValid() && url.isRelative())
1416  url = context->resolvedUrl(url);
1417 
1418  QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1));
1419  if(!parentArg)
1420  return ctxt->throwError(QLatin1String("Qt.createQmlObject(): Missing parent object"));
1421 
1422  QDeclarativeComponent component(activeEngine);
1423  component.setData(qml.toUtf8(), url);
1424 
1425  if(component.isError()) {
1426  QList<QDeclarativeError> errors = component.errors();
1427  QString errstr = QLatin1String("Qt.createQmlObject() failed to create object: ");
1428  QScriptValue arr = ctxt->engine()->newArray(errors.length());
1429  int i = 0;
1430  foreach (const QDeclarativeError &error, errors){
1431  errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n");
1432  QScriptValue qmlErrObject = ctxt->engine()->newObject();
1433  qmlErrObject.setProperty(QLatin1String("lineNumber"), QScriptValue(error.line()));
1434  qmlErrObject.setProperty(QLatin1String("columnNumber"), QScriptValue(error.column()));
1435  qmlErrObject.setProperty(QLatin1String("fileName"), QScriptValue(error.url().toString()));
1436  qmlErrObject.setProperty(QLatin1String("message"), QScriptValue(error.description()));
1437  arr.setProperty(i++, qmlErrObject);
1438  }
1439  QScriptValue err = ctxt->throwError(errstr);
1440  err.setProperty(QLatin1String("qmlErrors"),arr);
1441  return err;
1442  }
1443 
1444  if (!component.isReady())
1445  return ctxt->throwError(QLatin1String("Qt.createQmlObject(): Component is not ready"));
1446 
1447  QObject *obj = component.beginCreate(context->asQDeclarativeContext());
1448  if(obj)
1450  component.completeCreate();
1451 
1452  if(component.isError()) {
1453  QList<QDeclarativeError> errors = component.errors();
1454  QString errstr = QLatin1String("Qt.createQmlObject() failed to create object: ");
1455  QScriptValue arr = ctxt->engine()->newArray(errors.length());
1456  int i = 0;
1457  foreach (const QDeclarativeError &error, errors){
1458  errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n");
1459  QScriptValue qmlErrObject = ctxt->engine()->newObject();
1460  qmlErrObject.setProperty(QLatin1String("lineNumber"), QScriptValue(error.line()));
1461  qmlErrObject.setProperty(QLatin1String("columnNumber"), QScriptValue(error.column()));
1462  qmlErrObject.setProperty(QLatin1String("fileName"), QScriptValue(error.url().toString()));
1463  qmlErrObject.setProperty(QLatin1String("message"), QScriptValue(error.description()));
1464  arr.setProperty(i++, qmlErrObject);
1465  }
1466  QScriptValue err = ctxt->throwError(errstr);
1467  err.setProperty(QLatin1String("qmlErrors"),arr);
1468  return err;
1469  }
1470 
1471  Q_ASSERT(obj);
1472 
1473  obj->setParent(parentArg);
1474 
1476  for (int ii = 0; ii < functions.count(); ++ii) {
1477  if (QDeclarativePrivate::Parented == functions.at(ii)(obj, parentArg))
1478  break;
1479  }
1480 
1482  return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar);
1483 }
QUrl resolvedUrl(const QUrl &)
static QDeclarativeData * get(const QObject *object, bool create=false)
QUrl url() const
Returns the url for the file that caused this error.
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
Definition: qurl.cpp:4303
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
#define error(msg)
QObject * toQObject(const QScriptValue &) const
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
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
QScriptEngine * engine() const
Returns the QScriptEngine that this QScriptContext belongs to.
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
QString toString() const
Returns the error as a human readable string.
The QDeclarativeComponent class encapsulates a QML component definition.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QString description() const
Returns the error description.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QScriptValue newObject()
Creates a QtScript object of class Object.
The QDeclarativeError class encapsulates a QML error.
static QList< QDeclarativePrivate::AutoParentFunction > parentFunctions()
static qreal component(const QPointF &point, unsigned int i)
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
int line() const
Returns the error line number.
QDeclarativeObjectScriptClass * objectClass
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
The QDeclarativeEngine class provides an environment for instantiating QML components.
int column() const
Returns the error column number.
QDeclarativeContext * asQDeclarativeContext()
int length() const
This function is identical to count().
Definition: qlist.h:281
QScriptValue newArray(uint length=0)
Creates a QtScript object of class Array with the given length.
QDeclarativeContextData * getContext(QScriptContext *)
Returns the QDeclarativeContext for the executing QScript ctxt.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ darker()

QScriptValue QDeclarativeEnginePrivate::darker ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1856 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1857 {
1858  if(ctxt->argumentCount() != 1 && ctxt->argumentCount() != 2)
1859  return ctxt->throwError(QLatin1String("Qt.darker(): Invalid arguments"));
1860  QVariant v = ctxt->argument(0).toVariant();
1861  QColor color;
1862  if (v.userType() == QVariant::Color)
1863  color = v.value<QColor>();
1864  else if (v.userType() == QVariant::String) {
1865  bool ok;
1867  if (!ok)
1868  return engine->nullValue();
1869  } else
1870  return engine->nullValue();
1871  qsreal factor = 2.0;
1872  if (ctxt->argumentCount() == 2)
1873  factor = ctxt->argument(1).toNumber();
1874  color = color.darker(int(qRound(factor*100.)));
1875  return engine->toScriptValue(QVariant::fromValue(color));
1876 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QColor Q_DECLARATIVE_PRIVATE_EXPORT colorFromString(const QString &, bool *ok=0)
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
double qsreal
Definition: qscriptvalue.h:52
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
QScriptValue argument(int index) const
Returns the function argument at the given index.
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ defineModule()

void QDeclarativeEnginePrivate::defineModule ( )
static

Definition at line 189 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeEnginePrivate().

190 {
191  qmlRegisterType<QDeclarativeComponent>("QtQuick",1,0,"Component");
192  qmlRegisterType<QObject>("QtQuick",1,0,"QtObject");
193  qmlRegisterType<QDeclarativeWorkerScript>("QtQuick",1,0,"WorkerScript");
194 
195  qmlRegisterType<QDeclarativeBinding>();
196 }

◆ defineModuleCompat()

void QDeclarativeEnginePrivate::defineModuleCompat ( )
static

Definition at line 198 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeMetaType::isModule().

199 {
200  qmlRegisterType<QDeclarativeComponent>("Qt",4,7,"Component");
201  qmlRegisterType<QObject>("Qt",4,7,"QtObject");
202  qmlRegisterType<QDeclarativeWorkerScript>("Qt",4,7,"WorkerScript");
203 }

◆ desktopOpenUrl()

QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl ( QScriptContext ctxt,
QScriptEngine e 
)
static

Definition at line 1882 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1883 {
1884  if(ctxt->argumentCount() < 1)
1885  return QScriptValue(e, false);
1886  bool ret = false;
1887 #ifndef QT_NO_DESKTOPSERVICES
1888  ret = QDesktopServices::openUrl(QDeclarativeScriptEngine::get(e)->resolvedUrl(ctxt, QUrl(ctxt->argument(0).toString())));
1889 #endif
1890  return QScriptValue(e, ret);
1891 }
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
static QDeclarativeScriptEngine * get(QScriptEngine *e)
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.
static bool openUrl(const QUrl &url)
Opens the given url in the appropriate Web browser for the user&#39;s desktop environment, and returns true if successful; otherwise returns false.

◆ fontFamilies()

QScriptValue QDeclarativeEnginePrivate::fontFamilies ( QScriptContext ctxt,
QScriptEngine e 
)
static

Definition at line 1898 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1899 {
1900  if(ctxt->argumentCount() != 0)
1901  return ctxt->throwError(QLatin1String("Qt.fontFamilies(): Invalid arguments"));
1902 
1904  QFontDatabase database;
1905  return p->scriptValueFromVariant(database.families());
1906 }
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
The QFontDatabase class provides information about the fonts available in the underlying window syste...
Definition: qfontdatabase.h:66
QStringList families(WritingSystem writingSystem=Any) const
Returns a sorted list of the available font families which support the writingSystem.
QScriptValue scriptValueFromVariant(const QVariant &)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.

◆ formatDate()

QScriptValue QDeclarativeEnginePrivate::formatDate ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1526 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1527 {
1528  int argCount = ctxt->argumentCount();
1529  if(argCount == 0 || argCount > 2)
1530  return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid arguments"));
1531 
1532  QDate date = ctxt->argument(0).toDateTime().date();
1534  if (argCount == 2) {
1535  QScriptValue formatArg = ctxt->argument(1);
1536  if (formatArg.isString()) {
1537  QString format = formatArg.toString();
1538  return engine->newVariant(QVariant::fromValue(date.toString(format)));
1539  } else if (formatArg.isNumber()) {
1540  enumFormat = Qt::DateFormat(formatArg.toUInt32());
1541  } else {
1542  return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid date format"));
1543  }
1544  }
1545  return engine->newVariant(QVariant::fromValue(date.toString(enumFormat)));
1546 }
QDateTime toDateTime() const
Returns a QDateTime representation of this value, in local time.
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
quint32 toUInt32() const
Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described ...
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
bool isNumber() const
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the date as a string.
Definition: qdatetime.cpp:823
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue newVariant(const QVariant &value)
Creates a QtScript object holding the given variant value.
DateFormat
Definition: qnamespace.h:1392

◆ formatDateTime()

QScriptValue QDeclarativeEnginePrivate::formatDateTime ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1680 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1681 {
1682  int argCount = ctxt->argumentCount();
1683  if(argCount == 0 || argCount > 2)
1684  return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid arguments"));
1685 
1686  QDateTime date = ctxt->argument(0).toDateTime();
1688  if (argCount == 2) {
1689  QScriptValue formatArg = ctxt->argument(1);
1690  if (formatArg.isString()) {
1691  QString format = formatArg.toString();
1692  return engine->newVariant(QVariant::fromValue(date.toString(format)));
1693  } else if (formatArg.isNumber()) {
1694  enumFormat = Qt::DateFormat(formatArg.toUInt32());
1695  } else {
1696  return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format"));
1697  }
1698  }
1699  return engine->newVariant(QVariant::fromValue(date.toString(enumFormat)));
1700 }
QDateTime toDateTime() const
Returns a QDateTime representation of this value, in local time.
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
Definition: qdatetime.cpp:2628
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
quint32 toUInt32() const
Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described ...
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
bool isNumber() const
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false...
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue newVariant(const QVariant &value)
Creates a QtScript object holding the given variant value.
DateFormat
Definition: qnamespace.h:1392

◆ formatTime()

QScriptValue QDeclarativeEnginePrivate::formatTime ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1561 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1562 {
1563  int argCount = ctxt->argumentCount();
1564  if(argCount == 0 || argCount > 2)
1565  return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid arguments"));
1566 
1567  QTime time;
1568  QScriptValue sv = ctxt->argument(0);
1569  if (sv.isDate())
1570  time = sv.toDateTime().time();
1571  else if (sv.toVariant().type() == QVariant::Time)
1572  time = sv.toVariant().toTime();
1573 
1575  if (argCount == 2) {
1576  QScriptValue formatArg = ctxt->argument(1);
1577  if (formatArg.isString()) {
1578  QString format = formatArg.toString();
1579  return engine->newVariant(QVariant::fromValue(time.toString(format)));
1580  } else if (formatArg.isNumber()) {
1581  enumFormat = Qt::DateFormat(formatArg.toUInt32());
1582  } else {
1583  return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid time format"));
1584  }
1585  }
1586  return engine->newVariant(QVariant::fromValue(time.toString(enumFormat)));
1587 }
QDateTime toDateTime() const
Returns a QDateTime representation of this value, in local time.
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QTime class provides clock time functions.
Definition: qdatetime.h:148
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
quint32 toUInt32() const
Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described ...
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the time as a string.
Definition: qdatetime.cpp:1653
bool isNumber() const
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false...
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
bool isDate() const
Returns true if this QScriptValue is an object of the Date class; otherwise returns false...
QTime time() const
Returns the time part of the datetime.
Definition: qdatetime.cpp:2368
QTime toTime() const
Returns the variant as a QTime if the variant has type() Time , DateTime , or String ; otherwise retu...
Definition: qvariant.cpp:2330
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue newVariant(const QVariant &value)
Creates a QtScript object holding the given variant value.
DateFormat
Definition: qnamespace.h:1392

◆ get() [1/5]

static QDeclarativeEnginePrivate* QDeclarativeEnginePrivate::get ( QDeclarativeEngine e)
inlinestatic

Definition at line 316 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeIntegerCache::add(), QDeclarativeTypeNameCache::add(), QDeclarativeContextData::addImportedScript(), QDeclarativePropertyCache::append(), QDeclarativeComponentPrivate::begin(), QDeclarativeCompiler::compile(), QDeclarativeComponentPrivate::completeCreate(), QDeclarativeObjectMethodScriptClass::connect(), QDeclarativeBinding::createBinding(), QDeclarativeComponentPrivate::createObject(), createPixmapDataSync(), QDeclarativeCompiledData::TypeReference::createPropertyCache(), QDeclarativeObjectScriptClass::destroy(), QDeclarativeObjectMethodScriptClass::disconnect(), QDeclarativeWorkerScript::engine(), QDeclarativeQtScriptExpression::eval(), QDeclarativeExpressionPrivate::evalInObjectScope(), QDeclarativeCompiledBindingsPrivate::findgeneric(), QDeclarativeCompiledBindingsPrivate::findproperty(), QDeclarativeInclude::finished(), QDeclarativePropertyCache::Data::flagsForProperty(), fontFamilies(), get(), ContextData::getContext(), ContextData::getScope(), QDeclarativeInclude::include(), QDeclarativeListReferencePrivate::init(), QDeclarativeExpressionPrivate::init(), QDeclarativeDomDocument::load(), QDeclarativePixmap::load(), QDeclarativeComponent::loadUrl(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeProperty::name(), QDeclarativePixmapReader::networkAccessManager(), point(), QDeclarativeXMLHttpRequest::printError(), QDeclarativePixmapReader::processJob(), QDeclarativeListScriptClass::property(), QDeclarativeTypeNameScriptClass::property(), QDeclarativeObjectMethodScriptClass::property(), QDeclarativeContextScriptClass::property(), QDeclarativeObjectScriptClass::property(), QDeclarativePropertyCache::property(), QDeclarativeObjectScriptClass::propertyNames(), QDeclarativeProperty::propertyTypeName(), QDeclarativeCleanup::QDeclarativeCleanup(), QDeclarativeInclude::QDeclarativeInclude(), QDeclarativeListReference::QDeclarativeListReference(), QDeclarativeComponent::qmlAttachedProperties(), qmlExecuteDeferred(), qmlScriptObject(), QDeclarativeTypeNameScriptClass::queryProperty(), QDeclarativeContextScriptClass::queryProperty(), QDeclarativeObjectScriptClass::queryProperty(), QDeclarativePropertyPrivate::readValueProperty(), QDeclarativeVMEMetaObject::readVarProperty(), QDeclarativeVMEMetaObject::readVarPropertyAsVariant(), rect(), QDeclarativeTypeData::resolveTypes(), QDeclarativeVME::run(), QDeclarativeCompiledBindingsPrivate::run(), QDeclarativeQtScriptExpression::scriptValue(), QDeclarativeExpressionPrivate::scriptValue(), QDeclarativeContext::setContextProperty(), QDeclarativeComponent::setData(), QDeclarativeListAccessor::setList(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeTypeNameScriptClass::setProperty(), QDeclarativeContextScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), QDeclarativeAbstractAnimation::setRunning(), QDeclarativeBehavior::setTarget(), size(), throwException(), QDeclarativeBinding::update(), QDeclarativeExpressionPrivate::value(), vector3d(), warning(), QDeclarativePropertyPrivate::write(), and QDeclarativePropertyPrivate::writeValueProperty().

316 { return e->d_func(); }

◆ get() [2/5]

static QDeclarativeEnginePrivate* QDeclarativeEnginePrivate::get ( QDeclarativeContext c)
inlinestatic

Definition at line 317 of file qdeclarativeengine_p.h.

317 { return (c && c->engine()) ? QDeclarativeEnginePrivate::get(c->engine()) : 0; }
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QDeclarativeEngine * engine() const
Return the context&#39;s QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...

◆ get() [3/5]

static QDeclarativeEnginePrivate* QDeclarativeEnginePrivate::get ( QDeclarativeContextData c)
inlinestatic

Definition at line 318 of file qdeclarativeengine_p.h.

318 { return (c && c->engine) ? QDeclarativeEnginePrivate::get(c->engine) : 0; }
QDeclarativeEngine * engine
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)

◆ get() [4/5]

static QDeclarativeEnginePrivate* QDeclarativeEnginePrivate::get ( QScriptEngine e)
inlinestatic

Definition at line 319 of file qdeclarativeengine_p.h.

319 { return static_cast<QDeclarativeScriptEngine*>(e)->p; }

◆ get() [5/5]

static QDeclarativeEngine* QDeclarativeEnginePrivate::get ( QDeclarativeEnginePrivate p)
inlinestatic

Definition at line 320 of file qdeclarativeengine_p.h.

320 { return p->q_func(); }

◆ getContext()

QDeclarativeContextData * QDeclarativeEnginePrivate::getContext ( QScriptContext ctxt)

Returns the QDeclarativeContext for the executing QScript ctxt.

Definition at line 1293 of file qdeclarativeengine.cpp.

Referenced by createComponent(), createQmlObject(), and QDeclarativeValueTypeScriptClass::setProperty().

1294 {
1296  Q_ASSERT(scopeNode.isValid());
1298  return contextClass->contextFromValue(scopeNode);
1299 }
QDeclarativeContextData * contextFromValue(const QScriptValue &)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QScriptValue scopeChainValue(QScriptContext *, int index)
static QScriptDeclarativeClass * scriptClass(const QScriptValue &)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
bool isValid() const
Returns true if this QScriptValue is valid; otherwise returns false.
QDeclarativeContextScriptClass * contextClass

◆ getEngine()

static QDeclarativeEngine* QDeclarativeEnginePrivate::getEngine ( QScriptEngine e)
inlinestatic

Definition at line 315 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeInclude::include().

315 { return static_cast<QDeclarativeScriptEngine*>(e)->p->q_func(); }

◆ getImageFromProvider()

QImage QDeclarativeEnginePrivate::getImageFromProvider ( const QUrl url,
QSize size,
const QSize req_size 
)

Definition at line 844 of file qdeclarativeengine.cpp.

Referenced by createPixmapDataSync(), and QDeclarativePixmapReader::processJob().

845 {
846  QMutexLocker locker(&mutex);
847  QImage image;
849  locker.unlock();
850  if (provider) {
852  image = provider->requestImage(imageId, size, req_size);
853  }
854  return image;
855 }
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4837
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QHash< QString, QSharedPointer< QDeclarativeImageProvider > > imageProviders
virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize)
Implement this method to return the image with id.

◆ getImageProviderType()

QDeclarativeImageProvider::ImageType QDeclarativeEnginePrivate::getImageProviderType ( const QUrl url)

Definition at line 834 of file qdeclarativeengine.cpp.

Referenced by createPixmapDataSync(), and QDeclarativePixmap::load().

835 {
836  QMutexLocker locker(&mutex);
838  locker.unlock();
839  if (provider)
840  return provider->imageType();
841  return static_cast<QDeclarativeImageProvider::ImageType>(-1);
842 }
ImageType
Defines the type of image supported by this image provider.
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4837
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QHash< QString, QSharedPointer< QDeclarativeImageProvider > > imageProviders
ImageType imageType() const
Returns the image type supported by this provider.

◆ getNetworkAccessManager()

QNetworkAccessManager * QDeclarativeEnginePrivate::getNetworkAccessManager ( ) const

Definition at line 762 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::networkAccessManager().

763 {
764  Q_Q(const QDeclarativeEngine);
766  networkAccessManager = createNetworkAccessManager(const_cast<QDeclarativeEngine*>(q));
767  return networkAccessManager;
768 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QDeclarativeEngine class provides an environment for instantiating QML components.
QNetworkAccessManager * createNetworkAccessManager(QObject *parent) const
QNetworkAccessManager * networkAccessManager

◆ getPixmapFromProvider()

QPixmap QDeclarativeEnginePrivate::getPixmapFromProvider ( const QUrl url,
QSize size,
const QSize req_size 
)

Definition at line 857 of file qdeclarativeengine.cpp.

Referenced by createPixmapDataSync().

858 {
859  QMutexLocker locker(&mutex);
860  QPixmap pixmap;
862  locker.unlock();
863  if (provider) {
865  pixmap = provider->requestPixmap(imageId, size, req_size);
866  }
867  return pixmap;
868 }
virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
Implement this method to return the pixmap with id.
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4837
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QHash< QString, QSharedPointer< QDeclarativeImageProvider > > imageProviders

◆ getScriptEngine()

static QScriptEngine* QDeclarativeEnginePrivate::getScriptEngine ( QDeclarativeEngine e)
inlinestatic

◆ getUniqueId()

quint32 QDeclarativeEnginePrivate::getUniqueId ( ) const
inline

Definition at line 246 of file qdeclarativeengine_p.h.

246  {
247  return uniqueId++;
248  }

◆ getUrl()

QUrl QDeclarativeEnginePrivate::getUrl ( QScriptContext ctxt)

Returns the QUrl associated with the script ctxt for the case that there is no QDeclarativeContext.

Definition at line 1305 of file qdeclarativeengine.cpp.

1306 {
1308  Q_ASSERT(scopeNode.isValid());
1310  return contextClass->urlFromValue(scopeNode);
1311 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QScriptValue scopeChainValue(QScriptContext *, int index)
static QScriptDeclarativeClass * scriptClass(const QScriptValue &)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
bool isValid() const
Returns true if this QScriptValue is valid; otherwise returns false.
QDeclarativeContextScriptClass * contextClass

◆ getWorkerScriptEngine()

QDeclarativeWorkerScriptEngine * QDeclarativeEnginePrivate::getWorkerScriptEngine ( )

Definition at line 609 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeWorkerScript::engine().

610 {
612  if (!workerScriptEngine)
614  return workerScriptEngine;
615 }
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeWorkerScriptEngine * workerScriptEngine
The QDeclarativeEngine class provides an environment for instantiating QML components.

◆ hsla()

QScriptValue QDeclarativeEnginePrivate::hsla ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1737 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1738 {
1739  int argCount = ctxt->argumentCount();
1740  if(argCount < 3 || argCount > 4)
1741  return ctxt->throwError(QLatin1String("Qt.hsla(): Invalid arguments"));
1742  qsreal h = ctxt->argument(0).toNumber();
1743  qsreal s = ctxt->argument(1).toNumber();
1744  qsreal l = ctxt->argument(2).toNumber();
1745  qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
1746 
1747  if (h < 0.0) h=0.0;
1748  if (h > 1.0) h=1.0;
1749  if (s < 0.0) s=0.0;
1750  if (s > 1.0) s=1.0;
1751  if (l < 0.0) l=0.0;
1752  if (l > 1.0) l=1.0;
1753  if (a < 0.0) a=0.0;
1754  if (a > 1.0) a=1.0;
1755 
1756  return engine->toScriptValue(QVariant::fromValue(QColor::fromHslF(h, s, l, a)));
1757 }
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
static QColor fromHslF(qreal h, qreal s, qreal l, qreal a=1.0)
Static convenience function that returns a QColor constructed from the HSV color values, h (hue), s (saturation), l (lightness), and a (alpha-channel, i.
Definition: qcolor.cpp:2153
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
QFactoryLoader * l
double qsreal
Definition: qscriptvalue.h:52
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ init()

void QDeclarativeEnginePrivate::init ( )

Definition at line 581 of file qdeclarativeengine.cpp.

582 {
584  qRegisterMetaType<QVariant>("QVariant");
585  qRegisterMetaType<QDeclarativeScriptString>("QDeclarativeScriptString");
586  qRegisterMetaType<QScriptValue>("QScriptValue");
587  qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeComponent::Status");
588 
590 
596  rootContext = new QDeclarativeContext(q,true);
597 
598  QScriptValue applicationObject = objectClass->newQObject(new QDeclarativeApplication(q));
599  scriptEngine.globalObject().property(QLatin1String("Qt")).setProperty(QLatin1String("application"), applicationObject);
600 
601  if (QCoreApplication::instance()->thread() == q->thread() &&
603  isDebugging = true;
606  }
607 }
QDeclarativeTypeNameScriptClass * typeNameClass
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue&#39;s property with the given name, using the given mode to resolv...
void addEngine(QDeclarativeEngine *)
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
static void init()
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QDeclarativeContext * rootContext
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeScriptEngine scriptEngine
QDeclarativeValueTypeScriptClass * valueTypeClass
QDeclarativeObjectScriptClass * objectClass
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
The QDeclarativeEngine class provides an environment for instantiating QML components.
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
QDeclarativeListScriptClass * listClass
static QDeclarativeEngineDebugService * instance()
The QDeclarativeContext class defines a context within a QML engine.
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
static QJSDebugService * instance()
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QDeclarativeContextScriptClass * contextClass

◆ isList()

bool QDeclarativeEnginePrivate::isList ( int  t) const

Definition at line 2488 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeCompiler::buildListProperty(), QDeclarativeCompiler::buildProperty(), and QDeclarativeCompiler::genValueProperty().

2489 {
2491 }
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872

◆ isQObject()

bool QDeclarativeEnginePrivate::isQObject ( int  t)

Definition at line 2502 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeListAccessor::setList().

2503 {
2505 }
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
QHash< int, QDeclarativeCompiledData * > m_compositeTypes

◆ isQtObject()

QScriptValue QDeclarativeEnginePrivate::isQtObject ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1489 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1490 {
1491  if (ctxt->argumentCount() == 0)
1492  return QScriptValue(engine, false);
1493 
1494  return QScriptValue(engine, 0 != ctxt->argument(0).toQObject());
1495 }
QObject * toQObject() const
If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; othe...
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ lighter()

QScriptValue QDeclarativeEnginePrivate::lighter ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1819 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1820 {
1821  if(ctxt->argumentCount() != 1 && ctxt->argumentCount() != 2)
1822  return ctxt->throwError(QLatin1String("Qt.lighter(): Invalid arguments"));
1823  QVariant v = ctxt->argument(0).toVariant();
1824  QColor color;
1825  if (v.userType() == QVariant::Color)
1826  color = v.value<QColor>();
1827  else if (v.userType() == QVariant::String) {
1828  bool ok;
1830  if (!ok)
1831  return engine->nullValue();
1832  } else
1833  return engine->nullValue();
1834  qsreal factor = 1.5;
1835  if (ctxt->argumentCount() == 2)
1836  factor = ctxt->argument(1).toNumber();
1837  color = color.lighter(int(qRound(factor*100.)));
1838  return engine->toScriptValue(QVariant::fromValue(color));
1839 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
QColor Q_DECLARATIVE_PRIVATE_EXPORT colorFromString(const QString &, bool *ok=0)
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
double qsreal
Definition: qscriptvalue.h:52
QColor lighter(int f=150) const
Returns a lighter (or darker) color, but does not change this object.
Definition: qcolor.h:298
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
QScriptValue argument(int index) const
Returns the function argument at the given index.
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ listType()

int QDeclarativeEnginePrivate::listType ( int  t) const

Definition at line 2493 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeCompiler::buildListProperty(), QDeclarativeCompiler::genListProperty(), QDeclarativeListReferencePrivate::init(), QDeclarativeListReference::QDeclarativeListReference(), and QDeclarativePropertyPrivate::write().

2494 {
2496  if (iter != m_qmlLists.end())
2497  return *iter;
2498  else
2500 }
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ md5()

QScriptValue QDeclarativeEnginePrivate::md5 ( QScriptContext ctxt,
QScriptEngine  
)
static

Definition at line 1912 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1913 {
1914  if (ctxt->argumentCount() != 1)
1915  return ctxt->throwError(QLatin1String("Qt.md5(): Invalid arguments"));
1916 
1917  QByteArray data = ctxt->argument(0).toString().toUtf8();
1919 
1920  return QScriptValue(QLatin1String(result.toHex()));
1921 }
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
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QByteArray toHex() const
Returns a hex encoded copy of the byte array.
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.
static QByteArray hash(const QByteArray &data, Algorithm method)
Returns the hash of data using method.

◆ metaObjectForType()

const QMetaObject * QDeclarativeEnginePrivate::metaObjectForType ( int  t) const

Definition at line 2539 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeCompiler::buildGroupedProperty().

2540 {
2542  if (iter != m_compositeTypes.end()) {
2543  return (*iter)->root;
2544  } else {
2546  return type?type->metaObject():0;
2547  }
2548 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
int type
Definition: qmetatype.cpp:239
static QDeclarativeType * qmlType(const QByteArray &, int, int)
Returns the type (if any) of URI-qualified named name in version specified by version_major and versi...
QHash< int, QDeclarativeCompiledData * > m_compositeTypes
const QMetaObject * metaObject() const
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ point()

QScriptValue QDeclarativeEnginePrivate::point ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1783 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1784 {
1785  if(ctxt->argumentCount() != 2)
1786  return ctxt->throwError(QLatin1String("Qt.point(): Invalid arguments"));
1787  qsreal x = ctxt->argument(0).toNumber();
1788  qsreal y = ctxt->argument(1).toNumber();
1790 }
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QScriptValue scriptValueFromVariant(const QVariant &)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
double qsreal
Definition: qscriptvalue.h:52
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ qmlScriptObject()

QScriptValue QDeclarativeEnginePrivate::qmlScriptObject ( QObject object,
QDeclarativeEngine engine 
)
static

Creates a QScriptValue allowing you to use object in QML script.

engine is the QDeclarativeEngine it is to be created in.

The QScriptValue returned is a QtScript Object, not a QtScript QObject, due to the special needs of QML requiring more functionality than a standard QtScript QObject.

Definition at line 1283 of file qdeclarativeengine.cpp.

Referenced by NestedListModel::get().

1285 {
1287  return enginePriv->objectClass->newQObject(object);
1288 }
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
QDeclarativeObjectScriptClass * objectClass

◆ quit()

QScriptValue QDeclarativeEnginePrivate::quit ( QScriptContext ,
QScriptEngine e 
)
static

Definition at line 2047 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

2048 {
2049  QDeclarativeEnginePrivate *qe = get (e);
2050  qe->sendQuit();
2051  return QScriptValue();
2052 }
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ rawMetaObjectForType()

const QMetaObject * QDeclarativeEnginePrivate::rawMetaObjectForType ( int  t) const

Definition at line 2528 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeCompiler::buildPropertyObjectAssignment(), QDeclarativeCompiler::canCoerce(), QDeclarativeListReferencePrivate::init(), QDeclarativeObjectMethodScriptClass::property(), QDeclarativeListReference::QDeclarativeListReference(), QDeclarativePropertyPrivate::rawMetaObjectForType(), and QDeclarativePropertyPrivate::write().

2529 {
2531  if (iter != m_compositeTypes.end()) {
2532  return (*iter)->root;
2533  } else {
2535  return type?type->baseMetaObject():0;
2536  }
2537 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
int type
Definition: qmetatype.cpp:239
static QDeclarativeType * qmlType(const QByteArray &, int, int)
Returns the type (if any) of URI-qualified named name in version specified by version_major and versi...
const QMetaObject * baseMetaObject() const
QHash< int, QDeclarativeCompiledData * > m_compositeTypes
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ rect()

QScriptValue QDeclarativeEnginePrivate::rect ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1766 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1767 {
1768  if(ctxt->argumentCount() != 4)
1769  return ctxt->throwError(QLatin1String("Qt.rect(): Invalid arguments"));
1770 
1771  qsreal x = ctxt->argument(0).toNumber();
1772  qsreal y = ctxt->argument(1).toNumber();
1773  qsreal w = ctxt->argument(2).toNumber();
1774  qsreal h = ctxt->argument(3).toNumber();
1775 
1777 }
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QScriptValue scriptValueFromVariant(const QVariant &)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
double qsreal
Definition: qscriptvalue.h:52
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ registerCompositeType()

void QDeclarativeEnginePrivate::registerCompositeType ( QDeclarativeCompiledData data)

Definition at line 2471 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeCompiler::compileTree().

2472 {
2473  QByteArray name = data->root->className();
2474 
2475  QByteArray ptr = name + '*';
2476  QByteArray lst = "QDeclarativeListProperty<" + name + '>';
2477 
2482 
2483  m_qmlLists.insert(lst_type, ptr_type);
2484  m_compositeTypes.insert(ptr_type, data);
2485  data->addref();
2486 }
static void voidptr_destructor(void *v)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
static void * voidptr_constructor(const void *v)
const char * name
const T * ptr(const T &t)
QHash< int, QDeclarativeCompiledData * > m_compositeTypes
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
static int registerType(const char *typeName, Destructor destructor, Constructor constructor)
Registers a user type for marshalling, with typeName, a destructor, and a constructor.
Definition: qmetatype.cpp:477

◆ registerFinalizedParserStatusObject()

void QDeclarativeEnginePrivate::registerFinalizedParserStatusObject ( QObject obj,
int  index 
)
inline

Definition at line 222 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeAbstractAnimation::setRunning(), and QDeclarativeBehavior::setTarget().

222  {
224  }
QList< QPair< QDeclarativeGuard< QObject >, int > > finalizedParserStatus
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
quint16 index

◆ rgba()

QScriptValue QDeclarativeEnginePrivate::rgba ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1709 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1710 {
1711  int argCount = ctxt->argumentCount();
1712  if(argCount < 3 || argCount > 4)
1713  return ctxt->throwError(QLatin1String("Qt.rgba(): Invalid arguments"));
1714  qsreal r = ctxt->argument(0).toNumber();
1715  qsreal g = ctxt->argument(1).toNumber();
1716  qsreal b = ctxt->argument(2).toNumber();
1717  qsreal a = (argCount == 4) ? ctxt->argument(3).toNumber() : 1;
1718 
1719  if (r < 0.0) r=0.0;
1720  if (r > 1.0) r=1.0;
1721  if (g < 0.0) g=0.0;
1722  if (g > 1.0) g=1.0;
1723  if (b < 0.0) b=0.0;
1724  if (b > 1.0) b=1.0;
1725  if (a < 0.0) a=0.0;
1726  if (a > 1.0) a=1.0;
1727 
1728  return engine->toScriptValue(QVariant::fromValue(QColor::fromRgbF(r, g, b, a)));
1729 }
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
static QColor fromRgbF(qreal r, qreal g, qreal b, qreal a=1.0)
Static convenience function that returns a QColor constructed from the RGB color values, r (red), g (green), b (blue), and a (alpha-channel, i.e.
Definition: qcolor.cpp:2017
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
double qsreal
Definition: qscriptvalue.h:52
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ scriptValueFromVariant()

QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant ( const QVariant val)

Definition at line 2131 of file qdeclarativeengine.cpp.

Referenced by fontFamilies(), QDeclarativeVMEMetaObject::metaCall(), point(), QDeclarativeObjectMethodScriptClass::property(), QDeclarativeContextScriptClass::property(), QDeclarativeObjectScriptClass::property(), QDeclarativeVMEMetaObject::readVarProperty(), rect(), size(), and vector3d().

2132 {
2133  if (val.userType() == qMetaTypeId<QDeclarativeListReference>()) {
2136  if (p->object) {
2137  return listClass->newList(p->property, p->propertyType);
2138  } else {
2139  return scriptEngine.nullValue();
2140  }
2141  } else if (val.userType() == qMetaTypeId<QList<QObject *> >()) {
2142  const QList<QObject *> &list = *(QList<QObject *>*)val.constData();
2143  QScriptValue rv = scriptEngine.newArray(list.count());
2144  for (int ii = 0; ii < list.count(); ++ii) {
2145  QObject *object = list.at(ii);
2146  rv.setProperty(ii, objectClass->newQObject(object));
2147  }
2148  return rv;
2149  } else if (QDeclarativeValueType *vt = valueTypes[val.userType()]) {
2150  return valueTypeClass->newObject(val, vt);
2151  }
2152 
2153  bool objOk;
2154  QObject *obj = QDeclarativeMetaType::toQObject(val, &objOk);
2155  if (objOk) {
2156  return objectClass->newQObject(obj);
2157  } else {
2158  return scriptEngine.toScriptValue(val);
2159  }
2160 }
static QObject * toQObject(const QVariant &, bool *ok=0)
The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties...
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
QDeclarativeScriptEngine scriptEngine
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDeclarativeValueTypeScriptClass * valueTypeClass
QDeclarativeListProperty< QObject > property
QScriptValue newObject(QObject *object, int coreIndex, QDeclarativeValueType *)
QDeclarativeObjectScriptClass * objectClass
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
QDeclarativeListScriptClass * listClass
QDeclarativeValueTypeFactory valueTypes
static QDeclarativeListReferencePrivate * get(QDeclarativeListReference *ref)
const void * constData() const
Definition: qvariant.cpp:3065
QScriptValue newArray(uint length=0)
Creates a QtScript object of class Array with the given length.
QScriptValue newList(QObject *, int, int)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QDeclarativeGuard< QObject > object
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ scriptValueToVariant()

QVariant QDeclarativeEnginePrivate::scriptValueToVariant ( const QScriptValue val,
int  hint = QVariant::Invalid 
)

Definition at line 2162 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeVMEMetaObject::metaCall(), QDeclarativeObjectMethodScriptClass::property(), QDeclarativeVMEMetaObject::readVarPropertyAsVariant(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), QDeclarativeBinding::update(), and QDeclarativeExpressionPrivate::value().

2163 {
2165  if (dc == objectClass)
2167  else if (dc == valueTypeClass)
2168  return valueTypeClass->toVariant(val);
2169  else if (dc == contextClass)
2170  return QVariant();
2171 
2172  // Convert to a QList<QObject*> only if val is an array and we were explicitly hinted
2173  if (hint == qMetaTypeId<QList<QObject *> >() && val.isArray()) {
2174  QList<QObject *> list;
2175  int length = val.property(QLatin1String("length")).toInt32();
2176  for (int ii = 0; ii < length; ++ii) {
2177  QScriptValue arrayItem = val.property(ii);
2178  QObject *d = arrayItem.toQObject();
2179  list << d;
2180  }
2181  return QVariant::fromValue(list);
2182  }
2183 
2184  return val.toVariant();
2185 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue&#39;s property with the given name, using the given mode to resolv...
qint32 toInt32() const
Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in...
QObject * toQObject(const QScriptValue &) const
int qMetaTypeId()
Definition: qmetatype.h:224
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QObject * toQObject() const
If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; othe...
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual QVariant toVariant(Object *, bool *ok=0)
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
QDeclarativeValueTypeScriptClass * valueTypeClass
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
QDeclarativeObjectScriptClass * objectClass
static QScriptDeclarativeClass * scriptClass(const QScriptValue &)
bool isArray() const
Returns true if this QScriptValue is an object of the Array class; otherwise returns false...
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QDeclarativeContextScriptClass * contextClass

◆ sendQuit()

void QDeclarativeEnginePrivate::sendQuit ( )

Definition at line 1971 of file qdeclarativeengine.cpp.

Referenced by quit().

1972 {
1974  emit q->quit();
1975  if (q->receivers(SIGNAL(quit())) == 0) {
1976  qWarning("Signal QDeclarativeEngine::quit() emitted, but no receivers connected to handle it.");
1977  }
1978 }
static QScriptValue quit(QScriptContext *, QScriptEngine *)
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
#define emit
Definition: qobjectdefs.h:76
Q_CORE_EXPORT void qWarning(const char *,...)
The QDeclarativeEngine class provides an environment for instantiating QML components.

◆ size()

QScriptValue QDeclarativeEnginePrivate::size ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1796 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1797 {
1798  if(ctxt->argumentCount() != 2)
1799  return ctxt->throwError(QLatin1String("Qt.size(): Invalid arguments"));
1800  qsreal w = ctxt->argument(0).toNumber();
1801  qsreal h = ctxt->argument(1).toNumber();
1803 }
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
QScriptValue scriptValueFromVariant(const QVariant &)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
double qsreal
Definition: qscriptvalue.h:52
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ tint()

QScriptValue QDeclarativeEnginePrivate::tint ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 2081 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

2082 {
2083  if(ctxt->argumentCount() != 2)
2084  return ctxt->throwError(QLatin1String("Qt.tint(): Invalid arguments"));
2085  //get color
2086  QVariant v = ctxt->argument(0).toVariant();
2087  QColor color;
2088  if (v.userType() == QVariant::Color)
2089  color = v.value<QColor>();
2090  else if (v.userType() == QVariant::String) {
2091  bool ok;
2093  if (!ok)
2094  return engine->nullValue();
2095  } else
2096  return engine->nullValue();
2097 
2098  //get tint color
2099  v = ctxt->argument(1).toVariant();
2100  QColor tintColor;
2101  if (v.userType() == QVariant::Color)
2102  tintColor = v.value<QColor>();
2103  else if (v.userType() == QVariant::String) {
2104  bool ok;
2106  if (!ok)
2107  return engine->nullValue();
2108  } else
2109  return engine->nullValue();
2110 
2111  //tint
2112  QColor finalColor;
2113  int a = tintColor.alpha();
2114  if (a == 0xFF)
2115  finalColor = tintColor;
2116  else if (a == 0x00)
2117  finalColor = color;
2118  else {
2119  qreal a = tintColor.alphaF();
2120  qreal inv_a = 1.0 - a;
2121 
2122  finalColor.setRgbF(tintColor.redF() * a + color.redF() * inv_a,
2123  tintColor.greenF() * a + color.greenF() * inv_a,
2124  tintColor.blueF() * a + color.blueF() * inv_a,
2125  a + inv_a * color.alphaF());
2126  }
2127 
2128  return engine->toScriptValue(QVariant::fromValue(finalColor));
2129 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
qreal alphaF() const
Returns the alpha color component of this color.
Definition: qcolor.cpp:1106
QColor Q_DECLARATIVE_PRIVATE_EXPORT colorFromString(const QString &, bool *ok=0)
double qreal
Definition: qglobal.h:1193
qreal greenF() const
Returns the green color component of this color.
Definition: qcolor.cpp:1241
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
void setRgbF(qreal r, qreal g, qreal b, qreal a=1.0)
Sets the color channels of this color to r (red), g (green), b (blue) and a (alpha, transparency).
Definition: qcolor.cpp:954
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
long ASN1_INTEGER_get ASN1_INTEGER * a
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
qreal redF() const
Returns the red color component of this color.
Definition: qcolor.cpp:1213
qreal blueF() const
Returns the blue color component of this color.
Definition: qcolor.cpp:1269
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ toQObject()

QObject * QDeclarativeEnginePrivate::toQObject ( const QVariant v,
bool *  ok = 0 
) const

Definition at line 2507 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeObjectMethodScriptClass::property(), QDeclarativeContext::setContextProperty(), QDeclarativeListAccessor::setList(), and QDeclarativePropertyPrivate::write().

2508 {
2509  int t = v.userType();
2511  if (ok) *ok = true;
2512  return *(QObject **)(v.constData());
2513  } else {
2514  return QDeclarativeMetaType::toQObject(v, ok);
2515  }
2516 }
static QObject * toQObject(const QVariant &, bool *ok=0)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
QHash< int, QDeclarativeCompiledData * > m_compositeTypes
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
const void * constData() const
Definition: qvariant.cpp:3065

◆ typeCategory()

QDeclarativeMetaType::TypeCategory QDeclarativeEnginePrivate::typeCategory ( int  t) const

Definition at line 2518 of file qdeclarativeengine.cpp.

Referenced by QDeclarativePropertyCache::Data::flagsForProperty().

2519 {
2520  if (m_compositeTypes.contains(t))
2522  else if (m_qmlLists.contains(t))
2524  else
2526 }
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
static TypeCategory typeCategory(int)
QHash< int, QDeclarativeCompiledData * > m_compositeTypes

◆ urlToLocalFileOrQrc()

QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc ( const QUrl url)
static

Definition at line 1313 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeImportsPrivate::add(), createPixmapDataSync(), QDeclarativeTypeData::dataReceived(), QDeclarativeImportedNamespace::find_helper(), QDeclarativeTypeLoader::get(), QDeclarativeTypeLoader::getQmldir(), QDeclarativeTypeLoader::getScript(), QDeclarativeInclude::include(), QDeclarativeBorderImage::load(), QDeclarativeAnimatedImage::load(), QDeclarativeDataLoader::load(), QDeclarativePixmapReader::processJob(), QDeclarativeWorkerScriptEnginePrivate::processLoad(), QDeclarativeFontLoader::setSource(), and QDeclarativeInclude::worker_include().

1314 {
1315  if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) {
1316  if (url.authority().isEmpty())
1317  return QLatin1Char(':') + url.path();
1318  return QString();
1319  }
1320  return url.toLocalFile();
1321 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString authority() const
Returns the authority of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4592
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
int compare(const QString &s) const
Definition: qstring.cpp:5037
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ vector3d()

QScriptValue QDeclarativeEnginePrivate::vector3d ( QScriptContext ctxt,
QScriptEngine engine 
)
static

Definition at line 1501 of file qdeclarativeengine.cpp.

Referenced by QDeclarativeScriptEngine::QDeclarativeScriptEngine().

1502 {
1503  if(ctxt->argumentCount() != 3)
1504  return ctxt->throwError(QLatin1String("Qt.vector(): Invalid arguments"));
1505  qsreal x = ctxt->argument(0).toNumber();
1506  qsreal y = ctxt->argument(1).toNumber();
1507  qsreal z = ctxt->argument(2).toNumber();
1509 }
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
QScriptValue scriptValueFromVariant(const QVariant &)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
double qsreal
Definition: qscriptvalue.h:52
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ warning() [1/6]

void QDeclarativeEnginePrivate::warning ( const QDeclarativeError error)

◆ warning() [2/6]

void QDeclarativeEnginePrivate::warning ( const QList< QDeclarativeError > &  errors)

Definition at line 1999 of file qdeclarativeengine.cpp.

2000 {
2002  q->warnings(errors);
2004  dumpwarning(errors);
2005 }
static void dumpwarning(const QDeclarativeError &error)
#define Q_Q(Class)
Definition: qglobal.h:2483
The QDeclarativeEngine class provides an environment for instantiating QML components.

◆ warning() [3/6]

void QDeclarativeEnginePrivate::warning ( QDeclarativeEngine engine,
const QDeclarativeError error 
)
static

Definition at line 2007 of file qdeclarativeengine.cpp.

2008 {
2009  if (engine)
2010  QDeclarativeEnginePrivate::get(engine)->warning(error);
2011  else
2012  dumpwarning(error);
2013 }
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static void dumpwarning(const QDeclarativeError &error)
void warning(const QDeclarativeError &)

◆ warning() [4/6]

void QDeclarativeEnginePrivate::warning ( QDeclarativeEngine engine,
const QList< QDeclarativeError > &  error 
)
static

Definition at line 2015 of file qdeclarativeengine.cpp.

2016 {
2017  if (engine)
2018  QDeclarativeEnginePrivate::get(engine)->warning(error);
2019  else
2020  dumpwarning(error);
2021 }
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
static void dumpwarning(const QDeclarativeError &error)
void warning(const QDeclarativeError &)

◆ warning() [5/6]

void QDeclarativeEnginePrivate::warning ( QDeclarativeEnginePrivate engine,
const QDeclarativeError error 
)
static

Definition at line 2023 of file qdeclarativeengine.cpp.

2024 {
2025  if (engine)
2026  engine->warning(error);
2027  else
2028  dumpwarning(error);
2029 }
static void dumpwarning(const QDeclarativeError &error)
void warning(const QDeclarativeError &)

◆ warning() [6/6]

void QDeclarativeEnginePrivate::warning ( QDeclarativeEnginePrivate engine,
const QList< QDeclarativeError > &  error 
)
static

Definition at line 2031 of file qdeclarativeengine.cpp.

2032 {
2033  if (engine)
2034  engine->warning(error);
2035  else
2036  dumpwarning(error);
2037 }
static void dumpwarning(const QDeclarativeError &error)
void warning(const QDeclarativeError &)

Properties

◆ baseUrl

QUrl QDeclarativeEnginePrivate::baseUrl

Definition at line 189 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeScriptEngine::resolvedUrl().

◆ bindValues

QList<SimpleList<QDeclarativeAbstractBinding> > QDeclarativeEnginePrivate::bindValues

◆ capturedProperties

QPODVector<CapturedProperty, 16> QDeclarativeEnginePrivate::capturedProperties

◆ captureProperties

bool QDeclarativeEnginePrivate::captureProperties

◆ cleanup

QDeclarativeCleanup* QDeclarativeEnginePrivate::cleanup

Definition at line 178 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeCleanup::QDeclarativeCleanup().

◆ componentAttached

QDeclarativeComponentAttached* QDeclarativeEnginePrivate::componentAttached

◆ contextClass

QDeclarativeContextScriptClass* QDeclarativeEnginePrivate::contextClass

◆ erroredBindings

QDeclarativeDelayedError* QDeclarativeEnginePrivate::erroredBindings

◆ finalizedParserStatus

QList<QPair<QDeclarativeGuard<QObject>,int> > QDeclarativeEnginePrivate::finalizedParserStatus

◆ globalClass

QDeclarativeGlobalScriptClass* QDeclarativeEnginePrivate::globalClass

◆ imageProviders

QHash<QString,QSharedPointer<QDeclarativeImageProvider> > QDeclarativeEnginePrivate::imageProviders

Definition at line 233 of file qdeclarativeengine_p.h.

◆ importDatabase

QDeclarativeImportDatabase QDeclarativeEnginePrivate::importDatabase

Definition at line 241 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeTypeData::resolveTypes().

◆ inBeginCreate

bool QDeclarativeEnginePrivate::inBeginCreate

◆ inProgressCreations

int QDeclarativeEnginePrivate::inProgressCreations

◆ isDebugging

bool QDeclarativeEnginePrivate::isDebugging

Definition at line 163 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeComponentPrivate::begin().

◆ listClass

QDeclarativeListScriptClass* QDeclarativeEnginePrivate::listClass

◆ m_compositeTypes

QHash<int, QDeclarativeCompiledData *> QDeclarativeEnginePrivate::m_compositeTypes

Definition at line 270 of file qdeclarativeengine_p.h.

◆ m_qmlLists

QHash<int, int> QDeclarativeEnginePrivate::m_qmlLists

Definition at line 269 of file qdeclarativeengine_p.h.

◆ m_sharedScriptImports

QHash<QString, QScriptValue> QDeclarativeEnginePrivate::m_sharedScriptImports

Definition at line 272 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeContextData::addImportedScript().

◆ mutex

QMutex QDeclarativeEnginePrivate::mutex
mutable

Definition at line 238 of file qdeclarativeengine_p.h.

◆ networkAccessManager

QNetworkAccessManager* QDeclarativeEnginePrivate::networkAccessManager
mutable

Definition at line 230 of file qdeclarativeengine_p.h.

◆ networkAccessManagerFactory

QDeclarativeNetworkAccessManagerFactory* QDeclarativeEnginePrivate::networkAccessManagerFactory
mutable

Definition at line 231 of file qdeclarativeengine_p.h.

◆ objectClass

QDeclarativeObjectScriptClass* QDeclarativeEnginePrivate::objectClass

◆ offlineStoragePath

QString QDeclarativeEnginePrivate::offlineStoragePath

Definition at line 243 of file qdeclarativeengine_p.h.

◆ outputWarningsToStdErr

bool QDeclarativeEnginePrivate::outputWarningsToStdErr

Definition at line 165 of file qdeclarativeengine_p.h.

◆ parserStatus

QList<SimpleList<QDeclarativeParserStatus> > QDeclarativeEnginePrivate::parserStatus

◆ propertyCache

QHash<const QMetaObject *, QDeclarativePropertyCache *> QDeclarativeEnginePrivate::propertyCache

Definition at line 252 of file qdeclarativeengine_p.h.

◆ qml_debugging_enabled

bool QDeclarativeEnginePrivate::qml_debugging_enabled = false
static

◆ rootContext

QDeclarativeContext* QDeclarativeEnginePrivate::rootContext

Definition at line 162 of file qdeclarativeengine_p.h.

◆ scriptEngine

QDeclarativeScriptEngine QDeclarativeEnginePrivate::scriptEngine

◆ sharedContext

QDeclarativeContextData* QDeclarativeEnginePrivate::sharedContext

◆ sharedScope

QObject* QDeclarativeEnginePrivate::sharedScope

◆ typeLoader

QDeclarativeTypeLoader QDeclarativeEnginePrivate::typeLoader

◆ typeNameClass

QDeclarativeTypeNameScriptClass* QDeclarativeEnginePrivate::typeNameClass

◆ typePropertyCache

QHash<QPair<QDeclarativeType *, int>, QDeclarativePropertyCache *> QDeclarativeEnginePrivate::typePropertyCache

Definition at line 253 of file qdeclarativeengine_p.h.

◆ uniqueId

quint32 QDeclarativeEnginePrivate::uniqueId
mutable

Definition at line 245 of file qdeclarativeengine_p.h.

◆ valueTypeClass

QDeclarativeValueTypeScriptClass* QDeclarativeEnginePrivate::valueTypeClass

Definition at line 171 of file qdeclarativeengine_p.h.

Referenced by QDeclarativeObjectScriptClass::property().

◆ valueTypes

QDeclarativeValueTypeFactory QDeclarativeEnginePrivate::valueTypes

◆ workerScriptEngine

QDeclarativeWorkerScriptEngine* QDeclarativeEnginePrivate::workerScriptEngine

Definition at line 187 of file qdeclarativeengine_p.h.


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