diff options
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/extra/extra.pri | 2 | ||||
-rw-r--r-- | src/declarative/extra/qfxflowview.cpp | 379 | ||||
-rw-r--r-- | src/declarative/extra/qfxflowview.h | 108 | ||||
-rw-r--r-- | src/declarative/fx/qfxborderimage.cpp | 23 | ||||
-rw-r--r-- | src/declarative/fx/qfxgraphicsobjectcontainer.cpp | 96 | ||||
-rw-r--r-- | src/declarative/fx/qfxgraphicsobjectcontainer.h | 9 | ||||
-rw-r--r-- | src/declarative/fx/qfxgridview.cpp | 162 | ||||
-rw-r--r-- | src/declarative/fx/qfxgridview.h | 6 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.cpp | 63 | ||||
-rw-r--r-- | src/declarative/fx/qfxlistview.h | 11 | ||||
-rw-r--r-- | src/declarative/fx/qfxpathview.cpp | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxrect.cpp | 38 | ||||
-rw-r--r-- | src/declarative/fx/qfxrepeater.cpp | 24 | ||||
-rw-r--r-- | src/declarative/fx/qfxrepeater.h | 5 | ||||
-rw-r--r-- | src/declarative/fx/qfxscalegrid.cpp | 10 | ||||
-rw-r--r-- | src/declarative/fx/qfxvisualitemmodel.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 42 | ||||
-rw-r--r-- | src/declarative/util/qmllistaccessor.cpp | 2 | ||||
-rw-r--r-- | src/declarative/util/qmlstateoperations.cpp | 7 |
19 files changed, 370 insertions, 625 deletions
diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index ae07a19..6730550 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -5,7 +5,6 @@ SOURCES += \ extra/qfxintegermodel.cpp \ extra/qmlfolderlistmodel.cpp \ extra/qfxanimatedimageitem.cpp \ - extra/qfxflowview.cpp \ extra/qfxparticles.cpp \ extra/qmlbehavior.cpp \ extra/qbindablemap.cpp \ @@ -19,7 +18,6 @@ HEADERS += \ extra/qmlfolderlistmodel.h \ extra/qfxanimatedimageitem.h \ extra/qfxanimatedimageitem_p.h \ - extra/qfxflowview.h \ extra/qfxparticles.h \ extra/qmlbehavior.h \ extra/qbindablemap.h \ diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp deleted file mode 100644 index b2470ba..0000000 --- a/src/declarative/extra/qfxflowview.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxvisualitemmodel.h" -#include "qfxflowview.h" - -#include <QGraphicsSceneMouseEvent> - -QT_BEGIN_NAMESPACE - -class QFxFlowViewAttached : public QObject -{ -Q_OBJECT -Q_PROPERTY(int row READ row NOTIFY posChanged) -Q_PROPERTY(int column READ column NOTIFY posChanged) -public: - QFxFlowViewAttached(QObject *parent); - - int row() const; - int column() const; - -Q_SIGNALS: - void posChanged(); - -private: - friend class QFxFlowView; - int m_row; - int m_column; -}; - - -QFxFlowView::QFxFlowView() -: m_columns(0), m_model(0), m_vertical(false), m_dragItem(0), m_dragIdx(-1) -{ - setAcceptedMouseButtons(Qt::LeftButton); -} - -QFxVisualModel *QFxFlowView::model() const -{ - return m_model; -} - -void QFxFlowView::setModel(QFxVisualModel *m) -{ - m_model = m; - refresh(); -} - -int QFxFlowView::columns() const -{ - return m_columns; -} - -void QFxFlowView::setColumns(int c) -{ - m_columns = c; - refresh(); -} - -bool QFxFlowView::vertical() const -{ - return m_vertical; -} - -void QFxFlowView::setVertical(bool v) -{ - m_vertical = v; -} - -class QFxFlowViewValue : public QmlTimeLineValue -{ -public: - enum Property { xProperty, yProperty }; - - QFxFlowViewValue(QFxItem *item, Property p) - : m_item(item), m_property(p) {} - - qreal value() const { - return (m_property == xProperty)?m_item->x():m_item->y(); - } - void setValue(qreal v) { - if (m_property == xProperty) m_item->setX(v); - else m_item->setY(v); - } -private: - QFxItem *m_item; - Property m_property; -}; - -void QFxFlowView::refresh() -{ - if (m_model && m_columns >= 1) { - for (int ii = 0; ii < m_model->count(); ++ii) { - if (QFxItem *item = m_model->item(ii)) { - item->setParent(this); - item->setZValue(0); - m_items << item; - } - } - - reflow(); - } -} - -void QFxFlowView::reflow(bool animate) -{ - qreal y = 0; - qreal maxY = 0; - qreal x = 0; - int row = 0; - int column = -1; - if (animate) - clearTimeLine(); - - for (int ii = 0; ii < m_items.count(); ++ii) { - if (0 == (ii % m_columns)) { - y += maxY; - maxY = 0; - x = 0; - row = 0; - column++; - } - - QFxItem *item = m_items.at(ii); - QFxFlowViewAttached *att = - (QFxFlowViewAttached *)qmlAttachedPropertiesObject<QFxFlowView>(item); - att->m_row = row; - att->m_column = column; - emit att->posChanged(); - - - if (animate) { - if (vertical()) - moveItem(item, QPointF(y, x)); - else - moveItem(item, QPointF(x, y)); - } else { - if (vertical()) { - item->setX(y); - item->setY(x); - } else { - item->setX(x); - item->setY(y); - } - } - if (vertical()) { - x += item->height(); - maxY = qMax(maxY, item->width()); - } else { - x += item->width(); - maxY = qMax(maxY, item->height()); - } - ++row; - } -} - -void QFxFlowView::reflowDrag(const QPointF &dp) -{ - qreal y = 0; - qreal maxY = 0; - qreal x = 0; - - clearTimeLine(); - - QList<QFxItem *> items; - - bool dragUsed = false; - bool dragSeen = false; - for (int ii = 0; ii < m_items.count(); ++ii) { - if (0 == (ii % m_columns)) { - y += maxY; - maxY = 0; - x = 0; - } - - QFxItem *item = m_items.at(ii); - if (item == m_dragItem) - dragSeen = true; - if (item == m_dragItem && dragUsed) - continue; - QRectF r; - if (vertical()) - r = QRectF(y, x, item->width(), item->height()); - else - r = QRectF(x, y, item->width(), item->height()); - if (r.contains(dp)) { - dragUsed = true; - if (dragSeen) - m_dragIdx = items.count() + 1; - else - m_dragIdx = items.count(); - - items.append(m_dragItem); - if (m_dragItem != item) { - if (dragSeen) - items.insert(items.count() - 1, item); - else - items.append(item); - } - } else { - if (m_dragItem != item) - items.append(item); - } - - if (vertical()) { - x += item->height(); - maxY = qMax(maxY, item->width()); - } else { - x += item->width(); - maxY = qMax(maxY, item->height()); - } - } - - y = 0; - maxY = 0; - x = 0; - clearTimeLine(); - for (int ii = 0; ii < items.count(); ++ii) { - if (0 == (ii % m_columns)) { - y += maxY; - maxY = 0; - x = 0; - } - - QFxItem *item = items.at(ii); - if (item != m_dragItem) { - if (vertical()) - moveItem(item, QPointF(y, x)); - else - moveItem(item, QPointF(x, y)); - } - if (vertical()) { - x += item->height(); - maxY = qMax(maxY, item->width()); - } else { - x += item->width(); - maxY = qMax(maxY, item->height()); - } - } - -} - -void QFxFlowView::moveItem(QFxItem *item, const QPointF &p) -{ - QFxFlowViewValue *xv = new QFxFlowViewValue(item, QFxFlowViewValue::xProperty); - QFxFlowViewValue *yv = new QFxFlowViewValue(item, QFxFlowViewValue::yProperty); - m_values << xv << yv; - m_timeline.move(*xv, p.x(), 100); - m_timeline.move(*yv, p.y(), 100); -} - -void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - for (int ii = 0; ii < m_items.count(); ++ii) { - QFxItem *item = m_items.at(ii); - QRectF r = rectForItem(ii); - - if (r.contains(event->pos())) { - m_dragItem = item; - m_dragItem->setZValue(1); - m_dragOffset = r.topLeft() - event->pos(); - event->accept(); - return; - } - } - event->ignore(); -} - -QRectF QFxFlowView::rectForItem(int idx) const -{ - QFxItem *item = m_items.at(idx); - QRectF r(item->x(), item->y(), item->width(), item->height()); - return r; -} - -void QFxFlowView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_UNUSED(event); - if (m_dragItem) { - m_dragItem->setZValue(0); - - clearTimeLine(); - - if (m_dragIdx != -1) { - m_items.removeAll(m_dragItem); - m_items.insert(m_dragIdx, m_dragItem); - } - - reflow(true); - m_dragItem = 0; - m_dragIdx = -1; - } -} - -QFxFlowViewAttached::QFxFlowViewAttached(QObject *parent) -: QObject(parent), m_row(0), m_column(0) -{ -} - -int QFxFlowViewAttached::row() const -{ - return m_row; -} - -int QFxFlowViewAttached::column() const -{ - return m_column; -} - -QFxFlowViewAttached *QFxFlowView::qmlAttachedProperties(QObject *obj) -{ - return new QFxFlowViewAttached(obj); -} - -void QFxFlowView::clearTimeLine() -{ - m_timeline.clear(); - qDeleteAll(m_values); - m_values.clear(); -} - -void QFxFlowView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if (m_dragItem) { - QPointF p = event->pos() + m_dragOffset; - m_dragItem->setX(p.x()); - m_dragItem->setY(p.y()); - - for (int ii = 0; ii < m_items.count(); ++ii) { - if (m_items.at(ii) != m_dragItem && rectForItem(ii).contains(event->pos())) { - reflowDrag(event->pos()); - } - } - } -} - -QML_DEFINE_TYPE(Qt, 4,6, (QT_VERSION&0x00ff00)>>8, FlowView, QFxFlowView); - -QT_END_NAMESPACE - -#include "qfxflowview.moc" diff --git a/src/declarative/extra/qfxflowview.h b/src/declarative/extra/qfxflowview.h deleted file mode 100644 index 2d7a8bd..0000000 --- a/src/declarative/extra/qfxflowview.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXFLOWVIEW_H -#define QFXFLOWVIEW_H - -#include <private/qmltimeline_p.h> -#include <QtDeclarative/qfxitem.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QFxVisualModel; -class QFxFlowViewValue; -class QFxFlowViewAttached; -class Q_DECLARATIVE_EXPORT QFxFlowView : public QFxItem -{ - Q_OBJECT - Q_PROPERTY(QFxVisualModel *model READ model WRITE setModel) - Q_PROPERTY(int column READ columns WRITE setColumns) - Q_PROPERTY(bool vertical READ vertical WRITE setVertical) - -public: - QFxFlowView(); - - QFxVisualModel *model() const; - void setModel(QFxVisualModel *); - - int columns() const; - void setColumns(int); - - bool vertical() const; - void setVertical(bool); - - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - - static QFxFlowViewAttached *qmlAttachedProperties(QObject *); - -private: - QRectF rectForItem(int idx) const; - void refresh(); - void reflow(bool animate = false); - void reflowDrag(const QPointF &); - void clearTimeLine(); - int m_columns; - QFxVisualModel *m_model; - QList<QFxItem *> m_items; - bool m_vertical; - void moveItem(QFxItem *item, const QPointF &); - - QPointF m_dragOffset; - QFxItem *m_dragItem; - - QmlTimeLine m_timeline; - QList<QFxFlowViewValue *> m_values; - int m_dragIdx; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxFlowView) - -QT_END_HEADER - -#endif // QFXFLOWVIEW_H diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp index 3bc76da..6616912 100644 --- a/src/declarative/fx/qfxborderimage.cpp +++ b/src/declarative/fx/qfxborderimage.cpp @@ -124,19 +124,16 @@ QFxBorderImage::~QFxBorderImage() BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies - \list - \i the grid lines describing a \l {BorderImage::border.left}{scale grid}. - \i an image file. - \endlist - - The following .sci file sets grid line offsets of 10 on each side for the image \c picture.png: - \code - gridLeft: 10 - gridTop: 10 - gridBottom: 10 - gridRight: 10 - imageFile: picture.png - \endcode + the borders, the image file and the tile rules. + + The following .sci file sets the borders to 10 on each side for the image \c picture.png: + \qml + border.left: 10 + border.top: 10 + border.bottom: 10 + border.right: 10 + source: picture.png + \endqml The URL may be absolute, or relative to the URL of the component. */ diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp index 08120fc..c0cac6c 100644 --- a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp @@ -41,6 +41,8 @@ #include "qfxgraphicsobjectcontainer.h" #include <QGraphicsObject> +#include <QGraphicsWidget> +#include <QGraphicsSceneResizeEvent> QT_BEGIN_NAMESPACE @@ -59,7 +61,7 @@ QML_DEFINE_NOCREATE_TYPE(QGraphicsObject) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GraphicsObjectContainer,QFxGraphicsObjectContainer) QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent) -: QFxItem(parent), _graphicsObject(0) +: QFxItem(parent), _graphicsObject(0), _syncedResize(false) { } @@ -81,9 +83,20 @@ void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object) if (object == _graphicsObject) return; + //### what should we do with previously set object? + _graphicsObject = object; - _graphicsObject->setParentItem(this); + if (_graphicsObject) { + _graphicsObject->setParentItem(this); + + if (_syncedResize && _graphicsObject->isWidget()) { + _graphicsObject->installEventFilter(this); + QSizeF newSize = static_cast<QGraphicsWidget*>(_graphicsObject)->size(); //### use sizeHint? + setImplicitWidth(newSize.width()); + setImplicitHeight(newSize.height()); + } + } } QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value) @@ -96,4 +109,83 @@ QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const return QFxItem::itemChange(change, value); } +bool QFxGraphicsObjectContainer::eventFilter(QObject *watched, QEvent *e) +{ + if (watched == _graphicsObject && e->type() == QEvent::GraphicsSceneResize) { + if (_graphicsObject && _graphicsObject->isWidget() && _syncedResize) { + QSizeF newSize = static_cast<QGraphicsWidget*>(_graphicsObject)->size(); + setImplicitWidth(newSize.width()); + setImplicitHeight(newSize.height()); + } + } + return QFxItem::eventFilter(watched, e); +} + +/*! + \qmlproperty bool GraphicsObjectContainer::synchronizedResizing + + This property determines whether or not the container and graphics object will synchronize their + sizes. + + \note This property only applies when wrapping a QGraphicsWidget. + + If synchronizedResizing is enabled, the container and widget will + synchronize their sizes as follows. + \list + \o If a size has been set on the container, the widget will be resized to the container. + Any changes in the container's size will be reflected in the widget. + + \o \e Otherwise, the container will initially be sized to the preferred size of the widget. + Any changes to the container's size will be reflected in the widget, and any changes to the + widget's size will be reflected in the container. + \endlist +*/ +bool QFxGraphicsObjectContainer::synchronizedResizing() const +{ + return _syncedResize; +} + +void QFxGraphicsObjectContainer::setSynchronizedResizing(bool on) +{ + if (on == _syncedResize) + return; + + if (_graphicsObject && _graphicsObject->isWidget()) { + if (!on) { + _graphicsObject->removeEventFilter(this); + disconnect(this, SIGNAL(widthChanged()), this, SLOT(_q_updateSize())); + disconnect(this, SIGNAL(heightChanged()), this, SLOT(_q_updateSize())); + } + } + + _syncedResize = on; + + if (_graphicsObject && _graphicsObject->isWidget()) { + if (on) { + _graphicsObject->installEventFilter(this); + connect(this, SIGNAL(widthChanged()), this, SLOT(_q_updateSize())); + connect(this, SIGNAL(heightChanged()), this, SLOT(_q_updateSize())); + } + } +} + +void QFxGraphicsObjectContainer::_q_updateSize() +{ + if (!_graphicsObject || !_graphicsObject->isWidget() || !_syncedResize) + return; + + QGraphicsWidget *gw = static_cast<QGraphicsWidget*>(_graphicsObject); + const QSizeF newSize(width(), height()); + gw->resize(newSize); + + //### will respecting the widgets min/max ever get us in trouble? (all other items always + // size to exactly what you tell them) + /*QSizeF constrainedSize = newSize.expandedTo(gw->minimumSize()).boundedTo(gw->maximumSize()); + gw->resize(constrainedSize); + if (constrainedSize != newSize) { + setImplicitWidth(constrainedSize.width()); + setImplicitHeight(constrainedSize.height()); + }*/ +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h index 165bc48..a8b7c8c 100644 --- a/src/declarative/fx/qfxgraphicsobjectcontainer.h +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h @@ -58,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem Q_CLASSINFO("DefaultProperty", "graphicsObject") Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject) + Q_PROPERTY(bool synchronizedResizing READ synchronizedResizing WRITE setSynchronizedResizing) public: QFxGraphicsObjectContainer(QFxItem *parent = 0); @@ -66,11 +67,19 @@ public: QGraphicsObject *graphicsObject() const; void setGraphicsObject(QGraphicsObject *); + bool synchronizedResizing() const; + void setSynchronizedResizing(bool on); + protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value); + bool eventFilter(QObject *watched, QEvent *e); + +private Q_SLOTS: + void _q_updateSize(); private: QGraphicsObject *_graphicsObject; + bool _syncedResize; }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 1095dc1..9aa1198 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -593,11 +593,11 @@ void QFxGridViewPrivate::createHighlight() highlight = new FxGridItem(item, q); highlightXAnimator = new QmlEaseFollow(q); highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x"))); - highlightXAnimator->setVelocity(400); + highlightXAnimator->setDuration(150); highlightXAnimator->setEnabled(autoHighlight); highlightYAnimator = new QmlEaseFollow(q); highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y"))); - highlightYAnimator->setVelocity(400); + highlightYAnimator->setDuration(150); highlightYAnimator->setEnabled(autoHighlight); } else { delete highlightContext; @@ -710,6 +710,8 @@ QFxGridView::~QFxGridView() for the view. For large or dynamic datasets the model is usually provided by a C++ model object. The C++ model object must be a \l {QAbstractItemModel} subclass, a VisualModel, or a simple list. + + \sa {qmlmodels}{Data Models} */ QVariant QFxGridView::model() const { @@ -1064,54 +1066,134 @@ qreal QFxGridView::maxXExtent() const Q_D(const QFxGridView); if (d->flow == QFxGridView::LeftToRight) return QFxFlickable::maxXExtent(); - return -(d->endPosition() - height()); + return -(d->endPosition() - width()); } void QFxGridView::keyPressEvent(QKeyEvent *event) { Q_D(QFxGridView); + QFxFlickable::keyPressEvent(event); + if (event->isAccepted()) + return; + if (d->model && d->model->count() && d->interactive) { - if ((d->flow == QFxGridView::LeftToRight && event->key() == Qt::Key_Up) - || (d->flow == QFxGridView::TopToBottom && event->key() == Qt::Key_Left)) { - if (currentIndex() >= d->columns || d->wrap) { - d->moveReason = QFxGridViewPrivate::Key; - int index = currentIndex() - d->columns; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); - event->accept(); - return; - } - } else if ((d->flow == QFxGridView::LeftToRight && event->key() == Qt::Key_Down) - || (d->flow == QFxGridView::TopToBottom && event->key() == Qt::Key_Right)) { - if (currentIndex() < d->model->count() - d->columns || d->wrap) { - d->moveReason = QFxGridViewPrivate::Key; - int index = currentIndex()+d->columns; - setCurrentIndex(index < d->model->count() ? index : 0); - event->accept(); - return; - } - } else if ((d->flow == QFxGridView::LeftToRight && event->key() == Qt::Key_Left) - || (d->flow == QFxGridView::TopToBottom && event->key() == Qt::Key_Up)) { - if (currentIndex() > 0 || d->wrap) { - d->moveReason = QFxGridViewPrivate::Key; - int index = currentIndex() - 1; - setCurrentIndex(index >= 0 ? index : d->model->count()-1); - event->accept(); - return; - } - } else if ((d->flow == QFxGridView::LeftToRight && event->key() == Qt::Key_Right) - || (d->flow == QFxGridView::TopToBottom && event->key() == Qt::Key_Down)) { - if (currentIndex() < d->model->count() - 1 || d->wrap) { - d->moveReason = QFxGridViewPrivate::Key; - int index = currentIndex() + 1; - setCurrentIndex(index < d->model->count() ? index : 0); - event->accept(); - return; - } + d->moveReason = QFxGridViewPrivate::Key; + int oldCurrent = currentIndex(); + switch (event->key()) { + case Qt::Key_Up: + moveCurrentIndexUp(); + break; + case Qt::Key_Down: + moveCurrentIndexDown(); + break; + case Qt::Key_Left: + moveCurrentIndexLeft(); + break; + case Qt::Key_Right: + moveCurrentIndexRight(); + break; + default: + break; + } + if (oldCurrent != currentIndex()) { + event->accept(); + return; } } d->moveReason = QFxGridViewPrivate::Other; event->ignore(); - QFxFlickable::keyPressEvent(event); +} + +/*! + \qmlmethod GridView::moveCurrentIndexUp + + Move the currentIndex up one item in the view. + The current index will wrap if keyNavigationWraps is true and it + is currently at the end. +*/ +void QFxGridView::moveCurrentIndexUp() +{ + Q_D(QFxGridView); + if (d->flow == QFxGridView::LeftToRight) { + if (currentIndex() >= d->columns || d->wrap) { + int index = currentIndex() - d->columns; + setCurrentIndex(index >= 0 ? index : d->model->count()-1); + } + } else { + if (currentIndex() > 0 || d->wrap) { + int index = currentIndex() - 1; + setCurrentIndex(index >= 0 ? index : d->model->count()-1); + } + } +} + +/*! + \qmlmethod GridView::moveCurrentIndexDown + + Move the currentIndex down one item in the view. + The current index will wrap if keyNavigationWraps is true and it + is currently at the end. +*/ +void QFxGridView::moveCurrentIndexDown() +{ + Q_D(QFxGridView); + if (d->flow == QFxGridView::LeftToRight) { + if (currentIndex() < d->model->count() - d->columns || d->wrap) { + int index = currentIndex()+d->columns; + setCurrentIndex(index < d->model->count() ? index : 0); + } + } else { + if (currentIndex() < d->model->count() - 1 || d->wrap) { + int index = currentIndex() + 1; + setCurrentIndex(index < d->model->count() ? index : 0); + } + } +} + +/*! + \qmlmethod GridView::moveCurrentIndexLeft + + Move the currentIndex left one item in the view. + The current index will wrap if keyNavigationWraps is true and it + is currently at the end. +*/ +void QFxGridView::moveCurrentIndexLeft() +{ + Q_D(QFxGridView); + if (d->flow == QFxGridView::LeftToRight) { + if (currentIndex() > 0 || d->wrap) { + int index = currentIndex() - 1; + setCurrentIndex(index >= 0 ? index : d->model->count()-1); + } + } else { + if (currentIndex() >= d->columns || d->wrap) { + int index = currentIndex() - d->columns; + setCurrentIndex(index >= 0 ? index : d->model->count()-1); + } + } +} + +/*! + \qmlmethod GridView::moveCurrentIndexRight + + Move the currentIndex right one item in the view. + The current index will wrap if keyNavigationWraps is true and it + is currently at the end. +*/ +void QFxGridView::moveCurrentIndexRight() +{ + Q_D(QFxGridView); + if (d->flow == QFxGridView::LeftToRight) { + if (currentIndex() < d->model->count() - 1 || d->wrap) { + int index = currentIndex() + 1; + setCurrentIndex(index < d->model->count() ? index : 0); + } + } else { + if (currentIndex() < d->model->count() - d->columns || d->wrap) { + int index = currentIndex()+d->columns; + setCurrentIndex(index < d->model->count() ? index : 0); + } + } } void QFxGridView::componentComplete() diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h index 996141f..08a7565 100644 --- a/src/declarative/fx/qfxgridview.h +++ b/src/declarative/fx/qfxgridview.h @@ -112,6 +112,12 @@ public: static QFxGridViewAttached *qmlAttachedProperties(QObject *); +public Q_SLOTS: + void moveCurrentIndexUp(); + void moveCurrentIndexDown(); + void moveCurrentIndexLeft(); + void moveCurrentIndexRight(); + Q_SIGNALS: void countChanged(); void currentIndexChanged(); diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 3584892..1247021 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -178,6 +178,7 @@ public: , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0), spacing(0.0) , ownModel(false), wrap(false), autoHighlight(true) , haveHighlightRange(false), strictHighlightRange(false) + , highlightMoveSpeed(400), highlightResizeSpeed(400) {} void init(); @@ -390,6 +391,8 @@ public: QString sectionExpression; QString currentSection; qreal spacing; + qreal highlightMoveSpeed; + qreal highlightResizeSpeed; bool ownModel : 1; bool wrap : 1; @@ -667,11 +670,11 @@ void QFxListViewPrivate::createHighlight() const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x"); highlightPosAnimator = new QmlEaseFollow(q); highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp)); - highlightPosAnimator->setVelocity(400); + highlightPosAnimator->setVelocity(highlightMoveSpeed); highlightPosAnimator->setEnabled(autoHighlight); const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width"); highlightSizeAnimator = new QmlEaseFollow(q); - highlightSizeAnimator->setVelocity(400); + highlightSizeAnimator->setVelocity(highlightResizeSpeed); highlightSizeAnimator->setTarget(QmlMetaProperty(highlight->item, sizeProp)); highlightSizeAnimator->setEnabled(autoHighlight); } @@ -876,6 +879,8 @@ QFxListView::~QFxListView() Models can also be created directly in QML, using a \l{ListModel}, \l{XmlListModel} or \l{VisualItemModel}. + + \sa {qmlmodels}{Data Models} */ QVariant QFxListView::model() const { @@ -1257,6 +1262,48 @@ QString QFxListView::currentSection() const return d->currentSection; } +/*! + \qmlproperty real ListView::highlightMoveSpeed + + This property holds the moving animation speed of the highlight delegate. +*/ +qreal QFxListView::highlightMoveSpeed() const +{ + Q_D(const QFxListView);\ + return d->highlightMoveSpeed; +} + +void QFxListView::setHighlightMoveSpeed(qreal speed) +{ + Q_D(QFxListView);\ + if (d->highlightMoveSpeed != speed) + { + d->highlightMoveSpeed = speed; + emit highlightMoveSpeedChanged(); + } +} + +/*! + \qmlproperty real ListView::highlightResizeSpeed + + This property holds the resizing animation speed of the highlight delegate. +*/ +qreal QFxListView::highlightResizeSpeed() const +{ + Q_D(const QFxListView);\ + return d->highlightResizeSpeed; +} + +void QFxListView::setHighlightResizeSpeed(qreal speed) +{ + Q_D(QFxListView);\ + if (d->highlightResizeSpeed != speed) + { + d->highlightResizeSpeed = speed; + emit highlightResizeSpeedChanged(); + } +} + void QFxListView::viewportMoved() { Q_D(QFxListView); @@ -1372,6 +1419,12 @@ void QFxListView::keyPressEvent(QKeyEvent *event) event->ignore(); } +/*! + \qmlmethod ListView::incrementCurrentIndex + + Increments the current index. The current index will wrap + if keyNavigationWraps is true and it is currently at the end. +*/ void QFxListView::incrementCurrentIndex() { Q_D(QFxListView); @@ -1381,6 +1434,12 @@ void QFxListView::incrementCurrentIndex() } } +/*! + \qmlmethod ListView::decrementCurrentIndex + + Decrements the current index. The current index will wrap + if keyNavigationWraps is true and it is currently at the beginning. +*/ void QFxListView::decrementCurrentIndex() { Q_D(QFxListView); diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index fc15967..3cff422 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -77,6 +77,9 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) 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_CLASSINFO("DefaultProperty", "data") public: @@ -126,6 +129,12 @@ public: void setSectionExpression(const QString &); QString currentSection() const; + qreal highlightMoveSpeed() const; + void setHighlightMoveSpeed(qreal); + + qreal highlightResizeSpeed() const; + void setHighlightResizeSpeed(qreal); + static QFxListViewAttached *qmlAttachedProperties(QObject *); public Q_SLOTS: @@ -138,6 +147,8 @@ Q_SIGNALS: void currentIndexChanged(); void currentSectionChanged(); void sectionExpressionChanged(); + void highlightMoveSpeedChanged(); + void highlightResizeSpeedChanged(); protected: virtual void viewportMoved(); diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 86bc9a2..b127f39 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -140,6 +140,8 @@ QFxPathView::~QFxPathView() The model provides a set of data that is used to create the items for the view. For large or dynamic datasets the model is usually provided by a C++ model object. Models can also be created directly in XML, using the ListModel element. + + \sa {qmlmodels}{Data Models} */ QVariant QFxPathView::model() const { diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index eb8103c..f35fe3d 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -74,7 +74,7 @@ void QFxPen::setColor(const QColor &c) void QFxPen::setWidth(int w) { - if (_width == w) + if (_width == w && _valid) return; _width = w; @@ -425,41 +425,21 @@ void QFxRect::drawRect(QPainter &p) if (d->smooth) p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - int offset = 0; const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0; - if (d->radius > 0) { + if (d->radius > 0) generateRoundedRect(); - //### implicit conversion to int - offset = int(d->radius+1.5+pw); - } else { + else generateBorderedRect(); - offset = pw+1; - } - //basically same code as QFxImage uses to paint sci images - int w = width()+pw; - int h = height()+pw; - int xOffset = offset; - int xSide = xOffset * 2; - bool xMiddles=true; - if (xSide > w) { - xMiddles=false; - xOffset = w/2 + 1; - xSide = xOffset * 2; - } - int yOffset = offset; - int ySide = yOffset * 2; - bool yMiddles=true; - if (ySide > h) { - yMiddles = false; - yOffset = h/2 + 1; - ySide = yOffset * 2; - } + int xOffset = (d->rectImage.width()-1)/2; + int yOffset = (d->rectImage.height()-1)/2; + Q_ASSERT(d->rectImage.width() == 2*xOffset + 1); + Q_ASSERT(d->rectImage.height() == 2*yOffset + 1); QMargins margins(xOffset, yOffset, xOffset, yOffset); QTileRules rules(Qt::StretchTile, Qt::StretchTile); - qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, d->rectImage.width()/2 + xOffset*2, d->rectImage.height()/2 + yOffset*2), margins, d->rectImage, d->rectImage.rect(), margins, rules); + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules); if (d->smooth) { p.setRenderHint(QPainter::Antialiasing, oldAA); @@ -479,6 +459,8 @@ void QFxRect::drawRect(QPainter &p) \note Generally scaling artifacts are only visible if the item is stationary on the screen. A common pattern when animating an item is to disable smooth filtering at the beginning of the animation and reenable it at the conclusion. + + \image rect-smooth.png */ QRectF QFxRect::boundingRect() const diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp index bc34839..182dcc7 100644 --- a/src/declarative/fx/qfxrepeater.cpp +++ b/src/declarative/fx/qfxrepeater.cpp @@ -143,6 +143,8 @@ QFxRepeater::~QFxRepeater() based on the order they are created. Models can also be created directly in QML, using a \l{ListModel} or \l{XmlListModel}. + + \sa {qmlmodels}{Data Models} */ QVariant QFxRepeater::model() const { @@ -154,15 +156,15 @@ void QFxRepeater::setModel(const QVariant &model) { Q_D(QFxRepeater); clear(); - /* if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); + /* disconnect(d->model, SIGNAL(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*))); disconnect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*))); - } */ + } d->dataSource = model; QObject *object = qvariant_cast<QObject*>(model); QFxVisualModel *vim = 0; @@ -181,10 +183,10 @@ void QFxRepeater::setModel(const QVariant &model) dataModel->setModel(model); } if (d->model) { - /* 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, QFxItem*)), this, SLOT(createdItem(int,QFxItem*))); connect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*))); */ @@ -291,4 +293,20 @@ void QFxRepeater::regenerate() } } } + +void QFxRepeater::itemsInserted(int, int) +{ + regenerate(); +} + +void QFxRepeater::itemsRemoved(int, int) +{ + regenerate(); +} + +void QFxRepeater::itemsMoved(int,int,int) +{ + regenerate(); +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h index 7d64d86..7a0318b 100644 --- a/src/declarative/fx/qfxrepeater.h +++ b/src/declarative/fx/qfxrepeater.h @@ -84,6 +84,11 @@ protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value); QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent); +private Q_SLOTS: + void itemsInserted(int,int); + void itemsRemoved(int,int); + void itemsMoved(int,int,int); + private: Q_DISABLE_COPY(QFxRepeater) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxRepeater) diff --git a/src/declarative/fx/qfxscalegrid.cpp b/src/declarative/fx/qfxscalegrid.cpp index f0c5758..4c6a522 100644 --- a/src/declarative/fx/qfxscalegrid.cpp +++ b/src/declarative/fx/qfxscalegrid.cpp @@ -142,15 +142,15 @@ QFxGridScaledImage::QFxGridScaledImage(QIODevice *data) list[0] = list[0].trimmed(); list[1] = list[1].trimmed(); - if (list[0] == QLatin1String("gridLeft")) + if (list[0] == QLatin1String("border.left")) l = list[1].toInt(); - else if (list[0] == QLatin1String("gridRight")) + else if (list[0] == QLatin1String("border.right")) r = list[1].toInt(); - else if (list[0] == QLatin1String("gridTop")) + else if (list[0] == QLatin1String("border.top")) t = list[1].toInt(); - else if (list[0] == QLatin1String("gridBottom")) + else if (list[0] == QLatin1String("border.bottom")) b = list[1].toInt(); - else if (list[0] == QLatin1String("imageFile")) + else if (list[0] == QLatin1String("source")) imgFile = list[1]; else if (list[0] == QLatin1String("horizontalTileRule")) _h = stringToRule(list[1]); diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index 45166de..fb1cfcf 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -132,7 +132,11 @@ public: \brief The VisualItemModel allows items to be provided to a view. The children of the VisualItemModel are provided in a model which - can be used in a view. An item can determine its index within the + can be used in a view. Note that no delegate should be + provided to a view since the VisualItemModel contains the + visual delegate (items). + + An item can determine its index within the model via the VisualItemModel.index attached property. The example below places three colored rectangles in a ListView. diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index e67e42f..9ee0d1b 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -117,43 +117,9 @@ QScriptValue desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e) return e->newVariant(QVariant(ret)); } -// XXX Something like this should be exported by Qt. static QString userLocalDataPath(const QString& app) { - QString result; - -#ifdef Q_OS_WIN -#ifndef Q_OS_WINCE - QLibrary library(QLatin1String("shell32")); -#else - QLibrary library(QLatin1String("coredll")); -#endif // Q_OS_WINCE - typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL); - GetSpecialFolderPath SHGetSpecialFolderPath = (GetSpecialFolderPath)library.resolve("SHGetSpecialFolderPathW"); - if (SHGetSpecialFolderPath) { - wchar_t path[MAX_PATH]; - SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE); - result = QString::fromWCharArray(path); - } -#endif // Q_OS_WIN - -#ifdef Q_OS_MAC - result = QLatin1String(qgetenv("HOME")); - result += "/Library/Application Support"; -#else - if (result.isEmpty()) { - // Fallback: UNIX style - result = QLatin1String(qgetenv("XDG_DATA_HOME")); - if (result.isEmpty()) { - result = QLatin1String(qgetenv("HOME")); - result += QLatin1String("/.local/share"); - } - } -#endif - - result += QLatin1Char('/'); - result += app; - return result; + return QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/") + app; } QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) @@ -169,7 +135,7 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("DesktopServices"), desktopObject); scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject); - offlineStoragePath = userLocalDataPath(QLatin1String("Nokia/Qt/QML/OfflineStorage")); + offlineStoragePath = userLocalDataPath(QLatin1String("QML/OfflineStorage")); qt_add_qmlxmlhttprequest(&scriptEngine); qt_add_qmlsqldatabase(&scriptEngine); @@ -1134,7 +1100,7 @@ public: if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return)) return true; if (s->urls.count() == 1 && !s->isBuiltin[0] && !s->isLibrary[0] && url_return) { - *url_return = QUrl(s->urls[0]+"/").resolved(QUrl(QLatin1String(unqualifiedtype + ".qml"))); + *url_return = QUrl(s->urls[0]+QLatin1String("/")).resolved(QUrl(QLatin1String(unqualifiedtype + ".qml"))); return true; } } @@ -1304,7 +1270,7 @@ void QmlEngine::addImportPath(const QString& path) QFxWebView and the SQL databases created with openDatabase() are stored here. - The default is Nokia/Qt/QML/Databases/ in the platform-standard + The default is QML/OfflineStorage/ in the platform-standard user application data directory. */ void QmlEngine::setOfflineStoragePath(const QString& dir) diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index ef21ebf..578646b 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -76,7 +76,6 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine) } else if (d.type() == QMetaType::QVariantList) { m_type = VariantList; } else if (d.canConvert(QVariant::Int)) { - qDebug() << "integer"; m_type = Integer; } else if (d.type() != QVariant::UserType) { m_type = Instance; @@ -90,7 +89,6 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine) (enginePrivate && enginePrivate->isQmlList(d.userType()))) { m_type = QmlList; } else if (QmlMetaType::isList(d.userType())) { - qDebug() << "list"; m_type = QList; } else { m_type = Invalid; diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index a9a5bd5..921aa6c 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -208,9 +208,12 @@ void QmlParentChange::saveOriginals() d->origParent = d->target->parentItem(); - //try to determine the items original stack position so we can restore it - if (!d->origParent) + if (!d->origParent) { d->origStackBefore = 0; + return; + } + + //try to determine the item's original stack position so we can restore it int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1; QList<QGraphicsItem*> children = d->origParent->childItems(); for (int i = 0; i < children.count(); ++i) { |