class FxGridItemSG : public FxViewItem
{
public:
- FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own, bool trackGeometry) : FxViewItem(i, own, trackGeometry), view(v) {
+ FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own) : FxViewItem(i, v, own), view(v) {
attached = static_cast<QQuickGridViewAttached*>(qmlAttachedPropertiesObject<QQuickGridView>(item));
- if (trackGeometry) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- }
-
- ~FxGridItemSG() {
- if (trackGeom) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
}
qreal position() const {
{
Q_Q(QQuickGridView);
Q_UNUSED(modelIndex);
- return new FxGridItemSG(item, q, false, false);
+ return new FxGridItemSG(item, q, false);
}
void QQuickGridViewPrivate::initializeViewItem(FxViewItem *item)
QQuickItemViewPrivate::initializeViewItem(item);
// need to track current items that are animating
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ item->trackGeometry(true);
}
bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer)
if (currentItem) {
QQuickItem *item = createHighlightItem();
if (item) {
- FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true, true);
+ FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true);
+ newHighlight->trackGeometry(true);
if (autoHighlight)
resetHighlightPosition();
highlightXAnimator = new QSmoothedAnimation;
QQuickItem *item = createComponentItem(footerComponent, 1.0);
if (!item)
return;
- footer = new FxGridItemSG(item, q, true, true);
+ footer = new FxGridItemSG(item, q, true);
+ footer->trackGeometry(true);
created = true;
}
QQuickItem *item = createComponentItem(headerComponent, 1.0);
if (!item)
return;
- header = new FxGridItemSG(item, q, true, true);
+ header = new FxGridItemSG(item, q, true);
+ header->trackGeometry(true);
created = true;
}
#define QML_VIEW_DEFAULTCACHEBUFFER 320
#endif
-FxViewItem::FxViewItem(QQuickItem *i, bool own, bool trackGeometry)
+FxViewItem::FxViewItem(QQuickItem *i, QQuickItemView *v, bool own)
: item(i)
+ , view(v)
, transitionableItem(0)
, attached(0)
, ownItem(own)
, releaseAfterTransition(false)
- , trackGeom(trackGeometry)
+ , trackGeom(false)
{
}
QQuickItemPrivate::get(item)->setCulled(!visible);
}
+void FxViewItem::trackGeometry(bool track)
+{
+ if (track) {
+ if (!trackGeom) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
+ trackGeom = true;
+ }
+ } else {
+ if (trackGeom) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
+ trackGeom = false;
+ }
+ }
+}
+
QQuickItemViewTransitioner::TransitionType FxViewItem::scheduledTransitionType() const
{
return transitionableItem ? transitionableItem->nextTransitionType : QQuickItemViewTransitioner::NoTransition;
bool isRemove = it.key().moveId < 0;
if (isRemove) {
FxViewItem *item = *it;
+ item->trackGeometry(false);
item->releaseAfterTransition = true;
releasePendingTransition.append(item);
item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, true);
return true;
if (trackedItem == item)
trackedItem = 0;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
+ item->trackGeometry(false);
+
QQmlInstanceModel::ReleaseFlags flags = model->release(item->item);
if (flags == 0) {
// item was not destroyed, and we no longer reference it.
class FxViewItem
{
public:
- FxViewItem(QQuickItem *, bool own, bool trackGeometry);
+ FxViewItem(QQuickItem *, QQuickItemView *, bool own);
virtual ~FxViewItem();
qreal itemX() const;
void moveTo(const QPointF &pos, bool immediate);
void setVisible(bool visible);
+ void trackGeometry(bool track);
QQuickItemViewTransitioner::TransitionType scheduledTransitionType() const;
bool transitionScheduledOrRunning() const;
virtual bool contains(qreal x, qreal y) const = 0;
QQuickItem *item;
+ QQuickItemView *view;
QQuickItemViewTransitionableItem *transitionableItem;
QQuickItemViewAttached *attached;
int index;
class FxListItemSG : public FxViewItem
{
public:
- FxListItemSG(QQuickItem *i, QQuickListView *v, bool own, bool trackGeometry) : FxViewItem(i, own, trackGeometry), view(v) {
+ FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, v, own), view(v) {
attached = static_cast<QQuickListViewAttached*>(qmlAttachedPropertiesObject<QQuickListView>(item));
- if (trackGeometry) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- }
-
- ~FxListItemSG() {
- if (trackGeom) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
}
inline QQuickItem *section() const {
{
Q_Q(QQuickListView);
- FxListItemSG *listItem = new FxListItemSG(item, q, false, false);
+ FxListItemSG *listItem = new FxListItemSG(item, q, false);
listItem->index = modelIndex;
// initialise attached properties
{
QQuickItemViewPrivate::initializeViewItem(item);
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ // need to track current items that are animating
+ item->trackGeometry(true);
if (sectionCriteria && sectionCriteria->delegate()) {
if (QString::compare(item->attached->m_prevSection, item->attached->m_section, Qt::CaseInsensitive))
if (currentItem) {
QQuickItem *item = createHighlightItem();
if (item) {
- FxListItemSG *newHighlight = new FxListItemSG(item, q, true, true);
+ FxListItemSG *newHighlight = new FxListItemSG(item, q, true);
+ newHighlight->trackGeometry(true);
if (autoHighlight) {
newHighlight->setSize(static_cast<FxListItemSG*>(currentItem)->itemSize());
QQuickItem *item = createComponentItem(footerComponent, 1.0);
if (!item)
return;
- footer = new FxListItemSG(item, q, true, true);
+ footer = new FxListItemSG(item, q, true);
+ footer->trackGeometry(true);
created = true;
}
QQuickItem *item = createComponentItem(headerComponent, 1.0);
if (!item)
return;
- header = new FxListItemSG(item, q, true, true);
+ header = new FxListItemSG(item, q, true);
+ header->trackGeometry(true);
created = true;
}