88
88
// no animation, so we simply position the component
89
89
listItem->contentItem->setX(to);
90
// lock contentItem left/right edges
91
listItem->lockContentItem(true);
92
94
snap->setTargetObject(listItem->contentItem);
133
135
QObject::disconnect(snap, 0, 0, 0);
135
137
UCListItemPrivate *listItem = UCListItemPrivate::get(item);
136
if (listItem->attachedProperties) {
138
if (listItem->parentAttached) {
137
139
// restore flickable's interactive and cleanup
138
listItem->attachedProperties->disableInteractive(item, false);
140
listItem->parentAttached->disableInteractive(item, false);
139
141
// no need to listen flickables any longer
140
142
listItem->listenToRebind(false);
144
146
UCActionPanel::ungrabPanel(listItem->trailingPanel);
145
147
// set contentMoved to false
146
148
listItem->setContentMoving(false);
149
// lock contentItem left/right edges
150
listItem->lockContentItem(true);
602
607
// connects/disconnects from the Flickable anchestor to get notified when to do rebound
603
608
void UCListItemPrivate::listenToRebind(bool listen)
605
if (attachedProperties) {
610
if (parentAttached) {
607
attachedProperties->listenToRebind(q, listen);
611
void UCListItemPrivate::resize()
614
QRectF rect(q->boundingRect());
615
if (divider && divider->m_visible) {
616
rect.setHeight(rect.height() - divider->m_thickness);
618
contentItem->setSize(rect.size());
612
parentAttached->listenToRebind(q, listen);
616
// lock/unlock contentItem's left and right anchors to the ListItem's left and right
617
void UCListItemPrivate::lockContentItem(bool lock)
619
QQuickAnchors *contentAnchors = QQuickItemPrivate::get(contentItem)->anchors();
621
contentAnchors->setLeft(left());
622
contentAnchors->setRight(right());
624
contentAnchors->resetLeft();
625
contentAnchors->resetRight();
629
// adjust contentItem height depending on teh divider's visibility
630
void UCListItemPrivate::adjustContentItemHeight()
632
QQuickAnchors *contentAnchors = QQuickItemPrivate::get(contentItem)->anchors();
633
if (divider->m_visible) {
634
contentAnchors->setBottomMargin(divider->m_thickness);
636
contentAnchors->resetBottomMargin();
621
640
void UCListItemPrivate::update()
845
864
UCStyledItemBase::componentComplete();
866
// anchor contentItem prior doing anything else
867
QQuickAnchors *contentAnchors = QQuickItemPrivate::get(d->contentItem)->anchors();
868
contentAnchors->setTop(d->top());
869
contentAnchors->setBottom(d->bottom());
870
d->adjustContentItemHeight();
871
d->lockContentItem(true);
848
874
/* We only deal with ListView, as for other cases we would need to check the children
849
875
* changes, which would have an enormous impact on performance in case of huge amount
879
905
// attach ListItem properties to the flickable or to the parent item
880
906
if (d->flickable) {
881
907
// connect to flickable to get width changes
882
d->attachedProperties = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(d->flickable));
908
d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(d->flickable));
883
909
} else if (data.item) {
884
d->attachedProperties = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(data.item));
910
d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(data.item));
886
912
// mark as not ready, so no action should be performed which depends on readyness
887
913
d->ready = false;
888
914
// about to be deleted or reparented, disable attached
889
d->attachedProperties = 0;
915
d->parentAttached = 0;
901
void UCListItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
903
UCStyledItemBase::geometryChanged(newGeometry, oldGeometry);
904
// resize contentItem item
909
927
QSGNode *UCListItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
963
981
UCStyledItemBase::mousePressEvent(event);
965
if (d->attachedProperties && d->attachedProperties->isMoving()) {
983
if (d->parentAttached && d->parentAttached->isMoving()) {
966
984
// while moving, we cannot select any items
976
994
UCActionPanel::grabPanel(&d->leadingPanel, this, true);
977
995
UCActionPanel::grabPanel(&d->trailingPanel, this, false);
978
if (d->attachedProperties) {
979
d->attachedProperties->disableInteractive(this, true);
996
if (d->parentAttached) {
997
d->parentAttached->disableInteractive(this, true);
992
1010
if (d->highlighted) {
993
1011
d->listenToRebind(false);
994
if (d->attachedProperties) {
995
d->attachedProperties->disableInteractive(this, false);
1012
if (d->parentAttached) {
1013
d->parentAttached->disableInteractive(this, false);
998
1016
if (!d->suppressClick) {
1027
1045
// still in use in other panels. See UCListItemActionsPrivate::connectToListItem
1028
1046
leadingAttached = UCActionPanel::grabPanel(&d->leadingPanel, this, true);
1029
1047
trailingAttached = UCActionPanel::grabPanel(&d->trailingPanel, this, false);
1030
if (d->attachedProperties) {
1031
d->attachedProperties->disableInteractive(this, true);
1048
// unlock contentItem's left/right edges
1049
d->lockContentItem(false);
1050
if (d->parentAttached) {
1051
d->parentAttached->disableInteractive(this, true);
1033
1053
// create animator if not created yet
1034
1054
if (!d->animator) {