Merge lp:~zsombi/ubuntu-ui-toolkit/10-viewitem into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Superseded
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/10-viewitem
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/focusing-improvements
Diff against target: 1352 lines (+912/-117)
24 files modified
components.api (+53/-17)
debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install (+0/-1)
modules/Ubuntu/Components/10/UbuntuColors10.qml (+1/-0)
modules/Ubuntu/Components/11/UbuntuColors.qml (+1/-0)
modules/Ubuntu/Components/Colors/Colors.pro (+0/-9)
modules/Ubuntu/Components/Colors/FIXME (+0/-7)
modules/Ubuntu/Components/Components.pro (+1/-1)
modules/Ubuntu/Components/Pickers/PickerPanel.qml (+1/-0)
modules/Ubuntu/Components/Pickers/qmldir (+2/-0)
modules/Ubuntu/Components/plugin/plugin.cpp (+13/-50)
modules/Ubuntu/Components/plugin/plugin.h (+6/-2)
modules/Ubuntu/Components/plugin/plugin.pro (+5/-2)
modules/Ubuntu/Components/plugin/uclistitem.cpp (+352/-0)
modules/Ubuntu/Components/plugin/uclistitem.h (+62/-0)
modules/Ubuntu/Components/plugin/uclistitem_p.h (+87/-0)
modules/Ubuntu/Components/qmldir (+3/-0)
tests/qmlapicheck.py (+22/-18)
tests/qmlapicheck.sh (+1/-1)
tests/resources/listitems/ListItemTest.qml (+90/-0)
tests/unit/tst_performance/ItemList.qml (+30/-0)
tests/unit/tst_performance/ListItemList.qml (+28/-0)
tests/unit/tst_performance/tst_performance.cpp (+2/-8)
tests/unit/tst_performance/tst_performance.pro (+3/-1)
tests/unit_x11/tst_components/tst_listitem.qml (+149/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/10-viewitem
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Tim Peeters Pending
Review via email: mp+233024@code.launchpad.net

Commit message

New ListItem component. Component and its background grouped property.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1187. By Zsombor Egri

prereq merge

1188. By Zsombor Egri

More performance gain by using implicitWidth/implicitHeight, and in this way we can get rid of the additional QML component with bindings. No more need for the owningItem property either, which was introduced to help deciding from whom to take the width. Performance almost doubled in this way.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1189. By Zsombor Egri

minor updates on documentation; background renamed to contentItem, suits better for what it actually does

1190. By Zsombor Egri

API updated

1191. By Zsombor Egri

test updated

1192. By Zsombor Egri

staging merge

1193. By Zsombor Egri

staging sync

1194. By Zsombor Egri

staging merge

1195. By Zsombor Egri

more benchmarks added

1196. By Zsombor Egri

height set to 7 GU

1197. By Zsombor Egri

documentation and versioning fix

1198. By Zsombor Egri

API updated

1199. By Zsombor Egri

colors moved into ListItem

1200. By Zsombor Egri

documentation fixed

1201. By Zsombor Egri

staging merge

1202. By Zsombor Egri

staging sync

1203. By Zsombor Egri

staging merge

1204. By Zsombor Egri

staging sync

1205. By Zsombor Egri

staging sync

1206. By Zsombor Egri

pressedColor changed into highlightColor

1207. By Zsombor Egri

API updated

1208. By Zsombor Egri

staging sync

1209. By Zsombor Egri

fix activeFocusOnSet defaulting and setFocused override

1210. By Zsombor Egri

staging sync

1211. By Zsombor Egri

staging sync

1212. By Zsombor Egri

staging sync

1213. By Zsombor Egri

staging merge

1214. By Zsombor Egri

staging sync

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2014-08-26 14:16:46 +0000
3+++ components.api 2014-09-04 06:44:23 +0000
4@@ -43,22 +43,6 @@
5 CheckBox 0.1 1.0
6 AbstractButton
7 property bool checked
8-modules/Ubuntu/Components/Colors/UbuntuColors.qml
9-QtObject
10- readonly property color orange
11- readonly property color lightAubergine
12- readonly property color midAubergine
13- readonly property color darkAubergine
14- readonly property color warmGrey
15- readonly property color coolGrey
16- property Gradient orangeGradient
17- property Gradient greyGradient
18- readonly property color lightGrey
19- readonly property color darkGrey
20- readonly property color red
21- readonly property color green
22- readonly property color blue
23- readonly property color purple
24 ComboButton 1.1
25 Button
26 property bool expanded
27@@ -98,6 +82,8 @@
28 Label 0.1 1.0
29 Text
30 property string fontSize
31+ListItem 1.1
32+ListItemBase
33 Base 0.1 1.0
34 Empty
35 property variant icon
36@@ -353,7 +339,7 @@
37 PickerDelegate 0.1 1.0
38 AbstractButton
39 readonly property Picker picker
40-modules/Ubuntu/Components/Pickers/PickerPanel.qml
41+PickerPanel 0.1 1.0
42 Object
43 function openDatePicker(caller, property, mode)
44 ActionSelectionPopover 0.1 1.0
45@@ -657,6 +643,32 @@
46 property Item pageStack
47 property bool opened
48 property bool locked
49+UbuntuColors 1.1
50+QtObject
51+ readonly property color orange
52+ readonly property color lightAubergine
53+ readonly property color midAubergine
54+ readonly property color darkAubergine
55+ readonly property color warmGrey
56+ readonly property color coolGrey
57+ property Gradient orangeGradient
58+ property Gradient greyGradient
59+ readonly property color lightGrey
60+ readonly property color darkGrey
61+ readonly property color red
62+ readonly property color green
63+ readonly property color blue
64+ readonly property color purple
65+UbuntuColors 0.1 1.0
66+QtObject
67+ readonly property color orange
68+ readonly property color lightAubergine
69+ readonly property color midAubergine
70+ readonly property color darkAubergine
71+ readonly property color warmGrey
72+ readonly property color coolGrey
73+ property Gradient orangeGradient
74+ property Gradient greyGradient
75 UbuntuListView 0.1 1.0
76 ListView
77 property int expandedIndex
78@@ -804,6 +816,19 @@
79 name: "UCInverseMouse"
80 prototype: "UCMouse"
81 exports: ["InverseMouse 0.1", "InverseMouse 1.0"]
82+ name: "UCListItemBackground"
83+ prototype: "QQuickItem"
84+ Property { name: "color"; type: "QColor" }
85+ Property { name: "pressedColor"; type: "QColor" }
86+ name: "UCListItemBase"
87+ prototype: "UCStyledItemBase"
88+ exports: ["ListItemBase 1.1"]
89+ Property { name: "background"; type: "UCListItemBackground"; isReadonly: true; isPointer: true }
90+ Property { name: "pressed"; type: "bool"; isReadonly: true }
91+ Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
92+ Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true }
93+ Property { name: "owningItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
94+ Signal { name: "clicked" }
95 name: "UCMouse"
96 prototype: "QObject"
97 exports: ["Mouse 0.1", "Mouse 1.0"]
98@@ -924,6 +949,17 @@
99 Parameter { name: "singular"; type: "string" }
100 Parameter { name: "plural"; type: "string" }
101 Parameter { name: "n"; type: "int" }
102+ prototype: "QObject"
103+ name: "UbuntuColors"
104+ exports: ["UbuntuColors -1.-1"]
105+ Property { name: "orange"; type: "QColor"; isReadonly: true }
106+ Property { name: "lightAubergine"; type: "QColor"; isReadonly: true }
107+ Property { name: "midAubergine"; type: "QColor"; isReadonly: true }
108+ Property { name: "darkAubergine"; type: "QColor"; isReadonly: true }
109+ Property { name: "warmGrey"; type: "QColor"; isReadonly: true }
110+ Property { name: "coolGrey"; type: "QColor"; isReadonly: true }
111+ Property { name: "orangeGradient"; type: "QQuickGradient"; isPointer: true }
112+ Property { name: "greyGradient"; type: "QQuickGradient"; isPointer: true }
113 name: "ULConditionalLayout"
114 prototype: "QObject"
115 exports: ["ConditionalLayout 0.1", "ConditionalLayout 1.0"]
116
117=== modified file 'debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install'
118--- debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2014-07-28 10:34:06 +0000
119+++ debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2014-09-04 06:44:23 +0000
120@@ -21,7 +21,6 @@
121 usr/lib/*/qt5/qml/Ubuntu/Components/Popups/*.js
122 usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/*.qml
123 usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/qmldir
124-usr/lib/*/qt5/qml/Ubuntu/Components/Colors/*.qml
125 usr/lib/*/qt5/qml/Ubuntu/Components/Styles/*.qml
126 usr/lib/*/qt5/qml/Ubuntu/Components/Styles/qmldir
127 usr/lib/*/qt5/qml/Ubuntu/Test
128
129=== renamed file 'modules/Ubuntu/Components/Colors/UbuntuColors10.qml' => 'modules/Ubuntu/Components/10/UbuntuColors10.qml'
130--- modules/Ubuntu/Components/Colors/UbuntuColors10.qml 2014-07-01 20:52:48 +0000
131+++ modules/Ubuntu/Components/10/UbuntuColors10.qml 2014-09-04 06:44:23 +0000
132@@ -14,6 +14,7 @@
133 along with this program. If not, see <http://www.gnu.org/licenses/>.
134 */
135
136+pragma Singleton
137 import QtQuick 2.2
138
139 /*!
140
141=== renamed file 'modules/Ubuntu/Components/Colors/UbuntuColors.qml' => 'modules/Ubuntu/Components/11/UbuntuColors.qml'
142--- modules/Ubuntu/Components/Colors/UbuntuColors.qml 2014-07-24 16:02:47 +0000
143+++ modules/Ubuntu/Components/11/UbuntuColors.qml 2014-09-04 06:44:23 +0000
144@@ -14,6 +14,7 @@
145 along with this program. If not, see <http://www.gnu.org/licenses/>.
146 */
147
148+pragma Singleton
149 import QtQuick 2.2
150
151 /*!
152
153=== removed directory 'modules/Ubuntu/Components/Colors'
154=== removed file 'modules/Ubuntu/Components/Colors/Colors.pro'
155--- modules/Ubuntu/Components/Colors/Colors.pro 2013-07-01 05:54:33 +0000
156+++ modules/Ubuntu/Components/Colors/Colors.pro 1970-01-01 00:00:00 +0000
157@@ -1,9 +0,0 @@
158-TEMPLATE = subdirs
159-
160-uri = Ubuntu.Components.Colors
161-installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
162-
163-qml_files.path = $$installPath
164-qml_files.files = *.qml
165-
166-INSTALLS += qml_files
167
168=== removed file 'modules/Ubuntu/Components/Colors/FIXME'
169--- modules/Ubuntu/Components/Colors/FIXME 2014-07-01 20:52:48 +0000
170+++ modules/Ubuntu/Components/Colors/FIXME 1970-01-01 00:00:00 +0000
171@@ -1,7 +0,0 @@
172-UbuntuColors.qml is located in the Colors subdirectory because
173-QuickUtils::createQmlObject() fails if the QML file is located in a
174-folder that has a qmldir file with JavaScript modules.
175-
176-UbuntuColors 1.1 is not in a file named UbuntuColors11.qml but in
177-UbuntuColors.qml so that qdoc can properly detect the component
178-name without a qmldir file.
179
180=== modified file 'modules/Ubuntu/Components/Components.pro'
181--- modules/Ubuntu/Components/Components.pro 2014-07-28 15:04:39 +0000
182+++ modules/Ubuntu/Components/Components.pro 2014-09-04 06:44:23 +0000
183@@ -1,5 +1,5 @@
184 TEMPLATE = subdirs
185
186-SUBDIRS += plugin Themes Colors 10 11
187+SUBDIRS += plugin Themes 10 11
188
189 include(deployment.pri)
190
191=== modified file 'modules/Ubuntu/Components/Pickers/PickerPanel.qml'
192--- modules/Ubuntu/Components/Pickers/PickerPanel.qml 2014-08-11 15:21:14 +0000
193+++ modules/Ubuntu/Components/Pickers/PickerPanel.qml 2014-09-04 06:44:23 +0000
194@@ -14,6 +14,7 @@
195 * along with this program. If not, see <http://www.gnu.org/licenses/>.
196 */
197
198+pragma Singleton
199 import QtQuick 2.0
200 import QtQuick.Window 2.0
201 import Ubuntu.Components 1.1
202
203=== modified file 'modules/Ubuntu/Components/Pickers/qmldir'
204--- modules/Ubuntu/Components/Pickers/qmldir 2014-04-20 19:25:12 +0000
205+++ modules/Ubuntu/Components/Pickers/qmldir 2014-09-04 06:44:23 +0000
206@@ -8,6 +8,7 @@
207 internal MonthModel MonthModel.qml
208 internal DayModel DayModel.qml
209 internal PickerModelBase PickerModelBase.qml
210+singleton PickerPanel 0.1 PickerPanel.qml
211
212 #version 1.0
213 Picker 1.0 Picker.qml
214@@ -15,3 +16,4 @@
215 Dialer 1.0 Dialer.qml
216 DialerHand 1.0 DialerHand.qml
217 DatePicker 1.0 DatePicker.qml
218+singleton PickerPanel 1.0 PickerPanel.qml
219
220=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
221--- modules/Ubuntu/Components/plugin/plugin.cpp 2014-08-20 13:03:13 +0000
222+++ modules/Ubuntu/Components/plugin/plugin.cpp 2014-09-04 06:44:23 +0000
223@@ -50,22 +50,19 @@
224 #include "ucinversemouse.h"
225 #include "sortfiltermodel.h"
226 #include "ucstyleditembase.h"
227+#include "uclistitem.h"
228+#include "uclistitem_p.h"
229
230 #include <sys/types.h>
231 #include <unistd.h>
232 #include <stdexcept>
233
234+QUrl UbuntuComponentsPlugin::m_baseUrl = QUrl();
235+
236 /*
237 * Type registration functions.
238 */
239
240-static QObject *registerPickerPanel(QQmlEngine *engine, QJSEngine *scriptEngine)
241-{
242- Q_UNUSED(scriptEngine)
243- return UbuntuComponentsPlugin::registerQmlSingletonType(engine,
244- "Ubuntu.Components", "Pickers/PickerPanel.qml");
245-}
246-
247 static QObject *registerClipboard(QQmlEngine *engine, QJSEngine *scriptEngine)
248 {
249 Q_UNUSED(engine)
250@@ -93,45 +90,9 @@
251 return uriHandler;
252 }
253
254-static QObject *registerUbuntuColors10(QQmlEngine *engine, QJSEngine *scriptEngine)
255-{
256- Q_UNUSED(scriptEngine)
257- return UbuntuComponentsPlugin::registerQmlSingletonType(engine,
258- "Ubuntu.Components", "Colors/UbuntuColors10.qml");
259-}
260-
261-static QObject *registerUbuntuColors11(QQmlEngine *engine, QJSEngine *scriptEngine)
262-{
263- Q_UNUSED(scriptEngine)
264- return UbuntuComponentsPlugin::registerQmlSingletonType(engine,
265- "Ubuntu.Components", "Colors/UbuntuColors.qml");
266-}
267-
268-QUrl UbuntuComponentsPlugin::baseUrl(const QStringList& importPathList, const char* uri)
269-{
270- /* FIXME: remove when migrating to Qt 5.1 and use QQmlExtensionPlugin::baseUrl()
271- http://doc-snapshot.qt-project.org/qt5-stable/qtqml/qqmlextensionplugin.html#baseUrl
272- */
273- QString pluginRelativePath = QString::fromUtf8(uri).replace(".", "/").prepend("/").append("/");
274- QString pluginPath;
275- Q_FOREACH (QString importPath, importPathList) {
276- pluginPath = importPath.append(pluginRelativePath);
277- /* We verify that the directory ending in Ubuntu/Components contains the
278- file libUbuntuComponents.so therefore proving it's the right directory.
279-
280- Ref.: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1197293
281- */
282- if (QFile(pluginPath + "libUbuntuComponents.so").exists()) {
283- return QUrl::fromLocalFile(pluginPath);
284- }
285- }
286-
287- return QUrl();
288-}
289-
290-QObject *UbuntuComponentsPlugin::registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* qmlFile)
291-{
292- QUrl url = baseUrl(engine->importPathList(), uri).resolved(QUrl::fromLocalFile(qmlFile));
293+QObject *UbuntuComponentsPlugin::registerQmlSingletonType(QQmlEngine *engine, const char* qmlFile)
294+{
295+ QUrl url = m_baseUrl.resolved(QUrl::fromLocalFile(qmlFile));
296 return QuickUtils::instance().createQmlObject(url, engine);
297 }
298
299@@ -163,7 +124,6 @@
300 void UbuntuComponentsPlugin::registerTypesToVersion(const char *uri, int major, int minor)
301 {
302 qmlRegisterType<UCStyledItemBase>(uri, major, minor, "StyledItemBase");
303- qmlRegisterSingletonType<QObject>(uri, major, minor, "UbuntuColors", registerUbuntuColors10);
304 qmlRegisterUncreatableType<UbuntuI18n>(uri, major, minor, "i18n", "Singleton object");
305 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, major, minor, "QQuickImageBase");
306 qmlRegisterUncreatableType<UCUnits>(uri, major, minor, "UCUnits", "Not instantiable");
307@@ -184,8 +144,6 @@
308 qmlRegisterSingletonType<UCUriHandler>(uri, major, minor, "UriHandler", registerUriHandler);
309 qmlRegisterType<UCMouse>(uri, major, minor, "Mouse");
310 qmlRegisterType<UCInverseMouse>(uri, major, minor, "InverseMouse");
311- // register QML singletons
312- qmlRegisterSingletonType<QObject>(uri, major, minor, "PickerPanel", registerPickerPanel);
313 }
314
315 void UbuntuComponentsPlugin::registerTypes(const char *uri)
316@@ -195,7 +153,6 @@
317 // register 0.1 for backward compatibility
318 registerTypesToVersion(uri, 0, 1);
319 registerTypesToVersion(uri, 1, 0);
320- qmlRegisterSingletonType<QObject>(uri, 1, 1, "UbuntuColors", registerUbuntuColors11);
321
322 // register custom event
323 ForwardedEvent::registerForwardedEvent();
324@@ -208,10 +165,16 @@
325 qmlRegisterType<QSortFilterProxyModelQML>(uri, 1, 1, "SortFilterModel");
326 qmlRegisterUncreatableType<FilterBehavior>(uri, 1, 1, "FilterBehavior", "Not instantiable");
327 qmlRegisterUncreatableType<SortBehavior>(uri, 1, 1, "SortBehavior", "Not instantiable");
328+ // ListItem and related types
329+ qmlRegisterType<UCListItem, 1>(uri, 1, 1, "ListItem");
330+ qmlRegisterType<UCListItemBackground>();
331 }
332
333 void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
334 {
335+ // initialize baseURL
336+ m_baseUrl = QUrl(baseUrl().toString() + '/');
337+
338 QQmlExtensionPlugin::initializeEngine(engine, uri);
339 QQmlContext* context = engine->rootContext();
340
341
342=== modified file 'modules/Ubuntu/Components/plugin/plugin.h'
343--- modules/Ubuntu/Components/plugin/plugin.h 2014-04-20 19:25:12 +0000
344+++ modules/Ubuntu/Components/plugin/plugin.h 2014-09-04 06:44:23 +0000
345@@ -32,14 +32,18 @@
346 public:
347 void registerTypes(const char *uri);
348 void initializeEngine(QQmlEngine *engine, const char *uri);
349- static QUrl baseUrl(const QStringList& importPathList, const char* uri);
350- static QObject *registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* qmlFile);
351+ static QObject *registerQmlSingletonType(QQmlEngine *engine, const char* qmlFile);
352+ static const QUrl &pluginUrl()
353+ {
354+ return m_baseUrl;
355+ }
356
357 private Q_SLOTS:
358 void registerWindowContextProperty();
359 void setWindowContextProperty(QWindow* focusWindow);
360
361 private:
362+ static QUrl m_baseUrl;
363 void registerTypesToVersion(const char *uri, int major, int minor);
364 };
365 #endif // UBUNTU_COMPONENTS_PLUGIN_H
366
367=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
368--- modules/Ubuntu/Components/plugin/plugin.pro 2014-09-02 09:39:09 +0000
369+++ modules/Ubuntu/Components/plugin/plugin.pro 2014-09-04 06:44:23 +0000
370@@ -65,7 +65,9 @@
371 ucmouse.h \
372 unixsignalhandler_p.h \
373 ucstyleditembase.h \
374- ucstyleditembase_p.h
375+ ucstyleditembase_p.h \
376+ uclistitem.h \
377+ uclistitem_p.h
378
379 SOURCES += plugin.cpp \
380 uctheme.cpp \
381@@ -99,7 +101,8 @@
382 ucurihandler.cpp \
383 ucmousefilters.cpp \
384 unixsignalhandler_p.cpp \
385- ucstyleditembase.cpp
386+ ucstyleditembase.cpp \
387+ uclistitem.cpp
388
389 # adapters
390 SOURCES += adapters/alarmsadapter_organizer.cpp
391
392=== added file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
393--- modules/Ubuntu/Components/plugin/uclistitem.cpp 1970-01-01 00:00:00 +0000
394+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-09-04 06:44:23 +0000
395@@ -0,0 +1,352 @@
396+/*
397+ * Copyright 2014 Canonical Ltd.
398+ *
399+ * This program is free software; you can redistribute it and/or modify
400+ * it under the terms of the GNU Lesser General Public License as published by
401+ * the Free Software Foundation; version 3.
402+ *
403+ * This program is distributed in the hope that it will be useful,
404+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
405+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
406+ * GNU Lesser General Public License for more details.
407+ *
408+ * You should have received a copy of the GNU Lesser General Public License
409+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
410+ */
411+
412+#include "ucunits.h"
413+#include "uctheme.h"
414+#include "uclistitem.h"
415+#include "uclistitem_p.h"
416+#include <QtQml/QQmlInfo>
417+#include <QtQuick/private/qquickitem_p.h>
418+#include <QtQuick/private/qquickflickable_p.h>
419+#include <QtQuick/private/qquickpositioners_p.h>
420+
421+QColor getPaletteColor(const char *profile, const char *color)
422+{
423+ QColor result;
424+ QObject *palette = UCTheme::instance().palette();
425+ if (palette) {
426+ QObject *paletteProfile = palette->property(profile).value<QObject*>();
427+ if (paletteProfile) {
428+ result = paletteProfile->property(color).value<QColor>();
429+ }
430+ }
431+ return result;
432+}
433+
434+
435+/******************************************************************************
436+ * ListItemBackground
437+ */
438+UCListItemBackground::UCListItemBackground(QQuickItem *parent)
439+ : QQuickItem(parent)
440+ , m_color(Qt::transparent)
441+ , m_pressedColor(Qt::yellow)
442+ , m_item(0)
443+{
444+ setFlag(QQuickItem::ItemHasContents);
445+ // catch theme palette changes
446+ connect(&UCTheme::instance(), &UCTheme::paletteChanged, this, &UCListItemBackground::updateColors);
447+ updateColors();
448+}
449+
450+UCListItemBackground::~UCListItemBackground()
451+{
452+}
453+
454+void UCListItemBackground::setColor(const QColor &color)
455+{
456+ if (m_color == color) {
457+ return;
458+ }
459+ m_color = color;
460+ update();
461+ Q_EMIT colorChanged();
462+}
463+
464+void UCListItemBackground::setPressedColor(const QColor &color)
465+{
466+ if (m_pressedColor == color) {
467+ return;
468+ }
469+ m_pressedColor = color;
470+ // no more theme change watch
471+ disconnect(&UCTheme::instance(), &UCTheme::paletteChanged, this, &UCListItemBackground::updateColors);
472+ update();
473+ Q_EMIT pressedColorChanged();
474+}
475+
476+void UCListItemBackground::updateColors()
477+{
478+ m_pressedColor = getPaletteColor("selected", "background");
479+ update();
480+}
481+
482+
483+void UCListItemBackground::itemChange(ItemChange change, const ItemChangeData &data)
484+{
485+ if (change == ItemParentHasChanged) {
486+ m_item = qobject_cast<UCListItem*>(data.item);
487+ }
488+ QQuickItem::itemChange(change, data);
489+}
490+
491+QSGNode *UCListItemBackground::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
492+{
493+ Q_UNUSED(data);
494+
495+ UCListItemPrivate *dd = UCListItemPrivate::get(m_item);
496+ bool pressed = (dd && dd->pressed);
497+ QColor color = pressed ? m_pressedColor : m_color;
498+
499+ if (width() <= 0 || height() <= 0 || (color.alpha() == 0)) {
500+ delete oldNode;
501+ return 0;
502+ }
503+ QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(oldNode);
504+ if (!rectNode) {
505+ rectNode = QQuickItemPrivate::get(this)->sceneGraphContext()->createRectangleNode();
506+ }
507+ rectNode->setColor(color);
508+ rectNode->setRect(boundingRect());
509+ rectNode->update();
510+ return rectNode;
511+}
512+
513+
514+UCListItemPrivate::UCListItemPrivate()
515+ : UCStyledItemBasePrivate()
516+ , pressed(false)
517+ , background(new UCListItemBackground)
518+{
519+}
520+UCListItemPrivate::~UCListItemPrivate()
521+{
522+}
523+
524+void UCListItemPrivate::init()
525+{
526+ Q_Q(UCListItem);
527+ background->setObjectName("ListItemHolder");
528+ QQml_setParent_noEvent(background, q);
529+ background->setParentItem(q);
530+ // content will be redirected to the background, therefore we must report
531+ // children changes as it would come from the main component
532+ QObject::connect(background, &UCListItemBackground::childrenChanged,
533+ q, &UCListItem::childrenChanged);
534+ q->setFlag(QQuickItem::ItemHasContents);
535+ // turn activeFocusOnPress on
536+ activeFocusOnPress = true;
537+ setFocusable();
538+
539+ // watch size change and set implicit size;
540+ QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), q, SLOT(_q_updateSize()));
541+ _q_updateSize();
542+}
543+
544+void UCListItemPrivate::setFocusable()
545+{
546+ // alsways accept mouse events
547+ Q_Q(UCListItem);
548+ q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton);
549+ q->setFiltersChildMouseEvents(true);
550+}
551+
552+void UCListItemPrivate::_q_rebound()
553+{
554+ setPressed(false);
555+ // disconnect the flickable
556+ listenToRebind(false);
557+}
558+
559+// called when units size changes
560+void UCListItemPrivate::_q_updateSize()
561+{
562+ Q_Q(UCListItem);
563+ QQuickItem *owner = flickable ? flickable : parentItem;
564+ q->setImplicitWidth(owner ? owner->width() : UCUnits::instance().gu(40));
565+ q->setImplicitHeight(UCUnits::instance().gu(6));
566+}
567+
568+// set pressed flag and update background
569+void UCListItemPrivate::setPressed(bool pressed)
570+{
571+ if (this->pressed != pressed) {
572+ this->pressed = pressed;
573+ background->update();
574+ Q_Q(UCListItem);
575+ Q_EMIT q->pressedChanged();
576+ }
577+}
578+
579+// connects/disconnects from the Flickable anchestor to get notified when to do rebound
580+void UCListItemPrivate::listenToRebind(bool listen)
581+{
582+ if (flickable.isNull()) {
583+ return;
584+ }
585+ if (listen) {
586+ QObject::connect(flickable.data(), SIGNAL(movementStarted()), q_ptr, SLOT(_q_rebound()));
587+ } else {
588+ QObject::disconnect(flickable.data(), SIGNAL(movementStarted()), q_ptr, SLOT(_q_rebound()));
589+ }
590+}
591+
592+/*!
593+ * \qmltype ListItem
594+ * \instantiates UCListItem
595+ * \inqmlmodule Ubuntu.Components 1.1
596+ * \ingroup ubuntu
597+ * \brief The ListItem element provides Ubuntu design standards for list or grid
598+ * views.
599+ *
600+ * The component is dedicated to be used in designs with static or dynamic lists
601+ * (i.e. list views where each item's layout differs or in lists where the content
602+ * is determined by a given model, thus each element has the same layout). The
603+ * element does not define any specific layout, components can be placed in any
604+ * ways on it. However, when used in list views, the content must be carefully
605+ * chosen to in order to keep the kinetic behavior and the highest FPS possible.
606+ */
607+
608+/*!
609+ * \qmlsignal ListItem::clicked()
610+ *
611+ * The signal is emitted when the component gets released while the \l pressed property
612+ * is set. When used in Flickable, the signal is not emitted if when the Flickable gets
613+ * moved.
614+ */
615+UCListItem::UCListItem(QQuickItem *parent)
616+ : UCStyledItemBase(*(new UCListItemPrivate), parent)
617+{
618+ Q_D(UCListItem);
619+ d->init();
620+}
621+
622+UCListItem::~UCListItem()
623+{
624+}
625+
626+void UCListItem::itemChange(ItemChange change, const ItemChangeData &data)
627+{
628+ UCStyledItemBase::itemChange(change, data);
629+ if (change == ItemParentHasChanged) {
630+ Q_D(UCListItem);
631+ // make sure we are not connected to the previous Flickable
632+ d->listenToRebind(false);
633+ // check if we are in a positioner, and if that positioner is in a Flickable
634+ QQuickBasePositioner *positioner = qobject_cast<QQuickBasePositioner*>(data.item);
635+ if (positioner && positioner->parentItem()) {
636+ d->flickable = qobject_cast<QQuickFlickable*>(positioner->parentItem()->parentItem());
637+ } else if (data.item && data.item->parentItem()){
638+ // check if we are in a Flickable then
639+ d->flickable = qobject_cast<QQuickFlickable*>(data.item->parentItem());
640+ }
641+
642+ if (d->flickable) {
643+ // connect to flickable to get width changes
644+ QObject::connect(d->flickable, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
645+ } else if (data.item) {
646+ QObject::connect(data.item, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
647+ }
648+
649+ // update size
650+ d->_q_updateSize();
651+ }
652+}
653+
654+void UCListItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
655+{
656+ UCStyledItemBase::geometryChanged(newGeometry, oldGeometry);
657+ // resize background item
658+ Q_D(UCListItem);
659+ QRectF rect(boundingRect());
660+ d->background->setSize(rect.size());
661+}
662+void UCListItem::mousePressEvent(QMouseEvent *event)
663+{
664+ UCStyledItemBase::mousePressEvent(event);
665+ Q_D(UCListItem);
666+ if (!d->flickable.isNull() && d->flickable->isMoving()) {
667+ // while moving, we cannot select any items
668+ return;
669+ }
670+ d->setPressed(true);
671+ // connect the Flickable to know when to rebound
672+ d->listenToRebind(true);
673+ // accept the event so we get the rest of the events as well
674+ event->setAccepted(true);
675+}
676+
677+void UCListItem::mouseReleaseEvent(QMouseEvent *event)
678+{
679+ Q_D(UCListItem);
680+ // set released
681+ if (d->pressed) {
682+ Q_EMIT clicked();
683+ }
684+ // save pressed state as UCFocusScope resets it seemlessly
685+ bool wasPressed = d->pressed;
686+ UCStyledItemBase::mouseReleaseEvent(event);
687+ d->pressed = wasPressed;
688+ d->setPressed(false);
689+}
690+
691+/*!
692+ * \qmlpropertygroup ::ListItem::background
693+ * \qmlproperty color ListItem::background.color
694+ * \qmlproperty color ListItem::background.pressedColor
695+ *
696+ * background grouped property is an Item which holds the layout of the item, with
697+ * abilities to show different colors when in normal state or when pressed. All
698+ * properties from Item are accessible and can be used to control user defined
699+ * actions or animations, with the exception of the followings:
700+ * \list A
701+ * \li do not alter x, y, width or height properties as those are controlled by the
702+ * item itself when leading or trailing options are revealed and will destroy
703+ * your logic
704+ * \li never anchor left or right as it will block revealing the options.
705+ * \endlist
706+ */
707+UCListItemBackground* UCListItem::background() const
708+{
709+ Q_D(const UCListItem);
710+ return d->background;
711+}
712+
713+/*!
714+ * \qmlproperty bool ListItem::pressed
715+ * True when the item is pressed. The items stays pressed when the mouse or touch
716+ * is moved horizontally. When in Flickable (or ListView), the item gets un-pressed
717+ * (false) when the mouse or touch is moved towards the vertical direction causing
718+ * the flickable to move.
719+ */
720+bool UCListItem::pressed() const
721+{
722+ Q_D(const UCListItem);
723+ return d->pressed;
724+}
725+
726+/*!
727+ * \qmlproperty list<Object> ListItem::data
728+ * \default
729+ * Overloaded default property containing all the children and resources.
730+ */
731+QQmlListProperty<QObject> UCListItem::data()
732+{
733+ Q_D(UCListItem);
734+ return QQuickItemPrivate::get(d->background)->data();
735+}
736+
737+/*!
738+ * \qmlproperty list<Item> ListItem::children
739+ * Overloaded default property containing all the visible children of the item.
740+ */
741+QQmlListProperty<QQuickItem> UCListItem::children()
742+{
743+ Q_D(UCListItem);
744+ return QQuickItemPrivate::get(d->background)->children();
745+}
746+
747+#include "moc_uclistitem.cpp"
748
749=== added file 'modules/Ubuntu/Components/plugin/uclistitem.h'
750--- modules/Ubuntu/Components/plugin/uclistitem.h 1970-01-01 00:00:00 +0000
751+++ modules/Ubuntu/Components/plugin/uclistitem.h 2014-09-04 06:44:23 +0000
752@@ -0,0 +1,62 @@
753+/*
754+ * Copyright 2014 Canonical Ltd.
755+ *
756+ * This program is free software; you can redistribute it and/or modify
757+ * it under the terms of the GNU Lesser General Public License as published by
758+ * the Free Software Foundation; version 3.
759+ *
760+ * This program is distributed in the hope that it will be useful,
761+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
762+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
763+ * GNU Lesser General Public License for more details.
764+ *
765+ * You should have received a copy of the GNU Lesser General Public License
766+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
767+ */
768+
769+#ifndef UCLISTITEM_H
770+#define UCLISTITEM_H
771+
772+#include <QtQuick/QQuickItem>
773+#include "ucstyleditembase.h"
774+
775+class UCListItemBackground;
776+class UCListItemPrivate;
777+class UCListItem : public UCStyledItemBase
778+{
779+ Q_OBJECT
780+ Q_PROPERTY(UCListItemBackground *background READ background CONSTANT)
781+ Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
782+ Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false)
783+ Q_PROPERTY(QQmlListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
784+ Q_CLASSINFO("DefaultProperty", "data")
785+public:
786+ explicit UCListItem(QQuickItem *parent = 0);
787+ ~UCListItem();
788+
789+ UCListItemBackground *background() const;
790+ bool pressed() const;
791+
792+protected:
793+ void itemChange(ItemChange change, const ItemChangeData &data);
794+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
795+ void mousePressEvent(QMouseEvent *event);
796+ void mouseReleaseEvent(QMouseEvent *event);
797+
798+Q_SIGNALS:
799+ void pressedChanged();
800+ void childrenChanged();
801+
802+ void clicked();
803+
804+public Q_SLOTS:
805+
806+private:
807+ Q_DECLARE_PRIVATE(UCListItem)
808+ QQmlListProperty<QObject> data();
809+ QQmlListProperty<QQuickItem> children();
810+ Q_PRIVATE_SLOT(d_func(), void _q_rebound())
811+ Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
812+};
813+
814+#endif // UCLISTITEM_H
815
816=== added file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
817--- modules/Ubuntu/Components/plugin/uclistitem_p.h 1970-01-01 00:00:00 +0000
818+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-09-04 06:44:23 +0000
819@@ -0,0 +1,87 @@
820+/*
821+ * Copyright 2014 Canonical Ltd.
822+ *
823+ * This program is free software; you can redistribute it and/or modify
824+ * it under the terms of the GNU Lesser General Public License as published by
825+ * the Free Software Foundation; version 3.
826+ *
827+ * This program is distributed in the hope that it will be useful,
828+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
829+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
830+ * GNU Lesser General Public License for more details.
831+ *
832+ * You should have received a copy of the GNU Lesser General Public License
833+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
834+ */
835+
836+#ifndef UCVIEWITEM_P_H
837+#define UCVIEWITEM_P_H
838+
839+#include "uclistitem.h"
840+#include "ucstyleditembase_p.h"
841+#include <QtCore/QPointer>
842+
843+class QQuickFlickable;
844+class UCListItemBackground;
845+class UCListItemPrivate : public UCStyledItemBasePrivate
846+{
847+ Q_DECLARE_PUBLIC(UCListItem)
848+public:
849+ UCListItemPrivate();
850+ virtual ~UCListItemPrivate();
851+ void init();
852+
853+ static inline UCListItemPrivate *get(UCListItem *that)
854+ {
855+ Q_ASSERT(that);
856+ return that->d_func();
857+ }
858+
859+ // override setFocusable()
860+ void setFocusable();
861+
862+ void _q_rebound();
863+ void _q_updateSize();
864+ void setPressed(bool pressed);
865+ void listenToRebind(bool listen);
866+
867+ bool pressed:1;
868+ QPointer<QQuickFlickable> flickable;
869+ UCListItemBackground *background;
870+};
871+
872+class UCListItemBackground : public QQuickItem
873+{
874+ Q_OBJECT
875+ Q_PROPERTY(QColor color MEMBER m_color WRITE setColor NOTIFY colorChanged)
876+ Q_PROPERTY(QColor pressedColor MEMBER m_pressedColor WRITE setPressedColor NOTIFY pressedColorChanged)
877+public:
878+ explicit UCListItemBackground(QQuickItem *parent = 0);
879+ ~UCListItemBackground();
880+
881+ void setColor(const QColor &color);
882+ void setPressedColor(const QColor &color);
883+
884+Q_SIGNALS:
885+ void colorChanged();
886+ void pressedColorChanged();
887+
888+protected:
889+ void itemChange(ItemChange change, const ItemChangeData &data);
890+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data);
891+
892+private Q_SLOTS:
893+ void updateColors();
894+
895+private:
896+ QColor m_color;
897+ QColor m_pressedColor;
898+ UCListItem *m_item;
899+ bool m_pressedColorChanged:1;
900+};
901+
902+QColor getPaletteColor(const char *profile, const char *color);
903+
904+QML_DECLARE_TYPE(UCListItemBackground)
905+
906+#endif // UCVIEWITEM_P_H
907
908=== modified file 'modules/Ubuntu/Components/qmldir'
909--- modules/Ubuntu/Components/qmldir 2014-08-19 13:04:26 +0000
910+++ modules/Ubuntu/Components/qmldir 2014-09-04 06:44:23 +0000
911@@ -44,6 +44,7 @@
912 ColorUtils 0.1 colorUtils.js
913 DateUtils 0.1 dateUtils.js
914 UbuntuListView 0.1 UbuntuListView.qml
915+singleton UbuntuColors 0.1 10/UbuntuColors10.qml
916
917 internal TextCursor TextCursor.qml
918 internal TextInputPopover TextInputPopover.qml
919@@ -88,6 +89,7 @@
920 ColorUtils 1.0 colorUtils.js
921 DateUtils 1.0 dateUtils.js
922 UbuntuListView 1.0 UbuntuListView.qml
923+singleton UbuntuColors 1.0 10/UbuntuColors10.qml
924
925 #version 1.1
926 ComboButton 1.1 ComboButton.qml
927@@ -103,3 +105,4 @@
928 PageHeadState 1.1 PageHeadState.qml
929 Icon 1.1 Icon11.qml
930 StyledItem 1.1 StyledItem.qml
931+singleton UbuntuColors 1.1 11/UbuntuColors.qml
932
933=== modified file 'tests/qmlapicheck.py'
934--- tests/qmlapicheck.py 2014-07-29 16:13:32 +0000
935+++ tests/qmlapicheck.py 2014-09-04 06:44:23 +0000
936@@ -48,28 +48,32 @@
937 classes = {}
938 for line in fileinput.input():
939 if fileinput.filename()[-6:] == 'qmldir':
940+ if line == '\n' or line[:1] == '#':
941+ # Comments
942+ continue
943 if line[:8] == 'internal':
944 # Internal components are not part of public API
945 continue
946 pieces = line.strip().split(' ')
947- if len(pieces) > 2:
948- filename = pieces[2]
949- # We only work with QML
950- if filename[-3:] == 'qml':
951- # Filenames are relative to the qmldir
952- # Foo 1.0 Foo.qml
953- folder = os.path.dirname(fileinput.filename())
954- fullpath = folder + '/' + filename
955- classname = pieces[0]
956- version = pieces[1]
957- if fullpath not in inputfiles:
958- inputfiles.append(fullpath)
959- classes[fullpath] = [classname, version]
960- else:
961- versions = classes[fullpath]
962- if classname not in versions:
963- versions.append(classname)
964- versions.append(version)
965+ # [singleton] Foo 1.0 Foo.qml
966+ if pieces[0] == 'singleton':
967+ pieces.pop(0)
968+ if pieces[0].islower():
969+ # Unknown keyword
970+ continue
971+ classname, version, filename = pieces
972+ if filename[-3:] == 'qml':
973+ # Filenames are relative to the qmldir
974+ folder = os.path.dirname(fileinput.filename())
975+ fullpath = folder + '/' + filename
976+ if fullpath not in inputfiles:
977+ inputfiles.append(fullpath)
978+ classes[fullpath] = [classname, version]
979+ else:
980+ versions = classes[fullpath]
981+ if classname not in versions:
982+ versions.append(classname)
983+ versions.append(version)
984 else:
985 inputfiles.append(fileinput.filename())
986 fileinput.nextfile()
987
988=== modified file 'tests/qmlapicheck.sh'
989--- tests/qmlapicheck.sh 2014-07-16 06:25:18 +0000
990+++ tests/qmlapicheck.sh 2014-09-04 06:44:23 +0000
991@@ -15,7 +15,7 @@
992 # along with this program. If not, see <http://www.gnu.org/licenses/>.
993 #
994 ################################################################################
995-QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/Colors/UbuntuColors.qml modules/Ubuntu/Components/*/qmldir modules/Ubuntu/Components/Pickers/PickerPanel.qml"
996+QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/*/qmldir"
997 CPP="Ubuntu.Components Ubuntu.Layouts Ubuntu.PerformanceMetrics Ubuntu.Test"
998
999 echo Dumping QML API of C++ components
1000
1001=== added directory 'tests/resources/listitems'
1002=== added file 'tests/resources/listitems/ListItemTest.qml'
1003--- tests/resources/listitems/ListItemTest.qml 1970-01-01 00:00:00 +0000
1004+++ tests/resources/listitems/ListItemTest.qml 2014-09-04 06:44:23 +0000
1005@@ -0,0 +1,90 @@
1006+/*
1007+ * Copyright 2014 Canonical Ltd.
1008+ *
1009+ * This program is free software; you can redistribute it and/or modify
1010+ * it under the terms of the GNU Lesser General Public License as published by
1011+ * the Free Software Foundation; version 3.
1012+ *
1013+ * This program is distributed in the hope that it will be useful,
1014+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1015+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1016+ * GNU Lesser General Public License for more details.
1017+ *
1018+ * You should have received a copy of the GNU Lesser General Public License
1019+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1020+ */
1021+
1022+import QtQuick 2.2
1023+import Ubuntu.Components 1.1
1024+
1025+MainView {
1026+ id: main
1027+ width: units.gu(50)
1028+ height: units.gu(100)
1029+
1030+ property bool override: false
1031+
1032+ Column {
1033+ anchors {
1034+ left: parent.left
1035+ right: parent.right
1036+ }
1037+
1038+ ListItem {
1039+ id: testItem
1040+ background.color: "green"
1041+ onClicked: {
1042+ print("click")
1043+ main.override = !main.override
1044+ }
1045+ Rectangle {
1046+ anchors.fill: parent
1047+ color: "tan"
1048+ }
1049+ }
1050+
1051+ ListView {
1052+ id: view
1053+ clip: true
1054+ width: parent.width
1055+ height: units.gu(40)
1056+ model: 100
1057+ pressDelay: 0
1058+ delegate: ListItem {
1059+ id: listItem
1060+ onClicked: print(" clicked")
1061+ Label {
1062+ text: modelData + " item"
1063+ }
1064+ states: State {
1065+ name: "override"
1066+ when: main.override
1067+ PropertyChanges {
1068+ target: listItem.background
1069+ pressedColor: "brown"
1070+ }
1071+ }
1072+ }
1073+ }
1074+ Flickable {
1075+ id: flicker
1076+ width: parent.width
1077+ height: units.gu(40)
1078+ clip: true
1079+ contentHeight: column.childrenRect.height
1080+ Column {
1081+ id: column
1082+ width: view.width
1083+ Repeater {
1084+ model: 100
1085+ ListItem {
1086+ background {
1087+ color: "red"
1088+ pressedColor: "lime"
1089+ }
1090+ }
1091+ }
1092+ }
1093+ }
1094+ }
1095+}
1096
1097=== added file 'tests/unit/tst_performance/ItemList.qml'
1098--- tests/unit/tst_performance/ItemList.qml 1970-01-01 00:00:00 +0000
1099+++ tests/unit/tst_performance/ItemList.qml 2014-09-04 06:44:23 +0000
1100@@ -0,0 +1,30 @@
1101+/*
1102+ * Copyright 2014 Canonical Ltd.
1103+ *
1104+ * This program is free software; you can redistribute it and/or modify
1105+ * it under the terms of the GNU Lesser General Public License as published by
1106+ * the Free Software Foundation; version 3.
1107+ *
1108+ * This program is distributed in the hope that it will be useful,
1109+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1110+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1111+ * GNU Lesser General Public License for more details.
1112+ *
1113+ * You should have received a copy of the GNU Lesser General Public License
1114+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1115+ */
1116+
1117+import QtQuick 2.0
1118+import Ubuntu.Components 1.1
1119+
1120+Column {
1121+ width: 800
1122+ height: 600
1123+ Repeater {
1124+ model: 10000
1125+ Item {
1126+ width: parent.width
1127+ height: units.gu(6)
1128+ }
1129+ }
1130+}
1131
1132=== added file 'tests/unit/tst_performance/ListItemList.qml'
1133--- tests/unit/tst_performance/ListItemList.qml 1970-01-01 00:00:00 +0000
1134+++ tests/unit/tst_performance/ListItemList.qml 2014-09-04 06:44:23 +0000
1135@@ -0,0 +1,28 @@
1136+/*
1137+ * Copyright 2014 Canonical Ltd.
1138+ *
1139+ * This program is free software; you can redistribute it and/or modify
1140+ * it under the terms of the GNU Lesser General Public License as published by
1141+ * the Free Software Foundation; version 3.
1142+ *
1143+ * This program is distributed in the hope that it will be useful,
1144+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1145+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1146+ * GNU Lesser General Public License for more details.
1147+ *
1148+ * You should have received a copy of the GNU Lesser General Public License
1149+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1150+ */
1151+
1152+import QtQuick 2.0
1153+import Ubuntu.Components 1.1
1154+
1155+Column {
1156+ width: 800
1157+ height: 600
1158+ Repeater {
1159+ model: 10000
1160+ ListItem {
1161+ }
1162+ }
1163+}
1164
1165=== modified file 'tests/unit/tst_performance/tst_performance.cpp'
1166--- tests/unit/tst_performance/tst_performance.cpp 2013-06-27 15:35:23 +0000
1167+++ tests/unit/tst_performance/tst_performance.cpp 2014-09-04 06:44:23 +0000
1168@@ -74,16 +74,10 @@
1169 QTest::newRow("grid with Label") << "LabelGrid.qml" << QUrl();
1170 QTest::newRow("grid with UbuntuShape") << "UbuntuShapeGrid.qml" << QUrl();
1171 QTest::newRow("grid with UbuntuShapePair") << "PairOfUbuntuShapeGrid.qml" << QUrl();
1172- QTest::newRow("grid with ButtonStyle") << "ButtonStyleGrid.qml" << QUrl();
1173 QTest::newRow("grid with Button") << "ButtonGrid.qml" << QUrl();
1174-// QTest::newRow("grid with CheckBoxStyle") << "CheckBoxStyleGrid.qml" << QUrl();
1175-// QTest::newRow("grid with CheckBox") << "CheckBoxGrid.qml" << QUrl();
1176-// QTest::newRow("grid with SwitchStyle") << "SwitchStyleGrid.qml" << QUrl();
1177-// QTest::newRow("grid with Switch") << "SwitchGrid.qml" << QUrl();
1178-// QTest::newRow("grid with SwitchStyle") << "SwitchStyleGrid.qml" << QUrl();
1179-// QTest::newRow("grid with Switch") << "SwitchGrid.qml" << QUrl();
1180- QTest::newRow("grid with SliderStyle") << "SliderStyleGrid.qml" << QUrl();
1181 QTest::newRow("grid with Slider") << "SliderGrid.qml" << QUrl();
1182+ QTest::newRow("list with Item") << "ItemList.qml" << QUrl();
1183+ QTest::newRow("list with ListItem") << "ListItemList.qml" << QUrl();
1184 }
1185
1186 void benchmark_GridOfComponents()
1187
1188=== modified file 'tests/unit/tst_performance/tst_performance.pro'
1189--- tests/unit/tst_performance/tst_performance.pro 2013-06-27 15:20:12 +0000
1190+++ tests/unit/tst_performance/tst_performance.pro 2014-09-04 06:44:23 +0000
1191@@ -19,4 +19,6 @@
1192 TextWithImport.qml \
1193 TextWithImportGrid.qml \
1194 TextWithImportPopupsGrid.qml \
1195- TextWithImportPopups.qml
1196+ TextWithImportPopups.qml \
1197+ ItemList.qml \
1198+ ListItemList.qml
1199
1200=== added file 'tests/unit_x11/tst_components/tst_listitem.qml'
1201--- tests/unit_x11/tst_components/tst_listitem.qml 1970-01-01 00:00:00 +0000
1202+++ tests/unit_x11/tst_components/tst_listitem.qml 2014-09-04 06:44:23 +0000
1203@@ -0,0 +1,149 @@
1204+/*
1205+ * Copyright 2014 Canonical Ltd.
1206+ *
1207+ * This program is free software; you can redistribute it and/or modify
1208+ * it under the terms of the GNU Lesser General Public License as published by
1209+ * the Free Software Foundation; version 3.
1210+ *
1211+ * This program is distributed in the hope that it will be useful,
1212+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1213+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1214+ * GNU Lesser General Public License for more details.
1215+ *
1216+ * You should have received a copy of the GNU Lesser General Public License
1217+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1218+ */
1219+
1220+import QtQuick 2.0
1221+import QtTest 1.0
1222+import Ubuntu.Test 1.0
1223+import Ubuntu.Components 1.1
1224+
1225+Item {
1226+ width: units.gu(40)
1227+ height: units.gu(71)
1228+
1229+ Column {
1230+ width: parent.width
1231+ ListItem {
1232+ id: defaults
1233+ width: parent.width
1234+ }
1235+ ListItem {
1236+ id: testItem
1237+ width: parent.width
1238+ background.color: "blue"
1239+ Item {
1240+ id: contentItem
1241+ anchors.fill: parent
1242+ }
1243+ }
1244+ ListView {
1245+ id: listView
1246+ width: parent.width
1247+ height: units.gu(24)
1248+ clip: true
1249+ model: 10
1250+ delegate: ListItem {
1251+ objectName: "listItem" + index
1252+ width: parent.width
1253+ }
1254+ }
1255+ }
1256+
1257+ UbuntuTestCase {
1258+ name: "ListItemAPI"
1259+ when: windowShown
1260+
1261+ SignalSpy {
1262+ id: pressedSpy
1263+ signalName: "pressedChanged"
1264+ target: testItem
1265+ }
1266+
1267+ SignalSpy {
1268+ id: clickSpy
1269+ signalName: "clicked"
1270+ target: testItem;
1271+ }
1272+
1273+ function centerOf(item) {
1274+ return Qt.point(item.width / 2, item.height / 2);
1275+ }
1276+
1277+ function initTestCase() {
1278+ TestExtras.registerTouchDevice();
1279+ }
1280+
1281+ function cleanup() {
1282+ pressedSpy.clear();
1283+ clickSpy.clear();
1284+ // make sure all events are processed
1285+ wait(200);
1286+ }
1287+
1288+ function test_0_defaults() {
1289+ verify(defaults.background !== null, "Defaults is null");
1290+ compare(defaults.background.color, "#000000", "Transparent by default");
1291+ compare(defaults.background.pressedColor, Theme.palette.selected.background, "Theme.palette.selected.background color by default")
1292+ compare(defaults.pressed, false, "Not pressed buy default");
1293+ }
1294+
1295+ function test_children_in_background() {
1296+ compare(contentItem.parent, testItem.background, "Content is not in the right holder!");
1297+ }
1298+
1299+ function test_pressedChanged_on_click() {
1300+ mousePress(testItem, testItem.width / 2, testItem.height / 2);
1301+ pressedSpy.wait();
1302+ mouseRelease(testItem, testItem.width / 2, testItem.height / 2);
1303+ }
1304+ function test_pressedChanged_on_tap() {
1305+ TestExtras.touchPress(0, testItem, centerOf(testItem));
1306+ pressedSpy.wait();
1307+ TestExtras.touchRelease(0, testItem, centerOf(testItem));
1308+ // local cleanup, wait few msecs to suppress double tap
1309+ wait(400);
1310+ }
1311+
1312+ function test_clicked_on_mouse() {
1313+ mouseClick(testItem, testItem.width / 2, testItem.height / 2);
1314+ clickSpy.wait();
1315+ }
1316+ function test_clicked_on_tap() {
1317+ TestExtras.touchClick(0, testItem, centerOf(testItem));
1318+ clickSpy.wait();
1319+ }
1320+
1321+ function test_mouse_click_on_listitem() {
1322+ var listItem = findChild(listView, "listItem0");
1323+ verify(listItem, "Cannot find listItem0");
1324+
1325+ mousePress(listItem, listItem.width / 2, 0);
1326+ compare(listItem.pressed, true, "Item is not pressed?");
1327+ // do 5 moves to be able to sense it
1328+ var dy = 0;
1329+ for (var i = 1; i <= 5; i++) {
1330+ dy += i * 10;
1331+ mouseMove(listItem, listItem.width / 2, dy);
1332+ }
1333+ compare(listItem.pressed, false, "Item is pressed still!");
1334+ mouseRelease(listItem, listItem.width / 2, dy);
1335+ }
1336+ function test_touch_click_on_listitem() {
1337+ var listItem = findChild(listView, "listItem0");
1338+ verify(listItem, "Cannot find listItem0");
1339+
1340+ TestExtras.touchPress(0, listItem, Qt.point(listItem.width / 2, 5));
1341+ compare(listItem.pressed, true, "Item is not pressed?");
1342+ // do 5 moves to be able to sense it
1343+ var dy = 0;
1344+ for (var i = 1; i <= 5; i++) {
1345+ dy += i * 10;
1346+ TestExtras.touchMove(0, listItem, Qt.point(listItem.width / 2, dy));
1347+ }
1348+ compare(listItem.pressed, false, "Item is pressed still!");
1349+ TestExtras.touchRelease(0, listItem, Qt.point(listItem.width / 2, dy));
1350+ }
1351+ }
1352+}

Subscribers

People subscribed via source and target branches