89
89
// no animation, so we simply position the component
90
90
listItem->contentItem->setX(to);
91
// lock contentItem left/right edges
92
listItem->lockContentItem(true);
93
95
snap->setTargetObject(listItem->contentItem);
134
136
QObject::disconnect(snap, 0, 0, 0);
136
138
UCListItemPrivate *listItem = UCListItemPrivate::get(item);
137
if (listItem->attachedProperties) {
139
if (listItem->parentAttached) {
138
140
// restore flickable's interactive and cleanup
139
listItem->attachedProperties->disableInteractive(item, false);
141
listItem->parentAttached->disableInteractive(item, false);
140
142
// no need to listen flickables any longer
141
143
listItem->listenToRebind(false);
145
147
UCActionPanel::ungrabPanel(listItem->trailingPanel);
146
148
// set contentMoved to false
147
149
listItem->setContentMoving(false);
150
// lock contentItem left/right edges
151
listItem->lockContentItem(true);
605
610
// connects/disconnects from the Flickable anchestor to get notified when to do rebound
606
611
void UCListItemPrivate::listenToRebind(bool listen)
608
if (attachedProperties) {
613
if (parentAttached) {
610
attachedProperties->listenToRebind(q, listen);
614
void UCListItemPrivate::resize()
617
QRectF rect(q->boundingRect());
618
if (divider && divider->m_visible) {
619
rect.setHeight(rect.height() - divider->m_thickness);
621
contentItem->setSize(rect.size());
615
parentAttached->listenToRebind(q, listen);
619
// lock/unlock contentItem's left and right anchors to the ListItem's left and right
620
void UCListItemPrivate::lockContentItem(bool lock)
622
QQuickAnchors *contentAnchors = QQuickItemPrivate::get(contentItem)->anchors();
624
contentAnchors->setLeft(left());
625
contentAnchors->setRight(right());
627
contentAnchors->resetLeft();
628
contentAnchors->resetRight();
632
// adjust contentItem height depending on teh divider's visibility
633
void UCListItemPrivate::adjustContentItemHeight()
635
QQuickAnchors *contentAnchors = QQuickItemPrivate::get(contentItem)->anchors();
636
if (divider->m_visible) {
637
contentAnchors->setBottomMargin(divider->m_thickness);
639
contentAnchors->resetBottomMargin();
624
643
void UCListItemPrivate::update()
848
867
UCStyledItemBase::componentComplete();
869
// anchor contentItem prior doing anything else
870
QQuickAnchors *contentAnchors = QQuickItemPrivate::get(d->contentItem)->anchors();
871
contentAnchors->setTop(d->top());
872
contentAnchors->setBottom(d->bottom());
873
d->adjustContentItemHeight();
874
d->lockContentItem(true);
851
877
/* We only deal with ListView, as for other cases we would need to check the children
852
878
* changes, which would have an enormous impact on performance in case of huge amount
882
908
// attach ListItem properties to the flickable or to the parent item
883
909
if (d->flickable) {
884
910
// connect to flickable to get width changes
885
d->attachedProperties = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(d->flickable));
911
d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(d->flickable));
886
912
} else if (data.item) {
887
d->attachedProperties = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(data.item));
913
d->parentAttached = static_cast<UCViewItemsAttached*>(qmlAttachedPropertiesObject<UCViewItemsAttached>(data.item));
889
915
// mark as not ready, so no action should be performed which depends on readyness
890
916
d->ready = false;
891
917
// about to be deleted or reparented, disable attached
892
d->attachedProperties = 0;
918
d->parentAttached = 0;
904
void UCListItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
906
UCStyledItemBase::geometryChanged(newGeometry, oldGeometry);
907
// resize contentItem item
912
930
QSGNode *UCListItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
966
984
UCStyledItemBase::mousePressEvent(event);
968
if (d->attachedProperties && d->attachedProperties->isMoving()) {
986
if (d->parentAttached && d->parentAttached->isMoving()) {
969
987
// while moving, we cannot select any items
980
998
UCActionPanel::grabPanel(&d->leadingPanel, this, true);
981
999
UCActionPanel::grabPanel(&d->trailingPanel, this, false);
982
if (d->attachedProperties) {
983
d->attachedProperties->disableInteractive(this, true);
1000
if (d->parentAttached) {
1001
d->parentAttached->disableInteractive(this, true);
996
1014
if (d->highlighted) {
997
1015
d->listenToRebind(false);
998
if (d->attachedProperties) {
999
d->attachedProperties->disableInteractive(this, false);
1016
if (d->parentAttached) {
1017
d->parentAttached->disableInteractive(this, false);
1002
1020
if (!d->suppressClick) {
1036
1054
// still in use in other panels. See UCListItemActionsPrivate::connectToListItem
1037
1055
leadingAttached = UCActionPanel::grabPanel(&d->leadingPanel, this, true);
1038
1056
trailingAttached = UCActionPanel::grabPanel(&d->trailingPanel, this, false);
1039
if (d->attachedProperties) {
1040
d->attachedProperties->disableInteractive(this, true);
1057
// unlock contentItem's left/right edges
1058
d->lockContentItem(false);
1059
if (d->parentAttached) {
1060
d->parentAttached->disableInteractive(this, true);
1042
1062
// create animator if not created yet
1043
1063
if (!d->animator) {