aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitemviewtransition_p.h
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2012-02-21 14:44:21 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-28 10:57:03 +0100
commit328c100ab3fc4d5ddccb0d19af9d7e87bd849f0b (patch)
tree5d20e04e97fc9818d966557a4115cde3ae505026 /src/quick/items/qquickitemviewtransition_p.h
parent60cae093d7e27e92198d626dc3df19dea9799faf (diff)
Separate view transition functionality into new file
Move most of the view transition functionality from qquickitemview* into qquickitemviewtransition*. - Move QQuickViewTransitionAttached - Move QQuickItemViewTransitionManager, rename to QQuickItemViewTransitionJob - Move FxViewItem transition-specific features into new QQuickViewItem - Move transition-specific functions like transitionNextReposition() and canTransition() into QQuickItemViewTransitioner which holds all the transition objects now Also mention in docs that there's no defined order for choosing between multiple matching displaced transitions. Change-Id: I8701c0d40d2af152c5d432a4c8de646854c76ea2 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/quick/items/qquickitemviewtransition_p.h')
-rw-r--r--src/quick/items/qquickitemviewtransition_p.h201
1 files changed, 201 insertions, 0 deletions
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h
new file mode 100644
index 0000000000..c388bed17e
--- /dev/null
+++ b/src/quick/items/qquickitemviewtransition_p.h
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKITEMVIEWTRANSITION_P_P_H
+#define QQUICKITEMVIEWTRANSITION_P_P_H
+
+#include <private/qdeclarativetransitionmanager_p_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QQuickItem;
+class QQuickViewItem;
+class QQuickItemViewTransitionJob;
+
+
+class QQuickItemViewTransitionChangeListener
+{
+public:
+ QQuickItemViewTransitionChangeListener() {}
+ virtual ~QQuickItemViewTransitionChangeListener() {}
+
+ virtual void viewItemTransitionFinished(QQuickViewItem *item) = 0;
+};
+
+
+class QQuickItemViewTransitioner
+{
+public:
+ enum TransitionType {
+ NoTransition,
+ PopulateTransition,
+ AddTransition,
+ MoveTransition,
+ RemoveTransition
+ };
+
+ QQuickItemViewTransitioner();
+ virtual ~QQuickItemViewTransitioner() {}
+
+ bool canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const;
+ void transitionNextReposition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, bool isTarget);
+
+ inline void setPopulateTransitionEnabled(bool b) { usePopulateTransition = b; }
+ inline void setChangeListener(QQuickItemViewTransitionChangeListener *obj) { changeListener = obj; }
+
+ QList<int> addTransitionIndexes;
+ QList<int> moveTransitionIndexes;
+ QList<int> removeTransitionIndexes;
+ QList<QObject *> addTransitionTargets;
+ QList<QObject *> moveTransitionTargets;
+ QList<QObject *> removeTransitionTargets;
+
+ QDeclarativeTransition *populateTransition;
+ QDeclarativeTransition *addTransition;
+ QDeclarativeTransition *addDisplacedTransition;
+ QDeclarativeTransition *moveTransition;
+ QDeclarativeTransition *moveDisplacedTransition;
+ QDeclarativeTransition *removeTransition;
+ QDeclarativeTransition *removeDisplacedTransition;
+
+private:
+ friend class QQuickItemViewTransitionJob;
+
+ QQuickItemViewTransitionChangeListener *changeListener;
+ bool usePopulateTransition;
+
+ void finishedTransition(QQuickViewItem *item);
+};
+
+
+/*
+ An item in a view, that can be transitioned using QQuickViewTransitionJob.
+ */
+class QQuickViewItem
+{
+public:
+ QQuickViewItem(QQuickItem *i);
+ virtual ~QQuickViewItem();
+
+ qreal itemX() const;
+ qreal itemY() const;
+
+ void moveTo(const QPointF &pos);
+ void setVisible(bool visible);
+
+ bool transitionScheduledOrRunning() const;
+ bool transitionRunning() const;
+ bool isPendingRemoval() const;
+
+ bool prepareTransition(const QRectF &viewBounds);
+ void startTransition(QQuickItemViewTransitioner *transitioner);
+ void stopTransition();
+
+ QPointF nextTransitionTo;
+ QQuickItem *item;
+ QQuickItemViewTransitionJob *transition;
+ QQuickItemViewTransitioner::TransitionType nextTransitionType;
+ int index;
+ bool isTransitionTarget;
+ bool nextTransitionToSet;
+
+private:
+ friend class QQuickItemViewTransitioner;
+ friend class QQuickItemViewTransitionJob;
+ void setNextTransition(QQuickItemViewTransitioner::TransitionType, bool isTargetItem);
+ void finishedTransition();
+ void resetTransitionData();
+};
+
+
+class QQuickViewTransitionAttached : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
+ Q_PROPERTY(QQuickItem* item READ item NOTIFY itemChanged)
+ Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged)
+
+ Q_PROPERTY(QList<int> targetIndexes READ targetIndexes NOTIFY targetIndexesChanged)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> targetItems READ targetItems NOTIFY targetItemsChanged)
+
+public:
+ QQuickViewTransitionAttached(QObject *parent);
+
+ int index() const { return m_index; }
+ QQuickItem *item() const { return m_item; }
+ QPointF destination() const { return m_destination; }
+
+ QList<int> targetIndexes() const { return m_targetIndexes; }
+ QDeclarativeListProperty<QObject> targetItems();
+
+ static QQuickViewTransitionAttached *qmlAttachedProperties(QObject *);
+
+signals:
+ void indexChanged();
+ void itemChanged();
+ void destinationChanged();
+
+ void targetIndexesChanged();
+ void targetItemsChanged();
+
+private:
+ friend class QQuickItemViewTransitionJob;
+ QPointF m_destination;
+ QList<int> m_targetIndexes;
+ QList<QObject *> m_targetItems;
+
+ QQuickItem *m_item;
+ int m_index;
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QQuickViewTransitionAttached)
+QML_DECLARE_TYPEINFO(QQuickViewTransitionAttached, QML_HAS_ATTACHED_PROPERTIES)
+
+QT_END_HEADER
+
+#endif // QQUICKITEMVIEWTRANSITION_P_P_H