Merge lp:~zsombi/ubuntu-ui-toolkit/65-last-divider-invisible into lp:~bzoltan/ubuntu-ui-toolkit/new_list_item

Proposed by Zsombor Egri
Status: Superseded
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/65-last-divider-invisible
Merge into: lp:~bzoltan/ubuntu-ui-toolkit/new_list_item
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/60-action-value-type
Diff against target: 184 lines (+64/-8)
5 files modified
modules/Ubuntu/Components/plugin/uclistitem.cpp (+55/-6)
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
Ubuntu SDK team Pending
Review via email: mp+234640@code.launchpad.net

Commit message

No divider shown for the last ListItem in a ListView or where a "count" property is present in the parent item.

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

prereq

1252. By Zsombor Egri

prereq

1253. By Zsombor Egri

removed clause restored

1254. By Zsombor Egri

prereq

1255. By Zsombor Egri

prereq

1256. By Zsombor Egri

prereq

1257. By Zsombor Egri

remove documentation which describes the 'easter egg'

1258. By Zsombor Egri

prereq

1259. By Zsombor Egri

prereq

1260. By Zsombor Egri

prereq

1261. By Zsombor Egri

prereq

1262. By Zsombor Egri

prereq

1263. By Zsombor Egri

prereq sync

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

Unmerged revisions

1298. By Zsombor Egri

prereq sync

1297. By Zsombor Egri

prereq sync

1296. By Zsombor Egri

prereq sync

1295. By Zsombor Egri

prereq sync

1294. By Zsombor Egri

prereq sync

1293. By Zsombor Egri

prereq sync

1292. By Zsombor Egri

prereq sync

1291. By Zsombor Egri

prereq sync

1290. By Zsombor Egri

prereq sync

1289. By Zsombor Egri

prereq sync

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-09-15 08:46:01 +0000
3+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-09-15 08:46:02 +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@@ -50,6 +51,7 @@
13 UCListItemDivider::UCListItemDivider(QObject *parent)
14 : QObject(parent)
15 , m_visible(true)
16+ , m_lastItem(false)
17 , m_leftMarginChanged(false)
18 , m_rightMarginChanged(false)
19 , m_colorFromChanged(false)
20@@ -123,7 +125,7 @@
21
22 QSGNode *UCListItemDivider::paint(QSGNode *paintNode, const QRectF &rect)
23 {
24- if (m_visible && (m_gradient.size() > 0)) {
25+ if (m_visible && !m_lastItem && (m_gradient.size() > 0)) {
26 QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(paintNode);
27 if (!rectNode) {
28 rectNode = m_listItem->sceneGraphContext()->createRectangleNode();
29@@ -358,6 +360,22 @@
30 grabPanel(trailingOptions, false);
31 }
32
33+void UCListItemPrivate::_q_updateIndex(QObject *ownerItem)
34+{
35+ Q_Q(UCListItem);
36+ if (!ownerItem) {
37+ ownerItem = q->sender();
38+ }
39+ Q_ASSERT(ownerItem);
40+ // update the index as well
41+ QQmlContext *context = qmlContext(q);
42+ if (context) {
43+ QVariant indexProperty = context->contextProperty("index");
44+ index = indexProperty.isValid() ? indexProperty.toInt() : -1;
45+ }
46+ divider->m_lastItem = ready && index == (ownerItem->property("count").toInt() - 1);
47+}
48+
49 // the function performs a cleanup on mouse release without any rebound animation
50 void UCListItemPrivate::cleanup()
51 {
52@@ -503,6 +521,28 @@
53 * Each ListItem has a thin divider shown on the bottom of the component. This
54 * divider can be configured through the \l divider grouped property, which can
55 * configure its margins from the edges of the ListItem as well as its visibility.
56+ * When used in \c ListView or \l UbuntuListView, the last list item will not
57+ * show the divider no matter of the visible property value set. In other
58+ * circumstances declaring a \c count property in the ListItem's parent item
59+ * or Flickable can help applying the last item detection logic.
60+ * \qml
61+ * Column {
62+ * width: units.gu(40)
63+ * // bring count to Column from Repeater
64+ * property alias count: repeater.count
65+ * Repeater {
66+ * model: 10
67+ * ListItem {
68+ * Label {
69+ * anchors.fill: parent
70+ * horizontalCenter: Text.AlignHCenter
71+ * verticalCenter: Text.AlignVCenter
72+ * text: "Item #" + modelData
73+ * }
74+ * }
75+ * }
76+ * }
77+ * \endqml
78 *
79 * ListItem can handle options that can ge tugged from front ot right of the item.
80 * These options are Action elements visualized in panels attached to the front
81@@ -574,11 +614,18 @@
82 UCStyledItemBase::componentComplete();
83 Q_D(UCListItem);
84 d->ready = true;
85- // is there an index context property?
86- QQmlContext *context = qmlContext(this);
87- QVariant index = context->contextProperty("index");
88- if (index.isValid()) {
89- d->index = index.toInt();
90+ /* We only deal with ListView, as for other cases we would need to check the children
91+ * changes, which would have an enormous impact on performance in case of huge amount
92+ * of items. However, if the parent item, or Flickable declares a "count" property,
93+ * the ListItem will take use of it!
94+ */
95+ QQuickItem *countOwner = (d->flickable && d->flickable->property("count").isValid()) ?
96+ d->flickable :
97+ (d->parentItem && d->parentItem->property("count").isValid()) ? d->parentItem : 0;
98+ if (countOwner) {
99+ QObject::connect(countOwner, SIGNAL(countChanged()),
100+ this, SLOT(_q_updateIndex()), Qt::DirectConnection);
101+ d->_q_updateIndex(countOwner);
102 }
103 }
104
105@@ -611,6 +658,8 @@
106 delete d->flickableInteractive;
107 d->flickableInteractive = 0;
108 }
109+ // mar as not ready, so no action should be performed which depends on readyness
110+ d->ready = false;
111 }
112
113 // update size
114
115=== modified file 'modules/Ubuntu/Components/plugin/uclistitem.h'
116--- modules/Ubuntu/Components/plugin/uclistitem.h 2014-09-15 08:46:01 +0000
117+++ modules/Ubuntu/Components/plugin/uclistitem.h 2014-09-15 08:46:02 +0000
118@@ -74,6 +74,7 @@
119 Q_PRIVATE_SLOT(d_func(), void _q_rebound())
120 Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
121 Q_PRIVATE_SLOT(d_func(), void _q_completeRebinding())
122+ Q_PRIVATE_SLOT(d_func(), void _q_updateIndex(QObject *ownerItem = 0))
123 };
124
125 #endif // UCLISTITEM_H
126
127=== modified file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
128--- modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-09-15 08:46:01 +0000
129+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-09-15 08:46:02 +0000
130@@ -48,6 +48,7 @@
131 void _q_rebound();
132 void _q_updateSize();
133 void _q_completeRebinding();
134+ void _q_updateIndex(QObject *ownerItem = 0);
135 void cleanup();
136 void reboundTo(qreal x);
137 void setPressed(bool pressed);
138@@ -141,6 +142,7 @@
139 void setColorTo(const QColor &color);
140
141 bool m_visible:1;
142+ bool m_lastItem:1;
143 bool m_leftMarginChanged:1;
144 bool m_rightMarginChanged:1;
145 bool m_colorFromChanged:1;
146
147=== modified file 'tests/resources/listitems/ListItemTest.qml'
148--- tests/resources/listitems/ListItemTest.qml 2014-09-15 08:46:01 +0000
149+++ tests/resources/listitems/ListItemTest.qml 2014-09-15 08:46:02 +0000
150@@ -98,7 +98,7 @@
151 clip: true
152 width: parent.width
153 height: units.gu(20)
154- model: 100
155+ model: 10
156 pressDelay: 0
157 delegate: ListItem {
158 objectName: "ListItem" + index
159@@ -127,8 +127,10 @@
160 Column {
161 id: column
162 width: view.width
163+ property alias count: repeater.count
164 Repeater {
165- model: 100
166+ id: repeater
167+ model: 10
168 ListItem {
169 objectName: "InFlickable"+index
170 leadingOptions: ListItemOptions {
171
172=== modified file 'tests/unit/tst_performance/ListItemList.qml'
173--- tests/unit/tst_performance/ListItemList.qml 2014-09-15 08:46:01 +0000
174+++ tests/unit/tst_performance/ListItemList.qml 2014-09-15 08:46:02 +0000
175@@ -20,7 +20,9 @@
176 Column {
177 width: 800
178 height: 600
179+ property alias count: repeater.count
180 Repeater {
181+ id: repeater
182 model: 5000
183 ListItem {
184 }

Subscribers

People subscribed via source and target branches

to all changes: