Qt 4.8
qdeclarativeengine.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "private/qdeclarativeengine_p.h"
43 #include "qdeclarativeengine.h"
44 
45 #include "private/qdeclarativeboundsignal_p.h"
46 #include "private/qdeclarativecontext_p.h"
47 #include "private/qdeclarativecompiler_p.h"
48 #include "private/qdeclarativeglobalscriptclass_p.h"
49 #include "qdeclarative.h"
50 #include "qdeclarativecontext.h"
51 #include "qdeclarativeexpression.h"
52 #include "qdeclarativecomponent.h"
53 #include "private/qdeclarativebinding_p_p.h"
54 #include "private/qdeclarativevme_p.h"
55 #include "private/qdeclarativeenginedebugservice_p.h"
56 #include "private/qdeclarativestringconverters_p.h"
57 #include "private/qdeclarativexmlhttprequest_p.h"
58 #include "private/qdeclarativesqldatabase_p.h"
59 #include "private/qdeclarativetypenamescriptclass_p.h"
60 #include "private/qdeclarativelistscriptclass_p.h"
62 #include "private/qdeclarativeglobal_p.h"
63 #include "private/qdeclarativeworkerscript_p.h"
64 #include "private/qdeclarativecomponent_p.h"
67 #include "private/qdeclarativedirparser_p.h"
69 #include "private/qdeclarativelist_p.h"
70 #include "private/qdeclarativetypenamecache_p.h"
71 #include "private/qdeclarativeinclude_p.h"
72 #include "private/qdeclarativenotifier_p.h"
73 #include "private/qdeclarativedebugtrace_p.h"
74 #include "private/qdeclarativeapplication_p.h"
75 #include "private/qjsdebugservice_p.h"
76 
77 #include <QtCore/qmetaobject.h>
78 #include <QScriptClass>
79 #include <QNetworkReply>
80 #include <QNetworkRequest>
81 #include <QNetworkAccessManager>
82 #include <QDesktopServices>
83 #include <QTimer>
84 #include <QList>
85 #include <QPair>
86 #include <QDebug>
87 #include <QMetaObject>
88 #include <QStack>
89 #include <QMap>
90 #include <QPluginLoader>
91 #include <QtGui/qapplication.h>
92 #include <QtGui/qfontdatabase.h>
93 #include <QtCore/qlibraryinfo.h>
94 #include <QtCore/qthreadstorage.h>
95 #include <QtCore/qthread.h>
96 #include <QtCore/qcoreapplication.h>
97 #include <QtCore/qdir.h>
98 #include <QtCore/qmutex.h>
99 #include <QtGui/qcolor.h>
100 #include <QtGui/qvector3d.h>
101 #include <QtGui/qsound.h>
102 #include <QtCore/qcryptographichash.h>
103 
104 #include <private/qobject_p.h>
105 #include <private/qscriptdeclarativeclass_p.h>
106 
107 #include <private/qdeclarativeitemsmodule_p.h>
108 #include <private/qdeclarativeutilmodule_p.h>
109 
110 #ifdef Q_OS_WIN // for %APPDATA%
111 #include <qt_windows.h>
112 #include <qlibrary.h>
113 #include <windows.h>
114 
115 #define CSIDL_APPDATA 0x001a // <username>\Application Data
116 #endif
117 
119 
121 
180 struct StaticQtMetaObject : public QObject
181 {
182  static const QMetaObject *get()
183  { return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
184 };
185 
186 static bool qt_QmlQtModule_registered = false;
188 
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 }
197 
199 {
200  qmlRegisterType<QDeclarativeComponent>("Qt",4,7,"Component");
201  qmlRegisterType<QObject>("Qt",4,7,"QtObject");
202  qmlRegisterType<QDeclarativeWorkerScript>("Qt",4,7,"WorkerScript");
203 }
204 
354 // Qt.include() is implemented in qdeclarativeinclude.cpp
355 
356 
358 : captureProperties(false), rootContext(0), isDebugging(false),
359  outputWarningsToStdErr(true), contextClass(0), sharedContext(0), sharedScope(0),
360  objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0),
361  inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttached(0),
362  inBeginCreate(false), networkAccessManager(0), networkAccessManagerFactory(0),
363  typeLoader(e), importDatabase(e), uniqueId(1)
364 {
371  }
373 }
374 
383 {
384  if (p) {
385  QDeclarativeContextData *ctxt = p->getContext(context);
386  if (ctxt)
387  return ctxt->resolvedUrl(url);
388  else
389  return p->getUrl(context).resolved(url);
390  }
391  return baseUrl.resolved(url);
392 }
393 
395 : p(priv), sqlQueryClass(0), namedNodeMapClass(0), nodeListClass(0)
396 {
397  // Note that all documentation for stuff put on the global object goes in
398  // doc/src/declarative/globalobject.qdoc
399 
400  bool mainthread = priv != 0;
401 
402  QScriptValue qtObject =
404  globalObject().setProperty(QLatin1String("Qt"), qtObject);
405 
406 #ifndef QT_NO_DESKTOPSERVICES
408  + QDir::separator() + QLatin1String("QML")
409  + QDir::separator() + QLatin1String("OfflineStorage");
410 #endif
411 
412 #ifndef QT_NO_XMLSTREAMREADER
414 #endif
415  qt_add_qmlsqldatabase(this);
416  // XXX A Multimedia "Qt.Sound" class also needs to be made available,
417  // XXX but we don't want a dependency in that cirection.
418  // XXX When the above a done some better way, that way should also be
419  // XXX used to add Qt.Sound class.
420 
421  //types
422  if (mainthread)
424  else
426 
434 
435  if (mainthread) {
436  //color helpers
440  }
441 
442 #ifndef QT_NO_DATESTRING
443  //date/time formatting
447 #endif
448 
449  //misc methods
457 
458  if (mainthread) {
459  qtObject.setProperty(QLatin1String("createQmlObject"),
461  qtObject.setProperty(QLatin1String("createComponent"),
463  }
464 
465  //firebug/webkit compat
466  QScriptValue consoleObject = newObject();
469  globalObject().setProperty(QLatin1String("console"), consoleObject);
470 
471  // translation functions need to be installed
472  // before the global script class is constructed (QTBUG-6437)
474 }
475 
477 {
478  delete sqlQueryClass;
479  delete nodeListClass;
480  delete namedNodeMapClass;
481 }
482 
484 {
485  QString arg = ctxt->argument(0).toString();
486  QUrl r = QDeclarativeScriptEngine::get(engine)->resolvedUrl(ctxt,QUrl(arg));
487  return QScriptValue(r.toString());
488 }
489 
491 {
492  return p->getNetworkAccessManager();
493 }
494 
496 {
497  Q_ASSERT(inProgressCreations == 0);
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 
525  for(QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.constBegin(); iter != m_compositeTypes.constEnd(); ++iter)
526  (*iter)->release();
527  for(QHash<const QMetaObject *, QDeclarativePropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter)
528  (*iter)->release();
529  for(QHash<QPair<QDeclarativeType *, int>, QDeclarativePropertyCache *>::Iterator iter = typePropertyCache.begin(); iter != typePropertyCache.end(); ++iter)
530  (*iter)->release();
531 
532 }
533 
535 {
536  bvs.clear();
537 }
538 
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 }
548 
550 {
552  if (p->declarativeData) {
553  QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
554  if (d->ownContext && d->context) {
555  d->context->destroy();
556  d->context = 0;
557  }
558 
559  // Disconnect the notifiers now - during object destruction this would be too late, since
560  // the disconnect call wouldn't be able to call disconnectNotify(), as it isn't possible to
561  // get the metaobject anymore.
562  d->disconnectNotifiers();
563  }
564 }
565 
567 {
568  static_cast<QDeclarativeData *>(d)->destroyed(o);
569 }
570 
572 {
573  static_cast<QDeclarativeData *>(d)->parentChanged(o, p);
574 }
575 
577 {
578  static_cast<QDeclarativeData *>(d)->objectNameChanged(o);
579 }
580 
582 {
584  qRegisterMetaType<QVariant>("QVariant");
585  qRegisterMetaType<QDeclarativeScriptString>("QDeclarativeScriptString");
586  qRegisterMetaType<QScriptValue>("QScriptValue");
587  qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeComponent::Status");
588 
590 
591  contextClass = new QDeclarativeContextScriptClass(q);
592  objectClass = new QDeclarativeObjectScriptClass(q);
593  valueTypeClass = new QDeclarativeValueTypeScriptClass(q);
594  typeNameClass = new QDeclarativeTypeNameScriptClass(q);
595  listClass = new QDeclarativeListScriptClass(q);
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 }
608 
610 {
612  if (!workerScriptEngine)
613  workerScriptEngine = new QDeclarativeWorkerScriptEngine(q);
614  return workerScriptEngine;
615 }
616 
655 : QObject(*new QDeclarativeEnginePrivate(this), parent)
656 {
658  d->init();
659 }
660 
669 {
671  if (d->isDebugging) {
674  }
675 }
676 
699 {
701  d->typeLoader.clearCache();
702 }
703 
716 {
717  Q_D(const QDeclarativeEngine);
718  return d->rootContext;
719 }
720 
732 {
734  QMutexLocker locker(&d->mutex);
735  d->networkAccessManagerFactory = factory;
736 }
737 
744 {
745  Q_D(const QDeclarativeEngine);
746  return d->networkAccessManagerFactory;
747 }
748 
750 {
751  QMutexLocker locker(&mutex);
754  nam = networkAccessManagerFactory->create(parent);
755  } else {
756  nam = new QNetworkAccessManager(parent);
757  }
758 
759  return nam;
760 }
761 
763 {
764  Q_Q(const QDeclarativeEngine);
766  networkAccessManager = createNetworkAccessManager(const_cast<QDeclarativeEngine*>(q));
767  return networkAccessManager;
768 }
769 
783 {
784  Q_D(const QDeclarativeEngine);
785  return d->getNetworkAccessManager();
786 }
787 
804 {
806  QMutexLocker locker(&d->mutex);
807  d->imageProviders.insert(providerId.toLower(), QSharedPointer<QDeclarativeImageProvider>(provider));
808 }
809 
814 {
815  Q_D(const QDeclarativeEngine);
816  QMutexLocker locker(&d->mutex);
817  return d->imageProviders.value(providerId).data();
818 }
819 
828 {
830  QMutexLocker locker(&d->mutex);
831  d->imageProviders.take(providerId);
832 }
833 
835 {
836  QMutexLocker locker(&mutex);
837  QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
838  locker.unlock();
839  if (provider)
840  return provider->imageType();
841  return static_cast<QDeclarativeImageProvider::ImageType>(-1);
842 }
843 
845 {
846  QMutexLocker locker(&mutex);
847  QImage image;
848  QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
849  locker.unlock();
850  if (provider) {
852  image = provider->requestImage(imageId, size, req_size);
853  }
854  return image;
855 }
856 
858 {
859  QMutexLocker locker(&mutex);
860  QPixmap pixmap;
861  QSharedPointer<QDeclarativeImageProvider> provider = imageProviders.value(url.host());
862  locker.unlock();
863  if (provider) {
865  pixmap = provider->requestPixmap(imageId, size, req_size);
866  }
867  return pixmap;
868 }
869 
881 {
882  Q_D(const QDeclarativeEngine);
883  if (d->baseUrl.isEmpty()) {
885  } else {
886  return d->baseUrl;
887  }
888 }
889 
896 {
898  d->baseUrl = url;
899 }
900 
908 {
909  Q_D(const QDeclarativeEngine);
910  return d->outputWarningsToStdErr;
911 }
912 
924 {
926  d->outputWarningsToStdErr = enabled;
927 }
928 
937 {
938  if(!object)
939  return 0;
940 
941  QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
942 
944  static_cast<QDeclarativeData *>(priv->declarativeData);
945 
946  if (!data)
947  return 0;
948  else if (data->outerContext)
949  return data->outerContext->asQDeclarativeContext();
950  else
951  return 0;
952 }
953 
963 {
964  if (!object || !context)
965  return;
966 
968  if (data->context) {
969  qWarning("QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext");
970  return;
971  }
972 
974  contextData->addObject(object);
975 }
976 
1020 {
1021  if (!object)
1022  return;
1023 
1024  QDeclarativeData *ddata = QDeclarativeData::get(object, true);
1025  if (!ddata)
1026  return;
1027 
1028  ddata->indestructible = (ownership == CppOwnership)?true:false;
1029  ddata->explicitIndestructibleSet = true;
1030 }
1031 
1036 {
1037  if (!object)
1038  return CppOwnership;
1039 
1040  QDeclarativeData *ddata = QDeclarativeData::get(object, false);
1041  if (!ddata)
1042  return CppOwnership;
1043  else
1045 }
1046 
1048 {
1050 
1051  if (data && data->deferredComponent) {
1057  if (data->outerContext)
1059  }
1061 
1063  QDeclarativeComponentPrivate::beginDeferred(ep, object, &state);
1064 
1065  data->deferredComponent->release();
1066  data->deferredComponent = 0;
1067 
1070  }
1071 }
1072 
1074 {
1076 }
1077 
1079 {
1081  return context?context->engine():0;
1082 }
1083 
1085 {
1087  if (!data)
1088  return 0; // Attached properties are only on objects created by QML
1089 
1090  QObject *rv = data->hasExtendedData()?data->attachedProperties()->value(id):0;
1091  if (rv || !create)
1092  return rv;
1093 
1095  if (!pf)
1096  return 0;
1097 
1098  rv = pf(const_cast<QObject *>(object));
1099 
1100  if (rv)
1101  data->attachedProperties()->insert(id, rv);
1102 
1103  return rv;
1104 }
1105 
1106 QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object,
1107  const QMetaObject *attachedMetaObject, bool create)
1108 {
1109  if (*idCache == -1)
1110  *idCache = QDeclarativeMetaType::attachedPropertiesFuncId(attachedMetaObject);
1111 
1112  if (*idCache == -1 || !object)
1113  return 0;
1114 
1115  return qmlAttachedPropertiesObjectById(*idCache, object, create);
1116 }
1117 
1119 {
1120 #ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL
1122  qDebug("Qml debugging is enabled. Only use this in a safe environment!");
1123  }
1125 #endif
1126 }
1127 
1128 
1130 public:
1133 
1137 };
1138 
1140 {
1141 }
1142 
1144 {
1145 }
1146 
1148 {
1149  if (!extendedData) extendedData = new QDeclarativeDataExtended;
1150  return &extendedData->objectNameNotifier;
1151 }
1152 
1154 {
1155  if (!extendedData) extendedData = new QDeclarativeDataExtended;
1156  return &extendedData->attachedProperties;
1157 }
1158 
1160 {
1161  if (!extendedData) extendedData = new QDeclarativeDataExtended;
1162  extendedData->boundSignals.append(signal);
1163 }
1164 
1166 {
1167  if (extendedData)
1168  extendedData->boundSignals.removeAll(signal);
1169 }
1170 
1172 {
1173  QDeclarativeAbstractBinding *binding = bindings;
1174  while (binding) {
1176  binding = binding->m_nextBinding;
1177  }
1178 
1179  if (extendedData) {
1180  Q_FOREACH (QDeclarativeAbstractBoundSignal *signal, extendedData->boundSignals)
1181  signal->disconnect();
1182  }
1183 }
1184 
1186 {
1187  if (deferredComponent)
1188  deferredComponent->release();
1189 
1190  if (nextContextObject)
1191  nextContextObject->prevContextObject = prevContextObject;
1192  if (prevContextObject)
1193  *prevContextObject = nextContextObject;
1194 
1195  QDeclarativeAbstractBinding *binding = bindings;
1196  while (binding) {
1197  QDeclarativeAbstractBinding *next = binding->m_nextBinding;
1198  binding->m_prevBinding = 0;
1199  binding->m_nextBinding = 0;
1201  binding = next;
1202  }
1203 
1204  if (bindingBits)
1205  free(bindingBits);
1206 
1207  if (propertyCache)
1208  propertyCache->release();
1209 
1210  if (ownContext && context)
1211  context->destroy();
1212 
1213  while (guards) {
1214  QDeclarativeGuard<QObject> *guard = static_cast<QDeclarativeGuard<QObject> *>(guards);
1215  *guard = (QObject *)0;
1216  guard->objectDestroyed(object);
1217  }
1218 
1219  if (scriptValue)
1220  delete scriptValue;
1221 
1222  if (extendedData)
1223  delete extendedData;
1224 
1225  if (ownMemory)
1226  delete this;
1227 }
1228 
1230 {
1231  if (!parent && scriptValue) { delete scriptValue; scriptValue = 0; }
1232 }
1233 
1235 {
1236  if (extendedData) objectNameNotifier()->notify();
1237 }
1238 
1240 {
1241  if (bindingBitsSize > bit)
1242  return bindingBits[bit / 32] & (1 << (bit % 32));
1243  else
1244  return false;
1245 }
1246 
1248 {
1249  if (bindingBitsSize > bit)
1250  bindingBits[bit / 32] &= ~(1 << (bit % 32));
1251 }
1252 
1254 {
1255  if (bindingBitsSize <= bit) {
1256  int props = obj->metaObject()->propertyCount();
1257  Q_ASSERT(bit < props);
1258 
1259  int arraySize = (props + 31) / 32;
1260  int oldArraySize = bindingBitsSize / 32;
1261 
1262  bindingBits = (quint32 *)q_check_ptr(realloc(bindingBits,
1263  arraySize * sizeof(quint32)));
1264 
1265  memset(bindingBits + oldArraySize,
1266  0x00,
1267  sizeof(quint32) * (arraySize - oldArraySize));
1268 
1269  bindingBitsSize = arraySize * 32;
1270  }
1271 
1272  bindingBits[bit / 32] |= (1 << (bit % 32));
1273 }
1274 
1284  QDeclarativeEngine* engine)
1285 {
1287  return enginePriv->objectClass->newQObject(object);
1288 }
1289 
1294 {
1296  Q_ASSERT(scopeNode.isValid());
1297  Q_ASSERT(QScriptDeclarativeClass::scriptClass(scopeNode) == contextClass);
1298  return contextClass->contextFromValue(scopeNode);
1299 }
1300 
1306 {
1308  Q_ASSERT(scopeNode.isValid());
1309  Q_ASSERT(QScriptDeclarativeClass::scriptClass(scopeNode) == contextClass);
1310  return contextClass->urlFromValue(scopeNode);
1311 }
1312 
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 }
1322 
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 }
1367 
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 }
1484 
1490 {
1491  if (ctxt->argumentCount() == 0)
1492  return QScriptValue(engine, false);
1493 
1494  return QScriptValue(engine, 0 != ctxt->argument(0).toQObject());
1495 }
1496 
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 }
1510 
1525 #ifndef QT_NO_DATESTRING
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 }
1547 
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 }
1588 
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 }
1701 #endif // QT_NO_DATESTRING
1702 
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 }
1730 
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 }
1758 
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 }
1778 
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 }
1791 
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 }
1804 
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 }
1840 
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 }
1877 
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 }
1892 
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 }
1907 
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 }
1922 
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 }
1936 
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 }
1951 
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 }
1970 
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 }
1979 
1981 {
1982  qWarning().nospace() << qPrintable(error.toString());
1983 }
1984 
1985 static void dumpwarning(const QList<QDeclarativeError> &errors)
1986 {
1987  for (int ii = 0; ii < errors.count(); ++ii)
1988  dumpwarning(errors.at(ii));
1989 }
1990 
1992 {
1994  q->warnings(QList<QDeclarativeError>() << error);
1995  if (outputWarningsToStdErr)
1996  dumpwarning(error);
1997 }
1998 
2000 {
2002  q->warnings(errors);
2003  if (outputWarningsToStdErr)
2004  dumpwarning(errors);
2005 }
2006 
2008 {
2009  if (engine)
2010  QDeclarativeEnginePrivate::get(engine)->warning(error);
2011  else
2012  dumpwarning(error);
2013 }
2014 
2016 {
2017  if (engine)
2018  QDeclarativeEnginePrivate::get(engine)->warning(error);
2019  else
2020  dumpwarning(error);
2021 }
2022 
2024 {
2025  if (engine)
2026  engine->warning(error);
2027  else
2028  dumpwarning(error);
2029 }
2030 
2032 {
2033  if (engine)
2034  engine->warning(error);
2035  else
2036  dumpwarning(error);
2037 }
2038 
2048 {
2049  QDeclarativeEnginePrivate *qe = get (e);
2050  qe->sendQuit();
2051  return QScriptValue();
2052 }
2053 
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 }
2130 
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 }
2161 
2163 {
2165  if (dc == objectClass)
2166  return QVariant::fromValue(objectClass->toQObject(val));
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 }
2186 
2197 {
2199  d->importDatabase.addImportPath(path);
2200 }
2201 
2219 {
2220  Q_D(const QDeclarativeEngine);
2221  return d->importDatabase.importPathList();
2222 }
2223 
2235 {
2237  d->importDatabase.setImportPathList(paths);
2238 }
2239 
2240 
2253 {
2255  d->importDatabase.addPluginPath(path);
2256 }
2257 
2258 
2269 {
2270  Q_D(const QDeclarativeEngine);
2271  return d->importDatabase.pluginPathList();
2272 }
2273 
2285 {
2287  d->importDatabase.setPluginPathList(paths);
2288 }
2289 
2290 
2300 {
2302  return d->importDatabase.importPlugin(filePath, uri, errorString);
2303 }
2304 
2326 {
2328  d->scriptEngine.offlineStoragePath = dir;
2329 }
2330 
2332 {
2333  Q_D(const QDeclarativeEngine);
2334  return d->scriptEngine.offlineStoragePath;
2335 }
2336 
2337 static void voidptr_destructor(void *v)
2338 {
2339  void **ptr = (void **)v;
2340  delete ptr;
2341 }
2342 
2343 static void *voidptr_constructor(const void *v)
2344 {
2345  if (!v) {
2346  return new void*;
2347  } else {
2348  return new void*(*(void **)v);
2349  }
2350 }
2351 
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 }
2368 
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 }
2470 
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 }
2487 
2489 {
2490  return m_qmlLists.contains(t) || QDeclarativeMetaType::isList(t);
2491 }
2492 
2494 {
2495  QHash<int, int>::ConstIterator iter = m_qmlLists.find(t);
2496  if (iter != m_qmlLists.end())
2497  return *iter;
2498  else
2500 }
2501 
2503 {
2504  return m_compositeTypes.contains(t) || QDeclarativeMetaType::isQObject(t);
2505 }
2506 
2508 {
2509  int t = v.userType();
2510  if (t == QMetaType::QObjectStar || m_compositeTypes.contains(t)) {
2511  if (ok) *ok = true;
2512  return *(QObject **)(v.constData());
2513  } else {
2514  return QDeclarativeMetaType::toQObject(v, ok);
2515  }
2516 }
2517 
2519 {
2520  if (m_compositeTypes.contains(t))
2522  else if (m_qmlLists.contains(t))
2524  else
2526 }
2527 
2529 {
2530  QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
2531  if (iter != m_compositeTypes.end()) {
2532  return (*iter)->root;
2533  } else {
2535  return type?type->baseMetaObject():0;
2536  }
2537 }
2538 
2540 {
2541  QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.find(t);
2542  if (iter != m_compositeTypes.end()) {
2543  return (*iter)->root;
2544  } else {
2546  return type?type->metaObject():0;
2547  }
2548 }
2549 
2551 {
2552 #if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
2553  QFileInfo info(fileName);
2554 
2555  QString absolute = info.absoluteFilePath();
2556 
2557 #if defined(Q_OS_MAC)
2558  QString canonical = info.canonicalFilePath();
2559 #elif defined(Q_OS_WIN32)
2560  wchar_t buffer[1024];
2561 
2562  DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024);
2563  if (rv == 0 || rv >= 1024) return true;
2564  rv = ::GetLongPathName(buffer, buffer, 1024);
2565  if (rv == 0 || rv >= 1024) return true;
2566 
2567  QString canonical((QChar *)buffer);
2568 #endif
2569 
2570  int absoluteLength = absolute.length();
2571  int canonicalLength = canonical.length();
2572 
2573  int length = qMin(absoluteLength, canonicalLength);
2574  for (int ii = 0; ii < length; ++ii) {
2575  const QChar &a = absolute.at(absoluteLength - 1 - ii);
2576  const QChar &c = canonical.at(canonicalLength - 1 - ii);
2577 
2578  if (a.toLower() != c.toLower())
2579  return true;
2580  if (a != c)
2581  return false;
2582  }
2583 #else
2584  Q_UNUSED(fileName)
2585 #endif
2586  return true;
2587 }
2588 
QDeclarativeContextData * outerContext
ImageType
Defines the type of image supported by this image provider.
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
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static QScriptValue isQtObject(QScriptContext *, QScriptEngine *)
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
static QScriptValue rgba(QScriptContext *, QScriptEngine *)
QUrl resolvedUrl(const QUrl &)
static ObjectOwnership objectOwnership(QObject *)
Returns the ownership of object.
static QDeclarativeComponentPrivate * get(QDeclarativeComponent *c)
static QObject * toQObject(const QVariant &, bool *ok=0)
static QString urlToLocalFileOrQrc(const QUrl &url)
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
double d
Definition: qnumeric_p.h:62
void setBindingBit(QObject *obj, int)
The QScriptContext class represents a Qt Script function invocation.
QObject *(* QDeclarativeAttachedPropertiesFunc)(QObject *)
T * q_check_ptr(T *p)
Definition: qglobal.h:1857
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QStringList importPathList() const
Returns the list of directories where the engine searches for installed modules in a URL-based direct...
QDeclarativeContextData * context
void addPluginPath(const QString &dir)
Adds path as a directory where the engine searches for native plugins for imported modules (reference...
virtual QNetworkAccessManager * create(QObject *parent)=0
Creates and returns a network access manager with the specified parent.
qreal alphaF() const
Returns the alpha color component of this color.
Definition: qcolor.cpp:1106
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
static QDeclarativeData * get(const QObject *object, bool create=false)
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
QColor Q_DECLARATIVE_PRIVATE_EXPORT colorFromString(const QString &, bool *ok=0)
virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
Implement this method to return the pixmap with id.
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...
virtual QNetworkAccessManager * networkAccessManager()
int type
Definition: qmetatype.cpp:239
QByteArray module() const
QUrl url() const
Returns the url for the file that caused this error.
static QScriptValue hsla(QScriptContext *, QScriptEngine *)
QNetworkAccessManager * getNetworkAccessManager() const
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
Definition: qurl.cpp:4303
void addEngine(QDeclarativeEngine *)
double qreal
Definition: qglobal.h:1193
static mach_timebase_info_data_t info
unsigned char c[8]
Definition: qnumeric_p.h:62
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QDeclarativeParserStatus ** d
void setDescription(const QString &)
Sets the error description.
QDeclarativeGuardedContextData creationContext
static QDeclarativeAttachedPropertiesFunc attachedPropertiesFuncById(int)
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
static void setContextForObject(QObject *, QDeclarativeContext *)
Sets the QDeclarativeContext for the object to context.
qreal greenF() const
Returns the green color component of this color.
Definition: qcolor.cpp:1241
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
static QString storageLocation(StandardLocation type)
Returns the default system directory where files of type belong, or an empty string if the location c...
static QScriptValue formatTime(QScriptContext *, QScriptEngine *)
QDateTime toDateTime() const
Returns a QDateTime representation of this value, in local time.
QDeclarativeEngine * engine
static void voidptr_destructor(void *v)
static void rangeLocation(RangeType, const QString &, int)
void addImportPath(const QString &dir)
Adds path as a directory where the engine searches for installed modules in a URL-based directory str...
QUrl getUrl(QScriptContext *)
Returns the QUrl associated with the script ctxt for the case that there is no QDeclarativeContext.
The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties...
void removeImageProvider(const QString &id)
Removes the QDeclarativeImageProvider for providerId.
static bool isDebugging
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
QUrl baseUrl() const
Return the base URL for this engine.
static QScriptValue include(QScriptContext *ctxt, QScriptEngine *engine)
#define error(msg)
qint32 toInt32() const
Returns the signed 32-bit integer value of this QScriptValue, using the conversion rules described in...
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QScriptValue createQmlObject(QScriptContext *, QScriptEngine *)
QObject * toQObject(const QScriptValue &) const
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
QScriptValue toScriptValue(const T &value)
Creates a QScriptValue with the given value.
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
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
QDeclarativeImageProvider * imageProvider(const QString &id) const
Returns the QDeclarativeImageProvider set for providerId.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QHash< int, QObject * > * attachedProperties() const
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
static QScriptValue quit(QScriptContext *, QScriptEngine *)
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
void unlock()
Unlocks this mutex locker.
Definition: qmutex.h:117
static const QMetaObject * get()
QDeclarativeGlobalScriptClass * globalClass
QScriptValue globalObject() const
Returns this engine&#39;s Global Object.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
static QScriptValue formatDate(QScriptContext *, QScriptEngine *)
static QScriptValue size(QScriptContext *, QScriptEngine *)
static void setObjectOwnership(QObject *, ObjectOwnership)
Sets the ownership of object.
void addBoundSignal(QDeclarativeAbstractBoundSignal *signal)
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...
static void init()
static QScriptValue btoa(QScriptContext *, QScriptEngine *)
static QScriptValue tint(QScriptContext *, QScriptEngine *)
bool isReady() const
Returns true if status() == QDeclarativeComponent::Ready.
void setData(const QByteArray &, const QUrl &baseUrl)
Sets the QDeclarativeComponent to use the given QML data.
int qMetaTypeId()
Definition: qmetatype.h:224
void removeEngine(QDeclarativeEngine *)
QString absoluteFilePath() const
Returns an absolute path including the file name.
Definition: qfileinfo.cpp:534
static int attachedPropertiesFuncId(const QMetaObject *)
The QDate class provides date functions.
Definition: qdatetime.h:55
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const QMetaObject * baseMetaObject() const
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QHash< int, QObject * > attachedProperties
void quit()
This signal is emitted when the QML loaded by the engine would like to quit.
QScriptEngine * engine() const
Returns the QScriptEngine that this QScriptContext belongs to.
void setOfflineStoragePath(const QString &dir)
static QScriptValue worker_include(QScriptContext *ctxt, QScriptEngine *engine)
QObject * toQObject() const
If this QScriptValue is a QObject, returns the QObject pointer that the QScriptValue represents; othe...
int propertyCount() const
Returns the number of properties in this class, including the number of properties provided by each b...
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 QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
QString host() const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition: qurl.cpp:4837
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
static QScriptValue lighter(QScriptContext *, QScriptEngine *)
QByteArray toHex() const
Returns a hex encoded copy of the byte array.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
static QScriptValue createComponent(QScriptContext *, QScriptEngine *)
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
Definition: qdir.cpp:1831
bool hasBindingBit(int) const
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
Definition: qdatetime.cpp:2628
static void dumpwarning(const QDeclarativeError &error)
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static TypeCategory typeCategory(int)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
virtual ~QDeclarativeEngine()
Destroys the QDeclarativeEngine.
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
static QDeclarativeScriptEngine * get(QScriptEngine *e)
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 objectNameChanged(QAbstractDeclarativeData *, QObject *)
void setParent(QObject *)
Makes the object a child of parent.
Definition: qobject.cpp:1950
QScriptValue newQObject(QObject *, int type=QMetaType::QObjectStar)
QVariant scriptValueToVariant(const QScriptValue &, int hint=QVariant::Invalid)
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeCompiledData * deferredComponent
QDeclarativeCleanup ** prev
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
QString toString() const
Returns the error as a human readable string.
static QScriptValue point(QScriptContext *, QScriptEngine *)
void setImportPathList(const QStringList &paths)
Sets paths as the list of directories where the engine searches for installed modules in a URL-based ...
Q_CORE_EXPORT void qDebug(const char *,...)
QColor darker(int f=200) const
Returns a darker (or lighter) color, but does not change this object.
Definition: qcolor.h:301
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void removeBoundSignal(QDeclarativeAbstractBoundSignal *signal)
QObject * qmlAttachedPropertiesObject(int *idCache, const QObject *object, const QMetaObject *attachedMetaObject, bool create)
bool QDeclarative_isFileCaseCorrect(const QString &fileName)
Returns true if the case of fileName is equivalent to the file case of fileName on disk...
static QScriptValue darker(QScriptContext *, QScriptEngine *)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
The QScriptEngine class provides an environment for evaluating Qt Script code.
The QTime class provides clock time functions.
Definition: qdatetime.h:148
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void qt_add_qmlxmlhttprequest(QScriptEngine *engine)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
The QDeclarativeComponent class encapsulates a QML component definition.
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.
static void * voidptr_constructor(const void *v)
QList< QDeclarativeError > errors() const
Return the list of errors that occurred during the last compile or create operation.
QDeclarativeScriptEngine scriptEngine
const char * typeName
Definition: qmetatype.cpp:239
void setBaseUrl(const QUrl &)
Set the base URL for this engine to url.
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
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
QDeclarativeImageProvider::ImageType getImageProviderType(const QUrl &url)
The QDeclarativeParserStatus class provides updates on the QML parser state.
bool importPlugin(const QString &filePath, const QString &uri, QString *errorString)
Imports the plugin named filePath with the uri provided.
const char * name
void installTranslatorFunctions(const QScriptValue &object=QScriptValue())
Installs translator functions on the given object, or on the Global Object if no object is specified...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDeclarativeContext * qmlContext(const QObject *obj)
#define emit
Definition: qobjectdefs.h:76
QString description() const
Returns the error description.
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QDeclarativeMetaType::TypeCategory typeCategory(int) const
static QScriptValue consoleLog(QScriptContext *, QScriptEngine *)
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
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
Definition: qfileinfo.cpp:551
QScriptValue scriptValueFromVariant(const QVariant &)
static QScriptValue qmlScriptObject(QObject *, QDeclarativeEngine *)
Creates a QScriptValue allowing you to use object in QML script.
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QDeclarativeContext * rootContext() const
Returns the engine&#39;s root context.
ObjectOwnership
Ownership controls whether or not QML automatically destroys the QObject when the object is garbage c...
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
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 void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *)
QScriptValue newObject()
Creates a QtScript object of class Object.
void qt_add_qmlsqldatabase(QScriptEngine *engine)
QDeclarativeScriptEngine(QDeclarativeEnginePrivate *priv)
virtual QObject * beginCreate(QDeclarativeContext *)
This method provides more advanced control over component instance creation.
QByteArray qmlTypeName() const
static QScriptValue md5(QScriptContext *, QScriptEngine *)
The QDeclarativeError class encapsulates a QML error.
static QList< QDeclarativePrivate::AutoParentFunction > parentFunctions()
quint32 toUInt32() const
Returns the unsigned 32-bit integer value of this QScriptValue, using the conversion rules described ...
QStringList pluginPathList() const
Returns the list of directories where the engine searches for native plugins for imported modules (re...
const T * ptr(const T &t)
QDeclarativeEngine * qmlEngine(const QObject *obj)
QDeclarativeNetworkAccessManagerFactory * networkAccessManagerFactory() const
Returns the current QDeclarativeNetworkAccessManagerFactory.
QList< QDeclarativeAbstractBoundSignal * > boundSignals
static qreal component(const QPointF &point, unsigned int i)
static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state)
QDeclarativeAbstractBinding * m_nextBinding
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
QDeclarativeListProperty< QObject > property
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
QDeclarativeEngine(QObject *p=0)
Create a new QDeclarativeEngine with the given parent.
static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, ConstructionState *state)
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
quint32 explicitIndestructibleSet
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
The QNetworkAccessManager class allows the application to send network requests and receive replies...
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
QAbstractDeclarativeData * declarativeData
Definition: qobject_p.h:214
bool hasExtendedData() const
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
static bool qt_QmlQtModule_registered
int line() const
Returns the error line number.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
QUrl resolvedUrl(QScriptContext *context, const QUrl &url)
static QScriptValue desktopOpenUrl(QScriptContext *, QScriptEngine *)
QDeclarativeObjectScriptClass * objectClass
static void endRange(RangeType)
QDeclarativeNotifier * objectNameNotifier() const
static void startRange(RangeType)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the time as a string.
Definition: qdatetime.cpp:1653
virtual void disconnect(DisconnectMode disconnectMode)=0
The QDeclarativeImageProvider class provides an interface for supporting pixmaps and threaded image r...
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
static QByteArray fromBase64(const QByteArray &base64)
Returns a decoded copy of the Base64 array base64.
static void destroyed(QAbstractDeclarativeData *, QObject *)
const QMetaObject * metaObject() const
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
bool isNumber() const
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false...
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 QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
QImage getImageFromProvider(const QUrl &url, QSize *size, const QSize &req_size)
virtual void clear()=0
void append(QDeclarativeEngine *, const QMetaObject *, Data::Flag propertyFlags=Data::NoFlags, Data::Flag methodFlags=Data::NoFlags, Data::Flag signalFlags=Data::NoFlags)
int compare(const QString &s) const
Definition: qstring.cpp:5037
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QDeclarativeNetworkAccessManagerFactory class creates QNetworkAccessManager instances for a QML e...
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[]
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
The QDeclarativeEngine class provides an environment for instantiating QML components.
int column() const
Returns the error column number.
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
static void clear(SimpleList< QDeclarativeAbstractBinding > &)
void Q_DECLARATIVE_EXPORT qdeclarativeelement_destructor(QObject *)
bool outputWarningsToStandardError() const
Returns true if warning messages will be output to stderr in addition to being emitted by the warning...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
static QDeclarativeEngineDebugService * instance()
qreal redF() const
Returns the red color component of this color.
Definition: qcolor.cpp:1213
QDeclarativeContext * asQDeclarativeContext()
const QMetaObject * metaObjectForType(int) const
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
static QDeclarativeListReferencePrivate * get(QDeclarativeListReference *ref)
int length() const
This function is identical to count().
Definition: qlist.h:281
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
const void * constData() const
Definition: qvariant.cpp:3065
static QScriptValue vector3d(QScriptContext *, QScriptEngine *)
void setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *)
Sets the factory to use for creating QNetworkAccessManager(s).
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
unsigned int quint32
Definition: qglobal.h:938
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
static const QMetaObjectPrivate * priv(const uint *data)
QDeclarativeNotifier objectNameNotifier
static void cleanup()
Definition: qpicture.cpp:1508
qreal blueF() const
Returns the blue color component of this color.
Definition: qcolor.cpp:1269
static QScriptValue rect(QScriptContext *, QScriptEngine *)
static QScriptValue scopeChainValue(QScriptContext *, int index)
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
QFactoryLoader * l
QByteArray toBase64() const
Returns a copy of the byte array, encoded as Base64.
double qsreal
Definition: qscriptvalue.h:52
static void rangeData(RangeType, const QString &)
static QScriptValue fontFamilies(QScriptContext *, QScriptEngine *)
static const QMetaObject staticQtMetaObject
Definition: qobject.h:322
The QDeclarativeContext class defines a context within a QML engine.
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QDeclarativeEngine * engine() const
Return the context&#39;s QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the QDeclar...
bool isDate() const
Returns true if this QScriptValue is an object of the Date class; otherwise returns false...
QObject * toQObject(const QVariant &, bool *ok=0) const
The QDeclarativeCleanup provides a callback when a QDeclarativeEngine is deleted. ...
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
void setOutputWarningsToStandardError(bool)
Set whether warning messages will be output to stderr to enabled.
QDeclarativeEnginePrivate * p
#define Q_FOREACH(variable, container)
Same as foreach(variable, container).
Definition: qglobal.h:2435
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition: qurl.cpp:6374
QScriptValue newQMetaObject(const QMetaObject *metaObject, const QScriptValue &ctor=QScriptValue())
Creates a QtScript object that represents a QObject class, using the the given metaObject and constru...
static QScriptDeclarativeClass * scriptClass(const QScriptValue &)
QDeclarativeEnginePrivate(QDeclarativeEngine *)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
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
static QDeclarativeContext * contextForObject(const QObject *)
Returns the QDeclarativeContext for the object, or 0 if no context has been set.
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
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
QDeclarativeCleanup * next
static QScriptValue atob(QScriptContext *, QScriptEngine *)
void clearComponentCache()
Clears the engine&#39;s internal component cache.
QScriptValue newArray(uint length=0)
Creates a QtScript object of class Array with the given length.
QDeclarativeAbstractBinding ** m_prevBinding
bool isArray() const
Returns true if this QScriptValue is an object of the Array class; otherwise returns false...
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
QNetworkAccessManager * networkAccessManager() const
Returns a common QNetworkAccessManager which can be used by any QML element instantiated by this engi...
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition: qurl.cpp:5819
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
void registerCompositeType(QDeclarativeCompiledData *)
static QJSDebugService * instance()
static QScriptValue formatDateTime(QScriptContext *, QScriptEngine *)
bool isError() const
Returns true if status() == QDeclarativeComponent::Error.
QString offlineStoragePath() const
void warning(const QDeclarativeError &)
QDeclarativeContextData * getContext(QScriptContext *)
Returns the QDeclarativeContext for the executing QScript ctxt.
void setPluginPathList(const QStringList &paths)
Sets the list of directories where the engine searches for native plugins for imported modules (refer...
#define qPrintable(string)
Definition: qglobal.h:1750
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QDeclarativeGuard< QObject > object
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the date as a string.
Definition: qdatetime.cpp:823
static QString fileName(const QString &fileUrl)
const QMetaObject * rawMetaObjectForType(int) const
QDeclarativeWorkerScriptEngine * getWorkerScriptEngine()
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1239
QDeclarativePropertyCache * copy() const
ImageType imageType() const
Returns the image type supported by this provider.
QNetworkAccessManager * createNetworkAccessManager(QObject *parent) const
QScriptValue argument(int index) const
Returns the function argument at the given index.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool isValid() const
Returns true if this QScriptValue is valid; otherwise returns false.
static QByteArray hash(const QByteArray &data, Algorithm method)
Returns the hash of data using method.
virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize)
Implement this method to return the image with id.
QDeclarativePropertyCache * createCache(const QMetaObject *)
#define enabled
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
virtual void completeCreate()
This method provides more advanced control over component instance creation.
QScriptValue newVariant(const QVariant &value)
Creates a QtScript object holding the given variant value.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.
Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object)
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
QPixmap getPixmapFromProvider(const QUrl &url, QSize *size, const QSize &req_size)
QObject * qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create)
void addImageProvider(const QString &id, QDeclarativeImageProvider *)
Sets the provider to use for images requested via the image: url scheme, with host providerId...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
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.
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290
DateFormat
Definition: qnamespace.h:1392
static QDeclarativeContextData * get(QDeclarativeContext *context)