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