src/declarative/graphicsitems/qdeclarativepathview_p_p.h
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    66 
    66 
    67 QT_BEGIN_NAMESPACE
    67 QT_BEGIN_NAMESPACE
    68 
    68 
    69 class QDeclarativeOpenMetaObjectType;
    69 class QDeclarativeOpenMetaObjectType;
    70 class QDeclarativePathViewAttached;
    70 class QDeclarativePathViewAttached;
    71 class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate
    71 class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
    72 {
    72 {
    73     Q_DECLARE_PUBLIC(QDeclarativePathView)
    73     Q_DECLARE_PUBLIC(QDeclarativePathView)
    74 
    74 
    75 public:
    75 public:
    76     QDeclarativePathViewPrivate()
    76     QDeclarativePathViewPrivate()
    77       : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0)
    77       : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0)
    78         , lastElapsed(0), mappedRange(1.0)
    78         , lastElapsed(0), mappedRange(1.0)
    79         , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
    79         , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
    80         , autoHighlight(true), highlightUp(false), dragMargin(0), deceleration(100)
    80         , autoHighlight(true), highlightUp(false), layoutScheduled(false)
       
    81         , dragMargin(0), deceleration(100)
    81         , moveOffset(this, &QDeclarativePathViewPrivate::setOffset)
    82         , moveOffset(this, &QDeclarativePathViewPrivate::setOffset)
    82         , firstIndex(-1), pathItems(-1), requestedIndex(-1)
    83         , firstIndex(-1), pathItems(-1), requestedIndex(-1)
    83         , moveReason(Other), attType(0), highlightComponent(0), highlightItem(0)
    84         , moveReason(Other), attType(0), highlightComponent(0), highlightItem(0)
    84         , moveHighlight(this, &QDeclarativePathViewPrivate::setHighlightPosition)
    85         , moveHighlight(this, &QDeclarativePathViewPrivate::setHighlightPosition)
    85         , highlightPosition(0)
    86         , highlightPosition(0)
    87         , highlightRangeMode(QDeclarativePathView::StrictlyEnforceRange)
    88         , highlightRangeMode(QDeclarativePathView::StrictlyEnforceRange)
    88         , highlightMoveDuration(300)
    89         , highlightMoveDuration(300)
    89     {
    90     {
    90     }
    91     }
    91 
    92 
    92     void init()
    93     void init() {
    93     {
       
    94         Q_Q(QDeclarativePathView);
    94         Q_Q(QDeclarativePathView);
    95         offset = 0;
    95         offset = 0;
    96         q->setAcceptedMouseButtons(Qt::LeftButton);
    96         q->setAcceptedMouseButtons(Qt::LeftButton);
    97         q->setFlag(QGraphicsItem::ItemIsFocusScope);
    97         q->setFlag(QGraphicsItem::ItemIsFocusScope);
    98         q->setFiltersChildEvents(true);
    98         q->setFiltersChildEvents(true);
    99         q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
    99         q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
       
   100         lastPosTime.invalidate();
       
   101     }
       
   102 
       
   103     void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
       
   104         if ((newGeometry.size() != oldGeometry.size())
       
   105             && (!highlightItem || item != highlightItem)) {
       
   106             scheduleLayout();
       
   107         }
       
   108     }
       
   109 
       
   110     void scheduleLayout() {
       
   111         Q_Q(QDeclarativePathView);
       
   112         if (!layoutScheduled) {
       
   113             layoutScheduled = true;
       
   114             QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority);
       
   115         }
   100     }
   116     }
   101 
   117 
   102     QDeclarativeItem *getItem(int modelIndex);
   118     QDeclarativeItem *getItem(int modelIndex);
   103     void releaseItem(QDeclarativeItem *item);
   119     void releaseItem(QDeclarativeItem *item);
   104     QDeclarativePathViewAttached *attached(QDeclarativeItem *item);
   120     QDeclarativePathViewAttached *attached(QDeclarativeItem *item);
   136     bool ownModel : 1;
   152     bool ownModel : 1;
   137     bool interactive : 1;
   153     bool interactive : 1;
   138     bool haveHighlightRange : 1;
   154     bool haveHighlightRange : 1;
   139     bool autoHighlight : 1;
   155     bool autoHighlight : 1;
   140     bool highlightUp : 1;
   156     bool highlightUp : 1;
   141     QTime lastPosTime;
   157     bool layoutScheduled : 1;
       
   158     QElapsedTimer lastPosTime;
   142     QPointF lastPos;
   159     QPointF lastPos;
   143     qreal dragMargin;
   160     qreal dragMargin;
   144     qreal deceleration;
   161     qreal deceleration;
   145     QDeclarativeTimeLine tl;
   162     QDeclarativeTimeLine tl;
   146     QDeclarativeTimeLineValueProxy<QDeclarativePathViewPrivate> moveOffset;
   163     QDeclarativeTimeLineValueProxy<QDeclarativePathViewPrivate> moveOffset;