diff options
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/declarative.pro | 1 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem.cpp | 22 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativepathview.cpp | 95 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativecompiler.cpp | 16 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeexpression.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeexpression_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativefastproperties_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativemetatype.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativevaluetype.cpp | 12 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativevme.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativexmlhttprequest.cpp | 2 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeanimation_p.h | 11 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativefontloader.cpp | 4 |
15 files changed, 119 insertions, 63 deletions
diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index be3978aa..365cb04e 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -29,7 +29,6 @@ HEADERS += \ linux-g++-maemo:DEFINES += QDECLARATIVEVIEW_NOBACKGROUND DEFINES += QT_NO_OPENTYPE -INCLUDEPATH += ../3rdparty/harfbuzz/src blackberry: { DEFINES += CUSTOM_DECLARATIVE_DEBUG_TRACE_INSTANCE diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 39ec4881..a38938bc 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -2627,10 +2627,17 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, qreal x, qr return 0; } - QScriptValue sv = item.engine()->newObject(); - // If QGraphicsItem::mapFromItem() is called with 0, behaves the same as mapFromScene() QPointF p = qobject_cast<QGraphicsItem*>(this)->mapFromItem(itemObj, x, y); + + // Use the script engine from the passed item, if available. Use this item's one otherwise. + QScriptEngine* const se = itemObj ? item.engine() : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this)); + + // Engine-less items are unlikely, but nevertheless possible. Handle them. + if (0 == se) + return QScriptValue(QScriptValue::UndefinedValue); + + QScriptValue sv = se->newObject(); sv.setProperty(QLatin1String("x"), p.x()); sv.setProperty(QLatin1String("y"), p.y()); return sv; @@ -2665,10 +2672,17 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea return 0; } - QScriptValue sv = item.engine()->newObject(); - // If QGraphicsItem::mapToItem() is called with 0, behaves the same as mapToScene() QPointF p = qobject_cast<QGraphicsItem*>(this)->mapToItem(itemObj, x, y); + + // Use the script engine from the passed item, if available. Use this item's one otherwise. + QScriptEngine* const se = itemObj ? item.engine() : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this)); + + // Engine-less items are unlikely, but nevertheless possible. Handle them. + if (0 == se) + return QScriptValue(QScriptValue::UndefinedValue); + + QScriptValue sv = se->newObject(); sv.setProperty(QLatin1String("x"), p.x()); sv.setProperty(QLatin1String("y"), p.y()); return sv; diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 9ccb4000..e49c1e76 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -163,6 +163,7 @@ void QDeclarativePathViewPrivate::clear() releaseItem(p); } items.clear(); + tl.clear(); } void QDeclarativePathViewPrivate::updateMappedRange() @@ -475,6 +476,8 @@ QDeclarativePathView::~QDeclarativePathView() For large or dynamic datasets the model is usually provided by a C++ model object. Models can also be created directly in QML, using the ListModel element. + \note changing the model will reset the offset and currentIndex to 0. + \sa {qmlmodels}{Data Models} */ QVariant QDeclarativePathView::model() const @@ -495,11 +498,7 @@ void QDeclarativePathView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - for (int i=0; i<d->items.count(); i++){ - QDeclarativeItem *p = d->items[i]; - d->model->release(p); - } - d->items.clear(); + d->clear(); } d->modelVariant = model; @@ -519,6 +518,7 @@ void QDeclarativePathView::setModel(const QVariant &model) if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) dataModel->setModel(model); } + int oldModelCount = d->modelCount; d->modelCount = 0; if (d->model) { connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); @@ -527,14 +527,20 @@ void QDeclarativePathView::setModel(const QVariant &model) connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); d->modelCount = d->model->count(); - if (d->model->count()) - d->offset = qmlMod(d->offset, qreal(d->model->count())); - if (d->offset < 0) - d->offset = d->model->count() + d->offset; -} + } + if (isComponentComplete()) { + if (d->currentIndex != 0) { + d->currentIndex = 0; + emit currentIndexChanged(); + } + if (d->offset != 0.0) { + d->offset = 0; + emit offsetChanged(); + } + } d->regenerate(); - d->fixOffset(); - emit countChanged(); + if (d->modelCount != oldModelCount) + emit countChanged(); emit modelChanged(); } @@ -592,8 +598,17 @@ int QDeclarativePathView::currentIndex() const void QDeclarativePathView::setCurrentIndex(int idx) { Q_D(QDeclarativePathView); - if (d->model && d->modelCount) - idx = qAbs(idx % d->modelCount); + if (!isComponentComplete()) { + if (idx != d->currentIndex) { + d->currentIndex = idx; + emit currentIndexChanged(); + } + return; + } + + idx = d->modelCount + ? ((idx % d->modelCount) + d->modelCount) % d->modelCount + : 0; if (d->model && idx != d->currentIndex) { if (d->modelCount) { int itemIndex = (d->currentIndex - d->firstIndex + d->modelCount) % d->modelCount; @@ -649,13 +664,8 @@ void QDeclarativePathView::incrementCurrentIndex() void QDeclarativePathView::decrementCurrentIndex() { Q_D(QDeclarativePathView); - if (d->model && d->modelCount) { - int idx = currentIndex()-1; - if (idx < 0) - idx = d->modelCount - 1; - d->moveDirection = QDeclarativePathViewPrivate::Negative; - setCurrentIndex(idx); - } + d->moveDirection = QDeclarativePathViewPrivate::Negative; + setCurrentIndex(currentIndex()-1); } /*! @@ -1323,15 +1333,20 @@ void QDeclarativePathView::componentComplete() { Q_D(QDeclarativePathView); QDeclarativeItem::componentComplete(); - d->createHighlight(); - // It is possible that a refill has already happended to to Path - // bindings being handled in the componentComplete(). If so - // don't do it again. - if (d->items.count() == 0 && d->model) { + + if (d->model) { d->modelCount = d->model->count(); - d->regenerate(); + if (d->modelCount && d->currentIndex != 0) // an initial value has been provided for currentIndex + d->offset = qmlMod(d->modelCount - d->currentIndex, d->modelCount); } + + d->createHighlight(); + d->regenerate(); d->updateHighlight(); + d->updateCurrent(); + + if (d->modelCount) + emit countChanged(); } void QDeclarativePathView::refill() @@ -1522,6 +1537,10 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count) } d->modelCount -= count; + + if (d->currentIndex == -1) + d->currentIndex = d->calcCurrentIndex(); + if (!d->modelCount) { while (d->itemCache.count()) d->releaseItem(d->itemCache.takeLast()); @@ -1548,19 +1567,19 @@ void QDeclarativePathView::itemsMoved(int /*from*/, int /*to*/, int /*count*/) if (!d->isValid() || !isComponentComplete()) return; + int oldCurrent = d->currentIndex; + // Fix current index + if (d->currentIndex >= 0 && d->currentItem) + d->currentIndex = d->model->indexOf(d->currentItem, this); + QList<QDeclarativeItem *> removedItems = d->items; d->items.clear(); d->regenerate(); while (removedItems.count()) d->releaseItem(removedItems.takeLast()); - // Fix current index - if (d->currentIndex >= 0 && d->currentItem) { - int oldCurrent = d->currentIndex; - d->currentIndex = d->model->indexOf(d->currentItem, this); - if (oldCurrent != d->currentIndex) - emit currentIndexChanged(); - } + if (oldCurrent != d->currentIndex) + emit currentIndexChanged(); d->updateCurrent(); } @@ -1623,7 +1642,7 @@ void QDeclarativePathView::movementEnding() // find the item closest to the snap position int QDeclarativePathViewPrivate::calcCurrentIndex() { - int current = -1; + int current = 0; if (modelCount && model && items.count()) { offset = qmlMod(offset, modelCount); if (offset < 0) @@ -1644,7 +1663,7 @@ void QDeclarativePathViewPrivate::updateCurrent() return; int idx = calcCurrentIndex(); - if (model && idx != currentIndex) { + if (model && (idx != currentIndex || !currentItem)) { int itemIndex = (currentIndex - firstIndex + modelCount) % modelCount; if (itemIndex < items.count()) { if (QDeclarativeItem *item = items.at(itemIndex)) { @@ -1652,6 +1671,7 @@ void QDeclarativePathViewPrivate::updateCurrent() att->setIsCurrentItem(false); } } + int oldCurrentIndex = currentIndex; currentIndex = idx; currentItem = 0; itemIndex = (idx - firstIndex + modelCount) % modelCount; @@ -1661,7 +1681,8 @@ void QDeclarativePathViewPrivate::updateCurrent() if (QDeclarativePathViewAttached *att = attached(currentItem)) att->setIsCurrentItem(true); } - emit q->currentIndexChanged(); + if (oldCurrentIndex != currentIndex) + emit q->currentIndexChanged(); } } diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index f73de7f3..ab321203 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -662,7 +662,8 @@ void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree) output->bytecode << init; // Build global import scripts - QHash<QString, Object::ScriptBlock> importedScripts; + QSet<QString> importedScripts; + QList<Object::ScriptBlock> importedScriptList; QStringList importedScriptIndexes; foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) { @@ -672,24 +673,23 @@ void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree) Q_ASSERT(!importedScripts.contains(script.qualifier)); if (!scriptCode.isEmpty()) { - Object::ScriptBlock &scriptBlock = importedScripts[script.qualifier]; + importedScripts.insert(script.qualifier); + Object::ScriptBlock scriptBlock; scriptBlock.code = scriptCode; scriptBlock.file = script.script->finalUrl().toString(); scriptBlock.pragmas = pragmas; + importedScriptList.append(scriptBlock); + importedScriptIndexes.append(script.qualifier); } } - for (QHash<QString, Object::ScriptBlock>::Iterator iter = importedScripts.begin(); - iter != importedScripts.end(); ++iter) { - - importedScriptIndexes.append(iter.key()); - + for (int i = 0; i < importedScriptList.count(); ++i) { QDeclarativeInstruction import; import.type = QDeclarativeInstruction::StoreImportedScript; import.line = 0; import.storeScript.value = output->scripts.count(); - output->scripts << *iter; + output->scripts << importedScriptList.at(i); output->bytecode << import; } diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index fa7134ed..23bc9aa1 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -114,6 +114,7 @@ #endif Q_DECLARE_METATYPE(QDeclarativeProperty) +Q_DECLARE_METATYPE(QScriptValue) QT_BEGIN_NAMESPACE @@ -570,7 +571,7 @@ void QDeclarativeEnginePrivate::init() Q_Q(QDeclarativeEngine); qRegisterMetaType<QVariant>("QVariant"); qRegisterMetaType<QDeclarativeScriptString>("QDeclarativeScriptString"); - qRegisterMetaType<QScriptValue>("QScriptValue"); + qRegisterMetaType<QScriptValue>(); qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeComponent::Status"); QDeclarativeData::init(); diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index cc1d5520..4f22b94d 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -157,7 +157,7 @@ public: int notifyIndex; }; bool captureProperties; - QPODVector<CapturedProperty> capturedProperties; + QPODVector<CapturedProperty, 16> capturedProperties; QDeclarativeContext *rootContext; bool isDebugging; diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index b52a0748..58897c9e 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -460,7 +460,7 @@ QScriptValue QDeclarativeQtScriptExpression::scriptValue(QObject *secondaryScope QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context()->engine); bool lastCaptureProperties = ep->captureProperties; - QPODVector<QDeclarativeEnginePrivate::CapturedProperty> lastCapturedProperties; + QPODVector<QDeclarativeEnginePrivate::CapturedProperty, 16> lastCapturedProperties; ep->captureProperties = trackChange; ep->capturedProperties.copyAndClear(lastCapturedProperties); @@ -539,7 +539,7 @@ QScriptValue QDeclarativeQtScriptExpression::eval(QObject *secondaryScope, bool } } -void QDeclarativeQtScriptExpression::updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties) +void QDeclarativeQtScriptExpression::updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty, 16> &properties) { Q_ASSERT(guardObject); Q_ASSERT(guardObjectNotifyIndex != -1); diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index 6e8df8ae..402ae846 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -153,7 +153,7 @@ public: private: void clearGuards(); QScriptValue eval(QObject *secondaryScope, bool *isUndefined); - void updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties); + void updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty, 16> &properties); bool trackChange; diff --git a/src/declarative/qml/qdeclarativefastproperties_p.h b/src/declarative/qml/qdeclarativefastproperties_p.h index 8747eeba..f0e94779 100644 --- a/src/declarative/qml/qdeclarativefastproperties_p.h +++ b/src/declarative/qml/qdeclarativefastproperties_p.h @@ -50,7 +50,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class QObject; -class QMetaObject; +struct QMetaObject; class QDeclarativeNotifierEndpoint; class QDeclarativeFastProperties { diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index 09390646..4a771de9 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -449,7 +449,7 @@ QObject *QDeclarativeType::create() const d->m_newFunc(rv); if (rv && !d->m_metaObjects.isEmpty()) - (void *)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects); + (void)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects); return rv; } @@ -462,7 +462,7 @@ void QDeclarativeType::create(QObject **out, void **memory, size_t additionalMem d->m_newFunc(rv); if (rv && !d->m_metaObjects.isEmpty()) - (void *)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects); + (void)new QDeclarativeProxyMetaObject(rv, &d->m_metaObjects); *out = rv; *memory = ((char *)rv) + d->m_allocationSize; diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index 00b9a4de..9043760a 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -80,9 +80,19 @@ int qmlRegisterValueTypeEnums(const char *uri, int versionMajor, int versionMino QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory() { + static int isGuiApp = -1; + memset(valueTypes, 0, sizeof(valueTypes)); + /*FIXME: is there a better way to tell if an app is Gui or not?*/ + if (isGuiApp == -1) + isGuiApp = (int) qApp->inherits("QGuiApplication"); // ### Optimize - for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii) + for (unsigned int ii = 0; ii <= QVariant::LastCoreType; ++ii) valueTypes[ii] = valueType(ii); + + if (isGuiApp) { + for (unsigned int ii = QVariant::LastCoreType + 1; ii < (QVariant::UserType - 1); ++ii) + valueTypes[ii] = valueType(ii); + } } QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory() diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 5c875510..49ce35da 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -283,7 +283,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack, { QObject *o = (QObject *)operator new(instr.createSimple.typeSize + sizeof(QDeclarativeData)); - ::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeData)); + ::memset(static_cast<void *>(o), 0, instr.createSimple.typeSize + sizeof(QDeclarativeData)); instr.createSimple.create(o); QDeclarativeData *ddata = (QDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize); diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index bb16a9c1..dd091ca7 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -1321,7 +1321,7 @@ void QDeclarativeXMLHttpRequest::readEncoding() if (header.first == "content-type") { int separatorIdx = header.second.indexOf(';'); if (separatorIdx == -1) { - m_mime == header.second; + m_mime = header.second; } else { m_mime = header.second.mid(0, separatorIdx); int charsetIdx = header.second.indexOf("charset="); diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index bf3019de..2c09235b 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -61,6 +61,12 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && \ + (defined(Q_CC_CLANG) || (__GNUC__ * 100 + __GNUC_MINOR__) > 406) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Woverloaded-virtual" +#endif + class QDeclarativeAbstractAnimationPrivate; class QDeclarativeAnimationGroup; class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus @@ -507,6 +513,11 @@ protected: virtual QAbstractAnimation *qtAnimation(); }; +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && \ + (defined(Q_CC_CLANG) || (__GNUC__ * 100 + __GNUC_MINOR__) > 406) +# pragma GCC diagnostic pop +#endif + QT_END_NAMESPACE QML_DECLARE_TYPE(QDeclarativeAbstractAnimation) diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 6304ee40..60b3f9be 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -64,7 +64,7 @@ class QDeclarativeFontObject : public QObject Q_OBJECT public: - QDeclarativeFontObject(int _id); + QDeclarativeFontObject(int _id = -1); void download(const QUrl &url, QNetworkAccessManager *manager); @@ -84,7 +84,7 @@ private: Q_DISABLE_COPY(QDeclarativeFontObject) }; -QDeclarativeFontObject::QDeclarativeFontObject(int _id = -1) +QDeclarativeFontObject::QDeclarativeFontObject(int _id) : QObject(0), id(_id), reply(0), redirectCount(0) {} |