8#include <private/qqmlobjectmodel_p.h>
9#include <private/qquicksmoothedanimation_p_p.h>
11#include <QtGui/qevent.h>
12#include <QtCore/qmath.h>
13#include <QtCore/qcoreapplication.h>
14#include "qplatformdefs.h"
20#ifndef QML_FLICK_SNAPONETHRESHOLD
21#define QML_FLICK_SNAPONETHRESHOLD 30
61 return colSize * (columns-1) -
itemX();
87 moveTo(pointForPosition(col,
row), immediate);
165#if QT_CONFIG(quick_viewtransitions)
166 void translateAndTransitionItemsAfter(
int afterModelIndex,
const ChangeResult &insertionResult,
const ChangeResult &removalResult)
override;
281 return firstItem->
colPos();
305 return firstItem->
rowPos();
348 pos += highlightStart;
352 snapPos -= highlightStart;
373 if (
item->index == -1)
386 if (
item->index == -1)
394 return gridItem->
index;
406 return -
q->leftMargin();
417 return -
pos -
q->width();
429 return -
pos -
q->height();
433 return -
q->topMargin();
435 return -
q->height() +
q->bottomMargin();
443 ?
q->width() -
q->leftMargin() -
q->rightMargin()
444 :
q->height() -
q->topMargin() -
q->bottomMargin();
460 item->trackGeometry(
true);
469 rowPos = lastItem->
rowPos();
479 modelIndex = modelIndex < 0 ?
visibleIndex : modelIndex + 1;
490 else if (modelIndex < 0)
500 bool changed =
false;
505 qCDebug(lcItemViewDelegateLifecycle) <<
"refill: append item" << modelIndex << colPos << rowPos;
508#if QT_CONFIG(quick_viewtransitions)
510 item->setPosition(colPos, rowPos,
true);
529 rowPos = firstItem->
rowPos();
530 colPos = firstItem->
colPos();
541 qCDebug(lcItemViewDelegateLifecycle) <<
"refill: prepend item" <<
visibleIndex-1 <<
"top pos" << rowPos << colPos;
545#if QT_CONFIG(quick_viewtransitions)
547 item->setPosition(colPos, rowPos,
true);
564#if QT_CONFIG(quick_viewtransitions)
565 if (
item->transitionScheduledOrRunning()) {
566 qCDebug(lcItemViewDelegateLifecycle) <<
"\tnot releasing animating item:" <<
item->index <<
item->item->objectName();
567 item->releaseAfterTransition =
true;
568 releasePendingTransition.append(
item);
579 bool changed =
false;
584 if (
item->attached->delayRemove())
586 qCDebug(lcItemViewDelegateLifecycle) <<
"refill: remove first" <<
visibleIndex <<
"top end pos" <<
item->endRowPos();
587 if (
item->index != -1)
596 if (
item->attached->delayRemove())
623 if (colPos != col *
colSize()) {
635 if (
item->index >= fromModelIndex) {
636 item->setPosition(colPos, rowPos);
684 int moveCount = (forwards - backwards) /
rowSize();
685 if (moveCount == 0 && changeBeforeVisible != 0)
694 bool changed =
false;
715 std::unique_ptr<FxGridItemSG> newHighlight
716 = std::make_unique<FxGridItemSG>(
item,
q,
true);
717 newHighlight->trackGeometry(
true);
732 emit q->highlightItemChanged();
789 bool created =
false;
817 gridItem->
setPosition(colOffset, endPos + rowOffset);
820 if (endPos <= visiblePos || gridItem->
endPosition() <= endPos + rowOffset)
821 gridItem->
setPosition(colOffset, endPos + rowOffset);
828 emit q->footerItemChanged();
834 qmlAttachedPropertiesObject<QQuickGridView>(
item));
842 bool created =
false;
870 gridItem->
setPosition(colOffset, startPos + rowOffset);
874 if (tempPos <= startPos || headerPos > startPos + rowOffset)
875 gridItem->
setPosition(colOffset, startPos + rowOffset);
885 emit q->headerItemChanged();
897 || !actualItem->transitionScheduledOrRunning()
931 else if (
data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -
rowSize()/2)
935 tempPosition -=
bias;
951 if (topItem && (isInBounds || strictHighlightRange)) {
961 }
else if (bottomItem && isInBounds) {
976 data.fixingUp =
true;
991 viewPos = -viewPos-
size();
996 data.fixingUp =
true;
1006 data.inOvershoot =
false;
1013 data.fixingUp =
false;
1019 qreal maxDistance = 0;
1031 maxDistance =
qAbs(
data.flickTarget -
data.move.value());
1048 maxDistance =
qAbs(
data.flickTarget -
data.move.value());
1058 if (maxDistance > 0 || overShoot) {
1069 qreal overshootDist = 0.0;
1084 data.flickTarget += overshootDist;
1087 data.flickTarget -= overshootDist;
1093 qreal adjv2 = accel * 2.0f *
qAbs(adjDist);
1258 if (
d->autoHighlight != autoHighlight) {
1259 if (!autoHighlight &&
d->highlightXAnimator) {
1260 d->highlightXAnimator->stop();
1261 d->highlightYAnimator->stop();
1588 if (
d->highlightMoveDuration != duration) {
1589 if (
d->highlightYAnimator) {
1590 d->highlightXAnimator->userDuration = duration;
1591 d->highlightYAnimator->userDuration = duration;
1615 if (
d->flow !=
flow) {
1626 d->regenerate(
true);
1643 return d->cellWidth;
1651 d->updateViewport();
1653 d->forceLayoutPolish();
1661 return d->cellHeight;
1669 d->updateViewport();
1671 d->forceLayoutPolish();
1697 if (
d->snapMode !=
mode) {
2055 if (
d->inViewportMoved)
2057 d->inViewportMoved =
true;
2060 if (
d->isContentFlowReversed())
2065 if (
d->isContentFlowReversed())
2071 d->refillOrLayout();
2074 qreal from =
d->isContentFlowReversed() ? -
d->position()-
d->displayMarginBeginning-
d->size() :
d->position()-
d->displayMarginBeginning;
2075 qreal to =
d->isContentFlowReversed() ? -
d->position()+
d->displayMarginEnd :
d->position()+
d->size()+
d->displayMarginEnd;
2080 if (
d->currentItem) {
2085 if (
d->hData.flicking ||
d->vData.flicking ||
d->hData.moving ||
d->vData.moving)
2091 qreal viewPos =
d->isContentFlowReversed() ? -
d->position()-
d->size() :
d->position();
2092 if (
pos > viewPos +
d->highlightRangeEnd -
d->highlight->size())
2093 pos = viewPos +
d->highlightRangeEnd -
d->highlight->size();
2094 if (pos < viewPos + d->highlightRangeStart)
2095 pos = viewPos +
d->highlightRangeStart;
2097 if (
pos !=
d->highlight->position()) {
2098 d->highlightXAnimator->stop();
2099 d->highlightYAnimator->stop();
2103 d->updateHighlight();
2107 int idx =
d->snapIndex();
2108 if (idx >= 0 && idx !=
d->currentIndex) {
2109 d->updateCurrent(idx);
2113 &&
d->autoHighlight) {
2115 d->highlightXAnimator->to =
d->currentItem->itemX();
2117 d->highlightYAnimator->to =
d->currentItem->itemY();
2123 d->inViewportMoved =
false;
2129 if (
d->model &&
d->model->count() && ((
d->interactive && !
d->explicitKeyNavigationEnabled)
2130 || (
d->explicitKeyNavigationEnabled &&
d->keyNavigationEnabled))) {
2133 switch (
event->key()) {
2163 if (newGeometry.
width() != oldGeometry.
width()
2165 d->setPosition(
d->position());
2166 }
else if (newGeometry.
width() != oldGeometry.
width()) {
2168 }
else if (newGeometry.
height() != oldGeometry.
height()) {
2184 qmlAttachedPropertiesObject<QQuickGridView>(
item));
2204 const int count =
d->model ?
d->model->count() : 0;
2246 const int count =
d->model ?
d->model->count() : 0;
2289 const int count =
d->model ?
d->model->count() : 0;
2332 const int count =
d->model ?
d->model->count() : 0;
2366 if (
q->size().isEmpty())
2369 int modelIndex = change.
index;
2386 if (
item->index != -1 &&
item->index >= modelIndex)
2401 colPos = gridItem->
colPos();
2402 rowPos = gridItem->
rowPos();
2407 rowPos = gridItem->
rowPos();
2417#if QT_CONFIG(quick_viewtransitions)
2420 if (
item->index != -1 &&
item->index >= modelIndex) {
2433 int insertionIdx =
index;
2446 item->index = modelIndex +
i;
2454 if (insertionIdx == 0)
2458#if QT_CONFIG(quick_viewtransitions)
2467 if (--colNum < 0 ) {
2480 int firstOkIdx = -1;
2488 for (
int i = 0;
i < firstOkIdx;
i++) {
2500 item->index = modelIndex +
i;
2501 bool newItem = !
item;
2522#if QT_CONFIG(quick_viewtransitions)
2546#if QT_CONFIG(quick_viewtransitions)
2547void QQuickGridViewPrivate::translateAndTransitionItemsAfter(
int afterModelIndex,
const ChangeResult &insertionResult,
const ChangeResult &removalResult)
2552 int markerItemIndex = -1;
2555 markerItemIndex =
i;
2559 if (markerItemIndex < 0)
2563 int countItemsRemoved = -(removalResult.sizeChangesAfterVisiblePos /
rowSize());
2566 int changeBeforeVisible = insertionResult.countChangeBeforeVisible - removalResult.countChangeBeforeVisible;
2567 if (changeBeforeVisible != 0)
2568 countItemsRemoved += (changeBeforeVisible %
columns) - (
columns - 1);
2570 countItemsRemoved -= removalResult.countChangeAfterVisibleItems;
2574 if (gridItem->
position() >= viewEndPos)
2576 if (!gridItem->transitionScheduledOrRunning()) {
2579 int indexDiff = gridItem->
index - countItemsRemoved;
2733#include "moc_qquickgridview_p.cpp"
bool contains(qreal x, qreal y) const override
qreal position() const override
void setPosition(qreal col, qreal row, bool immediate=false)
qreal size() const override
qreal sectionSize() const override
qreal endPosition() const override
FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own)
Type
This enum type defines the valid event types in Qt.
qreal y() const
This convenience function is equivalent to calling pos().y().
qreal x() const
This convenience function is equivalent to calling pos().x().
void setVisible(bool visible)
If visible is true, the item is made visible.
The QKeyEvent class describes a key event.
qsizetype size() const noexcept
void removeFirst() noexcept
bool isEmpty() const noexcept
const T & constLast() const noexcept
iterator insert(qsizetype i, parameter_type t)
bool removeOne(const AT &t)
const_reference at(qsizetype i) const noexcept
void prepend(rvalue_ref t)
const T & constFirst() const noexcept
void removeLast() noexcept
void append(parameter_type t)
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it.
\inmodule QtCore\reentrant
IncubationMode
Specifies the mode the incubator operates in.
The QQmlProperty class abstracts accessing properties on objects created from QML.
virtual bool flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QQuickTimeLineCallback::Callback fixupCallback, QEvent::Type eventType, qreal velocity)
MovementReason moveReason
qreal overShootDistance(qreal velocity) const
virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent)
QQuickFlickable::BoundsBehavior boundsBehavior
void setContentWidth(qreal)
virtual void setContentX(qreal pos)
virtual void viewportMoved(Qt::Orientations orient)
virtual void setContentY(qreal pos)
void setFlickableDirection(FlickableDirection)
void setContentHeight(qreal)
qreal footerSize() const override
bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) override
qreal snapPosAt(qreal pos) const
void fixupPosition() override
void updateViewport() override
void updateHighlight() override
bool showFooterForIndex(int index) const override
bool isContentFlowReversed() const override
bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, QQuickTimeLineCallback::Callback fixupCallback, QEvent::Type eventType, qreal velocity) override
void repositionPackageItemAt(QQuickItem *item, int index) override
bool showHeaderForIndex(int index) const override
bool needsRefillForAddedOrRemovedIndex(int index) const override
QQuickGridView::Flow flow
void createHighlight(bool onDestruction=false) override
QQuickGridView::SnapMode snapMode
void initializeViewItem(FxViewItem *item) override
void removeItem(FxViewItem *item)
qreal positionAt(int index) const override
void updateFooter() override
Qt::Orientation layoutOrientation() const override
qreal endPositionAt(int index) const override
void setPosition(qreal pos) override
void resetFirstItemPosition(qreal pos=0.0) override
bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList< FxViewItem * > *addedItems, QList< MovedItem > *movingIntoView) override
void initializeComponentItem(QQuickItem *item) const override
void adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible) override
QSmoothedAnimation * highlightYAnimator
qreal rowPosAt(int modelIndex) const
void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) override
FxViewItem * snapItemAt(qreal pos) const
void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override
void resetHighlightPosition() override
void changedVisibleIndex(int newIndex) override
void layoutVisibleItems(int fromModelIndex=0) override
qreal contentYForPosition(qreal pos) const
qreal lastPosition() const override
FxViewItem * newViewItem(int index, QQuickItem *item) override
QSmoothedAnimation * highlightXAnimator
qreal contentXForPosition(qreal pos) const
qreal headerSize() const override
qreal originPosition() const override
void updateHeader() override
bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) override
qreal colPosAt(int modelIndex) const
void initializeCurrentItem() override
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void setHighlightFollowsCurrentItem(bool) override
void moveCurrentIndexRight()
\qmlmethod QtQuick::GridView::moveCurrentIndexRight()
static QQuickGridViewAttached * qmlAttachedProperties(QObject *)
\qmlmethod QtQuick::GridView::positionViewAtIndex(int index, PositionMode mode)
void moveCurrentIndexDown()
\qmlmethod QtQuick::GridView::moveCurrentIndexDown()
void moveCurrentIndexUp()
\qmlmethod QtQuick::GridView::moveCurrentIndexUp()
QQuickGridView(QQuickItem *parent=nullptr)
\qmltype GridView \instantiates QQuickGridView \inqmlmodule QtQuick
void moveCurrentIndexLeft()
\qmlmethod QtQuick::GridView::moveCurrentIndexLeft()
void setCellHeight(qreal)
void setHighlightMoveDuration(int) override
\qmlattachedproperty bool QtQuick::GridView::isCurrentItem \readonly
void setSnapMode(SnapMode mode)
void viewportMoved(Qt::Orientations) override
\qmlproperty Component QtQuick::GridView::footer This property holds the component to use as the foot...
void keyPressEvent(QKeyEvent *) override
This event handler can be reimplemented in a subclass to receive key press events for an item.
static QQuickItemPrivate * get(QQuickItem *item)
void setView(QQuickItemView *view)
QMultiHash< QQmlChangeSet::MoveKey, FxViewItem * > removedItems
QPointer< QQuickItem > item
virtual qreal position() const =0
void setVisible(bool visible)
void moveTo(const QPointF &pos, bool immediate)
void trackGeometry(bool track)
int findLastVisibleIndex(int defaultValue=-1) const
qreal highlightRangeStart
virtual void updateViewport()
FxViewItem * visibleItem(int modelIndex) const
int highlightMoveDuration
QQuickItem * createHighlightItem() const
QPointer< QQmlInstanceModel > model
QList< FxViewItem * > visibleItems
int displayMarginBeginning
virtual void initializeViewItem(FxViewItem *)
qreal endPosition() const
QQmlComponent * footerComponent
QQuickItemViewChangeSet currentChanges
void applyPendingChanges()
QQuickItemView::VerticalLayoutDirection verticalLayoutDirection
int mapFromModel(int modelIndex) const
void updateVisibleIndex()
QQuickItem * createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault=false) const
void releaseVisibleItems(QQmlInstanceModel::ReusableFlag reusableFlag)
FxViewItem * createItem(int modelIndex, QQmlIncubator::IncubationMode incubationMode=QQmlIncubator::AsynchronousIfNested)
QQmlComponent * headerComponent
virtual bool releaseItem(FxViewItem *item, QQmlInstanceModel::ReusableFlag reusableFlag)
QQmlInstanceModel::ReusableFlag reusableFlag
std::unique_ptr< FxViewItem > highlight
virtual void setHighlightFollowsCurrentItem(bool)
void setContentX(qreal pos) override
Qt::LayoutDirection effectiveLayoutDirection
void setContentY(qreal pos) override
virtual void initItem(int index, QObject *item)
virtual void setHighlightMoveDuration(int)
void setCurrentIndex(int idx)
VerticalLayoutDirection verticalLayoutDirection
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
virtual void keyPressEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key press events for an item.
qreal width
This property holds the width of this item.
qreal height
This property holds the height of this item.
void reset(QQuickTimeLineValue &)
Cancel (but don't complete) all scheduled actions for timeLineValue.
int accel(QQuickTimeLineValue &, qreal velocity, qreal accel)
Decelerate timeLineValue from the starting velocity to zero at the given acceleration rate.
void callback(const QQuickTimeLineCallback &)
Execute the event.
void set(QQuickTimeLineValue &, qreal)
Set the value of timeLineValue.
void move(QQuickTimeLineValue &, qreal destination, int time=500)
Linearly change the timeLineValue from its current value to the given destination value over time mil...
\inmodule QtCore\reentrant
constexpr qreal height() const noexcept
Returns the height of the rectangle.
constexpr qreal width() const noexcept
Returns the width of the rectangle.
cache insert(employee->id(), employee)
Combined button and popup list for selecting options.
qfloat16 qSqrt(qfloat16 f)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
n void setPosition(void) \n\
GLint GLfloat GLfloat GLfloat v2
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
QObject * qmlAttachedPropertiesObject(QObject *object, QQmlAttachedPropertiesFunc func, bool create)
QQuickItem * qmlobject_cast< QQuickItem * >(QObject *object)
#define QML_FLICK_SNAPONETHRESHOLD
QLatin1StringView QLatin1String
#define QT_CONFIG(feature)
std::uniform_real_distribution dist(1, 2.5)
[2]
MoveKey moveKey(int index) const
QQmlNullableValue< qreal > visiblePos
qreal sizeChangesAfterVisiblePos
qreal sizeChangesBeforeVisiblePos
int countChangeBeforeVisible
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent