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
=== modified file 'components.api'
--- components.api 2014-08-26 14:16:46 +0000
+++ components.api 2014-09-04 06:44:23 +0000
@@ -43,22 +43,6 @@
43CheckBox 0.1 1.043CheckBox 0.1 1.0
44AbstractButton44AbstractButton
45 property bool checked45 property bool checked
46modules/Ubuntu/Components/Colors/UbuntuColors.qml
47QtObject
48 readonly property color orange
49 readonly property color lightAubergine
50 readonly property color midAubergine
51 readonly property color darkAubergine
52 readonly property color warmGrey
53 readonly property color coolGrey
54 property Gradient orangeGradient
55 property Gradient greyGradient
56 readonly property color lightGrey
57 readonly property color darkGrey
58 readonly property color red
59 readonly property color green
60 readonly property color blue
61 readonly property color purple
62ComboButton 1.146ComboButton 1.1
63Button47Button
64 property bool expanded48 property bool expanded
@@ -98,6 +82,8 @@
98Label 0.1 1.082Label 0.1 1.0
99Text83Text
100 property string fontSize84 property string fontSize
85ListItem 1.1
86ListItemBase
101Base 0.1 1.087Base 0.1 1.0
102Empty88Empty
103 property variant icon89 property variant icon
@@ -353,7 +339,7 @@
353PickerDelegate 0.1 1.0339PickerDelegate 0.1 1.0
354AbstractButton340AbstractButton
355 readonly property Picker picker341 readonly property Picker picker
356modules/Ubuntu/Components/Pickers/PickerPanel.qml342PickerPanel 0.1 1.0
357Object343Object
358 function openDatePicker(caller, property, mode)344 function openDatePicker(caller, property, mode)
359ActionSelectionPopover 0.1 1.0345ActionSelectionPopover 0.1 1.0
@@ -657,6 +643,32 @@
657 property Item pageStack643 property Item pageStack
658 property bool opened644 property bool opened
659 property bool locked645 property bool locked
646UbuntuColors 1.1
647QtObject
648 readonly property color orange
649 readonly property color lightAubergine
650 readonly property color midAubergine
651 readonly property color darkAubergine
652 readonly property color warmGrey
653 readonly property color coolGrey
654 property Gradient orangeGradient
655 property Gradient greyGradient
656 readonly property color lightGrey
657 readonly property color darkGrey
658 readonly property color red
659 readonly property color green
660 readonly property color blue
661 readonly property color purple
662UbuntuColors 0.1 1.0
663QtObject
664 readonly property color orange
665 readonly property color lightAubergine
666 readonly property color midAubergine
667 readonly property color darkAubergine
668 readonly property color warmGrey
669 readonly property color coolGrey
670 property Gradient orangeGradient
671 property Gradient greyGradient
660UbuntuListView 0.1 1.0672UbuntuListView 0.1 1.0
661ListView673ListView
662 property int expandedIndex674 property int expandedIndex
@@ -804,6 +816,19 @@
804 name: "UCInverseMouse"816 name: "UCInverseMouse"
805 prototype: "UCMouse"817 prototype: "UCMouse"
806 exports: ["InverseMouse 0.1", "InverseMouse 1.0"]818 exports: ["InverseMouse 0.1", "InverseMouse 1.0"]
819 name: "UCListItemBackground"
820 prototype: "QQuickItem"
821 Property { name: "color"; type: "QColor" }
822 Property { name: "pressedColor"; type: "QColor" }
823 name: "UCListItemBase"
824 prototype: "UCStyledItemBase"
825 exports: ["ListItemBase 1.1"]
826 Property { name: "background"; type: "UCListItemBackground"; isReadonly: true; isPointer: true }
827 Property { name: "pressed"; type: "bool"; isReadonly: true }
828 Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
829 Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true }
830 Property { name: "owningItem"; type: "QQuickItem"; isReadonly: true; isPointer: true }
831 Signal { name: "clicked" }
807 name: "UCMouse"832 name: "UCMouse"
808 prototype: "QObject"833 prototype: "QObject"
809 exports: ["Mouse 0.1", "Mouse 1.0"]834 exports: ["Mouse 0.1", "Mouse 1.0"]
@@ -924,6 +949,17 @@
924 Parameter { name: "singular"; type: "string" }949 Parameter { name: "singular"; type: "string" }
925 Parameter { name: "plural"; type: "string" }950 Parameter { name: "plural"; type: "string" }
926 Parameter { name: "n"; type: "int" }951 Parameter { name: "n"; type: "int" }
952 prototype: "QObject"
953 name: "UbuntuColors"
954 exports: ["UbuntuColors -1.-1"]
955 Property { name: "orange"; type: "QColor"; isReadonly: true }
956 Property { name: "lightAubergine"; type: "QColor"; isReadonly: true }
957 Property { name: "midAubergine"; type: "QColor"; isReadonly: true }
958 Property { name: "darkAubergine"; type: "QColor"; isReadonly: true }
959 Property { name: "warmGrey"; type: "QColor"; isReadonly: true }
960 Property { name: "coolGrey"; type: "QColor"; isReadonly: true }
961 Property { name: "orangeGradient"; type: "QQuickGradient"; isPointer: true }
962 Property { name: "greyGradient"; type: "QQuickGradient"; isPointer: true }
927 name: "ULConditionalLayout"963 name: "ULConditionalLayout"
928 prototype: "QObject"964 prototype: "QObject"
929 exports: ["ConditionalLayout 0.1", "ConditionalLayout 1.0"]965 exports: ["ConditionalLayout 0.1", "ConditionalLayout 1.0"]
930966
=== modified file 'debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install'
--- debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2014-07-28 10:34:06 +0000
+++ debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2014-09-04 06:44:23 +0000
@@ -21,7 +21,6 @@
21usr/lib/*/qt5/qml/Ubuntu/Components/Popups/*.js21usr/lib/*/qt5/qml/Ubuntu/Components/Popups/*.js
22usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/*.qml22usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/*.qml
23usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/qmldir23usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/qmldir
24usr/lib/*/qt5/qml/Ubuntu/Components/Colors/*.qml
25usr/lib/*/qt5/qml/Ubuntu/Components/Styles/*.qml24usr/lib/*/qt5/qml/Ubuntu/Components/Styles/*.qml
26usr/lib/*/qt5/qml/Ubuntu/Components/Styles/qmldir25usr/lib/*/qt5/qml/Ubuntu/Components/Styles/qmldir
27usr/lib/*/qt5/qml/Ubuntu/Test26usr/lib/*/qt5/qml/Ubuntu/Test
2827
=== renamed file 'modules/Ubuntu/Components/Colors/UbuntuColors10.qml' => 'modules/Ubuntu/Components/10/UbuntuColors10.qml'
--- modules/Ubuntu/Components/Colors/UbuntuColors10.qml 2014-07-01 20:52:48 +0000
+++ modules/Ubuntu/Components/10/UbuntuColors10.qml 2014-09-04 06:44:23 +0000
@@ -14,6 +14,7 @@
14 along with this program. If not, see <http://www.gnu.org/licenses/>.14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17pragma Singleton
17import QtQuick 2.218import QtQuick 2.2
1819
19/*!20/*!
2021
=== renamed file 'modules/Ubuntu/Components/Colors/UbuntuColors.qml' => 'modules/Ubuntu/Components/11/UbuntuColors.qml'
--- modules/Ubuntu/Components/Colors/UbuntuColors.qml 2014-07-24 16:02:47 +0000
+++ modules/Ubuntu/Components/11/UbuntuColors.qml 2014-09-04 06:44:23 +0000
@@ -14,6 +14,7 @@
14 along with this program. If not, see <http://www.gnu.org/licenses/>.14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17pragma Singleton
17import QtQuick 2.218import QtQuick 2.2
1819
19/*!20/*!
2021
=== removed directory 'modules/Ubuntu/Components/Colors'
=== removed file 'modules/Ubuntu/Components/Colors/Colors.pro'
--- modules/Ubuntu/Components/Colors/Colors.pro 2013-07-01 05:54:33 +0000
+++ modules/Ubuntu/Components/Colors/Colors.pro 1970-01-01 00:00:00 +0000
@@ -1,9 +0,0 @@
1TEMPLATE = subdirs
2
3uri = Ubuntu.Components.Colors
4installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
5
6qml_files.path = $$installPath
7qml_files.files = *.qml
8
9INSTALLS += qml_files
100
=== removed file 'modules/Ubuntu/Components/Colors/FIXME'
--- modules/Ubuntu/Components/Colors/FIXME 2014-07-01 20:52:48 +0000
+++ modules/Ubuntu/Components/Colors/FIXME 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1UbuntuColors.qml is located in the Colors subdirectory because
2QuickUtils::createQmlObject() fails if the QML file is located in a
3folder that has a qmldir file with JavaScript modules.
4
5UbuntuColors 1.1 is not in a file named UbuntuColors11.qml but in
6UbuntuColors.qml so that qdoc can properly detect the component
7name without a qmldir file.
80
=== modified file 'modules/Ubuntu/Components/Components.pro'
--- modules/Ubuntu/Components/Components.pro 2014-07-28 15:04:39 +0000
+++ modules/Ubuntu/Components/Components.pro 2014-09-04 06:44:23 +0000
@@ -1,5 +1,5 @@
1TEMPLATE = subdirs1TEMPLATE = subdirs
22
3SUBDIRS += plugin Themes Colors 10 113SUBDIRS += plugin Themes 10 11
44
5include(deployment.pri)5include(deployment.pri)
66
=== modified file 'modules/Ubuntu/Components/Pickers/PickerPanel.qml'
--- modules/Ubuntu/Components/Pickers/PickerPanel.qml 2014-08-11 15:21:14 +0000
+++ modules/Ubuntu/Components/Pickers/PickerPanel.qml 2014-09-04 06:44:23 +0000
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17pragma Singleton
17import QtQuick 2.018import QtQuick 2.0
18import QtQuick.Window 2.019import QtQuick.Window 2.0
19import Ubuntu.Components 1.120import Ubuntu.Components 1.1
2021
=== modified file 'modules/Ubuntu/Components/Pickers/qmldir'
--- modules/Ubuntu/Components/Pickers/qmldir 2014-04-20 19:25:12 +0000
+++ modules/Ubuntu/Components/Pickers/qmldir 2014-09-04 06:44:23 +0000
@@ -8,6 +8,7 @@
8internal MonthModel MonthModel.qml8internal MonthModel MonthModel.qml
9internal DayModel DayModel.qml9internal DayModel DayModel.qml
10internal PickerModelBase PickerModelBase.qml10internal PickerModelBase PickerModelBase.qml
11singleton PickerPanel 0.1 PickerPanel.qml
1112
12#version 1.013#version 1.0
13Picker 1.0 Picker.qml14Picker 1.0 Picker.qml
@@ -15,3 +16,4 @@
15Dialer 1.0 Dialer.qml16Dialer 1.0 Dialer.qml
16DialerHand 1.0 DialerHand.qml17DialerHand 1.0 DialerHand.qml
17DatePicker 1.0 DatePicker.qml18DatePicker 1.0 DatePicker.qml
19singleton PickerPanel 1.0 PickerPanel.qml
1820
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2014-08-20 13:03:13 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2014-09-04 06:44:23 +0000
@@ -50,22 +50,19 @@
50#include "ucinversemouse.h"50#include "ucinversemouse.h"
51#include "sortfiltermodel.h"51#include "sortfiltermodel.h"
52#include "ucstyleditembase.h"52#include "ucstyleditembase.h"
53#include "uclistitem.h"
54#include "uclistitem_p.h"
5355
54#include <sys/types.h>56#include <sys/types.h>
55#include <unistd.h>57#include <unistd.h>
56#include <stdexcept>58#include <stdexcept>
5759
60QUrl UbuntuComponentsPlugin::m_baseUrl = QUrl();
61
58/*62/*
59 * Type registration functions.63 * Type registration functions.
60 */64 */
6165
62static QObject *registerPickerPanel(QQmlEngine *engine, QJSEngine *scriptEngine)
63{
64 Q_UNUSED(scriptEngine)
65 return UbuntuComponentsPlugin::registerQmlSingletonType(engine,
66 "Ubuntu.Components", "Pickers/PickerPanel.qml");
67}
68
69static QObject *registerClipboard(QQmlEngine *engine, QJSEngine *scriptEngine)66static QObject *registerClipboard(QQmlEngine *engine, QJSEngine *scriptEngine)
70{67{
71 Q_UNUSED(engine)68 Q_UNUSED(engine)
@@ -93,45 +90,9 @@
93 return uriHandler;90 return uriHandler;
94}91}
9592
96static QObject *registerUbuntuColors10(QQmlEngine *engine, QJSEngine *scriptEngine)93QObject *UbuntuComponentsPlugin::registerQmlSingletonType(QQmlEngine *engine, const char* qmlFile)
97{94{
98 Q_UNUSED(scriptEngine)95 QUrl url = m_baseUrl.resolved(QUrl::fromLocalFile(qmlFile));
99 return UbuntuComponentsPlugin::registerQmlSingletonType(engine,
100 "Ubuntu.Components", "Colors/UbuntuColors10.qml");
101}
102
103static QObject *registerUbuntuColors11(QQmlEngine *engine, QJSEngine *scriptEngine)
104{
105 Q_UNUSED(scriptEngine)
106 return UbuntuComponentsPlugin::registerQmlSingletonType(engine,
107 "Ubuntu.Components", "Colors/UbuntuColors.qml");
108}
109
110QUrl UbuntuComponentsPlugin::baseUrl(const QStringList& importPathList, const char* uri)
111{
112 /* FIXME: remove when migrating to Qt 5.1 and use QQmlExtensionPlugin::baseUrl()
113 http://doc-snapshot.qt-project.org/qt5-stable/qtqml/qqmlextensionplugin.html#baseUrl
114 */
115 QString pluginRelativePath = QString::fromUtf8(uri).replace(".", "/").prepend("/").append("/");
116 QString pluginPath;
117 Q_FOREACH (QString importPath, importPathList) {
118 pluginPath = importPath.append(pluginRelativePath);
119 /* We verify that the directory ending in Ubuntu/Components contains the
120 file libUbuntuComponents.so therefore proving it's the right directory.
121
122 Ref.: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1197293
123 */
124 if (QFile(pluginPath + "libUbuntuComponents.so").exists()) {
125 return QUrl::fromLocalFile(pluginPath);
126 }
127 }
128
129 return QUrl();
130}
131
132QObject *UbuntuComponentsPlugin::registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* qmlFile)
133{
134 QUrl url = baseUrl(engine->importPathList(), uri).resolved(QUrl::fromLocalFile(qmlFile));
135 return QuickUtils::instance().createQmlObject(url, engine);96 return QuickUtils::instance().createQmlObject(url, engine);
136}97}
13798
@@ -163,7 +124,6 @@
163void UbuntuComponentsPlugin::registerTypesToVersion(const char *uri, int major, int minor)124void UbuntuComponentsPlugin::registerTypesToVersion(const char *uri, int major, int minor)
164{125{
165 qmlRegisterType<UCStyledItemBase>(uri, major, minor, "StyledItemBase");126 qmlRegisterType<UCStyledItemBase>(uri, major, minor, "StyledItemBase");
166 qmlRegisterSingletonType<QObject>(uri, major, minor, "UbuntuColors", registerUbuntuColors10);
167 qmlRegisterUncreatableType<UbuntuI18n>(uri, major, minor, "i18n", "Singleton object");127 qmlRegisterUncreatableType<UbuntuI18n>(uri, major, minor, "i18n", "Singleton object");
168 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, major, minor, "QQuickImageBase");128 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, major, minor, "QQuickImageBase");
169 qmlRegisterUncreatableType<UCUnits>(uri, major, minor, "UCUnits", "Not instantiable");129 qmlRegisterUncreatableType<UCUnits>(uri, major, minor, "UCUnits", "Not instantiable");
@@ -184,8 +144,6 @@
184 qmlRegisterSingletonType<UCUriHandler>(uri, major, minor, "UriHandler", registerUriHandler);144 qmlRegisterSingletonType<UCUriHandler>(uri, major, minor, "UriHandler", registerUriHandler);
185 qmlRegisterType<UCMouse>(uri, major, minor, "Mouse");145 qmlRegisterType<UCMouse>(uri, major, minor, "Mouse");
186 qmlRegisterType<UCInverseMouse>(uri, major, minor, "InverseMouse");146 qmlRegisterType<UCInverseMouse>(uri, major, minor, "InverseMouse");
187 // register QML singletons
188 qmlRegisterSingletonType<QObject>(uri, major, minor, "PickerPanel", registerPickerPanel);
189}147}
190148
191void UbuntuComponentsPlugin::registerTypes(const char *uri)149void UbuntuComponentsPlugin::registerTypes(const char *uri)
@@ -195,7 +153,6 @@
195 // register 0.1 for backward compatibility153 // register 0.1 for backward compatibility
196 registerTypesToVersion(uri, 0, 1);154 registerTypesToVersion(uri, 0, 1);
197 registerTypesToVersion(uri, 1, 0);155 registerTypesToVersion(uri, 1, 0);
198 qmlRegisterSingletonType<QObject>(uri, 1, 1, "UbuntuColors", registerUbuntuColors11);
199156
200 // register custom event157 // register custom event
201 ForwardedEvent::registerForwardedEvent();158 ForwardedEvent::registerForwardedEvent();
@@ -208,10 +165,16 @@
208 qmlRegisterType<QSortFilterProxyModelQML>(uri, 1, 1, "SortFilterModel");165 qmlRegisterType<QSortFilterProxyModelQML>(uri, 1, 1, "SortFilterModel");
209 qmlRegisterUncreatableType<FilterBehavior>(uri, 1, 1, "FilterBehavior", "Not instantiable");166 qmlRegisterUncreatableType<FilterBehavior>(uri, 1, 1, "FilterBehavior", "Not instantiable");
210 qmlRegisterUncreatableType<SortBehavior>(uri, 1, 1, "SortBehavior", "Not instantiable");167 qmlRegisterUncreatableType<SortBehavior>(uri, 1, 1, "SortBehavior", "Not instantiable");
168 // ListItem and related types
169 qmlRegisterType<UCListItem, 1>(uri, 1, 1, "ListItem");
170 qmlRegisterType<UCListItemBackground>();
211}171}
212172
213void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)173void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
214{174{
175 // initialize baseURL
176 m_baseUrl = QUrl(baseUrl().toString() + '/');
177
215 QQmlExtensionPlugin::initializeEngine(engine, uri);178 QQmlExtensionPlugin::initializeEngine(engine, uri);
216 QQmlContext* context = engine->rootContext();179 QQmlContext* context = engine->rootContext();
217180
218181
=== modified file 'modules/Ubuntu/Components/plugin/plugin.h'
--- modules/Ubuntu/Components/plugin/plugin.h 2014-04-20 19:25:12 +0000
+++ modules/Ubuntu/Components/plugin/plugin.h 2014-09-04 06:44:23 +0000
@@ -32,14 +32,18 @@
32public:32public:
33 void registerTypes(const char *uri);33 void registerTypes(const char *uri);
34 void initializeEngine(QQmlEngine *engine, const char *uri);34 void initializeEngine(QQmlEngine *engine, const char *uri);
35 static QUrl baseUrl(const QStringList& importPathList, const char* uri);35 static QObject *registerQmlSingletonType(QQmlEngine *engine, const char* qmlFile);
36 static QObject *registerQmlSingletonType(QQmlEngine *engine, const char* uri, const char* qmlFile);36 static const QUrl &pluginUrl()
37 {
38 return m_baseUrl;
39 }
3740
38private Q_SLOTS:41private Q_SLOTS:
39 void registerWindowContextProperty();42 void registerWindowContextProperty();
40 void setWindowContextProperty(QWindow* focusWindow);43 void setWindowContextProperty(QWindow* focusWindow);
4144
42private:45private:
46 static QUrl m_baseUrl;
43 void registerTypesToVersion(const char *uri, int major, int minor);47 void registerTypesToVersion(const char *uri, int major, int minor);
44};48};
45#endif // UBUNTU_COMPONENTS_PLUGIN_H49#endif // UBUNTU_COMPONENTS_PLUGIN_H
4650
=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
--- modules/Ubuntu/Components/plugin/plugin.pro 2014-09-02 09:39:09 +0000
+++ modules/Ubuntu/Components/plugin/plugin.pro 2014-09-04 06:44:23 +0000
@@ -65,7 +65,9 @@
65 ucmouse.h \65 ucmouse.h \
66 unixsignalhandler_p.h \66 unixsignalhandler_p.h \
67 ucstyleditembase.h \67 ucstyleditembase.h \
68 ucstyleditembase_p.h68 ucstyleditembase_p.h \
69 uclistitem.h \
70 uclistitem_p.h
6971
70SOURCES += plugin.cpp \72SOURCES += plugin.cpp \
71 uctheme.cpp \73 uctheme.cpp \
@@ -99,7 +101,8 @@
99 ucurihandler.cpp \101 ucurihandler.cpp \
100 ucmousefilters.cpp \102 ucmousefilters.cpp \
101 unixsignalhandler_p.cpp \103 unixsignalhandler_p.cpp \
102 ucstyleditembase.cpp104 ucstyleditembase.cpp \
105 uclistitem.cpp
103106
104# adapters107# adapters
105SOURCES += adapters/alarmsadapter_organizer.cpp108SOURCES += adapters/alarmsadapter_organizer.cpp
106109
=== added file 'modules/Ubuntu/Components/plugin/uclistitem.cpp'
--- modules/Ubuntu/Components/plugin/uclistitem.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/uclistitem.cpp 2014-09-04 06:44:23 +0000
@@ -0,0 +1,352 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "ucunits.h"
18#include "uctheme.h"
19#include "uclistitem.h"
20#include "uclistitem_p.h"
21#include <QtQml/QQmlInfo>
22#include <QtQuick/private/qquickitem_p.h>
23#include <QtQuick/private/qquickflickable_p.h>
24#include <QtQuick/private/qquickpositioners_p.h>
25
26QColor getPaletteColor(const char *profile, const char *color)
27{
28 QColor result;
29 QObject *palette = UCTheme::instance().palette();
30 if (palette) {
31 QObject *paletteProfile = palette->property(profile).value<QObject*>();
32 if (paletteProfile) {
33 result = paletteProfile->property(color).value<QColor>();
34 }
35 }
36 return result;
37}
38
39
40/******************************************************************************
41 * ListItemBackground
42 */
43UCListItemBackground::UCListItemBackground(QQuickItem *parent)
44 : QQuickItem(parent)
45 , m_color(Qt::transparent)
46 , m_pressedColor(Qt::yellow)
47 , m_item(0)
48{
49 setFlag(QQuickItem::ItemHasContents);
50 // catch theme palette changes
51 connect(&UCTheme::instance(), &UCTheme::paletteChanged, this, &UCListItemBackground::updateColors);
52 updateColors();
53}
54
55UCListItemBackground::~UCListItemBackground()
56{
57}
58
59void UCListItemBackground::setColor(const QColor &color)
60{
61 if (m_color == color) {
62 return;
63 }
64 m_color = color;
65 update();
66 Q_EMIT colorChanged();
67}
68
69void UCListItemBackground::setPressedColor(const QColor &color)
70{
71 if (m_pressedColor == color) {
72 return;
73 }
74 m_pressedColor = color;
75 // no more theme change watch
76 disconnect(&UCTheme::instance(), &UCTheme::paletteChanged, this, &UCListItemBackground::updateColors);
77 update();
78 Q_EMIT pressedColorChanged();
79}
80
81void UCListItemBackground::updateColors()
82{
83 m_pressedColor = getPaletteColor("selected", "background");
84 update();
85}
86
87
88void UCListItemBackground::itemChange(ItemChange change, const ItemChangeData &data)
89{
90 if (change == ItemParentHasChanged) {
91 m_item = qobject_cast<UCListItem*>(data.item);
92 }
93 QQuickItem::itemChange(change, data);
94}
95
96QSGNode *UCListItemBackground::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
97{
98 Q_UNUSED(data);
99
100 UCListItemPrivate *dd = UCListItemPrivate::get(m_item);
101 bool pressed = (dd && dd->pressed);
102 QColor color = pressed ? m_pressedColor : m_color;
103
104 if (width() <= 0 || height() <= 0 || (color.alpha() == 0)) {
105 delete oldNode;
106 return 0;
107 }
108 QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(oldNode);
109 if (!rectNode) {
110 rectNode = QQuickItemPrivate::get(this)->sceneGraphContext()->createRectangleNode();
111 }
112 rectNode->setColor(color);
113 rectNode->setRect(boundingRect());
114 rectNode->update();
115 return rectNode;
116}
117
118
119UCListItemPrivate::UCListItemPrivate()
120 : UCStyledItemBasePrivate()
121 , pressed(false)
122 , background(new UCListItemBackground)
123{
124}
125UCListItemPrivate::~UCListItemPrivate()
126{
127}
128
129void UCListItemPrivate::init()
130{
131 Q_Q(UCListItem);
132 background->setObjectName("ListItemHolder");
133 QQml_setParent_noEvent(background, q);
134 background->setParentItem(q);
135 // content will be redirected to the background, therefore we must report
136 // children changes as it would come from the main component
137 QObject::connect(background, &UCListItemBackground::childrenChanged,
138 q, &UCListItem::childrenChanged);
139 q->setFlag(QQuickItem::ItemHasContents);
140 // turn activeFocusOnPress on
141 activeFocusOnPress = true;
142 setFocusable();
143
144 // watch size change and set implicit size;
145 QObject::connect(&UCUnits::instance(), SIGNAL(gridUnitChanged()), q, SLOT(_q_updateSize()));
146 _q_updateSize();
147}
148
149void UCListItemPrivate::setFocusable()
150{
151 // alsways accept mouse events
152 Q_Q(UCListItem);
153 q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton);
154 q->setFiltersChildMouseEvents(true);
155}
156
157void UCListItemPrivate::_q_rebound()
158{
159 setPressed(false);
160 // disconnect the flickable
161 listenToRebind(false);
162}
163
164// called when units size changes
165void UCListItemPrivate::_q_updateSize()
166{
167 Q_Q(UCListItem);
168 QQuickItem *owner = flickable ? flickable : parentItem;
169 q->setImplicitWidth(owner ? owner->width() : UCUnits::instance().gu(40));
170 q->setImplicitHeight(UCUnits::instance().gu(6));
171}
172
173// set pressed flag and update background
174void UCListItemPrivate::setPressed(bool pressed)
175{
176 if (this->pressed != pressed) {
177 this->pressed = pressed;
178 background->update();
179 Q_Q(UCListItem);
180 Q_EMIT q->pressedChanged();
181 }
182}
183
184// connects/disconnects from the Flickable anchestor to get notified when to do rebound
185void UCListItemPrivate::listenToRebind(bool listen)
186{
187 if (flickable.isNull()) {
188 return;
189 }
190 if (listen) {
191 QObject::connect(flickable.data(), SIGNAL(movementStarted()), q_ptr, SLOT(_q_rebound()));
192 } else {
193 QObject::disconnect(flickable.data(), SIGNAL(movementStarted()), q_ptr, SLOT(_q_rebound()));
194 }
195}
196
197/*!
198 * \qmltype ListItem
199 * \instantiates UCListItem
200 * \inqmlmodule Ubuntu.Components 1.1
201 * \ingroup ubuntu
202 * \brief The ListItem element provides Ubuntu design standards for list or grid
203 * views.
204 *
205 * The component is dedicated to be used in designs with static or dynamic lists
206 * (i.e. list views where each item's layout differs or in lists where the content
207 * is determined by a given model, thus each element has the same layout). The
208 * element does not define any specific layout, components can be placed in any
209 * ways on it. However, when used in list views, the content must be carefully
210 * chosen to in order to keep the kinetic behavior and the highest FPS possible.
211 */
212
213/*!
214 * \qmlsignal ListItem::clicked()
215 *
216 * The signal is emitted when the component gets released while the \l pressed property
217 * is set. When used in Flickable, the signal is not emitted if when the Flickable gets
218 * moved.
219 */
220UCListItem::UCListItem(QQuickItem *parent)
221 : UCStyledItemBase(*(new UCListItemPrivate), parent)
222{
223 Q_D(UCListItem);
224 d->init();
225}
226
227UCListItem::~UCListItem()
228{
229}
230
231void UCListItem::itemChange(ItemChange change, const ItemChangeData &data)
232{
233 UCStyledItemBase::itemChange(change, data);
234 if (change == ItemParentHasChanged) {
235 Q_D(UCListItem);
236 // make sure we are not connected to the previous Flickable
237 d->listenToRebind(false);
238 // check if we are in a positioner, and if that positioner is in a Flickable
239 QQuickBasePositioner *positioner = qobject_cast<QQuickBasePositioner*>(data.item);
240 if (positioner && positioner->parentItem()) {
241 d->flickable = qobject_cast<QQuickFlickable*>(positioner->parentItem()->parentItem());
242 } else if (data.item && data.item->parentItem()){
243 // check if we are in a Flickable then
244 d->flickable = qobject_cast<QQuickFlickable*>(data.item->parentItem());
245 }
246
247 if (d->flickable) {
248 // connect to flickable to get width changes
249 QObject::connect(d->flickable, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
250 } else if (data.item) {
251 QObject::connect(data.item, SIGNAL(widthChanged()), this, SLOT(_q_updateSize()));
252 }
253
254 // update size
255 d->_q_updateSize();
256 }
257}
258
259void UCListItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
260{
261 UCStyledItemBase::geometryChanged(newGeometry, oldGeometry);
262 // resize background item
263 Q_D(UCListItem);
264 QRectF rect(boundingRect());
265 d->background->setSize(rect.size());
266}
267void UCListItem::mousePressEvent(QMouseEvent *event)
268{
269 UCStyledItemBase::mousePressEvent(event);
270 Q_D(UCListItem);
271 if (!d->flickable.isNull() && d->flickable->isMoving()) {
272 // while moving, we cannot select any items
273 return;
274 }
275 d->setPressed(true);
276 // connect the Flickable to know when to rebound
277 d->listenToRebind(true);
278 // accept the event so we get the rest of the events as well
279 event->setAccepted(true);
280}
281
282void UCListItem::mouseReleaseEvent(QMouseEvent *event)
283{
284 Q_D(UCListItem);
285 // set released
286 if (d->pressed) {
287 Q_EMIT clicked();
288 }
289 // save pressed state as UCFocusScope resets it seemlessly
290 bool wasPressed = d->pressed;
291 UCStyledItemBase::mouseReleaseEvent(event);
292 d->pressed = wasPressed;
293 d->setPressed(false);
294}
295
296/*!
297 * \qmlpropertygroup ::ListItem::background
298 * \qmlproperty color ListItem::background.color
299 * \qmlproperty color ListItem::background.pressedColor
300 *
301 * background grouped property is an Item which holds the layout of the item, with
302 * abilities to show different colors when in normal state or when pressed. All
303 * properties from Item are accessible and can be used to control user defined
304 * actions or animations, with the exception of the followings:
305 * \list A
306 * \li do not alter x, y, width or height properties as those are controlled by the
307 * item itself when leading or trailing options are revealed and will destroy
308 * your logic
309 * \li never anchor left or right as it will block revealing the options.
310 * \endlist
311 */
312UCListItemBackground* UCListItem::background() const
313{
314 Q_D(const UCListItem);
315 return d->background;
316}
317
318/*!
319 * \qmlproperty bool ListItem::pressed
320 * True when the item is pressed. The items stays pressed when the mouse or touch
321 * is moved horizontally. When in Flickable (or ListView), the item gets un-pressed
322 * (false) when the mouse or touch is moved towards the vertical direction causing
323 * the flickable to move.
324 */
325bool UCListItem::pressed() const
326{
327 Q_D(const UCListItem);
328 return d->pressed;
329}
330
331/*!
332 * \qmlproperty list<Object> ListItem::data
333 * \default
334 * Overloaded default property containing all the children and resources.
335 */
336QQmlListProperty<QObject> UCListItem::data()
337{
338 Q_D(UCListItem);
339 return QQuickItemPrivate::get(d->background)->data();
340}
341
342/*!
343 * \qmlproperty list<Item> ListItem::children
344 * Overloaded default property containing all the visible children of the item.
345 */
346QQmlListProperty<QQuickItem> UCListItem::children()
347{
348 Q_D(UCListItem);
349 return QQuickItemPrivate::get(d->background)->children();
350}
351
352#include "moc_uclistitem.cpp"
0353
=== added file 'modules/Ubuntu/Components/plugin/uclistitem.h'
--- modules/Ubuntu/Components/plugin/uclistitem.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/uclistitem.h 2014-09-04 06:44:23 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UCLISTITEM_H
18#define UCLISTITEM_H
19
20#include <QtQuick/QQuickItem>
21#include "ucstyleditembase.h"
22
23class UCListItemBackground;
24class UCListItemPrivate;
25class UCListItem : public UCStyledItemBase
26{
27 Q_OBJECT
28 Q_PROPERTY(UCListItemBackground *background READ background CONSTANT)
29 Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
30 Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false)
31 Q_PROPERTY(QQmlListProperty<QQuickItem> children READ children NOTIFY childrenChanged DESIGNABLE false)
32 Q_CLASSINFO("DefaultProperty", "data")
33public:
34 explicit UCListItem(QQuickItem *parent = 0);
35 ~UCListItem();
36
37 UCListItemBackground *background() const;
38 bool pressed() const;
39
40protected:
41 void itemChange(ItemChange change, const ItemChangeData &data);
42 void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
43 void mousePressEvent(QMouseEvent *event);
44 void mouseReleaseEvent(QMouseEvent *event);
45
46Q_SIGNALS:
47 void pressedChanged();
48 void childrenChanged();
49
50 void clicked();
51
52public Q_SLOTS:
53
54private:
55 Q_DECLARE_PRIVATE(UCListItem)
56 QQmlListProperty<QObject> data();
57 QQmlListProperty<QQuickItem> children();
58 Q_PRIVATE_SLOT(d_func(), void _q_rebound())
59 Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
60};
61
62#endif // UCLISTITEM_H
063
=== added file 'modules/Ubuntu/Components/plugin/uclistitem_p.h'
--- modules/Ubuntu/Components/plugin/uclistitem_p.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/uclistitem_p.h 2014-09-04 06:44:23 +0000
@@ -0,0 +1,87 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UCVIEWITEM_P_H
18#define UCVIEWITEM_P_H
19
20#include "uclistitem.h"
21#include "ucstyleditembase_p.h"
22#include <QtCore/QPointer>
23
24class QQuickFlickable;
25class UCListItemBackground;
26class UCListItemPrivate : public UCStyledItemBasePrivate
27{
28 Q_DECLARE_PUBLIC(UCListItem)
29public:
30 UCListItemPrivate();
31 virtual ~UCListItemPrivate();
32 void init();
33
34 static inline UCListItemPrivate *get(UCListItem *that)
35 {
36 Q_ASSERT(that);
37 return that->d_func();
38 }
39
40 // override setFocusable()
41 void setFocusable();
42
43 void _q_rebound();
44 void _q_updateSize();
45 void setPressed(bool pressed);
46 void listenToRebind(bool listen);
47
48 bool pressed:1;
49 QPointer<QQuickFlickable> flickable;
50 UCListItemBackground *background;
51};
52
53class UCListItemBackground : public QQuickItem
54{
55 Q_OBJECT
56 Q_PROPERTY(QColor color MEMBER m_color WRITE setColor NOTIFY colorChanged)
57 Q_PROPERTY(QColor pressedColor MEMBER m_pressedColor WRITE setPressedColor NOTIFY pressedColorChanged)
58public:
59 explicit UCListItemBackground(QQuickItem *parent = 0);
60 ~UCListItemBackground();
61
62 void setColor(const QColor &color);
63 void setPressedColor(const QColor &color);
64
65Q_SIGNALS:
66 void colorChanged();
67 void pressedColorChanged();
68
69protected:
70 void itemChange(ItemChange change, const ItemChangeData &data);
71 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data);
72
73private Q_SLOTS:
74 void updateColors();
75
76private:
77 QColor m_color;
78 QColor m_pressedColor;
79 UCListItem *m_item;
80 bool m_pressedColorChanged:1;
81};
82
83QColor getPaletteColor(const char *profile, const char *color);
84
85QML_DECLARE_TYPE(UCListItemBackground)
86
87#endif // UCVIEWITEM_P_H
088
=== modified file 'modules/Ubuntu/Components/qmldir'
--- modules/Ubuntu/Components/qmldir 2014-08-19 13:04:26 +0000
+++ modules/Ubuntu/Components/qmldir 2014-09-04 06:44:23 +0000
@@ -44,6 +44,7 @@
44ColorUtils 0.1 colorUtils.js44ColorUtils 0.1 colorUtils.js
45DateUtils 0.1 dateUtils.js45DateUtils 0.1 dateUtils.js
46UbuntuListView 0.1 UbuntuListView.qml46UbuntuListView 0.1 UbuntuListView.qml
47singleton UbuntuColors 0.1 10/UbuntuColors10.qml
4748
48internal TextCursor TextCursor.qml49internal TextCursor TextCursor.qml
49internal TextInputPopover TextInputPopover.qml50internal TextInputPopover TextInputPopover.qml
@@ -88,6 +89,7 @@
88ColorUtils 1.0 colorUtils.js89ColorUtils 1.0 colorUtils.js
89DateUtils 1.0 dateUtils.js90DateUtils 1.0 dateUtils.js
90UbuntuListView 1.0 UbuntuListView.qml91UbuntuListView 1.0 UbuntuListView.qml
92singleton UbuntuColors 1.0 10/UbuntuColors10.qml
9193
92#version 1.194#version 1.1
93ComboButton 1.1 ComboButton.qml95ComboButton 1.1 ComboButton.qml
@@ -103,3 +105,4 @@
103PageHeadState 1.1 PageHeadState.qml105PageHeadState 1.1 PageHeadState.qml
104Icon 1.1 Icon11.qml106Icon 1.1 Icon11.qml
105StyledItem 1.1 StyledItem.qml107StyledItem 1.1 StyledItem.qml
108singleton UbuntuColors 1.1 11/UbuntuColors.qml
106109
=== modified file 'tests/qmlapicheck.py'
--- tests/qmlapicheck.py 2014-07-29 16:13:32 +0000
+++ tests/qmlapicheck.py 2014-09-04 06:44:23 +0000
@@ -48,28 +48,32 @@
48classes = {}48classes = {}
49for line in fileinput.input():49for line in fileinput.input():
50 if fileinput.filename()[-6:] == 'qmldir':50 if fileinput.filename()[-6:] == 'qmldir':
51 if line == '\n' or line[:1] == '#':
52 # Comments
53 continue
51 if line[:8] == 'internal':54 if line[:8] == 'internal':
52 # Internal components are not part of public API55 # Internal components are not part of public API
53 continue56 continue
54 pieces = line.strip().split(' ')57 pieces = line.strip().split(' ')
55 if len(pieces) > 2:58 # [singleton] Foo 1.0 Foo.qml
56 filename = pieces[2]59 if pieces[0] == 'singleton':
57 # We only work with QML60 pieces.pop(0)
58 if filename[-3:] == 'qml':61 if pieces[0].islower():
59 # Filenames are relative to the qmldir62 # Unknown keyword
60 # Foo 1.0 Foo.qml63 continue
61 folder = os.path.dirname(fileinput.filename())64 classname, version, filename = pieces
62 fullpath = folder + '/' + filename65 if filename[-3:] == 'qml':
63 classname = pieces[0]66 # Filenames are relative to the qmldir
64 version = pieces[1]67 folder = os.path.dirname(fileinput.filename())
65 if fullpath not in inputfiles:68 fullpath = folder + '/' + filename
66 inputfiles.append(fullpath)69 if fullpath not in inputfiles:
67 classes[fullpath] = [classname, version]70 inputfiles.append(fullpath)
68 else:71 classes[fullpath] = [classname, version]
69 versions = classes[fullpath]72 else:
70 if classname not in versions:73 versions = classes[fullpath]
71 versions.append(classname)74 if classname not in versions:
72 versions.append(version)75 versions.append(classname)
76 versions.append(version)
73 else:77 else:
74 inputfiles.append(fileinput.filename())78 inputfiles.append(fileinput.filename())
75 fileinput.nextfile()79 fileinput.nextfile()
7680
=== modified file 'tests/qmlapicheck.sh'
--- tests/qmlapicheck.sh 2014-07-16 06:25:18 +0000
+++ tests/qmlapicheck.sh 2014-09-04 06:44:23 +0000
@@ -15,7 +15,7 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#16#
17################################################################################17################################################################################
18QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/Colors/UbuntuColors.qml modules/Ubuntu/Components/*/qmldir modules/Ubuntu/Components/Pickers/PickerPanel.qml"18QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/*/qmldir"
19CPP="Ubuntu.Components Ubuntu.Layouts Ubuntu.PerformanceMetrics Ubuntu.Test"19CPP="Ubuntu.Components Ubuntu.Layouts Ubuntu.PerformanceMetrics Ubuntu.Test"
2020
21echo Dumping QML API of C++ components21echo Dumping QML API of C++ components
2222
=== added directory 'tests/resources/listitems'
=== added file 'tests/resources/listitems/ListItemTest.qml'
--- tests/resources/listitems/ListItemTest.qml 1970-01-01 00:00:00 +0000
+++ tests/resources/listitems/ListItemTest.qml 2014-09-04 06:44:23 +0000
@@ -0,0 +1,90 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.2
18import Ubuntu.Components 1.1
19
20MainView {
21 id: main
22 width: units.gu(50)
23 height: units.gu(100)
24
25 property bool override: false
26
27 Column {
28 anchors {
29 left: parent.left
30 right: parent.right
31 }
32
33 ListItem {
34 id: testItem
35 background.color: "green"
36 onClicked: {
37 print("click")
38 main.override = !main.override
39 }
40 Rectangle {
41 anchors.fill: parent
42 color: "tan"
43 }
44 }
45
46 ListView {
47 id: view
48 clip: true
49 width: parent.width
50 height: units.gu(40)
51 model: 100
52 pressDelay: 0
53 delegate: ListItem {
54 id: listItem
55 onClicked: print(" clicked")
56 Label {
57 text: modelData + " item"
58 }
59 states: State {
60 name: "override"
61 when: main.override
62 PropertyChanges {
63 target: listItem.background
64 pressedColor: "brown"
65 }
66 }
67 }
68 }
69 Flickable {
70 id: flicker
71 width: parent.width
72 height: units.gu(40)
73 clip: true
74 contentHeight: column.childrenRect.height
75 Column {
76 id: column
77 width: view.width
78 Repeater {
79 model: 100
80 ListItem {
81 background {
82 color: "red"
83 pressedColor: "lime"
84 }
85 }
86 }
87 }
88 }
89 }
90}
091
=== added file 'tests/unit/tst_performance/ItemList.qml'
--- tests/unit/tst_performance/ItemList.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/tst_performance/ItemList.qml 2014-09-04 06:44:23 +0000
@@ -0,0 +1,30 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19
20Column {
21 width: 800
22 height: 600
23 Repeater {
24 model: 10000
25 Item {
26 width: parent.width
27 height: units.gu(6)
28 }
29 }
30}
031
=== added file 'tests/unit/tst_performance/ListItemList.qml'
--- tests/unit/tst_performance/ListItemList.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/tst_performance/ListItemList.qml 2014-09-04 06:44:23 +0000
@@ -0,0 +1,28 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19
20Column {
21 width: 800
22 height: 600
23 Repeater {
24 model: 10000
25 ListItem {
26 }
27 }
28}
029
=== modified file 'tests/unit/tst_performance/tst_performance.cpp'
--- tests/unit/tst_performance/tst_performance.cpp 2013-06-27 15:35:23 +0000
+++ tests/unit/tst_performance/tst_performance.cpp 2014-09-04 06:44:23 +0000
@@ -74,16 +74,10 @@
74 QTest::newRow("grid with Label") << "LabelGrid.qml" << QUrl();74 QTest::newRow("grid with Label") << "LabelGrid.qml" << QUrl();
75 QTest::newRow("grid with UbuntuShape") << "UbuntuShapeGrid.qml" << QUrl();75 QTest::newRow("grid with UbuntuShape") << "UbuntuShapeGrid.qml" << QUrl();
76 QTest::newRow("grid with UbuntuShapePair") << "PairOfUbuntuShapeGrid.qml" << QUrl();76 QTest::newRow("grid with UbuntuShapePair") << "PairOfUbuntuShapeGrid.qml" << QUrl();
77 QTest::newRow("grid with ButtonStyle") << "ButtonStyleGrid.qml" << QUrl();
78 QTest::newRow("grid with Button") << "ButtonGrid.qml" << QUrl();77 QTest::newRow("grid with Button") << "ButtonGrid.qml" << QUrl();
79// QTest::newRow("grid with CheckBoxStyle") << "CheckBoxStyleGrid.qml" << QUrl();
80// QTest::newRow("grid with CheckBox") << "CheckBoxGrid.qml" << QUrl();
81// QTest::newRow("grid with SwitchStyle") << "SwitchStyleGrid.qml" << QUrl();
82// QTest::newRow("grid with Switch") << "SwitchGrid.qml" << QUrl();
83// QTest::newRow("grid with SwitchStyle") << "SwitchStyleGrid.qml" << QUrl();
84// QTest::newRow("grid with Switch") << "SwitchGrid.qml" << QUrl();
85 QTest::newRow("grid with SliderStyle") << "SliderStyleGrid.qml" << QUrl();
86 QTest::newRow("grid with Slider") << "SliderGrid.qml" << QUrl();78 QTest::newRow("grid with Slider") << "SliderGrid.qml" << QUrl();
79 QTest::newRow("list with Item") << "ItemList.qml" << QUrl();
80 QTest::newRow("list with ListItem") << "ListItemList.qml" << QUrl();
87 }81 }
8882
89 void benchmark_GridOfComponents()83 void benchmark_GridOfComponents()
9084
=== modified file 'tests/unit/tst_performance/tst_performance.pro'
--- tests/unit/tst_performance/tst_performance.pro 2013-06-27 15:20:12 +0000
+++ tests/unit/tst_performance/tst_performance.pro 2014-09-04 06:44:23 +0000
@@ -19,4 +19,6 @@
19 TextWithImport.qml \19 TextWithImport.qml \
20 TextWithImportGrid.qml \20 TextWithImportGrid.qml \
21 TextWithImportPopupsGrid.qml \21 TextWithImportPopupsGrid.qml \
22 TextWithImportPopups.qml22 TextWithImportPopups.qml \
23 ItemList.qml \
24 ListItemList.qml
2325
=== added file 'tests/unit_x11/tst_components/tst_listitem.qml'
--- tests/unit_x11/tst_components/tst_listitem.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_components/tst_listitem.qml 2014-09-04 06:44:23 +0000
@@ -0,0 +1,149 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtTest 1.0
19import Ubuntu.Test 1.0
20import Ubuntu.Components 1.1
21
22Item {
23 width: units.gu(40)
24 height: units.gu(71)
25
26 Column {
27 width: parent.width
28 ListItem {
29 id: defaults
30 width: parent.width
31 }
32 ListItem {
33 id: testItem
34 width: parent.width
35 background.color: "blue"
36 Item {
37 id: contentItem
38 anchors.fill: parent
39 }
40 }
41 ListView {
42 id: listView
43 width: parent.width
44 height: units.gu(24)
45 clip: true
46 model: 10
47 delegate: ListItem {
48 objectName: "listItem" + index
49 width: parent.width
50 }
51 }
52 }
53
54 UbuntuTestCase {
55 name: "ListItemAPI"
56 when: windowShown
57
58 SignalSpy {
59 id: pressedSpy
60 signalName: "pressedChanged"
61 target: testItem
62 }
63
64 SignalSpy {
65 id: clickSpy
66 signalName: "clicked"
67 target: testItem;
68 }
69
70 function centerOf(item) {
71 return Qt.point(item.width / 2, item.height / 2);
72 }
73
74 function initTestCase() {
75 TestExtras.registerTouchDevice();
76 }
77
78 function cleanup() {
79 pressedSpy.clear();
80 clickSpy.clear();
81 // make sure all events are processed
82 wait(200);
83 }
84
85 function test_0_defaults() {
86 verify(defaults.background !== null, "Defaults is null");
87 compare(defaults.background.color, "#000000", "Transparent by default");
88 compare(defaults.background.pressedColor, Theme.palette.selected.background, "Theme.palette.selected.background color by default")
89 compare(defaults.pressed, false, "Not pressed buy default");
90 }
91
92 function test_children_in_background() {
93 compare(contentItem.parent, testItem.background, "Content is not in the right holder!");
94 }
95
96 function test_pressedChanged_on_click() {
97 mousePress(testItem, testItem.width / 2, testItem.height / 2);
98 pressedSpy.wait();
99 mouseRelease(testItem, testItem.width / 2, testItem.height / 2);
100 }
101 function test_pressedChanged_on_tap() {
102 TestExtras.touchPress(0, testItem, centerOf(testItem));
103 pressedSpy.wait();
104 TestExtras.touchRelease(0, testItem, centerOf(testItem));
105 // local cleanup, wait few msecs to suppress double tap
106 wait(400);
107 }
108
109 function test_clicked_on_mouse() {
110 mouseClick(testItem, testItem.width / 2, testItem.height / 2);
111 clickSpy.wait();
112 }
113 function test_clicked_on_tap() {
114 TestExtras.touchClick(0, testItem, centerOf(testItem));
115 clickSpy.wait();
116 }
117
118 function test_mouse_click_on_listitem() {
119 var listItem = findChild(listView, "listItem0");
120 verify(listItem, "Cannot find listItem0");
121
122 mousePress(listItem, listItem.width / 2, 0);
123 compare(listItem.pressed, true, "Item is not pressed?");
124 // do 5 moves to be able to sense it
125 var dy = 0;
126 for (var i = 1; i <= 5; i++) {
127 dy += i * 10;
128 mouseMove(listItem, listItem.width / 2, dy);
129 }
130 compare(listItem.pressed, false, "Item is pressed still!");
131 mouseRelease(listItem, listItem.width / 2, dy);
132 }
133 function test_touch_click_on_listitem() {
134 var listItem = findChild(listView, "listItem0");
135 verify(listItem, "Cannot find listItem0");
136
137 TestExtras.touchPress(0, listItem, Qt.point(listItem.width / 2, 5));
138 compare(listItem.pressed, true, "Item is not pressed?");
139 // do 5 moves to be able to sense it
140 var dy = 0;
141 for (var i = 1; i <= 5; i++) {
142 dy += i * 10;
143 TestExtras.touchMove(0, listItem, Qt.point(listItem.width / 2, dy));
144 }
145 compare(listItem.pressed, false, "Item is pressed still!");
146 TestExtras.touchRelease(0, listItem, Qt.point(listItem.width / 2, dy));
147 }
148 }
149}

Subscribers

People subscribed via source and target branches