Improve interaction of nested Flickables and PathView
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickpathview_p_p.h
index 9bf329d..412caa6 100644 (file)
@@ -1,11 +1,9 @@
-// Commit: ac5c099cc3c5b8c7eec7a49fdeb8a21037230350
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** 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.
+** This file is part of the QtQml module of the Qt Toolkit.
 **
 ** $QT_BEGIN_LICENSE:LGPL$
 ** GNU Lesser General Public License Usage
@@ -36,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
 #include "qquickitem_p.h"
 #include "qquickvisualdatamodel_p.h"
 
-#include <QtDeclarative/qdeclarative.h>
+#include <QtQml/qqml.h>
 #include <QtCore/qdatetime.h>
 #include <QtCore/qcoreapplication.h>
 
-#include <private/qdeclarativeanimation_p_p.h>
-#include <private/qdeclarativeguard_p.h>
-#include <private/qdeclarativetimeline_p_p.h>
+#include <private/qquickanimation_p_p.h>
+#include <private/qqmlguard_p.h>
+#include <private/qquicktimeline_p_p.h>
 
 QT_BEGIN_NAMESPACE
 
-class QDeclarativeOpenMetaObjectType;
+class QQmlOpenMetaObjectType;
 class QQuickPathViewAttached;
 class QQuickPathViewPrivate : public QQuickItemPrivate, public QQuickItemChangeListener
 {
@@ -82,7 +81,7 @@ public:
         , autoHighlight(true), highlightUp(false), layoutScheduled(false)
         , moving(false), flicking(false), requestedOnPath(false), inRequest(false)
         , dragMargin(0), deceleration(100)
-        , moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset)
+        , moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset), flickDuration(0)
         , firstIndex(-1), pathItems(-1), requestedIndex(-1), requestedZ(0)
         , moveReason(Other), moveDirection(Shortest), attType(0), highlightComponent(0), highlightItem(0)
         , moveHighlight(this, &QQuickPathViewPrivate::setHighlightPosition)
@@ -115,7 +114,7 @@ public:
     QQuickItem *getItem(int modelIndex, qreal z = 0, bool onPath=true);
     void releaseItem(QQuickItem *item);
     QQuickPathViewAttached *attached(QQuickItem *item);
-    QDeclarativeOpenMetaObjectType *attachedType();
+    QQmlOpenMetaObjectType *attachedType();
     void clear();
     void updateMappedRange();
     qreal positionOfIndex(qreal index) const;
@@ -141,10 +140,12 @@ public:
     void updateItem(QQuickItem *, qreal);
     void snapToCurrent();
     QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const;
+    void addVelocitySample(qreal v);
+    qreal calcVelocity() const;
 
-    QDeclarativePath *path;
+    QQuickPath *path;
     int currentIndex;
-    QDeclarativeGuard<QQuickItem> currentItem;
+    QQmlGuard<QQuickItem> currentItem;
     qreal currentItemOffset;
     qreal startPc;
     QPointF startPoint;
@@ -168,30 +169,32 @@ public:
     QPointF lastPos;
     qreal dragMargin;
     qreal deceleration;
-    QDeclarativeTimeLine tl;
-    QDeclarativeTimeLineValueProxy<QQuickPathViewPrivate> moveOffset;
+    QQuickTimeLine tl;
+    QQuickTimeLineValueProxy<QQuickPathViewPrivate> moveOffset;
+    int flickDuration;
     int firstIndex;
     int pathItems;
     int requestedIndex;
     qreal requestedZ;
     QList<QQuickItem *> items;
     QList<QQuickItem *> itemCache;
-    QDeclarativeGuard<QQuickVisualModel> model;
+    QQmlGuard<QQuickVisualModel> model;
     QVariant modelVariant;
     enum MovementReason { Other, SetIndex, Mouse };
     MovementReason moveReason;
     enum MovementDirection { Shortest, Negative, Positive };
     MovementDirection moveDirection;
-    QDeclarativeOpenMetaObjectType *attType;
-    QDeclarativeComponent *highlightComponent;
+    QQmlOpenMetaObjectType *attType;
+    QQmlComponent *highlightComponent;
     QQuickItem *highlightItem;
-    QDeclarativeTimeLineValueProxy<QQuickPathViewPrivate> moveHighlight;
+    QQuickTimeLineValueProxy<QQuickPathViewPrivate> moveHighlight;
     qreal highlightPosition;
     qreal highlightRangeStart;
     qreal highlightRangeEnd;
     QQuickPathView::HighlightRangeMode highlightRangeMode;
     int highlightMoveDuration;
     int modelCount;
+    QPODVector<qreal,10> velocityBuffer;
 };
 
 QT_END_NAMESPACE