src/declarative/graphicsitems/qdeclarativepathview_p_p.h
changeset 37 758a864f9613
parent 33 3e2da88830cd
--- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h	Fri Sep 17 08:34:18 2010 +0300
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h	Mon Oct 04 01:19:32 2010 +0300
@@ -75,34 +75,29 @@
 public:
     QDeclarativePathViewPrivate()
       : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0)
-        , lastElapsed(0), mappedRange(1.0)
+        , lastElapsed(0), offset(0.0), offsetAdj(0.0), mappedRange(1.0)
         , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
         , autoHighlight(true), highlightUp(false), layoutScheduled(false)
+        , moving(false), flicking(false)
         , dragMargin(0), deceleration(100)
-        , moveOffset(this, &QDeclarativePathViewPrivate::setOffset)
+        , moveOffset(this, &QDeclarativePathViewPrivate::setAdjustedOffset)
         , firstIndex(-1), pathItems(-1), requestedIndex(-1)
         , moveReason(Other), attType(0), highlightComponent(0), highlightItem(0)
         , moveHighlight(this, &QDeclarativePathViewPrivate::setHighlightPosition)
         , highlightPosition(0)
         , highlightRangeStart(0), highlightRangeEnd(0)
         , highlightRangeMode(QDeclarativePathView::StrictlyEnforceRange)
-        , highlightMoveDuration(300)
+        , highlightMoveDuration(300), modelCount(0)
     {
     }
 
-    void init() {
-        Q_Q(QDeclarativePathView);
-        offset = 0;
-        q->setAcceptedMouseButtons(Qt::LeftButton);
-        q->setFlag(QGraphicsItem::ItemIsFocusScope);
-        q->setFiltersChildEvents(true);
-        q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
-        lastPosTime.invalidate();
-    }
+    void init();
 
     void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
         if ((newGeometry.size() != oldGeometry.size())
             && (!highlightItem || item != highlightItem)) {
+            if (QDeclarativePathViewAttached *att = attached(item))
+                att->m_percent = -1;
             scheduleLayout();
         }
     }
@@ -133,6 +128,7 @@
     static void fixOffsetCallback(void*);
     void fixOffset();
     void setOffset(qreal offset);
+    void setAdjustedOffset(qreal offset);
     void regenerate();
     void updateItem(QDeclarativeItem *, qreal);
     void snapToCurrent();
@@ -147,6 +143,7 @@
     qreal lastDist;
     int lastElapsed;
     qreal offset;
+    qreal offsetAdj;
     qreal mappedRange;
     bool stealMouse : 1;
     bool ownModel : 1;
@@ -155,6 +152,8 @@
     bool autoHighlight : 1;
     bool highlightUp : 1;
     bool layoutScheduled : 1;
+    bool moving : 1;
+    bool flicking : 1;
     QElapsedTimer lastPosTime;
     QPointF lastPos;
     qreal dragMargin;
@@ -165,6 +164,7 @@
     int pathItems;
     int requestedIndex;
     QList<QDeclarativeItem *> items;
+    QList<QDeclarativeItem *> itemCache;
     QDeclarativeGuard<QDeclarativeVisualModel> model;
     QVariant modelVariant;
     enum MovementReason { Other, SetIndex, Mouse };
@@ -178,6 +178,7 @@
     qreal highlightRangeEnd;
     QDeclarativePathView::HighlightRangeMode highlightRangeMode;
     int highlightMoveDuration;
+    int modelCount;
 };
 
 QT_END_NAMESPACE