diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-12-10 11:43:28 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-12-10 11:43:28 (GMT) |
commit | a0e5b65b96cbe6a06f481d4930ac67ba415c8c66 (patch) | |
tree | 5cab74bfade7e3b2aad63d3873db5e033f6597e7 /src/declarative/graphicsitems | |
parent | 57d6bf52074761a0c6e9a79829ec845a7b0061fa (diff) | |
parent | dd4a244801eb9fa5f283fd0d5c1300dd4b717be7 (diff) | |
download | Qt-a0e5b65b96cbe6a06f481d4930ac67ba415c8c66.zip Qt-a0e5b65b96cbe6a06f481d4930ac67ba415c8c66.tar.gz Qt-a0e5b65b96cbe6a06f481d4930ac67ba415c8c66.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/graphicsitems')
4 files changed, 66 insertions, 36 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index 89c7657..eebc231 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -371,25 +371,34 @@ QML_DEFINE_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable) */ /*! - \internal - \class QmlGraphicsFlickable - \brief The QmlGraphicsFlickable class provides a view that can be "flicked". + \qmlsignal Flickable::onMovementStarted() - \ingroup group_widgets + This handler is called when the view begins moving due to user + interaction. +*/ - QmlGraphicsFlickable allows its children to be dragged and flicked. +/*! + \qmlsignal Flickable::onMovementEnded() -\code -Flickable { - width: 320; height: 480; viewportWidth: image.width; viewportHeight: image.height - Image { id: image; source: "bigimage.png" } -} -\endcode + This handler is called when the view stops moving due to user + interaction. If a flick was generated, this handler will + be triggered once the flick stops. If a flick was not + generated, the handler will be triggered when the + user stops dragging - i.e. a mouse or touch release. +*/ - Note that QmlGraphicsFlickable does not automatically clip its contents. If - it is not full-screen it is likely that QmlGraphicsItem::clip should be set - to true. +/*! + \qmlsignal Flickable::onFlickStarted() + + This handler is called when the view is flicked. A flick + starts from the point that the mouse or touch is released, + while still in motion. +*/ +/*! + \qmlsignal Flickable::onFlickEnded() + + This handler is called when the view stops moving due to a flick. */ /*! @@ -1195,6 +1204,12 @@ void QmlGraphicsFlickable::setFlickDeceleration(qreal deceleration) d->deceleration = deceleration; } +/*! + \qmlproperty bool Flickable::flicking + + This property holds whether the view is currently moving due to + the user flicking the view. +*/ bool QmlGraphicsFlickable::isFlicking() const { Q_D(const QmlGraphicsFlickable); @@ -1242,6 +1257,12 @@ void QmlGraphicsFlickable::setReportedVelocitySmoothing(qreal reportedVelocitySm emit reportedVelocitySmoothingChanged(reportedVelocitySmoothing); } +/*! + \qmlproperty bool Flickable::moving + + This property holds whether the view is currently moving due to + the user either dragging or flicking the view. +*/ bool QmlGraphicsFlickable::isMoving() const { Q_D(const QmlGraphicsFlickable); diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index a4fa07a..a49794c 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -2172,7 +2172,6 @@ void QmlGraphicsListView::trackedPositionChanged() } else { if (trackedPos < viewPos && d->currentItem->position() < viewPos) { d->setPosition(d->currentItem->position() < trackedPos ? trackedPos : d->currentItem->position()); - d->fixupPosition(); } else if (d->trackedItem->endPosition() > viewPos + d->size() && d->currentItem->endPosition() > viewPos + d->size()) { qreal pos; @@ -2186,7 +2185,6 @@ void QmlGraphicsListView::trackedPositionChanged() pos = d->currentItem->position(); } d->setPosition(pos); - d->fixupPosition(); } } } @@ -2493,7 +2491,7 @@ void QmlGraphicsListView::itemsMoved(int from, int to, int count) FxListItem *movedItem = moved.take(item->index); if (!movedItem) movedItem = d->createItem(item->index); - if (item->index < firstVisible->index) + if (item->index <= firstVisible->index) moveBy -= movedItem->size(); it = d->visibleItems.insert(it, movedItem); ++it; diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp index 159fc29..f788077 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp @@ -574,7 +574,7 @@ void QmlGraphicsMouseRegion::setHovered(bool h) \list \o Qt.LeftButton \o Qt.RightButton - \o Qt.MiddleButton + \o Qt.MidButton \endlist To accept more than one button the flags can be combined with the diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index a6c40c5..c6f790c 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -341,6 +341,9 @@ public: QmlGraphicsVisualDataModelParts *m_parts; friend class QmlGraphicsVisualItemParts; + QmlOpenMetaObjectType *m_delegateDataType; + friend class QmlGraphicsVisualDataModelData; + QmlGraphicsVisualDataModelData *data(QObject *item); QVariant m_modelVariant; @@ -362,10 +365,11 @@ public: class QmlGraphicsVisualDataModelDataMetaObject : public QmlOpenMetaObject { public: - QmlGraphicsVisualDataModelDataMetaObject(QObject *parent) - : QmlOpenMetaObject(parent) {} + QmlGraphicsVisualDataModelDataMetaObject(QObject *parent, QmlOpenMetaObjectType *type) + : QmlOpenMetaObject(parent, type) {} - virtual QVariant propertyCreated(int, QMetaPropertyBuilder &); + virtual void propertyCreated(int, QMetaPropertyBuilder &); + virtual QVariant initialValue(int); virtual int createProperty(const char *, const char *); private: @@ -442,20 +446,22 @@ int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, c return -1; } -QVariant -QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) +void QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) { prop.setWritable(false); +} +QVariant QmlGraphicsVisualDataModelDataMetaObject::initialValue(int propId) +{ QmlGraphicsVisualDataModelData *data = static_cast<QmlGraphicsVisualDataModelData *>(object()); Q_ASSERT(data->m_model); QmlGraphicsVisualDataModelPrivate *model = QmlGraphicsVisualDataModelPrivate::get(data->m_model); - QString name = QString::fromUtf8(prop.name()); + QString strName = QString::fromUtf8(name(propId)); if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { - if (name == QLatin1String("modelData")) { + if (strName == QLatin1String("modelData")) { if (model->m_listAccessor->type() == QmlListAccessor::Instance) { QObject *object = model->m_listAccessor->at(0).value<QObject*>(); return object->metaObject()->property(1).read(object); // the first property after objectName @@ -464,11 +470,11 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil } else { // return any property of a single object instance. QObject *object = model->m_listAccessor->at(data->m_index).value<QObject*>(); - return object->property(prop.name()); + return object->property(name(propId)); } } else if (model->m_listModelInterface) { model->ensureRoles(); - QHash<QString,int>::const_iterator it = model->m_roleNames.find(name); + QHash<QString,int>::const_iterator it = model->m_roleNames.find(strName); if (it != model->m_roleNames.end()) { roles.append(*it); QHash<int,QVariant> values = model->m_listModelInterface->data(data->m_index, QList<int>() << *it); @@ -476,7 +482,7 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil return QVariant(); else return values.value(*it); - } else if (model->m_roles.count() == 1 && name == QLatin1String("modelData")) { + } else if (model->m_roles.count() == 1 && strName == QLatin1String("modelData")) { //for compatability with other lists, assign modelData if there is only a single role QHash<int,QVariant> values = model->m_listModelInterface->data(data->m_index, QList<int>() << model->m_roles.first()); if (values.isEmpty()) @@ -486,7 +492,7 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil } } else if (model->m_abstractItemModel) { model->ensureRoles(); - QHash<QString,int>::const_iterator it = model->m_roleNames.find(name); + QHash<QString,int>::const_iterator it = model->m_roleNames.find(strName); if (it != model->m_roleNames.end()) { roles.append(*it); QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0); @@ -500,7 +506,7 @@ QmlGraphicsVisualDataModelDataMetaObject::propertyCreated(int, QMetaPropertyBuil QmlGraphicsVisualDataModelData::QmlGraphicsVisualDataModelData(int index, QmlGraphicsVisualDataModel *model) : m_index(index), m_model(model), - m_meta(new QmlGraphicsVisualDataModelDataMetaObject(this)) +m_meta(new QmlGraphicsVisualDataModelDataMetaObject(this, QmlGraphicsVisualDataModelPrivate::get(model)->m_delegateDataType)) { } @@ -526,7 +532,8 @@ public: QmlGraphicsVisualDataModelPartsMetaObject(QObject *parent) : QmlOpenMetaObject(parent) {} - virtual QVariant propertyCreated(int, QMetaPropertyBuilder &); + virtual void propertyCreated(int, QMetaPropertyBuilder &); + virtual QVariant initialValue(int); }; class QmlGraphicsVisualDataModelParts : public QObject @@ -540,14 +547,16 @@ private: QmlGraphicsVisualDataModel *model; }; -QVariant -QmlGraphicsVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) +void QmlGraphicsVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) { prop.setWritable(false); +} +QVariant QmlGraphicsVisualDataModelPartsMetaObject::initialValue(int id) +{ QmlGraphicsVisualDataModel *m = new QmlGraphicsVisualDataModel; m->setParent(object()); - m->setPart(QString::fromUtf8(prop.name())); + m->setPart(QString::fromUtf8(name(id))); m->setModel(QVariant::fromValue(static_cast<QmlGraphicsVisualDataModelParts *>(object())->model)); QVariant var = QVariant::fromValue((QObject *)m); @@ -562,7 +571,7 @@ QmlGraphicsVisualDataModelParts::QmlGraphicsVisualDataModelParts(QmlGraphicsVisu QmlGraphicsVisualDataModelPrivate::QmlGraphicsVisualDataModelPrivate(QmlContext *ctxt) : m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0) -, m_context(ctxt), m_parts(0), m_listAccessor(0) +, m_context(ctxt), m_parts(0), m_delegateDataType(0), m_listAccessor(0) { } @@ -639,6 +648,8 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model) d->m_roles.clear(); d->m_roleNames.clear(); + delete d->m_delegateDataType; + d->m_delegateDataType = new QmlOpenMetaObjectType(d->m_context?d->m_context->engine():qmlEngine(this)); QObject *object = qvariant_cast<QObject *>(model); if (object && (d->m_listModelInterface = qobject_cast<QListModelInterface *>(object))) { @@ -761,7 +772,7 @@ QmlGraphicsVisualDataModel::ReleaseFlags QmlGraphicsVisualDataModel::release(Qml if (inPackage) emit destroyingPackage(qobject_cast<QmlPackage*>(obj)); stat |= Destroyed; - delete obj; + obj->deleteLater(); } else if (!inPackage) { stat |= Referenced; } |