Merge lp:~zsombi/ubuntu-ui-toolkit/65-last-divider-invisible into lp:~zsombi/ubuntu-ui-toolkit/listitem-master

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: 1298
Merged at revision: 1278
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/65-last-divider-invisible
Merge into: lp:~zsombi/ubuntu-ui-toolkit/listitem-master
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/60-action-value-type
Diff against target: 143 lines (+35/-3)
5 files modified
modules/Ubuntu/Components/plugin/uclistitem.cpp (+26/-1)
modules/Ubuntu/Components/plugin/uclistitem.h (+1/-0)
modules/Ubuntu/Components/plugin/uclistitem_p.h (+2/-0)
tests/resources/listitems/ListItemTest.qml (+4/-2)
tests/unit/tst_performance/ListItemList.qml (+2/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/65-last-divider-invisible
Reviewer Review Type Date Requested Status
Tim Peeters Approve
Review via email: mp+235176@code.launchpad.net

Description of the change

Last item's divider in a ListView or when parent has count property is not visible.

To post a comment you must log in.
1264. By Zsombor Egri

prereq sync

1265. By Zsombor Egri

prereq sync

1266. By Zsombor Egri

prereq sync

1267. By Zsombor Egri

prereq sync

1268. By Zsombor Egri

prereq sync

1269. By Zsombor Egri

prereq sync

1270. By Zsombor Egri

prereq sync

1271. By Zsombor Egri

prereq sync

1272. By Zsombor Egri

prereq sync

1273. By Zsombor Egri

prereq sync

1274. By Zsombor Egri

prereq sync

1275. By Zsombor Egri

prereq sync

1276. By Zsombor Egri

prereq sync

1277. By Zsombor Egri

painting last divider fixed

1278. By Zsombor Egri

rogue debug line removed

1279. By Zsombor Egri

prereq sync

1280. By Zsombor Egri

last item is checked on paint

1281. By Zsombor Egri

prereq sync

1282. By Zsombor Egri

prereq sync

1283. By Zsombor Egri

prereq sync

1284. By Zsombor Egri

prereq sync

1285. By Zsombor Egri

prereq sync

1286. By Zsombor Egri

prereq sync

1287. By Zsombor Egri

prereq sync

1288. By Zsombor Egri

prereq sync

1289. By Zsombor Egri

prereq sync

1290. By Zsombor Egri

prereq sync

1291. By Zsombor Egri

prereq sync

1292. By Zsombor Egri

prereq sync

1293. By Zsombor Egri

prereq sync

1294. By Zsombor Egri

prereq sync

1295. By Zsombor Egri

prereq sync

1296. By Zsombor Egri

prereq sync

1297. By Zsombor Egri

prereq sync

1298. By Zsombor Egri

prereq sync

Revision history for this message
Tim Peeters (tpeeters) wrote :

it works

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
2--- modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-12-01 16:01:35 +0000
3+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-12-01 16:01:38 +0000
4@@ -23,6 +23,7 @@
5 #include "ucubuntuanimation.h"
6 #include "propertychange_p.h"
7 #include "i18n.h"
8+#include "quickutils.h"
9 #include <QtQml/QQmlInfo>
10 #include <QtQuick/private/qquickitem_p.h>
11 #include <QtQuick/private/qquickflickable_p.h>
12@@ -249,7 +250,8 @@
13 QSGNode *UCListItemDivider::paint(QSGNode *node, const QRectF &rect)
14 {
15 QSGRectangleNode *dividerNode = static_cast<QSGRectangleNode*>(node);
16- if (m_visible && (m_gradient.size() > 0) && ((m_colorFrom.alphaF() >= (1.0f / 255.0f)) || (m_colorTo.alphaF() >= (1.0f / 255.0f)))) {
17+ bool lastItem = m_listItem->countOwner ? (m_listItem->index() == (m_listItem->countOwner->property("count").toInt() - 1)): false;
18+ if (m_visible && !lastItem && (m_gradient.size() > 0) && ((m_colorFrom.alphaF() >= (1.0f / 255.0f)) || (m_colorTo.alphaF() >= (1.0f / 255.0f)))) {
19 if (!dividerNode) {
20 dividerNode = m_listItem->sceneGraphContext()->createRectangleNode();
21 }
22@@ -402,6 +404,12 @@
23 animator->snap(0);
24 }
25
26+void UCListItemPrivate::_q_updateIndex()
27+{
28+ Q_Q(UCListItem);
29+ q->update();
30+}
31+
32 /*!
33 * \qmlproperty Component ListItem::style
34 * Holds the style of the component defining the components visualizing the leading/
35@@ -647,6 +655,8 @@
36 * Each ListItem has a thin divider shown on the bottom of the component. This
37 * divider can be configured through the \c divider grouped property, which can
38 * configure its margins from the edges of the ListItem as well as its visibility.
39+ * When used in \c ListView or \l UbuntuListView, the last list item will not
40+ * show the divider no matter of the visible property value set.
41 *
42 * ListItem can handle actions that can get tugged from front to back of the item.
43 * These actions are Action elements visualized in panels attached to the front
44@@ -733,6 +743,19 @@
45 UCStyledItemBase::componentComplete();
46 Q_D(UCListItem);
47 d->ready = true;
48+ /* We only deal with ListView, as for other cases we would need to check the children
49+ * changes, which would have an enormous impact on performance in case of huge amount
50+ * of items. However, if the parent item, or Flickable declares a "count" property,
51+ * the ListItem will take use of it!
52+ */
53+ d->countOwner = (d->flickable && d->flickable->property("count").isValid()) ?
54+ d->flickable :
55+ (d->parentItem && d->parentItem->property("count").isValid()) ? d->parentItem : 0;
56+ if (d->countOwner) {
57+ QObject::connect(d->countOwner.data(), SIGNAL(countChanged()),
58+ this, SLOT(_q_updateIndex()), Qt::DirectConnection);
59+ update();
60+ }
61 }
62
63 void UCListItem::itemChange(ItemChange change, const ItemChangeData &data)
64@@ -758,6 +781,8 @@
65 } else if (data.item) {
66 d->attachedProperties = static_cast<UCListItemAttached*>(qmlAttachedPropertiesObject<UCListItem>(data.item));
67 } else {
68+ // mark as not ready, so no action should be performed which depends on readyness
69+ d->ready = false;
70 // about to be deleted or reparented, disable attached
71 d->attachedProperties = 0;
72 }
73
74=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.h'
75--- modules/Ubuntu/Components/plugin/uclistitem.h 2014-12-01 16:01:35 +0000
76+++ modules/Ubuntu/Components/plugin/uclistitem.h 2014-12-01 16:01:38 +0000
77@@ -98,6 +98,7 @@
78 Q_PRIVATE_SLOT(d_func(), void _q_updateThemedData())
79 Q_PRIVATE_SLOT(d_func(), void _q_rebound())
80 Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
81+ Q_PRIVATE_SLOT(d_func(), void _q_updateIndex())
82 };
83
84 QML_DECLARE_TYPEINFO(UCListItem, QML_HAS_ATTACHED_PROPERTIES)
85
86=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
87--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-12-01 16:01:35 +0000
88+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-12-01 16:01:38 +0000
89@@ -47,6 +47,7 @@
90 void _q_rebound();
91 void promptRebound();
92 void _q_updateSize();
93+ void _q_updateIndex();
94 int index();
95 bool canHighlight(QMouseEvent *event);
96 void setPressed(bool pressed);
97@@ -73,6 +74,7 @@
98 QPointF pressedPos;
99 QColor color;
100 QColor highlightColor;
101+ QPointer<QQuickItem> countOwner;
102 QPointer<QQuickFlickable> flickable;
103 QPointer<UCListItemAttached> attachedProperties;
104 QQuickItem *contentItem;
105
106=== modified file 'tests/resources/listitems/ListItemTest.qml'
107--- tests/resources/listitems/ListItemTest.qml 2014-12-01 16:01:35 +0000
108+++ tests/resources/listitems/ListItemTest.qml 2014-12-01 16:01:38 +0000
109@@ -137,7 +137,7 @@
110 clip: true
111 width: parent.width
112 height: units.gu(20)
113- model: 100
114+ model: 10
115 pressDelay: 0
116 delegate: ListItem {
117 objectName: "ListItem" + index
118@@ -171,8 +171,10 @@
119 Column {
120 id: column
121 width: view.width
122+ property alias count: repeater.count
123 Repeater {
124- model: 100
125+ id: repeater
126+ model: 10
127 ListItem {
128 objectName: "InFlickable"+index
129 color: "red"
130
131=== modified file 'tests/unit/tst_performance/ListItemList.qml'
132--- tests/unit/tst_performance/ListItemList.qml 2014-12-01 16:01:35 +0000
133+++ tests/unit/tst_performance/ListItemList.qml 2014-12-01 16:01:38 +0000
134@@ -20,7 +20,9 @@
135 Column {
136 width: 800
137 height: 600
138+ property alias count: repeater.count
139 Repeater {
140+ id: repeater
141 model: 5000
142 ListItem {
143 }

Subscribers

People subscribed via source and target branches

to all changes: