diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/debugger/qmldebug.cpp | 12 | ||||
-rw-r--r-- | src/declarative/debugger/qmldebug_p.h | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsflickable.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicslistview.cpp | 44 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicslistview_p.h | 5 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview.cpp | 17 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicswebview_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlenginedebug.cpp | 15 | ||||
-rw-r--r-- | src/declarative/qml/qmlinfo.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlinfo.h | 2 | ||||
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 73 | ||||
-rw-r--r-- | src/declarative/util/qmllistmodel_p.h | 3 |
12 files changed, 121 insertions, 62 deletions
diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index b06a250..1403ffa 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -69,6 +69,7 @@ public: void decode(QDataStream &, QmlDebugContextReference &); void decode(QDataStream &, QmlDebugObjectReference &, bool simple); + static void remove(QmlEngineDebug *, QmlDebugEnginesQuery *); static void remove(QmlEngineDebug *, QmlDebugRootContextQuery *); static void remove(QmlEngineDebug *, QmlDebugObjectQuery *); @@ -133,6 +134,7 @@ void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugExpressionQuery *q p->expressionQuery.remove(q->m_queryId); } + Q_DECLARE_METATYPE(QmlDebugObjectReference); void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, bool simple) @@ -345,6 +347,7 @@ QmlDebugPropertyWatch *QmlEngineDebug::addWatch(const QmlDebugPropertyReference if (d->client->isConnected()) { int queryId = d->getId(); watch->m_queryId = queryId; + watch->m_client = this; watch->m_objectDebugId = property.objectDebugId(); watch->m_name = property.name(); d->watched.insert(queryId, watch); @@ -373,6 +376,7 @@ QmlDebugObjectExpressionWatch *QmlEngineDebug::addWatch(const QmlDebugObjectRefe if (d->client->isConnected()) { int queryId = d->getId(); watch->m_queryId = queryId; + watch->m_client = this; watch->m_objectDebugId = object.debugId(); watch->m_expr = expr; d->watched.insert(queryId, watch); @@ -395,6 +399,7 @@ QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugObjectReference &object, Q if (d->client->isConnected()) { int queryId = d->getId(); watch->m_queryId = queryId; + watch->m_client = this; watch->m_objectDebugId = object.debugId(); d->watched.insert(queryId, watch); @@ -544,8 +549,13 @@ QmlDebugExpressionQuery *QmlEngineDebug::queryExpressionResult(int objectDebugId } QmlDebugWatch::QmlDebugWatch(QObject *parent) -: QObject(parent), m_state(Waiting), m_queryId(-1), m_objectDebugId(-1) +: QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) +{ +} + +QmlDebugWatch::~QmlDebugWatch() { + m_client->removeWatch(this); } int QmlDebugWatch::queryId() const diff --git a/src/declarative/debugger/qmldebug_p.h b/src/declarative/debugger/qmldebug_p.h index d7e4f5a..4bc54e8 100644 --- a/src/declarative/debugger/qmldebug_p.h +++ b/src/declarative/debugger/qmldebug_p.h @@ -106,6 +106,7 @@ public: enum State { Waiting, Active, Inactive, Dead }; QmlDebugWatch(QObject *); + ~QmlDebugWatch(); int queryId() const; int objectDebugId() const; @@ -125,6 +126,7 @@ private: void setState(State); State m_state; int m_queryId; + QmlEngineDebug *m_client; int m_objectDebugId; }; diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index b030495..ea9c173 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -1177,7 +1177,7 @@ void QmlGraphicsFlickable::setMaximumFlickVelocity(qreal v) } /*! - \qmlproperty real Flickable::maximumFlickVelocity + \qmlproperty real Flickable::flickDeceleration This property holds the rate at which a flick will decelerate. The default is 500. diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index a9bc721..53287a6 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -434,7 +434,6 @@ void QmlGraphicsListViewPrivate::clear() visibleIndex = 0; releaseItem(currentItem); currentItem = 0; - currentIndex = -1; createHighlight(); trackedItem = 0; } @@ -746,7 +745,7 @@ void QmlGraphicsListViewPrivate::updateCurrentSection() void QmlGraphicsListViewPrivate::updateCurrent(int modelIndex) { Q_Q(QmlGraphicsListView); - if (!isValid() || modelIndex < 0 || modelIndex >= model->count()) { + if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) { if (currentItem) { currentItem->attached->setIsCurrentItem(false); releaseItem(currentItem); @@ -1114,16 +1113,20 @@ void QmlGraphicsListView::setModel(const QVariant &model) dataModel->setModel(model); } if (d->model) { - if (d->currentIndex >= d->model->count() || d->currentIndex < 0) - setCurrentIndex(0); - else - d->updateCurrent(d->currentIndex); + if (isComponentComplete()) { + refill(); + if (d->currentIndex >= d->model->count() || d->currentIndex < 0) { + setCurrentIndex(0); + } else { + d->moveReason = QmlGraphicsListViewPrivate::SetIndex; + d->updateCurrent(d->currentIndex); + } + } connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); connect(d->model, SIGNAL(createdItem(int, QmlGraphicsItem*)), this, SLOT(createdItem(int,QmlGraphicsItem*))); connect(d->model, SIGNAL(destroyingItem(QmlGraphicsItem*)), this, SLOT(destroyingItem(QmlGraphicsItem*))); - refill(); emit countChanged(); } } @@ -1156,8 +1159,11 @@ void QmlGraphicsListView::setDelegate(QmlComponent *delegate) } if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) { dataModel->setDelegate(delegate); - d->updateCurrent(d->currentIndex); - refill(); + if (isComponentComplete()) { + refill(); + d->moveReason = QmlGraphicsListViewPrivate::SetIndex; + d->updateCurrent(d->currentIndex); + } } } @@ -1178,7 +1184,7 @@ int QmlGraphicsListView::currentIndex() const void QmlGraphicsListView::setCurrentIndex(int index) { Q_D(QmlGraphicsListView); - if (d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) { + if (isComponentComplete() && d->isValid() && index != d->currentIndex && index < d->model->count() && index >= 0) { d->moveReason = QmlGraphicsListViewPrivate::SetIndex; cancelFlick(); d->updateCurrent(index); @@ -1254,7 +1260,7 @@ void QmlGraphicsListView::setHighlight(QmlComponent *highlight) is scrolled. This is because the view moves to maintain the highlight within the preferred highlight range (or visible viewport). - \sa highlight + \sa highlight, highlightMoveSpeed */ bool QmlGraphicsListView::highlightFollowsCurrentItem() const { @@ -1473,8 +1479,13 @@ QString QmlGraphicsListView::currentSection() const /*! \qmlproperty real ListView::highlightMoveSpeed + \qmlproperty real ListView::highlightResizeSpeed + These properties hold the move and resize animation speed of the highlight delegate. + + highlightFollowsCurrentItem must be true for these properties + to have effect. - This property holds the moving animation speed of the highlight delegate. + \sa highlightFollowsCurrentItem */ qreal QmlGraphicsListView::highlightMoveSpeed() const { @@ -1494,11 +1505,6 @@ void QmlGraphicsListView::setHighlightMoveSpeed(qreal speed) } } -/*! - \qmlproperty real ListView::highlightResizeSpeed - - This property holds the resizing animation speed of the highlight delegate. -*/ qreal QmlGraphicsListView::highlightResizeSpeed() const { Q_D(const QmlGraphicsListView);\ @@ -1670,9 +1676,11 @@ void QmlGraphicsListView::componentComplete() { Q_D(QmlGraphicsListView); QmlGraphicsFlickable::componentComplete(); + refill(); if (d->currentIndex < 0) d->updateCurrent(0); - refill(); + else + d->updateCurrent(d->currentIndex); d->fixupPosition(); } diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h index 446d71a..3f46434 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h @@ -64,8 +64,11 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsListView : public QmlGraphicsFlickable Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(QmlGraphicsItem *currentItem READ currentItem NOTIFY currentIndexChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight) Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem) + Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged) + Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged) Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin) Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd) @@ -78,8 +81,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsListView : public QmlGraphicsFlickable Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged) Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged) - Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged) - Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged) Q_ENUMS(HighlightRangeMode) Q_ENUMS(Orientation) Q_CLASSINFO("DefaultProperty", "data") diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index 5ce0ee8..214117f 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -464,7 +464,8 @@ void QmlGraphicsWebView::setPreferredWidth(int iw) /*! \qmlproperty int WebView::webPageWidth - This property holds the page width suggested to the web engine. + This property holds the page width suggested to the web engine. The zoomFactor + will be changed to fit this with in preferredWidth. */ int QmlGraphicsWebView::webPageWidth() const { @@ -906,20 +907,6 @@ QPixmap QmlGraphicsWebView::icon() const /*! - \qmlproperty real WebView::textSizeMultiplier - This property holds the multiplier used to scale the text in a Web page -*/ -void QmlGraphicsWebView::setTextSizeMultiplier(qreal factor) -{ - page()->mainFrame()->setTextSizeMultiplier(factor); -} - -qreal QmlGraphicsWebView::textSizeMultiplier() const -{ - return page()->mainFrame()->textSizeMultiplier(); -} - -/*! \qmlproperty real WebView::zoomFactor This property holds the multiplier used to scale the contents of a Web page. */ diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index 6852bb0..d574c59 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -88,7 +88,6 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) - Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false) Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged) @@ -126,9 +125,6 @@ public: QPixmap icon() const; - qreal textSizeMultiplier() const; - void setTextSizeMultiplier(qreal); - qreal zoomFactor() const; void setZoomFactor(qreal); diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 2d8acf7..20d6fc1 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -99,6 +99,7 @@ QmlEngineDebugServer::QmlObjectProperty QmlEngineDebugServer::propertyData(QObject *obj, int propIdx) { QmlObjectProperty rv; +; QMetaProperty prop = obj->metaObject()->property(propIdx); @@ -165,7 +166,7 @@ void QmlEngineDebugServer::buildObjectDump(QDataStream &message, int childrenCount = children.count(); for (int ii = 0; ii < children.count(); ++ii) { - if (QmlBoundSignal::cast(children[ii])) + if (qobject_cast<QmlContext*>(children[ii]) || QmlBoundSignal::cast(children[ii])) --childrenCount; } @@ -175,6 +176,8 @@ void QmlEngineDebugServer::buildObjectDump(QDataStream &message, for (int ii = 0; ii < children.count(); ++ii) { QObject *child = children.at(ii); + if (qobject_cast<QmlContext*>(child)) + continue; QmlBoundSignal *signal = QmlBoundSignal::cast(child); if (signal) { QmlObjectProperty prop; @@ -271,10 +274,18 @@ QmlEngineDebugServer::objectData(QObject *object) } rv.objectName = object->objectName(); - rv.objectType = QString::fromUtf8(object->metaObject()->className()); rv.objectId = QmlDebugService::idForObject(object); rv.contextId = QmlDebugService::idForObject(qmlContext(object)); + QmlType *type = QmlMetaType::qmlType(object->metaObject()); + if (type) { + QString typeName = type->qmlTypeName(); + int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); + rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1); + } else { + rv.objectType = QString::fromUtf8(object->metaObject()->className()); + } + return rv; } diff --git a/src/declarative/qml/qmlinfo.cpp b/src/declarative/qml/qmlinfo.cpp index f62f5fd..5ebcd8d 100644 --- a/src/declarative/qml/qmlinfo.cpp +++ b/src/declarative/qml/qmlinfo.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE /*! - \fn void qmlInfo(const QString& message, QObject *object) + \fn void qmlInfo(const QString& message, const QObject *object) \brief Prints warnings messages that include the file and line number for QML types. @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE \endcode */ -void qmlInfo(const QString& msg, QObject* object) +void qmlInfo(const QString& msg, const QObject* object) { QString pos = QLatin1String("QML"); if (object) { diff --git a/src/declarative/qml/qmlinfo.h b/src/declarative/qml/qmlinfo.h index 2e26ea4..1660aa2 100644 --- a/src/declarative/qml/qmlinfo.h +++ b/src/declarative/qml/qmlinfo.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -Q_DECLARATIVE_EXPORT void qmlInfo(const QString& msg, QObject *me=0); +Q_DECLARATIVE_EXPORT void qmlInfo(const QString& msg, const QObject *me=0); QT_END_NAMESPACE diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index afc6735..fbd957c 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -45,9 +45,11 @@ #include <private/qmlcustomparser_p.h> #include <private/qmlparser_p.h> #include "qmlopenmetaobject_p.h" +#include <private/qmlengine_p.h> #include <qmlcontext.h> #include "qmllistmodel_p.h" #include <QtScript/qscriptvalueiterator.h> +#include "qmlinfo.h" Q_DECLARE_METATYPE(QListModelInterface *) @@ -264,6 +266,7 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(ModelNode *) QT_BEGIN_NAMESPACE + void ModelNode::setObjectValue(const QScriptValue& valuemap) { QScriptValueIterator it(valuemap); while (it.hasNext()) { @@ -451,14 +454,17 @@ void QmlListModel::clear() */ void QmlListModel::remove(int index) { - if (_root) { - ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); - _root->values.removeAt(index); - if (node) - delete node; - emit itemsRemoved(index,1); - emit countChanged(_root->values.count()); + if (!_root || index < 0 || index >= _root->values.count()) { + qmlInfo(tr("remove: index %1 out of range").arg(index),this); + return; } + + ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); + _root->values.removeAt(index); + if (node) + delete node; + emit itemsRemoved(index,1); + emit countChanged(_root->values.count()); } /*! @@ -480,9 +486,11 @@ void QmlListModel::insert(int index, const QScriptValue& valuemap) { if (!_root) _root = new ModelNode; - if (index >= _root->values.count()) { + if (index >= _root->values.count() || index<0) { if (index == _root->values.count()) append(valuemap); + else + qmlInfo(tr("insert: index %1 out of range").arg(index),this); return; } ModelNode *mn = new ModelNode; @@ -508,8 +516,10 @@ void QmlListModel::insert(int index, const QScriptValue& valuemap) */ void QmlListModel::move(int from, int to, int n) { - if (from+n > count() || to+n > count() || n==0 || from==to || from < 0 || to < 0) + if (n==0 || from==to) return; + if (from+n > count() || to+n > count() || from < 0 || to < 0) + qmlInfo(tr("move: out of range"),this); int origfrom=from; // preserve actual move, so any animations are correct int origto=to; int orign=n; @@ -556,7 +566,7 @@ void QmlListModel::move(int from, int to, int n) void QmlListModel::append(const QScriptValue& valuemap) { if (!valuemap.isObject()) { - qWarning("ListModel::append: value is not an object"); + qmlInfo(tr("append: value is not an object"),this); return; } if (!_root) @@ -569,10 +579,43 @@ void QmlListModel::append(const QScriptValue& valuemap) } /*! + \qmlmethod dict ListModel::get(index) + + Returns the item at \a index in the list model. + + \code + FruitModel.append({"cost": 5.95, "name":"Pizza"}) + FruitModel.get(0).cost + \endcode + + The \a index must be an element in the list. + + \sa append() +*/ +QScriptValue QmlListModel::get(int index) const +{ + if (index >= count()) { + qmlInfo(tr("get: index %1 out of range").arg(index),this); + return 0; + } + + ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); + if (!node) + return 0; + QmlEngine *eng = qmlEngine(this); + if (!eng) { + qWarning("Cannot call QmlListModel::get() without a QmlEngine"); + return 0; + } + return QmlEnginePrivate::qmlScriptObject(node->object(), eng); +} + +/*! \qmlmethod ListModel::set(index,dict) - Changes the item at \a index in the list model to the - values in \a dict. + Changes the item at \a index in the list model with the + values in \a dict. Properties not appearing in \a valuemap + are left unchanged. \code FruitModel.set(3, {"cost": 5.95, "name":"Pizza"}) @@ -586,8 +629,8 @@ void QmlListModel::set(int index, const QScriptValue& valuemap) { if (!_root) _root = new ModelNode; - if ( index >= _root->values.count()) { - qWarning() << "ListModel::set index out of range:" << index; + if ( index > _root->values.count()) { + qmlInfo(tr("set: index %1 out of range").arg(index),this); return; } if (index == _root->values.count()) @@ -628,7 +671,7 @@ void QmlListModel::set(int index, const QString& property, const QVariant& value if (!_root) _root = new ModelNode; if ( index >= _root->values.count()) { - qWarning() << "ListModel::set index out of range:" << index; + qmlInfo(tr("set: index %1 out of range").arg(index),this); return; } ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); diff --git a/src/declarative/util/qmllistmodel_p.h b/src/declarative/util/qmllistmodel_p.h index 31365d1..34b1562 100644 --- a/src/declarative/util/qmllistmodel_p.h +++ b/src/declarative/util/qmllistmodel_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) struct ModelNode; -class QmlListModel : public QListModelInterface +class Q_DECLARATIVE_EXPORT QmlListModel : public QListModelInterface { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) @@ -77,6 +77,7 @@ public: Q_INVOKABLE void remove(int index); Q_INVOKABLE void append(const QScriptValue&); Q_INVOKABLE void insert(int index, const QScriptValue&); + Q_INVOKABLE QScriptValue get(int index) const; Q_INVOKABLE void set(int index, const QScriptValue&); Q_INVOKABLE void set(int index, const QString& property, const QVariant& value); Q_INVOKABLE void move(int from, int to, int count); |