Qt 4.8
Public Types | Public Functions | Static Public Functions | Public Variables | List of all members
QDeclarativePathViewPrivate Class Reference

#include <qdeclarativepathview_p_p.h>

Inheritance diagram for QDeclarativePathViewPrivate:
QDeclarativeItemPrivate QDeclarativeItemChangeListener QGraphicsItemPrivate

Public Types

enum  MovementDirection { Shortest, Negative, Positive }
 
enum  MovementReason { Other, SetIndex, Mouse }
 
- Public Types inherited from QDeclarativeItemPrivate
enum  ChangeType {
  Geometry = 0x01, SiblingOrder = 0x02, Visibility = 0x04, Opacity = 0x08,
  Destroyed = 0x10
}
 
- Public Types inherited from QGraphicsItemPrivate
enum  AncestorFlag {
  NoFlag = 0, AncestorHandlesChildEvents = 0x1, AncestorClipsChildren = 0x2, AncestorIgnoresTransformations = 0x4,
  AncestorFiltersChildEvents = 0x8
}
 
enum  Extra {
  ExtraToolTip, ExtraCursor, ExtraCacheData, ExtraMaxDeviceCoordCacheSize,
  ExtraBoundingRegionGranularity
}
 
enum  InvalidateReason { OpacityChanged }
 

Public Functions

QDeclarativePathViewAttachedattached (QDeclarativeItem *item)
 
int calcCurrentIndex ()
 
void clear ()
 
void createHighlight ()
 
void fixOffset ()
 
QDeclarativeItemgetItem (int modelIndex)
 
void handleMouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
void handleMousePressEvent (QGraphicsSceneMouseEvent *event)
 
void handleMouseReleaseEvent (QGraphicsSceneMouseEvent *)
 
void init ()
 
bool isValid () const
 
void itemGeometryChanged (QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
 
QPointF pointNear (const QPointF &point, qreal *nearPercent=0) const
 
qreal positionOfIndex (qreal index) const
 
 QDeclarativePathViewPrivate ()
 
void regenerate ()
 
void releaseItem (QDeclarativeItem *item)
 
void scheduleLayout ()
 
void setAdjustedOffset (qreal offset)
 
void setHighlightPosition (qreal pos)
 
void setOffset (qreal offset)
 
void snapToCurrent ()
 
void updateCurrent ()
 
void updateHighlight ()
 
void updateItem (QDeclarativeItem *, qreal)
 
void updateMappedRange ()
 
- Public Functions inherited from QDeclarativeItemPrivate
QDeclarativeStateGroup_states ()
 
void addItemChangeListener (QDeclarativeItemChangeListener *listener, ChangeTypes types)
 
AnchorLinesanchorLines () const
 
QDeclarativeAnchorsanchors ()
 
QDeclarativeAnchorLine baseline () const
 
QDeclarativeAnchorLine bottom () const
 
QPointF computeTransformOrigin () const
 
QDeclarativeListProperty< QObjectdata ()
 
virtual void focusChanged (bool)
 
virtual void focusScopeItemChange (bool isSubFocusItem)
 Subclasses can reimplement this function to be notified when an item becomes a focusScopeItem (or is no longer a focusScopeItem). More...
 
qreal height () const
 
QDeclarativeAnchorLine horizontalCenter () const
 
virtual qreal implicitHeight () const
 
virtual void implicitHeightChanged ()
 
virtual qreal implicitWidth () const
 
virtual void implicitWidthChanged ()
 
void init (QDeclarativeItem *parent)
 
bool isMirrored () const
 
QDeclarativeAnchorLine left () const
 
virtual void mirrorChange ()
 
 QDeclarativeItemPrivate ()
 
void removeItemChangeListener (QDeclarativeItemChangeListener *, ChangeTypes types)
 
void resetHeight ()
 
void resetWidth ()
 
void resolveLayoutMirror ()
 
QDeclarativeListProperty< QObjectresources ()
 
QDeclarativeAnchorLine right () const
 
void setHeight (qreal)
 
void setImplicitLayoutMirror (bool mirror, bool inherit)
 
void setLayoutMirror (bool mirror)
 
virtual void setPosHelper (const QPointF &pos)
 Sets the position pos. More...
 
void setState (const QString &)
 
void setWidth (qreal)
 
virtual void siblingOrderChange ()
 Subclasses can reimplement this function to be notified when its siblingIndex order is changed. More...
 
QString state () const
 
QDeclarativeListProperty< QDeclarativeStatestates ()
 
QDeclarativeAnchorLine top () const
 
virtual void transformChanged ()
 
QDeclarativeListProperty< QDeclarativeTransitiontransitions ()
 
QDeclarativeAnchorLine verticalCenter () const
 
qreal width () const
 
- Public Functions inherited from QGraphicsItemPrivate
void addChild (QGraphicsItem *child)
 QGraphicsScenePrivate::registerTopLevelItem(). More...
 
void appendGraphicsTransform (QGraphicsTransform *t)
 
qreal calcEffectiveOpacity () const
 
void childrenBoundingRectHelper (QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem)
 Returns the bounding rect of this item's children (excluding itself). More...
 
bool childrenClippedToShape () const
 
bool childrenCombineOpacity () const
 
QDeclarativeListProperty< QGraphicsObjectchildrenList ()
 Returns a list of this item's children. More...
 
void clearFocusHelper (bool giveFocusToParent)
 
void clearSubFocus (QGraphicsItem *rootItem=0, QGraphicsItem *stopItem=0)
 
qreal combineOpacityFromParent (qreal parentOpacity) const
 
void combineTransformFromParent (QTransform *x, const QTransform *viewTransform=0) const
 Combines this item's position and transform onto transform. More...
 
void combineTransformToParent (QTransform *x, const QTransform *viewTransform=0) const
 Combines this item's position and transform onto transform. More...
 
int depth () const
 
bool discardUpdateRequest (bool ignoreVisibleBit=false, bool ignoreDirtyBit=false, bool ignoreOpacity=false) const
 Returns true if we can discard an update request; otherwise false. More...
 
QRectF effectiveBoundingRect (QGraphicsItem *topMostEffectItem=0) const
 Returns the effective bounding rect of the item. More...
 
QRectF effectiveBoundingRect (const QRectF &rect) const
 Returns the effective bounding rect of the given item space rect. More...
 
qreal effectiveOpacity () const
 
void ensureSceneTransform ()
 
void ensureSceneTransformRecursive (QGraphicsItem **topMostDirtyItem)
 
void ensureSequentialSiblingIndex ()
 Ensures that the list of children is sorted by insertion order, and that the siblingIndexes are packed (no gaps), and start at 0. More...
 
void ensureSortedChildren ()
 
QVariant extra (Extra type) const
 
QGraphicsItemCacheextraItemCache () const
 
QPointF genericMapFromScene (const QPointF &pos, const QWidget *viewport) const
 Maps the point pos from scene to item coordinates. More...
 
bool hasTranslateOnlySceneTransform ()
 
void initStyleOption (QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems=false) const
 
virtual QVariant inputMethodQueryHelper (Qt::InputMethodQuery query) const
 This helper function helped us add input method query support in Qt 4. More...
 
void invalidateChildGraphicsEffectsRecursively (InvalidateReason reason)
 
void invalidateChildrenSceneTransform ()
 
void invalidateDepthRecursively ()
 
void invalidateParentGraphicsEffectsRecursively ()
 
bool isFullyTransparent () const
 
bool isInvisible () const
 
bool isOpacityNull () const
 
virtual bool isProxyWidget () const
 
bool itemIsUntransformable () const
 
void markParentDirty (bool updateBoundingRect=false)
 
QGraphicsItemCachemaybeExtraItemCache () const
 
void prependGraphicsTransform (QGraphicsTransform *t)
 
 QGraphicsItemPrivate ()
 
void remapItemPos (QEvent *event, QGraphicsItem *item)
 Maps any item pos properties of event to item's coordinate system. More...
 
void removeChild (QGraphicsItem *child)
 QGraphicsScenePrivate::unregisterTopLevelItem(). More...
 
void removeExtraItemCache ()
 
void resetFocusProxy ()
 Sets the focusProxy pointer to 0 for all items that have this item as their focusProxy. More...
 
void resolveDepth ()
 Resolves the stacking depth of this object and all its ancestors. More...
 
virtual void resolveFont (uint inheritedMask)
 
virtual void resolvePalette (uint inheritedMask)
 
QRectF sceneEffectiveBoundingRect () const
 Returns the effective bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect(), taking into account the effect that the item might have. More...
 
void sendScenePosChange ()
 
void setEnabledHelper (bool newEnabled, bool explicitly, bool update=true)
 Sets this item's visibility to newEnabled. More...
 
void setExtra (Extra type, const QVariant &value)
 
void setFocusHelper (Qt::FocusReason focusReason, bool climb, bool focusFromHide)
 
void setIsMemberOfGroup (bool enabled)
 Propagates item group membership. More...
 
void setParentItemHelper (QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant)
 Make sure not to trigger any pure virtual function calls (e. More...
 
void setSubFocus (QGraphicsItem *rootItem=0, QGraphicsItem *stopItem=0)
 
void setTransformHelper (const QTransform &transform)
 Sets the transform transform. More...
 
void setVisibleHelper (bool newVisible, bool explicitly, bool update=true)
 Sets this item's visibility to newVisible. More...
 
virtual void subFocusItemChange ()
 Subclasses can reimplement this function to be notified when subFocusItem changes. More...
 
QTransform transformToParent () const
 
void unsetExtra (Extra type)
 
void updateAncestorFlag (QGraphicsItem::GraphicsItemFlag childFlag, AncestorFlag flag=NoFlag, bool enabled=false, bool root=true)
 Propagates the ancestor flag flag with value enabled to all this item's children. More...
 
void updateAncestorFlags ()
 
void updateChildWithGraphicsEffectFlagRecursively ()
 
void updatePaintedViewBoundingRects (bool updateChildren)
 
virtual void updateSceneTransformFromParent ()
 
virtual ~QGraphicsItemPrivate ()
 
- Public Functions inherited from QDeclarativeItemChangeListener
virtual QDeclarativeAnchorsPrivateanchorPrivate ()
 
virtual void itemDestroyed (QDeclarativeItem *)
 
virtual void itemOpacityChanged (QDeclarativeItem *)
 
virtual void itemSiblingOrderChanged (QDeclarativeItem *)
 
virtual void itemVisibilityChanged (QDeclarativeItem *)
 

Static Public Functions

static void fixOffsetCallback (void *)
 
- Static Public Functions inherited from QDeclarativeItemPrivate
static void data_append (QDeclarativeListProperty< QObject > *, QObject *)
 
static QObjectdata_at (QDeclarativeListProperty< QObject > *, int)
 
static void data_clear (QDeclarativeListProperty< QObject > *)
 
static int data_count (QDeclarativeListProperty< QObject > *)
 
static qint64 elapsed (QElapsedTimer &)
 
static QDeclarativeItemPrivateget (QDeclarativeItem *item)
 
static void parentProperty (QObject *o, void *rv, QDeclarativeNotifierEndpoint *e)
 
static void resources_append (QDeclarativeListProperty< QObject > *, QObject *)
 
static QObjectresources_at (QDeclarativeListProperty< QObject > *, int)
 
static void resources_clear (QDeclarativeListProperty< QObject > *)
 
static int resources_count (QDeclarativeListProperty< QObject > *)
 
static qint64 restart (QElapsedTimer &)
 
static void setConsistentTime (qint64 t)
 
static void start (QElapsedTimer &)
 
static void transform_append (QDeclarativeListProperty< QGraphicsTransform > *list, QGraphicsTransform *)
 
static QGraphicsTransformtransform_at (QDeclarativeListProperty< QGraphicsTransform > *list, int)
 
static void transform_clear (QDeclarativeListProperty< QGraphicsTransform > *list)
 
static int transform_count (QDeclarativeListProperty< QGraphicsTransform > *list)
 
- Static Public Functions inherited from QGraphicsItemPrivate
static void children_append (QDeclarativeListProperty< QGraphicsObject > *list, QGraphicsObject *item)
 
static QGraphicsObjectchildren_at (QDeclarativeListProperty< QGraphicsObject > *list, int)
 
static void children_clear (QDeclarativeListProperty< QGraphicsObject > *list)
 
static int children_count (QDeclarativeListProperty< QGraphicsObject > *list)
 
static const QGraphicsItemPrivateget (const QGraphicsItem *item)
 
static QGraphicsItemPrivateget (QGraphicsItem *item)
 
static bool insertionOrder (QGraphicsItem *a, QGraphicsItem *b)
 
static bool isOpacityNull (qreal opacity)
 
static bool movableAncestorIsSelected (const QGraphicsItem *item)
 

Public Variables

QDeclarativeOpenMetaObjectTypeattType
 
bool autoHighlight: 1
 
int currentIndex
 
QDeclarativeGuard< QDeclarativeItemcurrentItem
 
qreal currentItemOffset
 
qreal deceleration
 
qreal dragMargin
 
int firstIndex
 
bool flicking: 1
 
bool haveHighlightRange: 1
 
QDeclarativeComponenthighlightComponent
 
QDeclarativeItemhighlightItem
 
int highlightMoveDuration
 
qreal highlightPosition
 
qreal highlightRangeEnd
 
QDeclarativePathView::HighlightRangeMode highlightRangeMode
 
qreal highlightRangeStart
 
bool highlightUp: 1
 
bool interactive: 1
 
QList< QDeclarativeItem * > itemCache
 
QList< QDeclarativeItem * > items
 
qreal lastDist
 
int lastElapsed
 
QPointF lastPos
 
QElapsedTimer lastPosTime
 
bool layoutScheduled: 1
 
qreal mappedRange
 
QDeclarativeGuard< QDeclarativeVisualModelmodel
 
int modelCount
 
QVariant modelVariant
 
MovementDirection moveDirection
 
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivatemoveHighlight
 
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivatemoveOffset
 
MovementReason moveReason
 
bool moving: 1
 
qreal offset
 
qreal offsetAdj
 
bool ownModel: 1
 
QDeclarativePathpath
 
int pathItems
 
int requestedIndex
 
qreal startPc
 
QPointF startPoint
 
bool stealMouse: 1
 
QDeclarativeTimeLine tl
 
- Public Variables inherited from QDeclarativeItemPrivate
AnchorLines_anchorLines
 
QDeclarativeAnchors_anchors
 
QDeclarativeContents_contents
 
QDeclarativeStateGroup_stateGroup
 
QDeclarativeLayoutMirroringAttachedattachedLayoutDirection
 
QDeclarativeNullableValue< qrealbaselineOffset
 
QPODVector< ChangeListener, 4 > changeListeners
 
bool componentComplete:1
 
bool doneEventPreHandler: 1
 
bool effectiveLayoutMirror:1
 
bool hadActiveFocus:1
 
bool hadFocus:1
 
bool heightValid:1
 
bool inheritedLayoutMirror:1
 
bool inheritMirrorFromItem:1
 
bool inheritMirrorFromParent:1
 
bool isMirrorImplicit:1
 
bool keepMouse:1
 
QDeclarativeItemKeyFilterkeyHandler
 
qreal mHeight
 
qreal mImplicitHeight
 
qreal mImplicitWidth
 
qreal mWidth
 
QDeclarativeItem::TransformOrigin origin:5
 
QDeclarativeNotifier parentNotifier
 
bool smooth:1
 
bool transformOriginDirty: 1
 
bool widthValid:1
 
- Public Variables inherited from QGraphicsItemPrivate
quint32 acceptDrops: 1
 
quint32 acceptedMouseButtons: 5
 
quint32 acceptedTouchBeginEvent: 1
 
quint32 acceptsHover: 1
 
quint32 acceptTouchEvents: 1
 
quint32 allChildrenDirty: 1
 
quint32 ancestorFlags: 4
 
quint32 cacheMode: 2
 
QList< QGraphicsItem * > children
 
QRectF childrenBoundingRect
 
quint32 dirty: 1
 
quint32 dirtyChildren: 1
 
quint32 dirtyChildrenBoundingRect: 1
 
quint32 dirtySceneTransform: 1
 
quint32 enabled: 1
 
quint32 explicitActivate: 1
 
quint32 explicitlyDisabled: 1
 
quint32 explicitlyHidden: 1
 
QList< ExtraStructextras
 
quint32 filtersDescendantEvents: 1
 
quint32 flags: 19
 
QGraphicsItemfocusProxy
 
QList< QGraphicsItem ** > focusProxyRefs
 
QGraphicsItemfocusScopeItem
 
quint32 fullUpdatePending: 1
 
quint32 geometryChanged: 1
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
int globalStackingOrder
 
QGraphicsEffectgraphicsEffect
 
quint32 handlesChildEvents: 1
 
quint32 hasBoundingRegionGranularity: 1
 
quint32 hasCursor: 1
 
quint32 holesInSiblingIndex: 1
 
quint32 ignoreOpacity: 1
 
quint32 ignoreVisible: 1
 
Qt::InputMethodHints imHints
 
quint32 inDestructor: 1
 
int index
 
quint32 inSetPosHelper: 1
 
quint32 isDeclarativeItem: 1
 
quint32 isMemberOfGroup: 1
 
quint32 isObject: 1
 
quint32 isWidget: 1
 
int itemDepth
 
quint32 itemDiscovered: 1
 
quint32 localCollisionHack: 1
 
quint32 mayHaveChildWithGraphicsEffect: 1
 
quint32 mouseSetsFocus: 1
 
quint32 needSortChildren: 1
 
QRectF needsRepaint
 
quint32 notifyBoundingRectChanged: 1
 
quint32 notifyInvalidated: 1
 
qreal opacity
 
quint32 padding: 21
 
QMap< QWidget *, QRectpaintedViewBoundingRects
 
quint32 paintedViewBoundingRectsNeedRepaint: 1
 
QGraphicsItem::PanelModality panelModality
 
QGraphicsItemparent
 
quint32 pendingPolish: 1
 
QPointF pos
 
QGraphicsItemq_ptr
 
QGraphicsScenescene
 
quint32 scenePosDescendants: 1
 
QTransform sceneTransform
 
quint32 sceneTransformTranslateOnly: 1
 
quint32 selected: 1
 
quint32 sendParentChangeNotification: 1
 
quint32 sequentialOrdering: 1
 
int siblingIndex
 
QGraphicsItemsubFocusItem
 
TransformDatatransformData
 
quint32 updateDueToGraphicsEffect: 1
 
quint32 visible: 1
 
quint32 wantsActive: 1
 
qreal z
 

Additional Inherited Members

- Static Public Variables inherited from QDeclarativeItemPrivate
static qint64 consistentTime = -1
 

Detailed Description

Definition at line 71 of file qdeclarativepathview_p_p.h.

Enumerations

◆ MovementDirection

◆ MovementReason

Constructors and Destructors

◆ QDeclarativePathViewPrivate()

QDeclarativePathViewPrivate::QDeclarativePathViewPrivate ( )
inline

Definition at line 76 of file qdeclarativepathview_p_p.h.

77  : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0)
78  , lastElapsed(0), offset(0.0), offsetAdj(0.0), mappedRange(1.0)
79  , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
80  , autoHighlight(true), highlightUp(false), layoutScheduled(false)
81  , moving(false), flicking(false)
82  , dragMargin(0), deceleration(100)
84  , firstIndex(-1), pathItems(-1), requestedIndex(-1)
91  {
92  }
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivate > moveOffset
QDeclarativePathView::HighlightRangeMode highlightRangeMode
QDeclarativeComponent * highlightComponent
QDeclarativeOpenMetaObjectType * attType
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivate > moveHighlight

Functions

◆ attached()

QDeclarativePathViewAttached * QDeclarativePathViewPrivate::attached ( QDeclarativeItem item)

Definition at line 153 of file qdeclarativepathview.cpp.

Referenced by itemGeometryChanged(), and scheduleLayout().

154 {
155  return static_cast<QDeclarativePathViewAttached *>(qmlAttachedPropertiesObject<QDeclarativePathView>(item, false));
156 }

◆ calcCurrentIndex()

int QDeclarativePathViewPrivate::calcCurrentIndex ( )

Definition at line 1716 of file qdeclarativepathview.cpp.

Referenced by isValid().

1717 {
1718  int current = 0;
1719  if (modelCount && model && items.count()) {
1721  if (offset < 0)
1722  offset += modelCount;
1723  current = qRound(qAbs(qmlMod(modelCount - offset, modelCount)));
1724  current = current % modelCount;
1725  }
1726 
1727  return current;
1728 }
QDeclarativeGuard< QDeclarativeVisualModel > model
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
QList< QDeclarativeItem * > items
qreal qmlMod(qreal x, qreal y)
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ clear()

void QDeclarativePathViewPrivate::clear ( )

Definition at line 158 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

159 {
160  for (int i=0; i<items.count(); i++){
161  QDeclarativeItem *p = items[i];
162  releaseItem(p);
163  }
164  items.clear();
165  tl.clear();
166 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void releaseItem(QDeclarativeItem *item)
void clear()
Resets the timeline.
The QDeclarativeItem class provides the most basic of all visual items in QML.
void clear()
Removes all items from the list.
Definition: qlist.h:764
QList< QDeclarativeItem * > items

◆ createHighlight()

void QDeclarativePathViewPrivate::createHighlight ( )

Definition at line 199 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

200 {
202  if (!q->isComponentComplete())
203  return;
204 
205  bool changed = false;
206  if (highlightItem) {
207  if (highlightItem->scene())
210  highlightItem = 0;
211  changed = true;
212  }
213 
214  QDeclarativeItem *item = 0;
215  if (highlightComponent) {
216  QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q));
217  QObject *nobj = highlightComponent->create(highlightContext);
218  if (nobj) {
219  QDeclarative_setParent_noEvent(highlightContext, nobj);
220  item = qobject_cast<QDeclarativeItem *>(nobj);
221  if (!item)
222  delete nobj;
223  } else {
224  delete highlightContext;
225  }
226  } else {
227  item = new QDeclarativeItem;
228  }
229  if (item) {
231  item->setParentItem(q);
232  highlightItem = item;
233  changed = true;
234  }
235  if (changed)
236  emit q->highlightItemChanged();
237 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
virtual QObject * create(QDeclarativeContext *context=0)
Create an object instance from this component.
#define Q_Q(Class)
Definition: qglobal.h:2483
void setParentItem(QDeclarativeItem *parent)
The QDeclarativeItem class provides the most basic of all visual items in QML.
void removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene.
#define emit
Definition: qobjectdefs.h:76
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QDeclarativeComponent * highlightComponent
The QDeclarativeContext class defines a context within a QML engine.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145

◆ fixOffset()

void QDeclarativePathViewPrivate::fixOffset ( )

Definition at line 1767 of file qdeclarativepathview.cpp.

Referenced by isValid().

1768 {
1770  if (model && items.count()) {
1772  int curr = calcCurrentIndex();
1773  if (curr != currentIndex)
1774  q->setCurrentIndex(curr);
1775  else
1776  snapToCurrent();
1777  }
1778  }
1779 }
QDeclarativeGuard< QDeclarativeVisualModel > model
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativePathView::HighlightRangeMode highlightRangeMode
QList< QDeclarativeItem * > items

◆ fixOffsetCallback()

void QDeclarativePathViewPrivate::fixOffsetCallback ( void *  d)
static

Definition at line 1762 of file qdeclarativepathview.cpp.

Referenced by isValid().

1763 {
1764  ((QDeclarativePathViewPrivate *)d)->fixOffset();
1765 }
double d
Definition: qnumeric_p.h:62

◆ getItem()

QDeclarativeItem * QDeclarativePathViewPrivate::getItem ( int  modelIndex)

Definition at line 113 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

114 {
116  requestedIndex = modelIndex;
117  QDeclarativeItem *item = model->item(modelIndex, false);
118  if (item) {
119  if (!attType) {
120  // pre-create one metatype to share with all attached objects
122  foreach(const QString &attr, path->attributes())
123  attType->createProperty(attr.toUtf8());
124  }
126  QDeclarativePathViewAttached *att = static_cast<QDeclarativePathViewAttached *>(qmlAttachedPropertiesObject<QDeclarativePathView>(item));
128  if (att) {
129  att->m_view = q;
130  att->setOnPath(true);
131  }
132  item->setParentItem(q);
135  }
136  requestedIndex = -1;
137  return item;
138 }
int createProperty(const QByteArray &name)
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
QDeclarativeGuard< QDeclarativeVisualModel > model
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_Q(Class)
Definition: qglobal.h:2483
void setParentItem(QDeclarativeItem *parent)
The QDeclarativeItem class provides the most basic of all visual items in QML.
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
static QDeclarativeOpenMetaObjectType * qPathViewAttachedType
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)
virtual QDeclarativeItem * item(int index, bool complete=true)=0
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
QDeclarativeOpenMetaObjectType * attType
QStringList attributes() const

◆ handleMouseMoveEvent()

void QDeclarativePathViewPrivate::handleMouseMoveEvent ( QGraphicsSceneMouseEvent event)

Definition at line 1227 of file qdeclarativepathview.cpp.

Referenced by isValid().

1228 {
1230  if (!interactive || !lastPosTime.isValid())
1231  return;
1232 
1233  qreal newPc;
1234  QPointF pathPoint = pointNear(event->pos(), &newPc);
1235  if (!stealMouse) {
1236  QPointF delta = pathPoint - startPoint;
1237  if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance()) {
1238  stealMouse = true;
1239  startPc = newPc;
1240  }
1241  }
1242 
1243  if (stealMouse) {
1245  qreal diff = (newPc - startPc)*modelCount*mappedRange;
1246  if (diff) {
1247  q->setOffset(offset + diff);
1248 
1249  if (diff > modelCount/2)
1250  diff -= modelCount;
1251  else if (diff < -modelCount/2)
1252  diff += modelCount;
1253 
1255  lastDist = diff;
1256  startPc = newPc;
1257  }
1258  if (!moving) {
1259  moving = true;
1260  emit q->movingChanged();
1261  emit q->movementStarted();
1262  }
1263  }
1264 }
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
bool isValid() const
Returns false if this object was invalidated by a call to invalidate() and has not been restarted sin...
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
#define Q_Q(Class)
Definition: qglobal.h:2483
QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const
#define emit
Definition: qobjectdefs.h:76
static Bigint * diff(Bigint *a, Bigint *b)
static int startDragDistance()
static qint64 restart(QElapsedTimer &)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QPointF pos() const
Returns the mouse cursor position in item coordinates.

◆ handleMousePressEvent()

void QDeclarativePathViewPrivate::handleMousePressEvent ( QGraphicsSceneMouseEvent event)

Definition at line 1180 of file qdeclarativepathview.cpp.

Referenced by isValid().

1181 {
1183  if (!interactive || !items.count())
1184  return;
1185  QPointF scenePoint = q->mapToScene(event->pos());
1186  int idx = 0;
1187  for (; idx < items.count(); ++idx) {
1188  QRectF rect = items.at(idx)->boundingRect();
1189  rect = items.at(idx)->mapToScene(rect).boundingRect();
1190  if (rect.contains(scenePoint))
1191  break;
1192  }
1193  if (idx == items.count() && dragMargin == 0.) // didn't click on an item
1194  return;
1195 
1196  startPoint = pointNear(event->pos(), &startPc);
1197  if (idx == items.count()) {
1198  qreal distance = qAbs(event->pos().x() - startPoint.x()) + qAbs(event->pos().y() - startPoint.y());
1199  if (distance > dragMargin)
1200  return;
1201  }
1202 
1203  if (tl.isActive() && flicking)
1204  stealMouse = true; // If we've been flicked then steal the click.
1205  else
1206  stealMouse = false;
1207 
1208  lastElapsed = 0;
1209  lastDist = 0;
1211  tl.clear();
1212 }
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
#define Q_Q(Class)
Definition: qglobal.h:2483
QRectF boundingRect() const
bool isActive() const
Returns true if the timeline is active.
void clear()
Resets the timeline.
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349
QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
static void start(QElapsedTimer &)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QPointF pos() const
Returns the mouse cursor position in item coordinates.
QList< QDeclarativeItem * > items
QPointF mapToScene(const QPointF &point) const
Maps the point point, which is in this item&#39;s coordinate system, to the scene&#39;s coordinate system...

◆ handleMouseReleaseEvent()

void QDeclarativePathViewPrivate::handleMouseReleaseEvent ( QGraphicsSceneMouseEvent )

Definition at line 1278 of file qdeclarativepathview.cpp.

Referenced by isValid().

1279 {
1281  stealMouse = false;
1282  q->setKeepMouseGrab(false);
1283  if (!interactive || !lastPosTime.isValid())
1284  return;
1285 
1287  qreal velocity = elapsed > 0. ? lastDist / elapsed : 0;
1288  if (model && modelCount && qAbs(velocity) > qreal(1.)) {
1289  qreal count = pathItems == -1 ? modelCount : pathItems;
1290  if (qAbs(velocity) > count * 2) // limit velocity
1291  velocity = (velocity > 0 ? count : -count) * 2;
1292  // Calculate the distance to be travelled
1293  qreal v2 = velocity*velocity;
1294  qreal accel = deceleration/10;
1295  // + 0.25 to encourage moving at least one item in the flick direction
1296  qreal dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * qreal(2.0)) + qreal(0.25)));
1298  // round to nearest item.
1299  if (velocity > 0.)
1300  dist = qRound(dist + offset) - offset;
1301  else
1302  dist = qRound(dist - offset) + offset;
1303  // Calculate accel required to stop on item boundary
1304  if (dist <= 0.) {
1305  dist = qreal(0.);
1306  accel = qreal(0.);
1307  } else {
1308  accel = v2 / (2.0f * qAbs(dist));
1309  }
1310  }
1311  offsetAdj = qreal(0.0);
1313  tl.accel(moveOffset, velocity, accel, dist);
1315  if (!flicking) {
1316  flicking = true;
1317  emit q->flickingChanged();
1318  emit q->flickStarted();
1319  }
1320  } else {
1321  fixOffset();
1322  }
1323 
1325  if (!tl.isActive())
1326  q->movementEnding();
1327 }
double qreal
Definition: qglobal.h:1193
virtual void setValue(qreal v)
Set the current value.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
static qint64 elapsed(QElapsedTimer &)
int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel)
Decelerate timeLineValue from the starting velocity to zero at the given acceleration rate...
QDeclarativeGuard< QDeclarativeVisualModel > model
bool isValid() const
Returns false if this object was invalidated by a call to invalidate() and has not been restarted sin...
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivate > moveOffset
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isActive() const
Returns true if the timeline is active.
QDeclarativePathView::HighlightRangeMode highlightRangeMode
#define emit
Definition: qobjectdefs.h:76
void invalidate()
Marks this QElapsedTimer object as invalid.
void callback(const QDeclarativeTimeLineCallback &)
Execute the event.
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ init()

void QDeclarativePathViewPrivate::init ( )

Definition at line 94 of file qdeclarativepathview.cpp.

Referenced by QDeclarativePathViewPrivate().

95 {
97  offset = 0;
98  q->setAcceptedMouseButtons(Qt::LeftButton);
100  q->setFiltersChildEvents(true);
101  q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
103  static int timelineCompletedIdx = -1;
104  static int movementEndingIdx = -1;
105  if (timelineCompletedIdx == -1) {
106  timelineCompletedIdx = QDeclarativeTimeLine::staticMetaObject.indexOfSignal("completed()");
107  movementEndingIdx = QDeclarativePathView::staticMetaObject.indexOfSlot("movementEnding()");
108  }
109  QMetaObject::connect(&tl, timelineCompletedIdx,
110  q, movementEndingIdx, Qt::DirectConnection);
111 }
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Definition: qobject.cpp:3194
#define SLOT(a)
Definition: qobjectdefs.h:226
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void invalidate()
Marks this QElapsedTimer object as invalid.
int indexOfSlot(const char *slot) const
Finds slot and returns its index; otherwise returns -1.
int indexOfSignal(const char *signal) const
Finds signal and returns its index; otherwise returns -1.

◆ isValid()

bool QDeclarativePathViewPrivate::isValid ( ) const
inline

Definition at line 122 of file qdeclarativepathview_p_p.h.

122  {
123  return model && model->count() > 0 && model->isValid() && path;
124  }
virtual bool isValid() const =0
QDeclarativeGuard< QDeclarativeVisualModel > model

◆ itemGeometryChanged()

void QDeclarativePathViewPrivate::itemGeometryChanged ( QDeclarativeItem item,
const QRectF newGeometry,
const QRectF oldGeometry 
)
inlinevirtual

Reimplemented from QDeclarativeItemChangeListener.

Definition at line 96 of file qdeclarativepathview_p_p.h.

96  {
97  if ((newGeometry.size() != oldGeometry.size())
98  && (!highlightItem || item != highlightItem)) {
99  if (QDeclarativePathViewAttached *att = attached(item))
100  att->m_percent = -1;
101  scheduleLayout();
102  }
103  }
QDeclarativePathViewAttached * attached(QDeclarativeItem *item)
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713

◆ pointNear()

QPointF QDeclarativePathViewPrivate::pointNear ( const QPointF point,
qreal nearPercent = 0 
) const

Definition at line 1146 of file qdeclarativepathview.cpp.

Referenced by isValid().

1147 {
1148  //XXX maybe do recursively at increasing resolution.
1149  qreal mindist = 1e10; // big number
1150  QPointF nearPoint = path->pointAt(0);
1151  qreal nearPc = 0;
1152  for (qreal i=1; i < 1000; i++) {
1153  QPointF pt = path->pointAt(i/1000.0);
1154  QPointF diff = pt - point;
1155  qreal dist = diff.x()*diff.x() + diff.y()*diff.y();
1156  if (dist < mindist) {
1157  nearPoint = pt;
1158  nearPc = i;
1159  mindist = dist;
1160  }
1161  }
1162 
1163  if (nearPercent)
1164  *nearPercent = nearPc / 1000.0;
1165 
1166  return nearPoint;
1167 }
double qreal
Definition: qglobal.h:1193
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF pointAt(qreal) const
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
static Bigint * diff(Bigint *a, Bigint *b)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287

◆ positionOfIndex()

qreal QDeclarativePathViewPrivate::positionOfIndex ( qreal  index) const

Definition at line 176 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

177 {
178  qreal pos = -1.0;
179 
180  if (model && index >= 0 && index < modelCount) {
181  qreal start = 0.0;
183  start = highlightRangeStart;
184  qreal globalPos = index + offset;
185  globalPos = qmlMod(globalPos, qreal(modelCount)) / modelCount;
186  if (pathItems != -1 && pathItems < modelCount) {
187  globalPos += start * mappedRange;
188  globalPos = qmlMod(globalPos, 1.0);
189  if (globalPos < mappedRange)
190  pos = globalPos / mappedRange;
191  } else {
192  pos = qmlMod(globalPos + start, 1.0);
193  }
194  }
195 
196  return pos;
197 }
double qreal
Definition: qglobal.h:1193
QDeclarativeGuard< QDeclarativeVisualModel > model
QDeclarativePathView::HighlightRangeMode highlightRangeMode
static void start(QElapsedTimer &)
qreal qmlMod(qreal x, qreal y)

◆ regenerate()

void QDeclarativePathViewPrivate::regenerate ( )

Definition at line 333 of file qdeclarativepathview.cpp.

Referenced by isValid().

334 {
336  if (!q->isComponentComplete())
337  return;
338 
339  clear();
340 
341  if (!isValid())
342  return;
343 
344  firstIndex = -1;
346  q->refill();
347 }
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ releaseItem()

void QDeclarativePathViewPrivate::releaseItem ( QDeclarativeItem item)

Definition at line 140 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

141 {
142  if (!item || !model)
143  return;
146  if (model->release(item) == 0) {
147  // item was not destroyed, and we no longer reference it.
148  if (QDeclarativePathViewAttached *att = attached(item))
149  att->setOnPath(false);
150  }
151 }
virtual ReleaseFlags release(QDeclarativeItem *item)=0
QDeclarativeGuard< QDeclarativeVisualModel > model
void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types)
QDeclarativePathViewAttached * attached(QDeclarativeItem *item)
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)

◆ scheduleLayout()

void QDeclarativePathViewPrivate::scheduleLayout ( )
inline

Definition at line 105 of file qdeclarativepathview_p_p.h.

Referenced by itemGeometryChanged().

105  {
107  if (!layoutScheduled) {
108  layoutScheduled = true;
110  }
111  }
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
#define Q_Q(Class)
Definition: qglobal.h:2483
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56

◆ setAdjustedOffset()

void QDeclarativePathViewPrivate::setAdjustedOffset ( qreal  offset)

Definition at line 737 of file qdeclarativepathview.cpp.

Referenced by isValid().

◆ setHighlightPosition()

void QDeclarativePathViewPrivate::setHighlightPosition ( qreal  pos)

Definition at line 276 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

277 {
278  if (pos != highlightPosition) {
279  qreal start = 0.0;
280  qreal end = 1.0;
282  start = highlightRangeStart;
283  end = highlightRangeEnd;
284  }
285 
286  qreal range = qreal(modelCount);
287  // calc normalized position of highlight relative to offset
288  qreal relativeHighlight = qmlMod(pos + offset, range) / range;
289 
290  if (!highlightUp && relativeHighlight > end * mappedRange) {
291  qreal diff = qreal(1.0) - relativeHighlight;
292  setOffset(offset + diff * range);
293  } else if (highlightUp && relativeHighlight >= (end - start) * mappedRange) {
294  qreal diff = relativeHighlight - (end - start) * mappedRange;
295  setOffset(offset - diff * range - qreal(0.00001));
296  }
297 
299  qreal pathPos = positionOfIndex(pos);
300  updateItem(highlightItem, pathPos);
302  att->setOnPath(pathPos != qreal(-1.0));
303  }
304 }
double qreal
Definition: qglobal.h:1193
void updateItem(QDeclarativeItem *, qreal)
QDeclarativePathView::HighlightRangeMode highlightRangeMode
static Bigint * diff(Bigint *a, Bigint *b)
static void start(QElapsedTimer &)
QDeclarativePathViewAttached * attached(QDeclarativeItem *item)
static const KeyPair *const end
qreal qmlMod(qreal x, qreal y)
qreal positionOfIndex(qreal index) const

◆ setOffset()

void QDeclarativePathViewPrivate::setOffset ( qreal  offset)

Definition at line 721 of file qdeclarativepathview.cpp.

Referenced by isValid().

722 {
724  if (offset != o) {
725  if (isValid() && q->isComponentComplete()) {
726  offset = qmlMod(o, qreal(modelCount));
727  if (offset < 0)
728  offset += qreal(modelCount);
729  q->refill();
730  } else {
731  offset = o;
732  }
733  emit q->offsetChanged();
734  }
735 }
double qreal
Definition: qglobal.h:1193
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
qreal qmlMod(qreal x, qreal y)

◆ snapToCurrent()

void QDeclarativePathViewPrivate::snapToCurrent ( )

Definition at line 1781 of file qdeclarativepathview.cpp.

Referenced by isValid().

1782 {
1783  if (!model || modelCount <= 0)
1784  return;
1785 
1786  qreal targetOffset = qmlMod(modelCount - currentIndex, modelCount);
1787 
1788  moveReason = Other;
1789  offsetAdj = 0.0;
1790  tl.reset(moveOffset);
1792 
1793  const int duration = highlightMoveDuration;
1794 
1795  if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2)) {
1796  qreal distance = modelCount - targetOffset + offset;
1797  if (targetOffset > moveOffset) {
1798  tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance));
1800  tl.move(moveOffset, targetOffset, QEasingCurve(offset == 0.0 ? QEasingCurve::InOutQuad : QEasingCurve::OutQuad), int(duration * (modelCount-targetOffset) / distance));
1801  } else {
1802  tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration);
1803  }
1804  } else if (moveDirection == Negative || targetOffset - offset <= -modelCount/2) {
1805  qreal distance = modelCount - offset + targetOffset;
1806  if (targetOffset < moveOffset) {
1807  tl.move(moveOffset, modelCount, QEasingCurve(targetOffset == 0 ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance));
1808  tl.set(moveOffset, 0.0);
1809  tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance));
1810  } else {
1811  tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration);
1812  }
1813  } else {
1814  tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration);
1815  }
1817 }
double qreal
Definition: qglobal.h:1193
virtual void setValue(qreal v)
Set the current value.
The QEasingCurve class provides easing curves for controlling animation.
Definition: qeasingcurve.h:55
void move(QDeclarativeTimeLineValue &, qreal destination, int time=500)
Linearly change the timeLineValue from its current value to the given destination value over time mil...
QDeclarativeGuard< QDeclarativeVisualModel > model
void reset(QDeclarativeTimeLineValue &)
Cancel (but don&#39;t complete) all scheduled actions for timeLineValue.
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivate > moveOffset
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
void set(QDeclarativeTimeLineValue &, qreal)
Set the value of timeLineValue.
qreal qmlMod(qreal x, qreal y)

◆ updateCurrent()

void QDeclarativePathViewPrivate::updateCurrent ( )

Definition at line 1730 of file qdeclarativepathview.cpp.

Referenced by isValid().

1731 {
1733  if (moveReason != Mouse)
1734  return;
1736  return;
1737 
1738  int idx = calcCurrentIndex();
1739  if (model && (idx != currentIndex || !currentItem)) {
1740  int itemIndex = (currentIndex - firstIndex + modelCount) % modelCount;
1741  if (itemIndex < items.count()) {
1742  if (QDeclarativeItem *item = items.at(itemIndex)) {
1743  if (QDeclarativePathViewAttached *att = attached(item))
1744  att->setIsCurrentItem(false);
1745  }
1746  }
1747  int oldCurrentIndex = currentIndex;
1748  currentIndex = idx;
1749  currentItem = 0;
1750  itemIndex = (idx - firstIndex + modelCount) % modelCount;
1751  if (itemIndex < items.count()) {
1752  currentItem = items.at(itemIndex);
1753  currentItem->setFocus(true);
1755  att->setIsCurrentItem(true);
1756  }
1757  if (oldCurrentIndex != currentIndex)
1758  emit q->currentIndexChanged();
1759  }
1760 }
QDeclarativeGuard< QDeclarativeVisualModel > model
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativePathView::HighlightRangeMode highlightRangeMode
The QDeclarativeItem class provides the most basic of all visual items in QML.
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
QDeclarativeGuard< QDeclarativeItem > currentItem
QDeclarativePathViewAttached * attached(QDeclarativeItem *item)
QList< QDeclarativeItem * > items

◆ updateHighlight()

void QDeclarativePathViewPrivate::updateHighlight ( )

Definition at line 239 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

240 {
242  if (!q->isComponentComplete() || !isValid())
243  return;
244  if (highlightItem) {
247  } else {
248  qreal target = currentIndex;
249 
250  offsetAdj = qreal(0.0);
253 
254  const int duration = highlightMoveDuration;
255 
256  if (target - highlightPosition > modelCount/2) {
257  highlightUp = false;
259  tl.move(moveHighlight, qreal(0.0), QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance));
261  tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * (modelCount-target) / distance));
262  } else if (target - highlightPosition <= -modelCount/2) {
263  highlightUp = true;
264  qreal distance = modelCount - highlightPosition + target;
265  tl.move(moveHighlight, modelCount-qreal(0.01), QEasingCurve(QEasingCurve::InQuad), int(duration * (modelCount-highlightPosition) / distance));
266  tl.set(moveHighlight, qreal(0.0));
267  tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * target / distance));
268  } else {
269  highlightUp = highlightPosition - target < 0;
271  }
272  }
273  }
274 }
double qreal
Definition: qglobal.h:1193
virtual void setValue(qreal v)
Set the current value.
The QEasingCurve class provides easing curves for controlling animation.
Definition: qeasingcurve.h:55
void move(QDeclarativeTimeLineValue &, qreal destination, int time=500)
Linearly change the timeLineValue from its current value to the given destination value over time mil...
void updateItem(QDeclarativeItem *, qreal)
void reset(QDeclarativeTimeLineValue &)
Cancel (but don&#39;t complete) all scheduled actions for timeLineValue.
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativePathView::HighlightRangeMode highlightRangeMode
static int distance(QWidget *source, QWidget *target, QAccessible::RelationFlag relation)
void set(QDeclarativeTimeLineValue &, qreal)
Set the value of timeLineValue.
QDeclarativeTimeLineValueProxy< QDeclarativePathViewPrivate > moveHighlight

◆ updateItem()

void QDeclarativePathViewPrivate::updateItem ( QDeclarativeItem item,
qreal  percent 
)

Definition at line 319 of file qdeclarativepathview.cpp.

Referenced by isValid().

320 {
321  if (QDeclarativePathViewAttached *att = attached(item)) {
322  if (qFuzzyCompare(att->m_percent, percent))
323  return;
324  att->m_percent = percent;
325  foreach(const QString &attr, path->attributes())
326  att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
327  }
328  QPointF pf = path->pointAt(percent);
329  item->setX(qRound(pf.x() - item->width()/2));
330  item->setY(qRound(pf.y() - item->height()/2));
331 }
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
Definition: qglobal.h:2030
The QString class provides a Unicode character string.
Definition: qstring.h:83
QPointF pointAt(qreal) const
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void setX(qreal x)
Set&#39;s the x coordinate of the item&#39;s position.
void setY(qreal y)
Set&#39;s the y coordinate of the item&#39;s position.
QDeclarativePathViewAttached * attached(QDeclarativeItem *item)
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
qreal attributeAt(const QString &, qreal) const
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QStringList attributes() const

◆ updateMappedRange()

void QDeclarativePathViewPrivate::updateMappedRange ( )

Definition at line 168 of file qdeclarativepathview.cpp.

Referenced by scheduleLayout().

169 {
170  if (model && pathItems != -1 && pathItems < modelCount)
172  else
173  mappedRange = 1.0;
174 }
double qreal
Definition: qglobal.h:1193
QDeclarativeGuard< QDeclarativeVisualModel > model

Properties

◆ attType

QDeclarativeOpenMetaObjectType* QDeclarativePathViewPrivate::attType

Definition at line 178 of file qdeclarativepathview_p_p.h.

◆ autoHighlight

bool QDeclarativePathViewPrivate::autoHighlight

Definition at line 156 of file qdeclarativepathview_p_p.h.

◆ currentIndex

int QDeclarativePathViewPrivate::currentIndex

Definition at line 142 of file qdeclarativepathview_p_p.h.

◆ currentItem

QDeclarativeGuard<QDeclarativeItem> QDeclarativePathViewPrivate::currentItem

Definition at line 143 of file qdeclarativepathview_p_p.h.

◆ currentItemOffset

qreal QDeclarativePathViewPrivate::currentItemOffset

Definition at line 144 of file qdeclarativepathview_p_p.h.

◆ deceleration

qreal QDeclarativePathViewPrivate::deceleration

Definition at line 164 of file qdeclarativepathview_p_p.h.

◆ dragMargin

qreal QDeclarativePathViewPrivate::dragMargin

Definition at line 163 of file qdeclarativepathview_p_p.h.

◆ firstIndex

int QDeclarativePathViewPrivate::firstIndex

Definition at line 167 of file qdeclarativepathview_p_p.h.

◆ flicking

bool QDeclarativePathViewPrivate::flicking

Definition at line 160 of file qdeclarativepathview_p_p.h.

◆ haveHighlightRange

bool QDeclarativePathViewPrivate::haveHighlightRange

Definition at line 155 of file qdeclarativepathview_p_p.h.

◆ highlightComponent

QDeclarativeComponent* QDeclarativePathViewPrivate::highlightComponent

Definition at line 179 of file qdeclarativepathview_p_p.h.

◆ highlightItem

QDeclarativeItem* QDeclarativePathViewPrivate::highlightItem

Definition at line 180 of file qdeclarativepathview_p_p.h.

Referenced by itemGeometryChanged().

◆ highlightMoveDuration

int QDeclarativePathViewPrivate::highlightMoveDuration

Definition at line 186 of file qdeclarativepathview_p_p.h.

◆ highlightPosition

qreal QDeclarativePathViewPrivate::highlightPosition

Definition at line 182 of file qdeclarativepathview_p_p.h.

◆ highlightRangeEnd

qreal QDeclarativePathViewPrivate::highlightRangeEnd

Definition at line 184 of file qdeclarativepathview_p_p.h.

◆ highlightRangeMode

QDeclarativePathView::HighlightRangeMode QDeclarativePathViewPrivate::highlightRangeMode

Definition at line 185 of file qdeclarativepathview_p_p.h.

◆ highlightRangeStart

qreal QDeclarativePathViewPrivate::highlightRangeStart

Definition at line 183 of file qdeclarativepathview_p_p.h.

◆ highlightUp

bool QDeclarativePathViewPrivate::highlightUp

Definition at line 157 of file qdeclarativepathview_p_p.h.

◆ interactive

bool QDeclarativePathViewPrivate::interactive

Definition at line 154 of file qdeclarativepathview_p_p.h.

◆ itemCache

QList<QDeclarativeItem *> QDeclarativePathViewPrivate::itemCache

Definition at line 171 of file qdeclarativepathview_p_p.h.

◆ items

QList<QDeclarativeItem *> QDeclarativePathViewPrivate::items

Definition at line 170 of file qdeclarativepathview_p_p.h.

◆ lastDist

qreal QDeclarativePathViewPrivate::lastDist

Definition at line 147 of file qdeclarativepathview_p_p.h.

◆ lastElapsed

int QDeclarativePathViewPrivate::lastElapsed

Definition at line 148 of file qdeclarativepathview_p_p.h.

◆ lastPos

QPointF QDeclarativePathViewPrivate::lastPos

Definition at line 162 of file qdeclarativepathview_p_p.h.

◆ lastPosTime

QElapsedTimer QDeclarativePathViewPrivate::lastPosTime

Definition at line 161 of file qdeclarativepathview_p_p.h.

◆ layoutScheduled

bool QDeclarativePathViewPrivate::layoutScheduled

Definition at line 158 of file qdeclarativepathview_p_p.h.

Referenced by scheduleLayout().

◆ mappedRange

qreal QDeclarativePathViewPrivate::mappedRange

Definition at line 151 of file qdeclarativepathview_p_p.h.

◆ model

QDeclarativeGuard<QDeclarativeVisualModel> QDeclarativePathViewPrivate::model

Definition at line 172 of file qdeclarativepathview_p_p.h.

Referenced by isValid().

◆ modelCount

int QDeclarativePathViewPrivate::modelCount

Definition at line 187 of file qdeclarativepathview_p_p.h.

◆ modelVariant

QVariant QDeclarativePathViewPrivate::modelVariant

Definition at line 173 of file qdeclarativepathview_p_p.h.

◆ moveDirection

MovementDirection QDeclarativePathViewPrivate::moveDirection

Definition at line 177 of file qdeclarativepathview_p_p.h.

◆ moveHighlight

QDeclarativeTimeLineValueProxy<QDeclarativePathViewPrivate> QDeclarativePathViewPrivate::moveHighlight

Definition at line 181 of file qdeclarativepathview_p_p.h.

◆ moveOffset

QDeclarativeTimeLineValueProxy<QDeclarativePathViewPrivate> QDeclarativePathViewPrivate::moveOffset

Definition at line 166 of file qdeclarativepathview_p_p.h.

◆ moveReason

MovementReason QDeclarativePathViewPrivate::moveReason

Definition at line 175 of file qdeclarativepathview_p_p.h.

◆ moving

bool QDeclarativePathViewPrivate::moving

Definition at line 159 of file qdeclarativepathview_p_p.h.

◆ offset

qreal QDeclarativePathViewPrivate::offset

Definition at line 149 of file qdeclarativepathview_p_p.h.

Referenced by isValid().

◆ offsetAdj

qreal QDeclarativePathViewPrivate::offsetAdj

Definition at line 150 of file qdeclarativepathview_p_p.h.

◆ ownModel

bool QDeclarativePathViewPrivate::ownModel

Definition at line 153 of file qdeclarativepathview_p_p.h.

◆ path

QDeclarativePath* QDeclarativePathViewPrivate::path

Definition at line 141 of file qdeclarativepathview_p_p.h.

Referenced by isValid().

◆ pathItems

int QDeclarativePathViewPrivate::pathItems

Definition at line 168 of file qdeclarativepathview_p_p.h.

◆ requestedIndex

int QDeclarativePathViewPrivate::requestedIndex

Definition at line 169 of file qdeclarativepathview_p_p.h.

◆ startPc

qreal QDeclarativePathViewPrivate::startPc

Definition at line 145 of file qdeclarativepathview_p_p.h.

◆ startPoint

QPointF QDeclarativePathViewPrivate::startPoint

Definition at line 146 of file qdeclarativepathview_p_p.h.

◆ stealMouse

bool QDeclarativePathViewPrivate::stealMouse

Definition at line 152 of file qdeclarativepathview_p_p.h.

◆ tl

QDeclarativeTimeLine QDeclarativePathViewPrivate::tl

Definition at line 165 of file qdeclarativepathview_p_p.h.


The documentation for this class was generated from the following files: