Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QDeclarativeGridViewPrivate Class Reference
Inheritance diagram for QDeclarativeGridViewPrivate:
QDeclarativeFlickablePrivate QDeclarativeItemPrivate QDeclarativeItemChangeListener QGraphicsItemPrivate

Public Types

enum  BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }
 
enum  MovementReason { Other, SetIndex, Mouse }
 
- Public Types inherited from QDeclarativeFlickablePrivate
enum  FixupMode { Normal, Immediate, ExtentChanged }
 
- 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

void checkVisible () const
 
void clear ()
 
qreal colPosAt (int modelIndex) const
 
int colSize () const
 
QDeclarativeItemcreateComponentItem (QDeclarativeComponent *component)
 
void createHighlight ()
 
FxGridItemcreateItem (int modelIndex)
 
qreal endPosition () const
 
FxGridItemfirstVisibleItem () const
 
virtual void fixup (AxisData &data, qreal minExtent, qreal maxExtent)
 
void fixupPosition ()
 
virtual void flick (AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
 
qreal headerSize () const
 
void init ()
 
bool isRightToLeftTopToBottom () const
 
bool isValid () const
 
virtual void itemGeometryChanged (QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
 
qreal lastPosition () const
 
int lastVisibleIndex () const
 
void layout ()
 
int mapFromModel (int modelIndex) const
 
void mirrorChange ()
 
qreal originPosition () const
 
qreal position () const
 
void positionViewAtIndex (int index, int mode)
 
 QDeclarativeGridViewPrivate ()
 
void refill (qreal from, qreal to, bool doBuffer=false)
 
void regenerate ()
 
void releaseItem (FxGridItem *item)
 
qreal rowPosAt (int modelIndex) const
 
int rowSize () const
 
void scheduleLayout ()
 
void setPosition (qreal pos)
 
int size () const
 
int snapIndex ()
 
FxGridItemsnapItemAt (qreal pos)
 
qreal snapPosAt (qreal pos) const
 
qreal startPosition () const
 
void updateCurrent (int modelIndex)
 
void updateFooter ()
 
void updateGrid ()
 
void updateHeader ()
 
void updateHighlight ()
 
void updateTrackedItem ()
 
void updateUnrequestedIndexes ()
 
void updateUnrequestedPositions ()
 
FxGridItemvisibleItem (int modelIndex) const
 
- Public Functions inherited from QDeclarativeFlickablePrivate
void captureDelayedPress (QGraphicsSceneMouseEvent *event)
 
void clearDelayedPress ()
 
void fixupX ()
 
void fixupY ()
 
void flickX (qreal velocity)
 
void flickY (qreal velocity)
 
void handleMouseMoveEvent (QGraphicsSceneMouseEvent *)
 
void handleMousePressEvent (QGraphicsSceneMouseEvent *)
 
void handleMouseReleaseEvent (QGraphicsSceneMouseEvent *)
 
void init ()
 
bool isOutermostPressDelay () const
 
qreal overShootDistance (qreal size)
 
 QDeclarativeFlickablePrivate ()
 
void setRoundedViewportX (qreal x)
 
void setRoundedViewportY (qreal y)
 
void updateBeginningEnd ()
 
void updateVelocity ()
 
- 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
 
 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 *)
 

Public Variables

bool autoHighlight: 1
 
int buffer
 
int bufferMode
 
int cellHeight
 
int cellWidth
 
int columns
 
int currentIndex
 
bool currentIndexCleared: 1
 
FxGridItemcurrentItem
 
bool deferredRelease: 1
 
bool fixCurrentVisibility: 1
 
QDeclarativeGridView::Flow flow
 
FxGridItemfooter
 
QDeclarativeComponentfooterComponent
 
bool haveHighlightRange: 1
 
FxGridItemheader
 
QDeclarativeComponentheaderComponent
 
FxGridItemhighlight
 
QDeclarativeComponenthighlightComponent
 
int highlightMoveDuration
 
QDeclarativeGridView::HighlightRangeMode highlightRange
 
qreal highlightRangeEnd
 
bool highlightRangeEndValid
 
qreal highlightRangeStart
 
bool highlightRangeStartValid
 
QSmoothedAnimationhighlightXAnimator
 
QSmoothedAnimationhighlightYAnimator
 
int itemCount
 
Qt::LayoutDirection layoutDirection
 
bool layoutScheduled: 1
 
bool lazyRelease: 1
 
QDeclarativeGuard< QDeclarativeVisualModelmodel
 
QVariant modelVariant
 
MovementReason moveReason
 
bool ownModel: 1
 
int requestedIndex
 
QDeclarativeGridView::SnapMode snapMode
 
FxGridItemtrackedItem
 
QHash< QDeclarativeItem *, int > unrequestedItems
 
int visibleIndex
 
QList< FxGridItem * > visibleItems
 
bool wrap: 1
 
- Public Variables inherited from QDeclarativeFlickablePrivate
QDeclarativeFlickable::BoundsBehavior boundsBehavior
 
bool calcVelocity: 1
 
QDeclarativeItemcontentItem
 
qreal deceleration
 
QGraphicsSceneMouseEventdelayedPressEvent
 
QGraphicsItemdelayedPressTarget
 
QBasicTimer delayedPressTimer
 
int fixupDuration
 
FixupMode fixupMode
 
QDeclarativeFlickable::FlickableDirection flickableDirection
 
AxisData hData
 
bool hMoved: 1
 
bool interactive: 1
 
QPointF lastFlickablePosition
 
QPointF lastPos
 
QElapsedTimer lastPosTime
 
qreal maxVelocity
 
int pressDelay
 
bool pressed: 1
 
QPointF pressPos
 
QElapsedTimer pressTime
 
qreal reportedVelocitySmoothing
 
bool stealMouse: 1
 
QDeclarativeTimeLine timeline
 
AxisData vData
 
QElapsedTimer velocityTime
 
QDeclarativeTimeLine velocityTimeline
 
QDeclarativeFlickableVisibleAreavisibleArea
 
bool vMoved: 1
 
int vTime
 
- 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 Functions inherited from QDeclarativeFlickablePrivate
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 void fixupX_callback (void *)
 
static void fixupY_callback (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)
 
- Static Public Variables inherited from QDeclarativeItemPrivate
static qint64 consistentTime = -1
 

Detailed Description

Definition at line 143 of file qdeclarativegridview.cpp.

Enumerations

◆ BufferMode

◆ MovementReason

Constructors and Destructors

◆ QDeclarativeGridViewPrivate()

QDeclarativeGridViewPrivate::QDeclarativeGridViewPrivate ( )
inline

Definition at line 148 of file qdeclarativegridview.cpp.

150  , visibleIndex(0) , currentIndex(-1)
151  , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1), itemCount(0)
157  , highlightMoveDuration(150)
160  , ownModel(false), wrap(false), autoHighlight(true)
161  , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false)
162  , deferredRelease(false), haveHighlightRange(false), currentIndexCleared(false) {}
QDeclarativeGridView::HighlightRangeMode highlightRange
QDeclarativeComponent * headerComponent
QDeclarativeComponent * highlightComponent
QDeclarativeGridView::SnapMode snapMode
QDeclarativeComponent * footerComponent
QSmoothedAnimation * highlightYAnimator
QDeclarativeGridView::Flow flow
QSmoothedAnimation * highlightXAnimator

Functions

◆ checkVisible()

void QDeclarativeGridViewPrivate::checkVisible ( ) const
inline

Definition at line 437 of file qdeclarativegridview.cpp.

437  {
438  int skip = 0;
439  for (int i = 0; i < visibleItems.count(); ++i) {
440  FxGridItem *listItem = visibleItems.at(i);
441  if (listItem->index == -1) {
442  ++skip;
443  } else if (listItem->index != visibleIndex + i - skip) {
444  for (int j = 0; j < visibleItems.count(); j++)
445  qDebug() << " index" << j << "item index" << visibleItems.at(j)->index;
446  qFatal("index %d %d %d", visibleIndex, i, listItem->index);
447  }
448  }
449  }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_CORE_EXPORT void qDebug(const char *,...)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qFatal(const char *,...)
QList< FxGridItem * > visibleItems

◆ clear()

void QDeclarativeGridViewPrivate::clear ( )

Definition at line 507 of file qdeclarativegridview.cpp.

508 {
509  for (int i = 0; i < visibleItems.count(); ++i)
512  visibleIndex = 0;
514  currentItem = 0;
515  createHighlight();
516  trackedItem = 0;
517  itemCount = 0;
518 }
void releaseItem(FxGridItem *item)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void clear()
Removes all items from the list.
Definition: qlist.h:764
QList< FxGridItem * > visibleItems

◆ colPosAt()

qreal QDeclarativeGridViewPrivate::colPosAt ( int  modelIndex) const
inline

Definition at line 270 of file qdeclarativegridview.cpp.

270  {
271  if (FxGridItem *item = visibleItem(modelIndex))
272  return item->colPos();
273  if (!visibleItems.isEmpty()) {
274  if (modelIndex < visibleIndex) {
275  int count = (visibleIndex - modelIndex) % columns;
276  int col = visibleItems.first()->colPos() / colSize();
277  col = (columns - count + col) % columns;
278  return col * colSize();
279  } else {
280  int count = columns - 1 - (modelIndex - visibleItems.last()->index - 1) % columns;
281  return visibleItems.last()->colPos() - count * colSize();
282  }
283  } else {
284  return (modelIndex % columns) * colSize();
285  }
286  return 0;
287  }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
FxGridItem * visibleItem(int modelIndex) const
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
qreal colPos() const
QList< FxGridItem * > visibleItems

◆ colSize()

int QDeclarativeGridViewPrivate::colSize ( ) const
inline

◆ createComponentItem()

QDeclarativeItem * QDeclarativeGridViewPrivate::createComponentItem ( QDeclarativeComponent component)

Definition at line 561 of file qdeclarativegridview.cpp.

562 {
564  QDeclarativeItem *item = 0;
565  QDeclarativeContext *creationContext = component->creationContext();
567  creationContext ? creationContext : qmlContext(q));
568  QObject *nobj = component->create(context);
569  if (nobj) {
570  QDeclarative_setParent_noEvent(context, nobj);
571  item = qobject_cast<QDeclarativeItem *>(nobj);
572  if (!item)
573  delete nobj;
574  } else {
575  delete context;
576  }
577 
578  return item;
579 }
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
The QDeclarativeItem class provides the most basic of all visual items in QML.
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
The QDeclarativeContext class defines a context within a QML engine.
QDeclarativeContext * creationContext() const
Returns the QDeclarativeContext the component was created in.

◆ createHighlight()

void QDeclarativeGridViewPrivate::createHighlight ( )

Definition at line 840 of file qdeclarativegridview.cpp.

841 {
843  bool changed = false;
844  if (highlight) {
845  if (trackedItem == highlight)
846  trackedItem = 0;
847  if (highlight->item->scene())
850  delete highlight;
851  highlight = 0;
852  delete highlightXAnimator;
853  delete highlightYAnimator;
854  highlightXAnimator = 0;
855  highlightYAnimator = 0;
856  changed = true;
857  }
858 
859  if (currentItem) {
860  QDeclarativeItem *item = 0;
861  if (highlightComponent) {
863  } else {
864  item = new QDeclarativeItem;
865  QDeclarative_setParent_noEvent(item, q->contentItem());
866  item->setParentItem(q->contentItem());
867  }
868  if (item) {
869  QDeclarative_setParent_noEvent(item, q->contentItem());
870  item->setParentItem(q->contentItem());
871  highlight = new FxGridItem(item, q);
872  if (currentItem && autoHighlight)
880  if (autoHighlight) {
883  }
884  changed = true;
885  }
886  }
887  if (changed)
888  emit q->highlightItemChanged();
889 }
QDeclarativeComponent * highlightComponent
#define Q_Q(Class)
Definition: qglobal.h:2483
void setPosition(qreal col, qreal row)
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
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
qreal colPos() const
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
qreal rowPos() const
QSmoothedAnimation * highlightYAnimator
void deleteLater()
Schedules this object for deletion.
Definition: qobject.cpp:2145
QSmoothedAnimation * highlightXAnimator
QDeclarativeItem * item
QDeclarativeItem * createComponentItem(QDeclarativeComponent *component)

◆ createItem()

FxGridItem * QDeclarativeGridViewPrivate::createItem ( int  modelIndex)

Definition at line 520 of file qdeclarativegridview.cpp.

521 {
523  // create object
524  requestedIndex = modelIndex;
525  FxGridItem *listItem = 0;
526  if (QDeclarativeItem *item = model->item(modelIndex, false)) {
527  listItem = new FxGridItem(item, q);
528  listItem->index = modelIndex;
529  if (model->completePending()) {
530  // complete
531  listItem->item->setZValue(1);
532  listItem->item->setParentItem(q->contentItem());
533  model->completeItem();
534  } else {
535  listItem->item->setParentItem(q->contentItem());
536  }
537  unrequestedItems.remove(listItem->item);
538  }
539  requestedIndex = -1;
540  return listItem;
541 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
virtual bool completePending() const =0
#define Q_Q(Class)
Definition: qglobal.h:2483
void setParentItem(QDeclarativeItem *parent)
void setZValue(qreal z)
Sets the Z-value of the item to z.
The QDeclarativeItem class provides the most basic of all visual items in QML.
QDeclarativeGuard< QDeclarativeVisualModel > model
virtual QDeclarativeItem * item(int index, bool complete=true)=0
virtual void completeItem()=0
QDeclarativeItem * item
QHash< QDeclarativeItem *, int > unrequestedItems

◆ endPosition()

qreal QDeclarativeGridViewPrivate::endPosition ( ) const
inline

Definition at line 254 of file qdeclarativegridview.cpp.

254  {
256 
257  }

◆ firstVisibleItem()

FxGridItem* QDeclarativeGridViewPrivate::firstVisibleItem ( ) const
inline

Definition at line 312 of file qdeclarativegridview.cpp.

312  {
314  for (int i = 0; i < visibleItems.count(); ++i) {
315  FxGridItem *item = visibleItems.at(i);
316  if (item->index != -1 && item->endRowPos() > pos)
317  return item;
318  }
319  return visibleItems.count() ? visibleItems.first() : 0;
320  }
double qreal
Definition: qglobal.h:1193
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
qreal endRowPos() const
QList< FxGridItem * > visibleItems

◆ fixup()

void QDeclarativeGridViewPrivate::fixup ( AxisData data,
qreal  minExtent,
qreal  maxExtent 
)
virtual

Reimplemented from QDeclarativeFlickablePrivate.

Definition at line 1038 of file qdeclarativegridview.cpp.

1039 {
1042  return;
1043 
1045 
1046  qreal highlightStart;
1047  qreal highlightEnd;
1048  qreal viewPos;
1049  if (isRightToLeftTopToBottom()) {
1050  // Handle Right-To-Left exceptions
1051  viewPos = -position()-size();
1054  } else {
1055  viewPos = position();
1056  highlightStart = highlightRangeStart;
1057  highlightEnd = highlightRangeEnd;
1058  }
1059 
1061 
1063  qreal tempPosition = isRightToLeftTopToBottom() ? -position()-size() : position();
1065  // if we've been dragged < rowSize()/2 then bias towards the next row
1066  qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
1067  qreal bias = 0;
1068  if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < rowSize()/2)
1069  bias = rowSize()/2;
1070  else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -rowSize()/2)
1071  bias = -rowSize()/2;
1073  bias = -bias;
1074  tempPosition -= bias;
1075  }
1076  FxGridItem *topItem = snapItemAt(tempPosition+highlightStart);
1077  if (!topItem && strictHighlightRange && currentItem) {
1078  // StrictlyEnforceRange always keeps an item in range
1079  updateHighlight();
1080  topItem = currentItem;
1081  }
1082  FxGridItem *bottomItem = snapItemAt(tempPosition+highlightEnd);
1083  if (!bottomItem && strictHighlightRange && currentItem) {
1084  // StrictlyEnforceRange always keeps an item in range
1085  updateHighlight();
1086  bottomItem = currentItem;
1087  }
1088  qreal pos;
1089  bool isInBounds = -position() > maxExtent && -position() <= minExtent;
1090  if (topItem && (isInBounds || strictHighlightRange)) {
1091  if (topItem->index == 0 && header && tempPosition+highlightStart < header->rowPos()+headerSize()/2 && !strictHighlightRange) {
1092  pos = isRightToLeftTopToBottom() ? - header->rowPos() + highlightStart - size() : header->rowPos() - highlightStart;
1093  } else {
1095  pos = qMax(qMin(-topItem->rowPos() + highlightStart - size(), -maxExtent), -minExtent);
1096  else
1097  pos = qMax(qMin(topItem->rowPos() - highlightStart, -maxExtent), -minExtent);
1098  }
1099  } else if (bottomItem && isInBounds) {
1101  pos = qMax(qMin(-bottomItem->rowPos() + highlightEnd - size(), -maxExtent), -minExtent);
1102  else
1103  pos = qMax(qMin(bottomItem->rowPos() - highlightEnd, -maxExtent), -minExtent);
1104  } else {
1105  QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
1106  return;
1107  }
1108  qreal dist = qAbs(data.move + pos);
1109  if (dist > 0) {
1110  timeline.reset(data.move);
1111  if (fixupMode != Immediate) {
1113  data.fixingUp = true;
1114  } else {
1115  timeline.set(data.move, -pos);
1116  }
1117  vTime = timeline.time();
1118  }
1119  } else if (haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) {
1120  if (currentItem) {
1121  updateHighlight();
1122  qreal pos = currentItem->rowPos();
1123  if (viewPos < pos + rowSize() - highlightEnd)
1124  viewPos = pos + rowSize() - highlightEnd;
1125  if (viewPos > pos - highlightStart)
1126  viewPos = pos - highlightStart;
1128  viewPos = -viewPos-size();
1129  timeline.reset(data.move);
1130  if (viewPos != position()) {
1131  if (fixupMode != Immediate) {
1133  data.fixingUp = true;
1134  } else {
1135  timeline.set(data.move, -viewPos);
1136  }
1137  }
1138  vTime = timeline.time();
1139  }
1140  } else {
1141  QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
1142  }
1143  data.inOvershoot = false;
1144  fixupMode = Normal;
1145 }
QDeclarativeGridView::HighlightRangeMode highlightRange
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
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...
#define QML_FLICK_SNAPONETHRESHOLD
void reset(QDeclarativeTimeLineValue &)
Cancel (but don&#39;t complete) all scheduled actions for timeLineValue.
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
FxGridItem * snapItemAt(qreal pos)
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent)
void set(QDeclarativeTimeLineValue &, qreal)
Set the value of timeLineValue.
QDeclarativeGridView::SnapMode snapMode
qreal rowPos() const
QDeclarativeGridView::Flow flow
QDeclarativeListProperty< QObject > data()

◆ fixupPosition()

void QDeclarativeGridViewPrivate::fixupPosition ( )

◆ flick()

void QDeclarativeGridViewPrivate::flick ( AxisData data,
qreal  minExtent,
qreal  maxExtent,
qreal  vSize,
QDeclarativeTimeLineCallback::Callback  fixupCallback,
qreal  velocity 
)
virtual

Reimplemented from QDeclarativeFlickablePrivate.

Definition at line 1147 of file qdeclarativegridview.cpp.

1149 {
1151  data.fixingUp = false;
1152  moveReason = Mouse;
1155  QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
1156  return;
1157  }
1158  qreal maxDistance = 0;
1159  qreal dataValue = isRightToLeftTopToBottom() ? -data.move.value()+size() : data.move.value();
1160  // -ve velocity means list is moving up/left
1161  if (velocity > 0) {
1162  if (data.move.value() < minExtent) {
1164  // if we've been dragged < averageSize/2 then bias towards the next item
1165  qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
1166  qreal bias = dist < rowSize()/2 ? rowSize()/2 : 0;
1168  bias = -bias;
1169  data.flickTarget = -snapPosAt(-dataValue - bias);
1170  maxDistance = qAbs(data.flickTarget - data.move.value());
1171  velocity = maxVelocity;
1172  } else {
1173  maxDistance = qAbs(minExtent - data.move.value());
1174  }
1175  }
1177  data.flickTarget = minExtent;
1178  } else {
1179  if (data.move.value() > maxExtent) {
1181  // if we've been dragged < averageSize/2 then bias towards the next item
1182  qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset);
1183  qreal bias = -dist < rowSize()/2 ? rowSize()/2 : 0;
1185  bias = -bias;
1186  data.flickTarget = -snapPosAt(-dataValue + bias);
1187  maxDistance = qAbs(data.flickTarget - data.move.value());
1188  velocity = -maxVelocity;
1189  } else {
1190  maxDistance = qAbs(maxExtent - data.move.value());
1191  }
1192  }
1194  data.flickTarget = maxExtent;
1195  }
1196 
1198 
1199  if (maxDistance > 0 || overShoot) {
1200  // This mode requires the grid to stop exactly on a row boundary.
1201  qreal v = velocity;
1202  if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
1203  if (v < 0)
1204  v = -maxVelocity;
1205  else
1206  v = maxVelocity;
1207  }
1208  qreal accel = deceleration;
1209  qreal v2 = v * v;
1210  qreal overshootDist = qreal(0.0);
1211  if ((maxDistance > qreal(0.0) && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarativeGridView::SnapOneRow) {
1212  // + rowSize()/4 to encourage moving at least one item in the flick direction
1213  qreal dist = v2 / (accel * qreal(2.0)) + rowSize()/4;
1214  dist = qMin(dist, maxDistance);
1215  if (v > 0)
1216  dist = -dist;
1218  qreal distTemp = isRightToLeftTopToBottom() ? -dist : dist;
1219  data.flickTarget = -snapPosAt(-dataValue + distTemp);
1220  }
1221  data.flickTarget = isRightToLeftTopToBottom() ? -data.flickTarget+size() : data.flickTarget;
1222  if (overShoot) {
1223  if (data.flickTarget >= minExtent) {
1224  overshootDist = overShootDistance(vSize);
1225  data.flickTarget += overshootDist;
1226  } else if (data.flickTarget <= maxExtent) {
1227  overshootDist = overShootDistance(vSize);
1228  data.flickTarget -= overshootDist;
1229  }
1230  }
1231  qreal adjDist = -data.flickTarget + data.move.value();
1232  if (qAbs(adjDist) > qAbs(dist)) {
1233  // Prevent painfully slow flicking - adjust velocity to suit flickDeceleration
1234  qreal adjv2 = accel * 2.0f * qAbs(adjDist);
1235  if (adjv2 > v2) {
1236  v2 = adjv2;
1237  v = qSqrt(v2);
1238  if (dist > 0)
1239  v = -v;
1240  }
1241  }
1242  dist = adjDist;
1243  accel = v2 / (2.0f * qAbs(dist));
1244  } else {
1245  data.flickTarget = velocity > 0 ? minExtent : maxExtent;
1246  overshootDist = overShoot ? overShootDistance(vSize) : 0;
1247  }
1248  timeline.reset(data.move);
1249  timeline.accel(data.move, v, accel, maxDistance + overshootDist);
1250  timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
1251  if (!hData.flicking && q->xflick()) {
1252  hData.flicking = true;
1253  emit q->flickingChanged();
1254  emit q->flickingHorizontallyChanged();
1255  emit q->flickStarted();
1256  }
1257  if (!vData.flicking && q->yflick()) {
1258  vData.flicking = true;
1259  emit q->flickingChanged();
1260  emit q->flickingVerticallyChanged();
1261  emit q->flickStarted();
1262  }
1263  } else {
1264  timeline.reset(data.move);
1265  fixup(data, minExtent, maxExtent);
1266  }
1267 }
QDeclarativeGridView::HighlightRangeMode highlightRange
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int accel(QDeclarativeTimeLineValue &, qreal velocity, qreal accel)
Decelerate timeLineValue from the starting velocity to zero at the given acceleration rate...
void reset(QDeclarativeTimeLineValue &)
Cancel (but don&#39;t complete) all scheduled actions for timeLineValue.
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
QDeclarativeGridView::SnapMode snapMode
virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent)
qreal qSqrt(qreal v)
Definition: qmath.h:205
void callback(const QDeclarativeTimeLineCallback &)
Execute the event.
QDeclarativeListProperty< QObject > data()
qreal snapPosAt(qreal pos) const
QDeclarativeFlickable::BoundsBehavior boundsBehavior

◆ headerSize()

qreal QDeclarativeGridViewPrivate::headerSize ( ) const
inline

Definition at line 402 of file qdeclarativegridview.cpp.

402  {
403  if (!header)
404  return 0.0;
405 
407  ? header->item->height()
408  : header->item->width();
409  }
QDeclarativeGridView::Flow flow
QDeclarativeItem * item

◆ init()

void QDeclarativeGridViewPrivate::init ( )

Definition at line 498 of file qdeclarativegridview.cpp.

499 {
501  QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
503  q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick);
505 }
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)

◆ isRightToLeftTopToBottom()

bool QDeclarativeGridViewPrivate::isRightToLeftTopToBottom ( ) const
inline

Definition at line 195 of file qdeclarativegridview.cpp.

195  {
196  Q_Q(const QDeclarativeGridView);
197  return flow == QDeclarativeGridView::TopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft;
198  }
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeGridView::Flow flow

◆ isValid()

bool QDeclarativeGridViewPrivate::isValid ( ) const
inline

Definition at line 259 of file qdeclarativegridview.cpp.

259  {
260  return model && model->count() && model->isValid();
261  }
virtual bool isValid() const =0
QDeclarativeGuard< QDeclarativeVisualModel > model

◆ itemGeometryChanged()

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

Reimplemented from QDeclarativeFlickablePrivate.

Definition at line 412 of file qdeclarativegridview.cpp.

412  {
413  Q_Q(const QDeclarativeGridView);
414  QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
415  if (item == q) {
416  if (newGeometry.height() != oldGeometry.height()
417  || newGeometry.width() != oldGeometry.width()) {
418  if (q->isComponentComplete()) {
419  updateGrid();
420  scheduleLayout();
421  }
422  }
423  } else if ((header && header->item == item) || (footer && footer->item == item)) {
424  if (header)
425  updateHeader();
426  if (footer)
427  updateFooter();
428  }
429  }
void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &)
#define Q_Q(Class)
Definition: qglobal.h:2483
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
QDeclarativeItem * item

◆ lastPosition()

qreal QDeclarativeGridViewPrivate::lastPosition ( ) const
inline

Definition at line 243 of file qdeclarativegridview.cpp.

243  {
244  qreal pos = 0;
245  if (model && model->count())
246  pos = rowPosAt(model->count() - 1) + rowSize();
247  return pos;
248  }
double qreal
Definition: qglobal.h:1193
QDeclarativeGuard< QDeclarativeVisualModel > model
qreal rowPosAt(int modelIndex) const

◆ lastVisibleIndex()

int QDeclarativeGridViewPrivate::lastVisibleIndex ( ) const
inline

Definition at line 322 of file qdeclarativegridview.cpp.

322  {
323  for (int i = 0; i < visibleItems.count(); ++i) {
324  FxGridItem *item = visibleItems.at(i);
325  if (item->index != -1)
326  return item->index;
327  }
328  return -1;
329  }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< FxGridItem * > visibleItems

◆ layout()

void QDeclarativeGridViewPrivate::layout ( )

Definition at line 751 of file qdeclarativegridview.cpp.

752 {
754  layoutScheduled = false;
755  if (!isValid() && !visibleItems.count()) {
756  clear();
757  return;
758  }
759  if (visibleItems.count()) {
760  qreal rowPos = visibleItems.first()->rowPos();
761  qreal colPos = visibleItems.first()->colPos();
762  int col = visibleIndex % columns;
763  if (colPos != col * colSize()) {
764  colPos = col * colSize();
765  visibleItems.first()->setPosition(colPos, rowPos);
766  }
767  for (int i = 1; i < visibleItems.count(); ++i) {
768  FxGridItem *item = visibleItems.at(i);
769  colPos += colSize();
770  if (colPos > colSize() * (columns-1)) {
771  colPos = 0;
772  rowPos += rowSize();
773  }
774  item->setPosition(colPos, rowPos);
775  }
776  }
777  if (header)
778  updateHeader();
779  if (footer)
780  updateFooter();
781  q->refill();
782  updateHighlight();
783  moveReason = Other;
785  q->setContentHeight(endPosition() - startPosition());
786  fixupY();
787  } else {
788  q->setContentWidth(endPosition() - startPosition());
789  fixupX();
790  }
792 }
double qreal
Definition: qglobal.h:1193
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
void setPosition(qreal col, qreal row)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
qreal colPos() const
qreal rowPos() const
QList< FxGridItem * > visibleItems
QDeclarativeGridView::Flow flow

◆ mapFromModel()

int QDeclarativeGridViewPrivate::mapFromModel ( int  modelIndex) const
inline

Definition at line 334 of file qdeclarativegridview.cpp.

334  {
335  if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count())
336  return -1;
337  for (int i = 0; i < visibleItems.count(); ++i) {
338  FxGridItem *listItem = visibleItems.at(i);
339  if (listItem->index == modelIndex)
340  return i + visibleIndex;
341  if (listItem->index > modelIndex)
342  return -1;
343  }
344  return -1; // Not in visibleList
345  }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< FxGridItem * > visibleItems

◆ mirrorChange()

void QDeclarativeGridViewPrivate::mirrorChange ( )
inlinevirtual

Reimplemented from QDeclarativeItemPrivate.

Definition at line 211 of file qdeclarativegridview.cpp.

211  {
212  regenerate();
213  }

◆ originPosition()

qreal QDeclarativeGridViewPrivate::originPosition ( ) const
inline

Definition at line 236 of file qdeclarativegridview.cpp.

236  {
237  qreal pos = 0;
238  if (!visibleItems.isEmpty())
240  return pos;
241  }
double qreal
Definition: qglobal.h:1193
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
qreal rowPos() const
QList< FxGridItem * > visibleItems

◆ position()

qreal QDeclarativeGridViewPrivate::position ( ) const
inline

Definition at line 215 of file qdeclarativegridview.cpp.

215  {
216  Q_Q(const QDeclarativeGridView);
217  return flow == QDeclarativeGridView::LeftToRight ? q->contentY() : q->contentX();
218  }
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeGridView::Flow flow

◆ positionViewAtIndex()

void QDeclarativeGridViewPrivate::positionViewAtIndex ( int  index,
int  mode 
)

Definition at line 2572 of file qdeclarativegridview.cpp.

2573 {
2575  if (!isValid())
2576  return;
2577  if (mode < QDeclarativeGridView::Beginning || mode > QDeclarativeGridView::Contain)
2578  return;
2579 
2580  int idx = qMax(qMin(index, model->count()-1), 0);
2581 
2582  if (layoutScheduled)
2583  layout();
2585  FxGridItem *item = visibleItem(idx);
2586  qreal maxExtent;
2588  maxExtent = -q->maxYExtent();
2589  else
2590  maxExtent = isRightToLeftTopToBottom() ? q->minXExtent()-size() : -q->maxXExtent();
2591 
2592  if (!item) {
2593  int itemPos = rowPosAt(idx);
2594  // save the currently visible items in case any of them end up visible again
2595  QList<FxGridItem*> oldVisible = visibleItems;
2596  visibleItems.clear();
2597  visibleIndex = idx - idx % columns;
2599  maxExtent = -q->maxYExtent();
2600  else
2601  maxExtent = isRightToLeftTopToBottom() ? q->minXExtent()-size() : -q->maxXExtent();
2602  setPosition(qMin(qreal(itemPos), maxExtent));
2603  // now release the reference to all the old visible items.
2604  for (int i = 0; i < oldVisible.count(); ++i)
2605  releaseItem(oldVisible.at(i));
2606  item = visibleItem(idx);
2607  }
2608  if (item) {
2609  qreal itemPos = item->rowPos();
2610  switch (mode) {
2612  pos = itemPos;
2613  if (index < 0 && header) {
2615  ? header->item->height()
2616  : header->item->width();
2617  }
2618  break;
2620  pos = itemPos - (size() - rowSize())/2;
2621  break;
2623  pos = itemPos - size() + rowSize();
2624  if (index >= model->count() && footer) {
2626  ? footer->item->height()
2627  : footer->item->width();
2628  }
2629  break;
2631  if (itemPos > pos + size())
2632  pos = itemPos - size() + rowSize();
2633  else if (item->endRowPos() < pos)
2634  pos = itemPos;
2635  break;
2637  if (item->endRowPos() > pos + size())
2638  pos = itemPos - size() + rowSize();
2639  if (itemPos < pos)
2640  pos = itemPos;
2641  }
2642 
2643  pos = qMin(pos, maxExtent);
2644  qreal minExtent;
2646  minExtent = -q->minYExtent();
2647  else
2648  minExtent = isRightToLeftTopToBottom() ? q->maxXExtent()-size() : -q->minXExtent();
2649  pos = qMax(pos, minExtent);
2651  q->cancelFlick();
2652  setPosition(pos);
2653  }
2654  fixupPosition();
2655 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void releaseItem(FxGridItem *item)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDeclarativeGuard< QDeclarativeVisualModel > model
FxGridItem * visibleItem(int modelIndex) const
void clear()
Removes all items from the list.
Definition: qlist.h:764
qreal rowPosAt(int modelIndex) const
qreal endRowPos() const
qreal rowPos() const
QList< FxGridItem * > visibleItems
QDeclarativeGridView::Flow flow
QDeclarativeItem * item
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ refill()

void QDeclarativeGridViewPrivate::refill ( qreal  from,
qreal  to,
bool  doBuffer = false 
)

Definition at line 581 of file qdeclarativegridview.cpp.

582 {
584  if (!isValid() || !q->isComponentComplete())
585  return;
586  itemCount = model->count();
587  qreal bufferFrom = from - buffer;
588  qreal bufferTo = to + buffer;
589  qreal fillFrom = from;
590  qreal fillTo = to;
591  if (doBuffer && (bufferMode & BufferAfter))
592  fillTo = bufferTo;
593  if (doBuffer && (bufferMode & BufferBefore))
594  fillFrom = bufferFrom;
595 
596  bool changed = false;
597 
598  int colPos = colPosAt(visibleIndex);
599  int rowPos = rowPosAt(visibleIndex);
600  int modelIndex = visibleIndex;
601  if (visibleItems.count()) {
602  rowPos = visibleItems.last()->rowPos();
603  colPos = visibleItems.last()->colPos() + colSize();
604  if (colPos > colSize() * (columns-1)) {
605  colPos = 0;
606  rowPos += rowSize();
607  }
608  int i = visibleItems.count() - 1;
609  while (i > 0 && visibleItems.at(i)->index == -1)
610  --i;
611  modelIndex = visibleItems.at(i)->index + 1;
612  }
613 
614  if (visibleItems.count() && (fillFrom > rowPos + rowSize()*2
615  || fillTo < rowPosAt(visibleIndex) - rowSize())) {
616  // We've jumped more than a page. Estimate which items are now
617  // visible and fill from there.
618  int count = (fillFrom - (rowPos + rowSize())) / (rowSize()) * columns;
619  for (int i = 0; i < visibleItems.count(); ++i)
622  modelIndex += count;
623  if (modelIndex >= model->count())
624  modelIndex = model->count() - 1;
625  else if (modelIndex < 0)
626  modelIndex = 0;
627  modelIndex = modelIndex / columns * columns;
628  visibleIndex = modelIndex;
629  colPos = colPosAt(visibleIndex);
630  rowPos = rowPosAt(visibleIndex);
631  }
632 
633  int colNum = colPos / colSize();
634 
635  FxGridItem *item = 0;
636 
637  // Item creation and release is staggered in order to avoid
638  // creating/releasing multiple items in one frame
639  // while flicking (as much as possible).
640  while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) {
641 // qDebug() << "refill: append item" << modelIndex;
642  if (!(item = createItem(modelIndex)))
643  break;
644  item->setPosition(colPos, rowPos);
645  visibleItems.append(item);
646  colPos += colSize();
647  colNum++;
648  if (colPos > colSize() * (columns-1)) {
649  colPos = 0;
650  colNum = 0;
651  rowPos += rowSize();
652  }
653  ++modelIndex;
654  changed = true;
655  if (doBuffer) // never buffer more than one item per frame
656  break;
657  }
658 
659  if (visibleItems.count()) {
660  rowPos = visibleItems.first()->rowPos();
661  colPos = visibleItems.first()->colPos() - colSize();
662  if (colPos < 0) {
663  colPos = colSize() * (columns - 1);
664  rowPos -= rowSize();
665  }
666  }
667  colNum = colPos / colSize();
668  while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){
669 // qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos;
670  if (!(item = createItem(visibleIndex-1)))
671  break;
672  --visibleIndex;
673  item->setPosition(colPos, rowPos);
674  visibleItems.prepend(item);
675  colPos -= colSize();
676  colNum--;
677  if (colPos < 0) {
678  colPos = colSize() * (columns - 1);
679  colNum = columns-1;
680  rowPos -= rowSize();
681  }
682  changed = true;
683  if (doBuffer) // never buffer more than one item per frame
684  break;
685  }
686 
687  if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create
688  while (visibleItems.count() > 1
689  && (item = visibleItems.first())
690  && item->rowPos()+rowSize()-1 < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) {
691  if (item->attached->delayRemove())
692  break;
693 // qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos();
694  if (item->index != -1)
695  visibleIndex++;
697  releaseItem(item);
698  changed = true;
699  }
700  while (visibleItems.count() > 1
701  && (item = visibleItems.last())
702  && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) {
703  if (item->attached->delayRemove())
704  break;
705 // qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1;
707  releaseItem(item);
708  changed = true;
709  }
710  deferredRelease = false;
711  } else {
712  deferredRelease = true;
713  }
714  if (changed) {
715  if (header)
716  updateHeader();
717  if (footer)
718  updateFooter();
720  q->setContentHeight(endPosition() - startPosition());
721  else
722  q->setContentWidth(endPosition() - startPosition());
723  } else if (!doBuffer && buffer && bufferMode != NoBuffer) {
724  refill(from, to, true);
725  }
726  lazyRelease = false;
727 }
FxGridItem * createItem(int modelIndex)
double qreal
Definition: qglobal.h:1193
void releaseItem(FxGridItem *item)
QDeclarativeGridViewAttached * attached
void removeLast()
Removes the last item in the list.
Definition: qlist.h:287
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
void refill(qreal from, qreal to, bool doBuffer=false)
#define Q_Q(Class)
Definition: qglobal.h:2483
void setPosition(qreal col, qreal row)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDeclarativeGuard< QDeclarativeVisualModel > model
void removeFirst()
Removes the first item in the list.
Definition: qlist.h:286
void clear()
Removes all items from the list.
Definition: qlist.h:764
qreal rowPosAt(int modelIndex) const
qreal colPosAt(int modelIndex) const
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
qreal colPos() const
qreal rowPos() const
QList< FxGridItem * > visibleItems
QDeclarativeGridView::Flow flow

◆ regenerate()

void QDeclarativeGridViewPrivate::regenerate ( )
inline

Definition at line 200 of file qdeclarativegridview.cpp.

200  {
202  if (q->isComponentComplete()) {
203  clear();
204  updateGrid();
205  setPosition(0);
206  q->refill();
208  }
209  }
#define Q_Q(Class)
Definition: qglobal.h:2483

◆ releaseItem()

void QDeclarativeGridViewPrivate::releaseItem ( FxGridItem item)

Definition at line 544 of file qdeclarativegridview.cpp.

545 {
547  if (!item || !model)
548  return;
549  if (trackedItem == item) {
550  QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
551  QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
552  trackedItem = 0;
553  }
554  if (model->release(item->item) == 0) {
555  // item was not destroyed, and we no longer reference it.
556  unrequestedItems.insert(item->item, model->indexOf(item->item, q));
557  }
558  delete item;
559 }
virtual ReleaseFlags release(QDeclarativeItem *item)=0
#define SLOT(a)
Definition: qobjectdefs.h:226
virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const =0
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QDeclarativeGuard< QDeclarativeVisualModel > model
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
QDeclarativeItem * item
QHash< QDeclarativeItem *, int > unrequestedItems

◆ rowPosAt()

qreal QDeclarativeGridViewPrivate::rowPosAt ( int  modelIndex) const
inline

Definition at line 288 of file qdeclarativegridview.cpp.

288  {
289  if (FxGridItem *item = visibleItem(modelIndex))
290  return item->rowPos();
291  if (!visibleItems.isEmpty()) {
292  if (modelIndex < visibleIndex) {
293  int firstCol = visibleItems.first()->colPos() / colSize();
294  int col = visibleIndex - modelIndex + (columns - firstCol - 1);
295  int rows = col / columns;
296  return visibleItems.first()->rowPos() - rows * rowSize();
297  } else {
298  int count = modelIndex - visibleItems.last()->index;
299  int col = visibleItems.last()->colPos() + count * colSize();
300  int rows = col / (columns * colSize());
301  return visibleItems.last()->rowPos() + rows * rowSize();
302  }
303  } else {
304  qreal pos = (modelIndex / columns) * rowSize();
305  if (header)
306  pos += headerSize();
307  return pos;
308  }
309  return 0;
310  }
double qreal
Definition: qglobal.h:1193
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
FxGridItem * visibleItem(int modelIndex) const
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
qreal colPos() const
qreal rowPos() const
QList< FxGridItem * > visibleItems

◆ rowSize()

int QDeclarativeGridViewPrivate::rowSize ( ) const
inline

◆ scheduleLayout()

void QDeclarativeGridViewPrivate::scheduleLayout ( )

Definition at line 742 of file qdeclarativegridview.cpp.

743 {
745  if (!layoutScheduled) {
746  layoutScheduled = true;
748  }
749 }
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

◆ setPosition()

void QDeclarativeGridViewPrivate::setPosition ( qreal  pos)
inline

Definition at line 219 of file qdeclarativegridview.cpp.

219  {
222  q->QDeclarativeFlickable::setContentY(pos);
223  q->QDeclarativeFlickable::setContentX(0);
224  } else {
225  if (q->effectiveLayoutDirection() == Qt::LeftToRight)
226  q->QDeclarativeFlickable::setContentX(pos);
227  else
228  q->QDeclarativeFlickable::setContentX(-pos-size());
229  q->QDeclarativeFlickable::setContentY(0);
230  }
231  }
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeGridView::Flow flow

◆ size()

int QDeclarativeGridViewPrivate::size ( ) const
inline

Definition at line 232 of file qdeclarativegridview.cpp.

232  {
233  Q_Q(const QDeclarativeGridView);
234  return flow == QDeclarativeGridView::LeftToRight ? q->height() : q->width();
235  }
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeGridView::Flow flow

◆ snapIndex()

int QDeclarativeGridViewPrivate::snapIndex ( )
inline

Definition at line 386 of file qdeclarativegridview.cpp.

386  {
387  int index = currentIndex;
388  for (int i = 0; i < visibleItems.count(); ++i) {
389  FxGridItem *item = visibleItems[i];
390  if (item->index == -1)
391  continue;
392  qreal itemTop = item->rowPos();
393  if (itemTop >= highlight->rowPos()-rowSize()/2 && itemTop < highlight->rowPos()+rowSize()/2) {
394  index = item->index;
395  if (item->colPos() >= highlight->colPos()-colSize()/2 && item->colPos() < highlight->colPos()+colSize()/2)
396  return item->index;
397  }
398  }
399  return index;
400  }
double qreal
Definition: qglobal.h:1193
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
qreal colPos() const
qreal rowPos() const
QList< FxGridItem * > visibleItems

◆ snapItemAt()

FxGridItem* QDeclarativeGridViewPrivate::snapItemAt ( qreal  pos)
inline

Definition at line 374 of file qdeclarativegridview.cpp.

374  {
375  for (int i = 0; i < visibleItems.count(); ++i) {
376  FxGridItem *item = visibleItems[i];
377  if (item->index == -1)
378  continue;
379  qreal itemTop = item->rowPos();
380  if (itemTop+rowSize()/2 >= pos && itemTop - rowSize()/2 <= pos)
381  return item;
382  }
383  return 0;
384  }
double qreal
Definition: qglobal.h:1193
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
qreal rowPos() const
QList< FxGridItem * > visibleItems

◆ snapPosAt()

qreal QDeclarativeGridViewPrivate::snapPosAt ( qreal  pos) const
inline

Definition at line 347 of file qdeclarativegridview.cpp.

347  {
348  Q_Q(const QDeclarativeGridView);
349  qreal snapPos = 0;
350  if (!visibleItems.isEmpty()) {
352  pos += highlightStart;
353  pos += rowSize()/2;
354  snapPos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize();
355  snapPos = pos - fmodf(pos - snapPos, qreal(rowSize()));
356  snapPos -= highlightStart;
357  qreal maxExtent;
358  qreal minExtent;
359  if (isRightToLeftTopToBottom()) {
360  maxExtent = q->minXExtent();
361  minExtent = q->maxXExtent();
362  } else {
363  maxExtent = flow == QDeclarativeGridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent();
364  minExtent = flow == QDeclarativeGridView::LeftToRight ? -q->minYExtent() : -q->minXExtent();
365  }
366  if (snapPos > maxExtent)
367  snapPos = maxExtent;
368  if (snapPos < minExtent)
369  snapPos = minExtent;
370  }
371  return snapPos;
372  }
double qreal
Definition: qglobal.h:1193
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
#define Q_Q(Class)
Definition: qglobal.h:2483
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
qreal rowPos() const
QList< FxGridItem * > visibleItems
QDeclarativeGridView::Flow flow

◆ startPosition()

qreal QDeclarativeGridViewPrivate::startPosition ( ) const
inline

Definition at line 250 of file qdeclarativegridview.cpp.

◆ updateCurrent()

void QDeclarativeGridViewPrivate::updateCurrent ( int  modelIndex)

Definition at line 907 of file qdeclarativegridview.cpp.

908 {
910  if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) {
911  if (currentItem) {
914  currentItem = 0;
915  currentIndex = modelIndex;
916  emit q->currentIndexChanged();
917  updateHighlight();
918  } else if (currentIndex != modelIndex) {
919  currentIndex = modelIndex;
920  emit q->currentIndexChanged();
921  }
922  return;
923  }
924 
925  if (currentItem && currentIndex == modelIndex) {
926  updateHighlight();
927  return;
928  }
929 
930  FxGridItem *oldCurrentItem = currentItem;
931  currentIndex = modelIndex;
932  currentItem = createItem(modelIndex);
933  fixCurrentVisibility = true;
934  if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item))
935  oldCurrentItem->attached->setIsCurrentItem(false);
936  if (currentItem) {
937  currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex));
938  currentItem->item->setFocus(true);
940  }
941  updateHighlight();
942  emit q->currentIndexChanged();
943  releaseItem(oldCurrentItem);
944 }
FxGridItem * createItem(int modelIndex)
void releaseItem(FxGridItem *item)
QDeclarativeGridViewAttached * attached
#define Q_Q(Class)
Definition: qglobal.h:2483
void setPosition(qreal col, qreal row)
#define emit
Definition: qobjectdefs.h:76
QDeclarativeGuard< QDeclarativeVisualModel > model
qreal rowPosAt(int modelIndex) const
qreal colPosAt(int modelIndex) const
QDeclarativeItem * item

◆ updateFooter()

void QDeclarativeGridViewPrivate::updateFooter ( )

Definition at line 946 of file qdeclarativegridview.cpp.

947 {
949  if (!footer && footerComponent) {
951  if (item) {
952  QDeclarative_setParent_noEvent(item, q->contentItem());
953  item->setParentItem(q->contentItem());
954  item->setZValue(1);
957  footer = new FxGridItem(item, q);
958  }
959  }
960  if (footer) {
961  qreal colOffset = 0;
962  qreal rowOffset;
963  if (isRightToLeftTopToBottom()) {
964  rowOffset = footer->item->width()-cellWidth;
965  } else {
966  rowOffset = 0;
967  if (q->effectiveLayoutDirection() == Qt::RightToLeft)
968  colOffset = footer->item->width()-cellWidth;
969  }
970  if (visibleItems.count()) {
971  qreal endPos = lastPosition();
972  if (lastVisibleIndex() == model->count()-1) {
973  footer->setPosition(colOffset, endPos + rowOffset);
974  } else {
975  qreal visiblePos = isRightToLeftTopToBottom() ? -position() : position() + size();
976  if (endPos <= visiblePos || footer->endRowPos() < endPos + rowOffset)
977  footer->setPosition(colOffset, endPos + rowOffset);
978  }
979  } else {
980  qreal endPos = 0;
981  if (header) {
983  }
984  footer->setPosition(colOffset, endPos);
985  }
986  }
987 }
double qreal
Definition: qglobal.h:1193
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
void setPosition(qreal col, qreal row)
void setParentItem(QDeclarativeItem *parent)
void setZValue(qreal z)
Sets the Z-value of the item to z.
The QDeclarativeItem class provides the most basic of all visual items in QML.
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
QDeclarativeGuard< QDeclarativeVisualModel > model
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QDeclarativeComponent * footerComponent
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
QList< FxGridItem * > visibleItems
QDeclarativeGridView::Flow flow
QDeclarativeItem * item
QDeclarativeItem * createComponentItem(QDeclarativeComponent *component)

◆ updateGrid()

void QDeclarativeGridViewPrivate::updateGrid ( )

Definition at line 729 of file qdeclarativegridview.cpp.

730 {
732 
733  columns = (int)qMax((flow == QDeclarativeGridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.));
734  if (isValid()) {
736  q->setContentHeight(endPosition() - startPosition());
737  else
738  q->setContentWidth(lastPosition() - originPosition());
739  }
740 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeGridView::Flow flow

◆ updateHeader()

void QDeclarativeGridViewPrivate::updateHeader ( )

Definition at line 989 of file qdeclarativegridview.cpp.

990 {
992  if (!header && headerComponent) {
994  if (item) {
995  QDeclarative_setParent_noEvent(item, q->contentItem());
996  item->setParentItem(q->contentItem());
997  item->setZValue(1);
1000  header = new FxGridItem(item, q);
1001  }
1002  }
1003  if (header) {
1004  qreal colOffset = 0;
1005  qreal rowOffset;
1006  if (isRightToLeftTopToBottom()) {
1007  rowOffset = -cellWidth;
1008  } else {
1009  rowOffset = -headerSize();
1010  if (q->effectiveLayoutDirection() == Qt::RightToLeft)
1011  colOffset = header->item->width()-cellWidth;
1012  }
1013  if (visibleItems.count()) {
1014  qreal startPos = originPosition();
1015  if (visibleIndex == 0) {
1016  header->setPosition(colOffset, startPos + rowOffset);
1017  } else {
1018  qreal tempPos = isRightToLeftTopToBottom() ? -position()-size() : position();
1019  qreal headerPos = isRightToLeftTopToBottom() ? header->rowPos() + cellWidth - headerSize() : header->rowPos();
1020  if (tempPos <= startPos || headerPos > startPos + rowOffset)
1021  header->setPosition(colOffset, startPos + rowOffset);
1022  }
1023  } else {
1024  header->setPosition(colOffset, 0);
1025  }
1026  }
1027 }
double qreal
Definition: qglobal.h:1193
QDeclarativeComponent * headerComponent
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
void setPosition(qreal col, qreal row)
void setParentItem(QDeclarativeItem *parent)
void setZValue(qreal z)
Sets the Z-value of the item to z.
The QDeclarativeItem class provides the most basic of all visual items in QML.
void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types)
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
qreal rowPos() const
QList< FxGridItem * > visibleItems
QDeclarativeItem * item
QDeclarativeItem * createComponentItem(QDeclarativeComponent *component)

◆ updateHighlight()

void QDeclarativeGridViewPrivate::updateHighlight ( )

Definition at line 891 of file qdeclarativegridview.cpp.

892 {
893  if ((!currentItem && highlight) || (currentItem && !highlight))
894  createHighlight();
896  // auto-update highlight
903  }
905 }
qreal y() const
This convenience function is equivalent to calling pos().
qreal x() const
This convenience function is equivalent to calling pos().
QSmoothedAnimation * highlightYAnimator
QSmoothedAnimation * highlightXAnimator
QDeclarativeItem * item

◆ updateTrackedItem()

void QDeclarativeGridViewPrivate::updateTrackedItem ( )

Definition at line 818 of file qdeclarativegridview.cpp.

819 {
821  FxGridItem *item = currentItem;
822  if (highlight)
823  item = highlight;
824 
825  if (trackedItem && item != trackedItem) {
826  QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
827  QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
828  trackedItem = 0;
829  }
830 
831  if (!trackedItem && item) {
832  trackedItem = item;
833  QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
834  QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
835  }
836  if (trackedItem)
837  q->trackedPositionChanged();
838 }
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
QDeclarativeItem * item

◆ updateUnrequestedIndexes()

void QDeclarativeGridViewPrivate::updateUnrequestedIndexes ( )

Definition at line 794 of file qdeclarativegridview.cpp.

795 {
798  for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it)
799  *it = model->indexOf(it.key(), q);
800 }
#define it(className, varName)
virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const =0
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define Q_Q(Class)
Definition: qglobal.h:2483
QDeclarativeGuard< QDeclarativeVisualModel > model
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
QHash< QDeclarativeItem *, int > unrequestedItems

◆ updateUnrequestedPositions()

void QDeclarativeGridViewPrivate::updateUnrequestedPositions ( )

Definition at line 802 of file qdeclarativegridview.cpp.

803 {
805  for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) {
806  QDeclarativeItem *item = it.key();
808  item->setPos(QPointF(colPosAt(*it), rowPosAt(*it)));
809  } else {
811  item->setPos(QPointF(-rowPosAt(*it)-item->width(), colPosAt(*it)));
812  else
813  item->setPos(QPointF(rowPosAt(*it), colPosAt(*it)));
814  }
815  }
816 }
#define it(className, varName)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
void setPos(const QPointF &pos)
Sets the position of the item to pos, which is in parent coordinates.
The QDeclarativeItem class provides the most basic of all visual items in QML.
qreal rowPosAt(int modelIndex) const
qreal colPosAt(int modelIndex) const
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:464
QDeclarativeGridView::Flow flow
QHash< QDeclarativeItem *, int > unrequestedItems

◆ visibleItem()

FxGridItem* QDeclarativeGridViewPrivate::visibleItem ( int  modelIndex) const
inline

Definition at line 184 of file qdeclarativegridview.cpp.

184  {
185  if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
186  for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) {
187  FxGridItem *item = visibleItems.at(i);
188  if (item->index == modelIndex)
189  return item;
190  }
191  }
192  return 0;
193  }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< FxGridItem * > visibleItems

Properties

◆ autoHighlight

bool QDeclarativeGridViewPrivate::autoHighlight

Definition at line 489 of file qdeclarativegridview.cpp.

◆ buffer

int QDeclarativeGridViewPrivate::buffer

Definition at line 475 of file qdeclarativegridview.cpp.

◆ bufferMode

int QDeclarativeGridViewPrivate::bufferMode

Definition at line 484 of file qdeclarativegridview.cpp.

◆ cellHeight

int QDeclarativeGridViewPrivate::cellHeight

Definition at line 461 of file qdeclarativegridview.cpp.

◆ cellWidth

int QDeclarativeGridViewPrivate::cellWidth

Definition at line 460 of file qdeclarativegridview.cpp.

◆ columns

int QDeclarativeGridViewPrivate::columns

Definition at line 462 of file qdeclarativegridview.cpp.

◆ currentIndex

int QDeclarativeGridViewPrivate::currentIndex

Definition at line 459 of file qdeclarativegridview.cpp.

◆ currentIndexCleared

bool QDeclarativeGridViewPrivate::currentIndexCleared

Definition at line 495 of file qdeclarativegridview.cpp.

◆ currentItem

FxGridItem* QDeclarativeGridViewPrivate::currentItem

Definition at line 455 of file qdeclarativegridview.cpp.

◆ deferredRelease

bool QDeclarativeGridViewPrivate::deferredRelease

Definition at line 493 of file qdeclarativegridview.cpp.

◆ fixCurrentVisibility

bool QDeclarativeGridViewPrivate::fixCurrentVisibility

Definition at line 490 of file qdeclarativegridview.cpp.

◆ flow

QDeclarativeGridView::Flow QDeclarativeGridViewPrivate::flow

Definition at line 457 of file qdeclarativegridview.cpp.

◆ footer

FxGridItem* QDeclarativeGridViewPrivate::footer

Definition at line 480 of file qdeclarativegridview.cpp.

◆ footerComponent

QDeclarativeComponent* QDeclarativeGridViewPrivate::footerComponent

Definition at line 479 of file qdeclarativegridview.cpp.

◆ haveHighlightRange

bool QDeclarativeGridViewPrivate::haveHighlightRange

Definition at line 494 of file qdeclarativegridview.cpp.

◆ header

FxGridItem* QDeclarativeGridViewPrivate::header

Definition at line 482 of file qdeclarativegridview.cpp.

◆ headerComponent

QDeclarativeComponent* QDeclarativeGridViewPrivate::headerComponent

Definition at line 481 of file qdeclarativegridview.cpp.

◆ highlight

FxGridItem* QDeclarativeGridViewPrivate::highlight

Definition at line 471 of file qdeclarativegridview.cpp.

◆ highlightComponent

QDeclarativeComponent* QDeclarativeGridViewPrivate::highlightComponent

Definition at line 470 of file qdeclarativegridview.cpp.

◆ highlightMoveDuration

int QDeclarativeGridViewPrivate::highlightMoveDuration

Definition at line 478 of file qdeclarativegridview.cpp.

◆ highlightRange

QDeclarativeGridView::HighlightRangeMode QDeclarativeGridViewPrivate::highlightRange

Definition at line 469 of file qdeclarativegridview.cpp.

◆ highlightRangeEnd

qreal QDeclarativeGridViewPrivate::highlightRangeEnd

Definition at line 466 of file qdeclarativegridview.cpp.

◆ highlightRangeEndValid

bool QDeclarativeGridViewPrivate::highlightRangeEndValid

Definition at line 468 of file qdeclarativegridview.cpp.

◆ highlightRangeStart

qreal QDeclarativeGridViewPrivate::highlightRangeStart

Definition at line 465 of file qdeclarativegridview.cpp.

◆ highlightRangeStartValid

bool QDeclarativeGridViewPrivate::highlightRangeStartValid

Definition at line 467 of file qdeclarativegridview.cpp.

◆ highlightXAnimator

QSmoothedAnimation* QDeclarativeGridViewPrivate::highlightXAnimator

Definition at line 476 of file qdeclarativegridview.cpp.

◆ highlightYAnimator

QSmoothedAnimation* QDeclarativeGridViewPrivate::highlightYAnimator

Definition at line 477 of file qdeclarativegridview.cpp.

◆ itemCount

int QDeclarativeGridViewPrivate::itemCount

Definition at line 464 of file qdeclarativegridview.cpp.

◆ layoutDirection

Qt::LayoutDirection QDeclarativeGridViewPrivate::layoutDirection

Definition at line 456 of file qdeclarativegridview.cpp.

◆ layoutScheduled

bool QDeclarativeGridViewPrivate::layoutScheduled

Definition at line 492 of file qdeclarativegridview.cpp.

◆ lazyRelease

bool QDeclarativeGridViewPrivate::lazyRelease

Definition at line 491 of file qdeclarativegridview.cpp.

◆ model

QDeclarativeGuard<QDeclarativeVisualModel> QDeclarativeGridViewPrivate::model

Definition at line 451 of file qdeclarativegridview.cpp.

◆ modelVariant

QVariant QDeclarativeGridViewPrivate::modelVariant

Definition at line 452 of file qdeclarativegridview.cpp.

◆ moveReason

MovementReason QDeclarativeGridViewPrivate::moveReason

Definition at line 474 of file qdeclarativegridview.cpp.

◆ ownModel

bool QDeclarativeGridViewPrivate::ownModel

Definition at line 487 of file qdeclarativegridview.cpp.

◆ requestedIndex

int QDeclarativeGridViewPrivate::requestedIndex

Definition at line 463 of file qdeclarativegridview.cpp.

◆ snapMode

QDeclarativeGridView::SnapMode QDeclarativeGridViewPrivate::snapMode

Definition at line 485 of file qdeclarativegridview.cpp.

◆ trackedItem

FxGridItem* QDeclarativeGridViewPrivate::trackedItem

Definition at line 472 of file qdeclarativegridview.cpp.

◆ unrequestedItems

QHash<QDeclarativeItem*,int> QDeclarativeGridViewPrivate::unrequestedItems

Definition at line 454 of file qdeclarativegridview.cpp.

◆ visibleIndex

int QDeclarativeGridViewPrivate::visibleIndex

Definition at line 458 of file qdeclarativegridview.cpp.

◆ visibleItems

QList<FxGridItem*> QDeclarativeGridViewPrivate::visibleItems

Definition at line 453 of file qdeclarativegridview.cpp.

◆ wrap

bool QDeclarativeGridViewPrivate::wrap

Definition at line 488 of file qdeclarativegridview.cpp.


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