diff options
author | Bea Lam <bea.lam@nokia.com> | 2009-11-18 06:22:49 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2009-11-18 06:22:49 (GMT) |
commit | d15ac49efd7fab66258bd5b1e8998146ce204695 (patch) | |
tree | 86fd47a014e805f569f3d77255effc2213d862d3 /src/declarative/graphicsitems | |
parent | 1c719c4ea6abef35ccae67f6052d8baa74b4e2b3 (diff) | |
parent | c098fef1f410c54f0655af9532d45f80a77b3a91 (diff) | |
download | Qt-d15ac49efd7fab66258bd5b1e8998146ce204695.zip Qt-d15ac49efd7fab66258bd5b1e8998146ce204695.tar.gz Qt-d15ac49efd7fab66258bd5b1e8998146ce204695.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/graphicsitems')
8 files changed, 45 insertions, 11 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 9465c4c..473f9e5 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -824,7 +824,9 @@ void QmlGraphicsGridView::setModel(const QVariant &model) /*! \qmlproperty component GridView::delegate - The delegate provides a template describing what each item in the view should look and act like. + The delegate provides a template defining each item instantiated by the view. + The index is exposed as an accessible \c index property. Properties of the + model are also available depending upon the type of \l {qmlmodels}{Data Model}. Here is an example delegate: \snippet doc/src/snippets/declarative/gridview/gridview.qml 0 @@ -948,7 +950,6 @@ void QmlGraphicsGridView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsGridView); if (highlight != d->highlightComponent) { - delete d->highlightComponent; d->highlightComponent = highlight; d->updateCurrent(d->currentIndex); } diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index c075a8a..c6291f2 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -503,7 +503,7 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to) return; from -= buffer; to += buffer; - int modelIndex = 0; + int modelIndex = visibleIndex; qreal itemEnd = visiblePos-1; if (!visibleItems.isEmpty()) { visiblePos = visibleItems.first()->position(); @@ -1139,7 +1139,9 @@ void QmlGraphicsListView::setModel(const QVariant &model) /*! \qmlproperty component ListView::delegate - The delegate provides a template describing what each item in the view should look and act like. + The delegate provides a template defining each item instantiated by the view. + The index is exposed as an accessible \c index property. Properties of the + model are also available depending upon the type of \l {qmlmodels}{Data Model}. Here is an example delegate: \snippet doc/src/snippets/declarative/listview/listview.qml 0 @@ -1167,6 +1169,9 @@ void QmlGraphicsListView::setDelegate(QmlComponent *delegate) if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) { dataModel->setDelegate(delegate); if (isComponentComplete()) { + for (int i = 0; i < d->visibleItems.count(); ++i) + d->releaseItem(d->visibleItems.at(i)); + d->visibleItems.clear(); refill(); d->moveReason = QmlGraphicsListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); @@ -1266,9 +1271,10 @@ void QmlGraphicsListView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsListView); if (highlight != d->highlightComponent) { - delete d->highlightComponent; d->highlightComponent = highlight; - d->updateCurrent(d->currentIndex); + d->createHighlight(); + if (d->currentItem) + d->updateHighlight(); } } diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp index 0812d11..1791074 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp @@ -107,7 +107,7 @@ QmlGraphicsPath::~QmlGraphicsPath() /*! \qmlproperty real Path::startX \qmlproperty real Path::startY - This property holds the starting position of the path. + These properties hold the starting position of the path. */ qreal QmlGraphicsPath::startX() const { @@ -134,6 +134,16 @@ void QmlGraphicsPath::setStartY(qreal y) } /*! + \qmlproperty bool Path::closed + This property holds whether the start and end of the path are identical. +*/ +bool QmlGraphicsPath::isClosed() const +{ + Q_D(const QmlGraphicsPath); + return d->closed; +} + +/*! \qmlproperty list<PathElement> Path::pathElements This property holds the objects composing the path. @@ -220,12 +230,14 @@ void QmlGraphicsPath::processPath() d->_path.moveTo(d->startX, d->startY); + QmlGraphicsCurve *lastCurve = 0; foreach (QmlGraphicsPathElement *pathElement, d->_pathElements) { if (QmlGraphicsCurve *curve = qobject_cast<QmlGraphicsCurve *>(pathElement)) { curve->addToPath(d->_path); AttributePoint p; p.origpercent = d->_path.length(); d->_attributePoints << p; + lastCurve = curve; } else if (QmlGraphicsPathAttribute *attribute = qobject_cast<QmlGraphicsPathAttribute *>(pathElement)) { AttributePoint &point = d->_attributePoints.last(); point.values[attribute->name()] = attribute->value(); @@ -266,6 +278,8 @@ void QmlGraphicsPath::processPath() } } + d->closed = lastCurve && d->startX == lastCurve->x() && d->startY == lastCurve->y(); + emit changed(); } diff --git a/src/declarative/graphicsitems/qmlgraphicspath_p.h b/src/declarative/graphicsitems/qmlgraphicspath_p.h index 4b0c772..30a377e 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspath_p.h @@ -191,6 +191,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPath : public QObject, public QmlParserSta Q_PROPERTY(QList<QmlGraphicsPathElement *>* pathElements READ pathElements) Q_PROPERTY(qreal startX READ startX WRITE setStartX) Q_PROPERTY(qreal startY READ startY WRITE setStartY) + Q_PROPERTY(bool closed READ isClosed NOTIFY changed) Q_CLASSINFO("DefaultProperty", "pathElements") Q_INTERFACES(QmlParserStatus) public: @@ -205,6 +206,8 @@ public: qreal startY() const; void setStartY(qreal y); + bool isClosed() const; + QPainterPath path() const; QStringList attributes() const; qreal attributeAt(const QString &, qreal) const; diff --git a/src/declarative/graphicsitems/qmlgraphicspath_p_p.h b/src/declarative/graphicsitems/qmlgraphicspath_p_p.h index 36e8945..8c4c962 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspath_p_p.h @@ -64,7 +64,7 @@ class QmlGraphicsPathPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlGraphicsPath) public: - QmlGraphicsPathPrivate() : startX(0), startY(0) { } + QmlGraphicsPathPrivate() : startX(0), startY(0), closed(false) { } QPainterPath _path; QList<QmlGraphicsPathElement*> _pathElements; @@ -73,6 +73,7 @@ public: QStringList _attributes; int startX; int startY; + bool closed; }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 180954c..92751a0 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -298,7 +298,9 @@ void QmlGraphicsPathView::setDragMargin(qreal dragMargin) /*! \qmlproperty component PathView::delegate - The delegate provides a template describing what each item in the view should look and act like. + The delegate provides a template defining each item instantiated by the view. + The index is exposed as an accessible \c index property. Properties of the + model are also available depending upon the type of \l {qmlmodels}{Data Model}. Here is an example delegate: \snippet doc/src/snippets/declarative/pathview/pathview.qml 1 diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp index 7aed760..be10c24 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp @@ -199,7 +199,9 @@ void QmlGraphicsRepeater::setModel(const QVariant &model) \qmlproperty Component Repeater::delegate \default - The delegate provides a template describing what each item instantiated by the repeater should look and act like. + The delegate provides a template defining each item instantiated by the repeater. + The index is exposed as an accessible \c index property. Properties of the + model are also available depending upon the type of \l {qmlmodels}{Data Model}. */ QmlComponent *QmlGraphicsRepeater::delegate() const { diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index cf5fc5e..e8ee196 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -692,11 +692,16 @@ QmlComponent *QmlGraphicsVisualDataModel::delegate() const void QmlGraphicsVisualDataModel::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsVisualDataModel); + bool wasValid = d->m_delegate != 0; d->m_delegate = delegate; - if (d->modelCount()) { + if (!wasValid && d->modelCount() && d->m_delegate) { emit itemsInserted(0, d->modelCount()); emit countChanged(); } + if (wasValid && !d->m_delegate && d->modelCount()) { + emit itemsRemoved(0, d->modelCount()); + emit countChanged(); + } } QString QmlGraphicsVisualDataModel::part() const |