diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-10-27 06:30:08 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-10-27 06:30:08 (GMT) |
commit | d72970e54390f00be28efaac148b55f027a1eb69 (patch) | |
tree | efeb095eebca0c2cf29391d08f3bc58d5baa1f68 /src/declarative | |
parent | fc4dd3eab91fc1959e216a754620a96cf05932d7 (diff) | |
parent | f2c0f63c2db21e3a0dd2fb78312084a835840be8 (diff) | |
download | Qt-d72970e54390f00be28efaac148b55f027a1eb69.zip Qt-d72970e54390f00be28efaac148b55f027a1eb69.tar.gz Qt-d72970e54390f00be28efaac148b55f027a1eb69.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/fx/qfxflickable.cpp | 27 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 57 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.h | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxvisualitemmodel.cpp | 6 | ||||
-rw-r--r-- | src/declarative/fx/qfxvisualitemmodel.h | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlbasicscript.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 21 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext_p.h | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontextscriptclass.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 10 |
12 files changed, 80 insertions, 68 deletions
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index a83ee66..cbfe9f6 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -618,11 +618,18 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) newY = minY + (newY - minY) / 2; if (newY < maxY && maxY - minY < 0) newY = maxY + (newY - maxY) / 2; - if (q->overShoot() || (newY <= minY && newY >= maxY)) { + if (!q->overShoot() && (newY > minY || newY < maxY)) { + if (newY > minY) + newY = minY; + else if (newY < maxY) + newY = maxY; + else + rejectY = true; + } + if (!rejectY) { _moveY.setValue(newY); moved = true; - } else if (!q->overShoot()) - rejectY = true; + } if (qAbs(dy) > DragThreshold) stealMouse = true; } @@ -638,11 +645,19 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) newX = minX + (newX - minX) / 2; if (newX < maxX && maxX - minX < 0) newX = maxX + (newX - maxX) / 2; - if (q->overShoot() || (newX <= minX && newX >= maxX)) { + if (!q->overShoot() && (newX > minX || newX < maxX)) { + if (newX > minX) + newX = minX; + else if (newX < maxX) + newX = maxX; + else + rejectX = true; + } + if (!rejectX) { _moveX.setValue(newX); moved = true; - } else if (!q->overShoot()) - rejectX = true; + } + if (qAbs(dx) > DragThreshold) stealMouse = true; } diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 1a4a60c..28d2bb2 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -176,9 +176,9 @@ public: , highlightRangeStart(0), highlightRangeEnd(0) , highlightComponent(0), highlight(0), trackedItem(0) , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0) - , highlightMoveSpeed(400), highlightResizeSpeed(400) + , highlightMoveSpeed(400), highlightResizeSpeed(400), highlightRange(QFxListView::NoHighlightRange) , ownModel(false), wrap(false), autoHighlight(true) - , haveHighlightRange(false), strictHighlightRange(false) + , haveHighlightRange(false) {} void init(); @@ -392,12 +392,12 @@ public: qreal spacing; qreal highlightMoveSpeed; qreal highlightResizeSpeed; + QFxListView::HighlightRangeMode highlightRange; bool ownModel : 1; bool wrap : 1; bool autoHighlight : 1; bool haveHighlightRange : 1; - bool strictHighlightRange : 1; }; void QFxListViewPrivate::init() @@ -798,7 +798,7 @@ void QFxListViewPrivate::fixupY() if (orient == Qt::Horizontal) return; - if (haveHighlightRange && strictHighlightRange) { + if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) { if (currentItem && highlight && currentItem->position() != highlight->position()) { moveReason = Mouse; timeline.clear(); @@ -813,7 +813,7 @@ void QFxListViewPrivate::fixupX() if (orient == Qt::Vertical) return; - if (haveHighlightRange && strictHighlightRange) { + if (haveHighlightRange && highlightRange == QFxListView::StrictlyEnforceRange) { if (currentItem && highlight && currentItem->position() != highlight->position()) { moveReason = Mouse; timeline.clear(); @@ -1141,19 +1141,25 @@ void QFxListView::setHighlightFollowsCurrentItem(bool autoHighlight) /*! \qmlproperty real ListView::preferredHighlightBegin \qmlproperty real ListView::preferredHighlightEnd - \qmlproperty bool ListView::strictlyEnforceHighlightRange + \qmlproperty bool ListView::highlightRangeMode These properties set the preferred range of the highlight (current item) within the view. - If the strictlyEnforceHighlightRange property is false (default) + If highlightRangeMode is set to \e ApplyRange the view will + attempt to maintain the highlight within the range, however the highlight can move outside of the range at the ends of the list or due to a mouse interaction. - If strictlyEnforceHighlightRange is true then the highlight will never - move outside the range. This means that the current item will change + If highlightRangeMode is set to \e StrictlyEnforceRange the highlight will never + move outside of the range. This means that the current item will change if a keyboard or mouse action would cause the highlight to move outside of the range. + + The default value is \e NoHighlightRange. + + Note that a valid range requires preferredHighlightEnd to be greater + than or equal to preferredHighlightBegin. */ qreal QFxListView::preferredHighlightBegin() const { @@ -1165,7 +1171,7 @@ void QFxListView::setPreferredHighlightBegin(qreal start) { Q_D(QFxListView); d->highlightRangeStart = start; - d->haveHighlightRange = d->highlightRangeStart < d->highlightRangeEnd; + d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; } qreal QFxListView::preferredHighlightEnd() const @@ -1178,19 +1184,20 @@ void QFxListView::setPreferredHighlightEnd(qreal end) { Q_D(QFxListView); d->highlightRangeEnd = end; - d->haveHighlightRange = d->highlightRangeStart < d->highlightRangeEnd; + d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; } -bool QFxListView::strictlyEnforceHighlightRange() const +QFxListView::HighlightRangeMode QFxListView::highlightRangeMode() const { Q_D(const QFxListView); - return d->strictHighlightRange; + return d->highlightRange; } -void QFxListView::setStrictlyEnforceHighlightRange(bool strict) +void QFxListView::setHighlightRangeMode(HighlightRangeMode mode) { Q_D(QFxListView); - d->strictHighlightRange = strict; + d->highlightRange = mode; + d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; } /*! @@ -1375,14 +1382,14 @@ void QFxListView::viewportMoved() if (isFlicking() || d->pressed) d->moveReason = QFxListViewPrivate::Mouse; if (d->moveReason == QFxListViewPrivate::Mouse) { - if (d->haveHighlightRange && d->strictHighlightRange && d->highlight) { + if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { int idx = d->snapIndex(); if (idx >= 0 && idx != d->currentIndex) d->updateCurrent(idx); qreal pos = d->currentItem->position(); - if (pos > d->position() + d->highlightRangeEnd - d->highlight->size()) - pos = d->position() + d->highlightRangeEnd - d->highlight->size(); + if (pos > d->position() + d->highlightRangeEnd - 1 - d->highlight->size()) + pos = d->position() + d->highlightRangeEnd - 1 - d->highlight->size(); if (pos < d->position() + d->highlightRangeStart) pos = d->position() + d->highlightRangeStart; d->highlight->setPosition(pos); @@ -1396,7 +1403,7 @@ qreal QFxListView::minYExtent() const if (d->orient == Qt::Horizontal) return QFxFlickable::minYExtent(); qreal extent = -d->startPosition(); - if (d->haveHighlightRange && d->strictHighlightRange) + if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) extent += d->highlightRangeStart; return extent; @@ -1408,8 +1415,8 @@ qreal QFxListView::maxYExtent() const if (d->orient == Qt::Horizontal) return QFxFlickable::maxYExtent(); qreal extent; - if (d->haveHighlightRange && d->strictHighlightRange) - extent = -(d->endPosition() - d->highlightRangeEnd); + if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) + extent = -(d->positionAt(count()-1) - d->highlightRangeEnd); else extent = -(d->endPosition() - height()); qreal minY = minYExtent(); @@ -1424,7 +1431,7 @@ qreal QFxListView::minXExtent() const if (d->orient == Qt::Vertical) return QFxFlickable::minXExtent(); qreal extent = -d->startPosition(); - if (d->haveHighlightRange && d->strictHighlightRange) + if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) extent += d->highlightRangeStart; return extent; @@ -1436,8 +1443,8 @@ qreal QFxListView::maxXExtent() const if (d->orient == Qt::Vertical) return QFxFlickable::maxXExtent(); qreal extent; - if (d->haveHighlightRange && d->strictHighlightRange) - extent = -(d->endPosition() - d->highlightRangeEnd); + if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) + extent = -(d->positionAt(count()-1) - d->highlightRangeEnd); else extent = -(d->endPosition() - width()); qreal minX = minXExtent(); @@ -1536,7 +1543,7 @@ void QFxListView::trackedPositionChanged() if (!isFlicking() && !d->pressed && d->moveReason != QFxListViewPrivate::Mouse) { const qreal trackedPos = d->trackedItem->position(); if (d->haveHighlightRange) { - if (d->strictHighlightRange) { + if (d->highlightRange == StrictlyEnforceRange) { qreal pos = d->position(); if (trackedPos > pos + d->highlightRangeEnd - d->trackedItem->size()) pos = trackedPos - d->highlightRangeEnd + d->trackedItem->size(); diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index 1ff0e27..0fa0fa0 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -69,7 +69,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin) Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd) - Q_PROPERTY(bool strictlyEnforceHighlightRange READ strictlyEnforceHighlightRange WRITE setStrictlyEnforceHighlightRange) + Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode) Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) @@ -80,6 +80,7 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged) Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged) + Q_ENUMS(HighlightRangeMode) Q_CLASSINFO("DefaultProperty", "data") public: @@ -104,8 +105,9 @@ public: bool highlightFollowsCurrentItem() const; void setHighlightFollowsCurrentItem(bool); - bool strictlyEnforceHighlightRange() const; - void setStrictlyEnforceHighlightRange(bool strict); + enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange }; + HighlightRangeMode highlightRangeMode() const; + void setHighlightRangeMode(HighlightRangeMode mode); qreal preferredHighlightBegin() const; void setPreferredHighlightBegin(qreal); diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index e1ac246..7ee6eea 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -123,6 +123,10 @@ public: emit q->countChanged(); } + void emitChildrenChanged() { + Q_Q(QFxVisualItemModel); + emit q->childrenChanged(); + } ItemList children; }; @@ -224,6 +228,8 @@ void QFxVisualItemModelPrivate::ItemList::append(QFxItem *item) QmlConcreteList<QFxItem*>::append(item); item->QObject::setParent(model->q_ptr); model->itemAppended(); + + model->emitChildrenChanged(); } QFxVisualItemModelAttached *QFxVisualItemModel::qmlAttachedProperties(QObject *obj) diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h index 5b613d8..8e33279 100644 --- a/src/declarative/fx/qfxvisualitemmodel.h +++ b/src/declarative/fx/qfxvisualitemmodel.h @@ -108,7 +108,7 @@ class Q_DECLARATIVE_EXPORT QFxVisualItemModel : public QFxVisualModel Q_OBJECT Q_DECLARE_PRIVATE(QFxVisualItemModel) - Q_PROPERTY(QmlList<QFxItem *>* children READ children DESIGNABLE false) + Q_PROPERTY(QmlList<QFxItem *>* children READ children NOTIFY childrenChanged DESIGNABLE false) Q_CLASSINFO("DefaultProperty", "children") public: @@ -128,6 +128,9 @@ public: static QFxVisualItemModelAttached *qmlAttachedProperties(QObject *obj); +signals: + void childrenChanged(); + private: Q_DISABLE_COPY(QFxVisualItemModel) }; diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index b7aac54..eba4307 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -658,7 +658,7 @@ QVariant QmlBasicScript::run(QmlContext *context, QObject *me) case ScriptInstruction::FetchRootConstant: { - QObject *obj = contextPrivate->defaultObjects.last(); + QObject *obj = contextPrivate->defaultObjects.at(0); stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type)); if (obj && instr.constant.notify != 0) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 69ebf9c..60282dc 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -1687,7 +1687,7 @@ bool QmlCompiler::buildGroupedProperty(QmlParser::Property *prop, if (prop->type < (int)QVariant::UserType) { QmlEnginePrivate *ep = static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine)); - if (ep->valueTypes[prop->type]) { + if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) { COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type], prop->value, obj, ctxt.incr())); obj->addValueTypeProperty(prop); diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 7ba3544..2ebdf10 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -50,9 +50,6 @@ #include <private/qmlbindingoptimizations_p.h> #include <QtDeclarative/qmlinfo.h> -// 6-bits -#define MAXIMUM_DEFAULT_OBJECTS 63 - QT_BEGIN_NAMESPACE QmlContextPrivate::QmlContextPrivate() @@ -130,22 +127,6 @@ void QmlContextPrivate::init() parent->d_func()->childContexts.insert(q); } -void QmlContextPrivate::addDefaultObject(QObject *object, Priority priority) -{ - if (defaultObjects.count() >= (MAXIMUM_DEFAULT_OBJECTS - 1)) { - qWarning("QmlContext: Cannot have more than %d default objects on " - "one bind context.", MAXIMUM_DEFAULT_OBJECTS - 1); - return; - } - - if (priority == HighPriority) { - defaultObjects.insert(highPriorityCount++, object); - } else { - defaultObjects.append(object); - } -} - - /*! \class QmlContext \brief The QmlContext class defines a context within a QML engine. @@ -366,7 +347,7 @@ QmlContext *QmlContext::parentContext() const void QmlContext::addDefaultObject(QObject *defaultObject) { Q_D(QmlContext); - d->addDefaultObject(defaultObject, QmlContextPrivate::NormalPriority); + d->defaultObjects.prepend(defaultObject); } /*! diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index be7bf1d..6af5f64 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -104,12 +104,6 @@ public: void dump(); void dump(int depth); - enum Priority { - HighPriority, - NormalPriority - }; - void addDefaultObject(QObject *, Priority); - void invalidateEngines(); QSet<QmlContext *> childContexts; diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp index 4df23f0..a978df2 100644 --- a/src/declarative/qml/qmlcontextscriptclass.cpp +++ b/src/declarative/qml/qmlcontextscriptclass.cpp @@ -155,7 +155,7 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje } } - for (int ii = 0; ii < cp->defaultObjects.count(); ++ii) { + for (int ii = cp->defaultObjects.count() - 1; ii >= 0; --ii) { QScriptClass::QueryFlags rv = ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags, bindContext); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index ab3c23a..0e239ce 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -476,6 +476,8 @@ QmlEngine *qmlEngine(const QObject *obj) QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create) { QmlDeclarativeData *data = QmlDeclarativeData::get(object); + if (!data) + return 0; // Attached properties are only on objects created by QML QObject *rv = data->attachedProperties?data->attachedProperties->value(id):0; if (rv || !create) diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 3b89a23..c62756b 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -293,8 +293,7 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUnd QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); if (secondaryScope) - ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount, - secondaryScope); + ctxtPriv->defaultObjects.append(secondaryScope); QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); @@ -328,8 +327,11 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUnd return QVariant(); } - if (secondaryScope) - ctxtPriv->defaultObjects.removeAt(ctxtPriv->highPriorityCount); + if (secondaryScope) { + QObject *last = ctxtPriv->defaultObjects.takeLast(); + Q_ASSERT(last == secondaryScope); + Q_UNUSED(last); + } QVariant rv; |