Merge lp:~zsombi/ubuntu-ui-toolkit/ima-in-window into lp:ubuntu-ui-toolkit

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: 520
Merged at revision: 517
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/ima-in-window
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 668 lines (+279/-136)
16 files modified
CHANGES (+1/-0)
modules/Ubuntu/Components/Popups/Dialog.qml (+2/-1)
modules/Ubuntu/Components/Popups/PopupBase.qml (+8/-6)
modules/Ubuntu/Components/Popups/popupUtils.js (+10/-7)
modules/Ubuntu/Components/plugin/inversemouseareatype.cpp (+7/-5)
modules/Ubuntu/Components/plugin/quickutils.cpp (+35/-0)
modules/Ubuntu/Components/plugin/quickutils.h (+1/-0)
tests/unit/tst_components/tst_inversemousearea.qml (+1/-1)
tests/unit/tst_components/tst_quickutils.qml (+131/-113)
tests/unit/tst_inversemousearea/InverseMouseAreaDoNotPropagateEvents.qml (+1/-0)
tests/unit/tst_inversemousearea/InverseMouseAreaInWindow.qml (+65/-0)
tests/unit/tst_inversemousearea/InverseMouseAreaPropagateEvents.qml (+1/-0)
tests/unit/tst_inversemousearea/SensingAreaError.qml (+1/-0)
tests/unit/tst_inversemousearea/tst_inversemousearea.pro (+2/-1)
tests/unit/tst_inversemousearea/tst_inversemouseareatest.cpp (+11/-0)
themes/Ambiance/qmltheme/default.qmltheme (+2/-2)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/ima-in-window
Reviewer Review Type Date Requested Status
Tim Peeters Approve
PS Jenkins bot continuous-integration Approve
Olivier Tilloy (community) Needs Information
Review via email: mp+165567@code.launchpad.net

Commit message

InverseMouseArea sensingArea and Popovers' dismissArea works now when included in Window.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

113 + // get sening area upon parent change

typo: sening

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

In QuickUtils::rootItem(QObject *object), is it really correct to walk up the parent() hierarchy?
According to http://qt-project.org/doc/qt-5.0/qtquick/qquickitem.html#parent-prop, « The concept of the visual parent differs from that of the QObject parent. An item's visual parent may not necessarily be the same as its object parent. »

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

> In QuickUtils::rootItem(QObject *object), is it really correct to walk up the
> parent() hierarchy?
> According to http://qt-project.org/doc/qt-5.0/qtquick/qquickitem.html#parent-
> prop, « The concept of the visual parent differs from that of the QObject
> parent. An item's visual parent may not necessarily be the same as its object
> parent. »

Yes, true, but we don't necessarily have to walk the visual items only, as if we do, the Window won't be listed as a visual item. More, in case we have a Window, we need it's contentItem. And this is the way we can get it.

516. By Zsombor Egri

typo fixed

Revision history for this message
Olivier Tilloy (osomon) wrote :

> Yes, true, but we don't necessarily have to walk the visual items only, as if
> we do, the Window won't be listed as a visual item. More, in case we have a
> Window, we need it's contentItem. And this is the way we can get it.

So what about walking up the hierarchy of (visual) parent items, and when reaching the top level visual item, try to get the non-visual parent and check whether it’s a QQuickWindow?

Also, is QuickUtils::rootItem(…) meant to work for non visual elements? If not, its parameter should be of type QQuickItem*.

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

traversing visual items

Revision history for this message
Zsombor Egri (zsombi) wrote :

> > Yes, true, but we don't necessarily have to walk the visual items only, as
> if
> > we do, the Window won't be listed as a visual item. More, in case we have a
> > Window, we need it's contentItem. And this is the way we can get it.
>
> So what about walking up the hierarchy of (visual) parent items, and when
> reaching the top level visual item, try to get the non-visual parent and check
> whether it’s a QQuickWindow?

Did that in revision 517. The only issue is that we need to check whether the topmost item belongs to the QQuickView, and if it does, return the rootObject() of it instead of the topmost item found.
>
> Also, is QuickUtils::rootItem(…) meant to work for non visual elements? If
> not, its parameter should be of type QQuickItem*.

It must also work for non-visual elements.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

please mark rootObject() as \deprecated in its documentation.

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

What is the reason that we the QuickUtils docs internal only?

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

177 + if (m_rootView && (m_rootView->contentItem() == parentItem)) {
178 + return m_rootView->rootObject();
179 + } else {
180 + return parentItem;
181 + }

when does this else case occur?

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

169 + while (parentItem) {
170 + if (!parentItem->parentItem()) {
...
}

That could be written as
while (parentItem->parentItem() {
parentItem = parentItem->parentItem();
}

// ! parentIem->parentItem()

lookupQuickView();
77 + if (m_rootView && (m_rootView->contentItem() == parentItem)) {
178 + return m_rootView->rootObject();
179 + } else {
180 + return parentItem;
181 + }
182 + }
183 + parentItem = parentItem->parentItem();
184 + }
185 + }
186 + return 0;

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

can the return 0 in the end ever be reached? when?

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

13 === modified file 'modules/Ubuntu/Components/Popups/Dialog.qml'
20 + property Item dismissArea: dialog.dismissArea

why is that there?

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

83 var popupObject;
84 if (params !== undefined) {
85 - popupObject = popupComponent.createObject(QuickUtils.rootObject, params);
86 + popupObject = popupComponent.createObject(QuickUtils.rootItem(popup), params);
87 } else {
88 - popupObject = popupComponent.createObject(QuickUtils.rootObject);
89 + popupObject = popupComponent.createObject(QuickUtils.rootItem(popup));
90 }

popup can be a string. I think that will fail. Perhaps you need to use popupComponent here?
Please test this (our old popup demo may be added to tests/resources).

review: Needs Fixing
Revision history for this message
Zsombor Egri (zsombi) wrote :

> What is the reason that we the QuickUtils docs internal only?

Because we don't want to make it public.

Revision history for this message
Zsombor Egri (zsombi) wrote :

> please mark rootObject() as \deprecated in its documentation.

Fixed in rev.518

Revision history for this message
Zsombor Egri (zsombi) wrote :

> 177 + if (m_rootView && (m_rootView->contentItem() == parentItem)) {
> 178 + return m_rootView->rootObject();
> 179 + } else {
> 180 + return parentItem;
> 181 + }
>
>
> when does this else case occur?

Yes, when the IMA is in Window.

Revision history for this message
Zsombor Egri (zsombi) wrote :

> can the return 0 in the end ever be reached? when?

Yes, if the object is null.

Revision history for this message
Zsombor Egri (zsombi) wrote :

> 13 === modified file 'modules/Ubuntu/Components/Popups/Dialog.qml'
> 20 + property Item dismissArea: dialog.dismissArea
>
>
> why is that there?

Because we need that property in the theme file. Previously we were using QuickUtils.rootObject but as from now we have a function to get the same thing (and as QuickUtuls is NOT a public component therefore we shouldn't use it in the theme files), we need the dismissArea to be accessible in theme file.

Revision history for this message
Zsombor Egri (zsombi) wrote :

> 169 + while (parentItem) {
> 170 + if (!parentItem->parentItem()) {
> ...
> }
>
> That could be written as
> while (parentItem->parentItem() {
> parentItem = parentItem->parentItem();
> }
>
> // ! parentIem->parentItem()
>
> lookupQuickView();
> 77 + if (m_rootView && (m_rootView->contentItem() == parentItem)) {
> 178 + return m_rootView->rootObject();
> 179 + } else {
> 180 + return parentItem;
> 181 + }
> 182 + }
> 183 + parentItem = parentItem->parentItem();
> 184 + }
> 185 + }
> 186 + return 0;

fixed in rev 519

518. By Zsombor Egri

rootObject marked as deprecated in documentation

519. By Zsombor Egri

loop refined

520. By Zsombor Egri

PopupUtils fixed; rootItem() returns application's rootObject when the given object is null

Revision history for this message
Zsombor Egri (zsombi) wrote :

> 83 var popupObject;
> 84 if (params !== undefined) {
> 85 - popupObject = popupComponent.createObject(QuickUtils.rootObject,
> params);
> 86 + popupObject =
> popupComponent.createObject(QuickUtils.rootItem(popup), params);
> 87 } else {
> 88 - popupObject = popupComponent.createObject(QuickUtils.rootObject);
> 89 + popupObject =
> popupComponent.createObject(QuickUtils.rootItem(popup));
> 90 }
>
>
> popup can be a string. I think that will fail. Perhaps you need to use
> popupComponent here?
> Please test this (our old popup demo may be added to tests/resources).

Fixed in rev. 520

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

thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2013-05-22 08:54:31 +0000
3+++ CHANGES 2013-05-27 09:51:17 +0000
4@@ -10,6 +10,7 @@
5 API Changes
6 ***********
7
8+* DEPRECATED IN QuickUtils: property Item rootObject
9 * CHANGED IN Toolbar: property bool active TO property bool opened
10 * CHANGED IN Toolbar: property bool lock TO property bool locked
11 * CHANGED IN ToolbarActions: property bool active TO property bool opened
12
13=== modified file 'modules/Ubuntu/Components/Popups/Dialog.qml'
14--- modules/Ubuntu/Components/Popups/Dialog.qml 2013-05-24 09:12:56 +0000
15+++ modules/Ubuntu/Components/Popups/Dialog.qml 2013-05-27 09:51:17 +0000
16@@ -173,8 +173,9 @@
17 property real maxHeight: 3*dialog.height/4
18 property real margins
19 property real itemSpacing
20+ property Item dismissArea: dialog.dismissArea
21
22- height: childrenRect.height
23+ height: Math.min(childrenRect.height, dialog.height)
24
25 Column {
26 id: contentsColumn
27
28=== modified file 'modules/Ubuntu/Components/Popups/PopupBase.qml'
29--- modules/Ubuntu/Components/Popups/PopupBase.qml 2013-04-25 19:26:02 +0000
30+++ modules/Ubuntu/Components/Popups/PopupBase.qml 2013-05-27 09:51:17 +0000
31@@ -52,16 +52,14 @@
32 */
33 property PropertyAnimation fadingAnimation: PropertyAnimation{duration: 0}
34
35- anchors.fill: parent ? parent : undefined
36-
37 // without specifying width and height below, some width calculations go wrong in Sheet.
38 // I guess popupBase.width is not correctly set initially
39 width: parent ? parent.width : undefined
40 height: parent ? parent.height : undefined
41
42 // copy value of automaticOrientation from root object (typically a MainView)
43- automaticOrientation: QuickUtils.rootObject && QuickUtils.rootObject.automaticOrientation ?
44- QuickUtils.rootObject.automaticOrientation : false
45+ automaticOrientation: stateWrapper.rootItem && stateWrapper.rootItem.automaticOrientation ?
46+ stateWrapper.rootItem.automaticOrientation : false
47
48 /*!
49 \preliminary
50@@ -71,10 +69,10 @@
51 */
52 function show() {
53 if (!dismissArea)
54- dismissArea = QuickUtils.rootObject
55+ dismissArea = stateWrapper.rootItem
56
57 // Without setting the parent, mapFromItem() breaks in internalPopupUtils.
58- parent = QuickUtils.rootObject;
59+ parent = stateWrapper.rootItem;
60 stateWrapper.state = 'opened';
61 }
62
63@@ -161,9 +159,13 @@
64 opacity: 0.0
65 /*! \internal */
66 onVisibleChanged: stateWrapper.state = (visible) ? 'opened' : 'closed'
67+ /*! \internal */
68+ onParentChanged: stateWrapper.rootItem = QuickUtils.rootItem(popupBase)
69+ Component.onCompleted: stateWrapper.rootItem = QuickUtils.rootItem(popupBase);
70
71 Item {
72 id: stateWrapper
73+ property Item rootItem: QuickUtils.rootItem(popupBase)
74
75 states: [
76 State {
77
78=== modified file 'modules/Ubuntu/Components/Popups/popupUtils.js'
79--- modules/Ubuntu/Components/Popups/popupUtils.js 2013-02-21 15:28:30 +0000
80+++ modules/Ubuntu/Components/Popups/popupUtils.js 2013-05-27 09:51:17 +0000
81@@ -21,32 +21,35 @@
82 the popup to be opened. This can be any property defined by the popups and additional
83 custom ones defined in derived popups.
84
85- Sheets do not need callers to be specified, however when using non-modal Sheets or
86- Dialogs, it is worth to set the caller when opening Sheets to avoid leaving orphan
87- sheets on the screen.
88+ caller parameter must be given when the Sheet or Dialog is specified using url
89+ and opened inside a Window component. If not, the Sheet or Dialog will use the
90+ application's root item as dismiss area.
91 */
92 function open(popup, caller, params) {
93 var popupComponent = null;
94+ var rootObject = null;
95 if (popup.createObject) {
96 // popup is a component and can create an object
97 popupComponent = popup;
98+ rootObject = QuickUtils.rootItem(popup);
99 } else if (typeof popup === "string") {
100 popupComponent = Qt.createComponent(popup);
101+ rootObject = (caller !== undefined) ? QuickUtils.rootItem(caller) : QuickUtils.rootItem(null);
102 } else {
103 print("PopupUtils.open(): "+popup+" is not a component or a link");
104- return;
105+ return null;
106 }
107
108 var popupObject;
109 if (params !== undefined) {
110- popupObject = popupComponent.createObject(QuickUtils.rootObject, params);
111+ popupObject = popupComponent.createObject(rootObject, params);
112 } else {
113- popupObject = popupComponent.createObject(QuickUtils.rootObject);
114+ popupObject = popupComponent.createObject(rootObject);
115 }
116 if (!popupObject) {
117 print("PopupUtils.open(): Failed to create the popup object.");
118 return;
119- } else if (popupObject.hasOwnProperty("caller"))
120+ } else if (popupObject.hasOwnProperty("caller") && caller)
121 popupObject.caller = caller;
122
123 // if caller is specified, connect its cleanup to the popup's close
124
125=== modified file 'modules/Ubuntu/Components/plugin/inversemouseareatype.cpp'
126--- modules/Ubuntu/Components/plugin/inversemouseareatype.cpp 2013-04-15 08:39:51 +0000
127+++ modules/Ubuntu/Components/plugin/inversemouseareatype.cpp 2013-05-27 09:51:17 +0000
128@@ -87,7 +87,7 @@
129 m_moved(false),
130 m_propagateEvents(false),
131 m_acceptedButtons(Qt::LeftButton),
132- m_sensingArea(QuickUtils::instance().rootObject()),
133+ m_sensingArea(QuickUtils::instance().rootItem(this)),
134 m_event(0)
135 {
136 setAcceptedMouseButtons(m_acceptedButtons);
137@@ -96,8 +96,10 @@
138
139 QObject::connect(this, SIGNAL(enabledChanged()), this, SLOT(update()));
140
141- if (!m_sensingArea)
142- QObject::connect(&QuickUtils::instance(), SIGNAL(rootObjectChanged()), this, SLOT(update()));
143+ if (!m_sensingArea) {
144+ // get sensing area upon parent change
145+ QObject::connect(this, SIGNAL(parentChanged(QQuickItem*)), this, SLOT(update()));
146+ }
147
148 QGuiApplication::instance()->installEventFilter(this);
149 }
150@@ -118,7 +120,7 @@
151 {
152 // update sensing area
153 if (!m_sensingArea)
154- m_sensingArea = QuickUtils::instance().rootObject();
155+ m_sensingArea = QuickUtils::instance().rootItem(this);
156 if (!isEnabled() || !isVisible())
157 reset();
158 }
159@@ -263,7 +265,7 @@
160 void InverseMouseAreaType::setSensingArea(QQuickItem *sensing)
161 {
162 if (!sensing)
163- sensing = QuickUtils::instance().rootObject();
164+ sensing = QuickUtils::instance().rootItem(this);
165 if (sensing != m_sensingArea) {
166 m_sensingArea = sensing;
167 reset();
168
169=== modified file 'modules/Ubuntu/Components/plugin/quickutils.cpp'
170--- modules/Ubuntu/Components/plugin/quickutils.cpp 2013-05-24 05:34:28 +0000
171+++ modules/Ubuntu/Components/plugin/quickutils.cpp 2013-05-27 09:51:17 +0000
172@@ -24,6 +24,7 @@
173 #include <QtCore/QAbstractListModel>
174 #include <QtCore/QAbstractProxyModel>
175 #include <QtQml/QQmlPropertyMap>
176+#include <QtQml/QQmlInfo>
177
178 #include <private/qquicktextinput_p.h>
179 #include <private/qquicktextedit_p.h>
180@@ -71,15 +72,49 @@
181
182 /*!
183 * \internal
184+ * \deprecated
185 * Returns the current root object.
186 */
187 QQuickItem *QuickUtils::rootObject()
188 {
189+ qmlInfo(this) << "WARNING: QuickUtils.rootObject property is deprecated: Use QuickUtils::rootItem() function instead.";
190 if (!m_rootView)
191 lookupQuickView();
192 return (m_rootView) ? m_rootView->rootObject() : 0;
193 }
194
195+/*!
196+ * \internal
197+ * Returns the root item of a given item. In case there is a QQuickWindow (Window)
198+ * found in the hierarchy, the function will return the contentItem of the window.
199+ */
200+QQuickItem *QuickUtils::rootItem(QObject *object)
201+{
202+ // make sure we have the m_rootView updated
203+ lookupQuickView();
204+ if (!object) {
205+ return (m_rootView) ? m_rootView->rootObject() : 0;
206+ }
207+
208+ QQuickItem *item = qobject_cast<QQuickItem*>(object);
209+ // the given object may be a non-visual element (QtObject or QQmlComponent)
210+ // therefore those objects' parent object should be considered
211+ QQuickItem *parentItem = item ? item->parentItem() : qobject_cast<QQuickItem*>(object->parent());
212+ while (parentItem && parentItem->parentItem()) {
213+ parentItem = parentItem->parentItem();
214+ }
215+
216+ if (m_rootView && (m_rootView->contentItem() == parentItem)) {
217+ // when traversing visual parents of an element from the application,
218+ // we reach QQuickView's contentItem, whose size is invalid. Therefore
219+ // we need to return the QQuickView's rootObject() instead of the topmost
220+ // item found
221+ return m_rootView->rootObject();
222+ }
223+ return parentItem;
224+}
225+
226+
227 QString QuickUtils::inputMethodProvider() const
228 {
229 return QString(getenv("QT_IM_MODULE"));
230
231=== modified file 'modules/Ubuntu/Components/plugin/quickutils.h'
232--- modules/Ubuntu/Components/plugin/quickutils.h 2013-04-18 11:29:24 +0000
233+++ modules/Ubuntu/Components/plugin/quickutils.h 2013-05-27 09:51:17 +0000
234@@ -38,6 +38,7 @@
235 }
236
237 QQuickItem *rootObject();
238+ Q_INVOKABLE QQuickItem *rootItem(QObject *object);
239 QString inputMethodProvider() const;
240
241 Q_INVOKABLE qreal modelDelegateHeight(QQmlComponent *delegate, const QVariant &model);
242
243=== modified file 'tests/unit/tst_components/tst_inversemousearea.qml'
244--- tests/unit/tst_components/tst_inversemousearea.qml 2013-01-15 08:44:48 +0000
245+++ tests/unit/tst_components/tst_inversemousearea.qml 2013-05-27 09:51:17 +0000
246@@ -96,7 +96,7 @@
247 }
248
249 function test_0_sensingArea() {
250- compare(ima.sensingArea, QuickUtils.rootObject, "InverseMouseArea senses the root item area");
251+ compare(ima.sensingArea, QuickUtils.rootItem(ima), "InverseMouseArea senses the root item area");
252 ima.sensingArea = testSensingArea
253 compare(ima.sensingArea, testSensingArea, "InverseMouseArea sensing area set to testSensingArea");
254 }
255
256=== modified file 'tests/unit/tst_components/tst_quickutils.qml'
257--- tests/unit/tst_components/tst_quickutils.qml 2012-12-03 06:10:00 +0000
258+++ tests/unit/tst_components/tst_quickutils.qml 2013-05-27 09:51:17 +0000
259@@ -19,117 +19,135 @@
260 import Ubuntu.Components 0.1
261 import Ubuntu.Components.ListItems 0.1
262
263-
264-TestCase {
265- name: "QuickUtilsAPI"
266-
267- function test_modelDelegateHeightForEmptyObjectModelElements()
268- {
269- list.model = emptyModel;
270- list.section.property = "";
271-
272- var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
273- compare(itemHeight, 0, "itemHeight failure");
274-
275-
276- for (var i = 0; i < 10; i++) {
277- emptyModel.append({});
278- var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
279- compare(itemHeight, 50, "itemHeight failure");
280- }
281- }
282-
283- function test_modelDelegateHeightForObjectModel()
284- {
285- list.model = objectList;
286- list.section.property = "label";
287-
288- var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
289- compare(sectionHeight, 25, "sectionHeight failure");
290-
291- var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
292- compare(itemHeight, 50, "itemHeight failure");
293- }
294-
295- function test_modelDelegateHeightForVariantListModel()
296- {
297- list.model = variantList;
298- list.section.property = "label";
299-
300- var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
301- compare(sectionHeight, 25, "sectionHeight failure");
302-
303- var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
304- compare(itemHeight, 50, "itemHeight failure");
305- }
306-
307- function test_modelDelegateHeightForStringListModel()
308- {
309- list.model = stringList;
310- list.section.property = "modelData";
311-
312- var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
313- compare(sectionHeight, 25, "sectionHeight failure");
314-
315- var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
316- compare(itemHeight, 50, "itemHeight failure");
317- }
318-
319- function test_modelDelegateHeightForNumericModel()
320- {
321- list.model = 100;
322- list.section.property = "modelData";
323-
324- var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
325- compare(sectionHeight, 25, "sectionHeight failure");
326-
327- var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
328- compare(itemHeight, 50, "itemHeight failure");
329- }
330-
331- property var emptyModel: ListModel {}
332-
333- property var objectList: ListModel {
334- ListElement {label: "1"}
335- ListElement {label: "10"}
336- ListElement {label: "100"}
337- ListElement {label: "2"}
338- ListElement {label: "3"}
339- ListElement {label: "4"}
340- ListElement {label: "5"}
341- ListElement {label: "6"}
342- ListElement {label: "7"}
343- ListElement {label: "8"}
344- }
345-
346- property var variantList: [
347- {"label": "1"},
348- {"label": "10"},
349- {"label": "100"},
350- {"label": "2"},
351- {"label": "3"},
352- {"label": "4"},
353- {"label": "5"},
354- {"label": "6"},
355- {"label": "7"},
356- {"label": "8"}
357- ]
358-
359- property var stringList: ["1", "10", "100", "2", "3", "4", "5", "6", "7", "8", "9"]
360-
361- ListView {
362- id: list
363-
364- section.criteria: ViewSection.FirstCharacter
365- section.delegate: Header{
366- text: section
367- height: 25
368- }
369-
370- delegate: Standard {
371- text: label
372- height: 50
373- }
374- }
375-
376+Item {
377+ id: root
378+ width: units.gu(40)
379+ height: units.gu(40)
380+
381+ TestCase {
382+ id: test
383+ name: "QuickUtilsAPI"
384+ when: windowShown
385+
386+ function test_rootItem()
387+ {
388+ compare(QuickUtils.rootItem(test) != 0, true, "Root item is not null");
389+ }
390+
391+ function test_className()
392+ {
393+ compare(QuickUtils.className(test), "TestCase", "className for TestCase");
394+ compare(QuickUtils.className(root), "QQuickItem", "className for Item");
395+ }
396+
397+ function test_modelDelegateHeightForEmptyObjectModelElements()
398+ {
399+ list.model = emptyModel;
400+ list.section.property = "";
401+
402+ var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
403+ compare(itemHeight, 0, "itemHeight failure");
404+
405+
406+ for (var i = 0; i < 10; i++) {
407+ emptyModel.append({});
408+ var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
409+ compare(itemHeight, 50, "itemHeight failure");
410+ }
411+ }
412+
413+ function test_modelDelegateHeightForObjectModel()
414+ {
415+ list.model = objectList;
416+ list.section.property = "label";
417+
418+ var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
419+ compare(sectionHeight, 25, "sectionHeight failure");
420+
421+ var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
422+ compare(itemHeight, 50, "itemHeight failure");
423+ }
424+
425+ function test_modelDelegateHeightForVariantListModel()
426+ {
427+ list.model = variantList;
428+ list.section.property = "label";
429+
430+ var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
431+ compare(sectionHeight, 25, "sectionHeight failure");
432+
433+ var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
434+ compare(itemHeight, 50, "itemHeight failure");
435+ }
436+
437+ function test_modelDelegateHeightForStringListModel()
438+ {
439+ list.model = stringList;
440+ list.section.property = "modelData";
441+
442+ var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
443+ compare(sectionHeight, 25, "sectionHeight failure");
444+
445+ var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
446+ compare(itemHeight, 50, "itemHeight failure");
447+ }
448+
449+ function test_modelDelegateHeightForNumericModel()
450+ {
451+ list.model = 100;
452+ list.section.property = "modelData";
453+
454+ var sectionHeight = QuickUtils.modelDelegateHeight(list.section.delegate, list.model);
455+ compare(sectionHeight, 25, "sectionHeight failure");
456+
457+ var itemHeight = QuickUtils.modelDelegateHeight(list.delegate, list.model);
458+ compare(itemHeight, 50, "itemHeight failure");
459+ }
460+
461+ property var emptyModel: ListModel {}
462+
463+ property var objectList: ListModel {
464+ ListElement {label: "1"}
465+ ListElement {label: "10"}
466+ ListElement {label: "100"}
467+ ListElement {label: "2"}
468+ ListElement {label: "3"}
469+ ListElement {label: "4"}
470+ ListElement {label: "5"}
471+ ListElement {label: "6"}
472+ ListElement {label: "7"}
473+ ListElement {label: "8"}
474+ }
475+
476+ property var variantList: [
477+ {"label": "1"},
478+ {"label": "10"},
479+ {"label": "100"},
480+ {"label": "2"},
481+ {"label": "3"},
482+ {"label": "4"},
483+ {"label": "5"},
484+ {"label": "6"},
485+ {"label": "7"},
486+ {"label": "8"}
487+ ]
488+
489+ property var stringList: ["1", "10", "100", "2", "3", "4", "5", "6", "7", "8", "9"]
490+
491+ ListView {
492+ id: list
493+
494+ section.criteria: ViewSection.FirstCharacter
495+ section.delegate: Header{
496+ text: section
497+ height: 25
498+ }
499+
500+ delegate: Standard {
501+ text: label
502+ height: 50
503+ }
504+ }
505+
506+ }
507 }
508
509=== modified file 'tests/unit/tst_inversemousearea/InverseMouseAreaDoNotPropagateEvents.qml'
510--- tests/unit/tst_inversemousearea/InverseMouseAreaDoNotPropagateEvents.qml 2013-04-15 07:49:30 +0000
511+++ tests/unit/tst_inversemousearea/InverseMouseAreaDoNotPropagateEvents.qml 2013-05-27 09:51:17 +0000
512@@ -18,6 +18,7 @@
513 import Ubuntu.Components 0.1
514
515 Item {
516+ objectName: "root"
517 width: 100
518 height: 100
519
520
521=== added file 'tests/unit/tst_inversemousearea/InverseMouseAreaInWindow.qml'
522--- tests/unit/tst_inversemousearea/InverseMouseAreaInWindow.qml 1970-01-01 00:00:00 +0000
523+++ tests/unit/tst_inversemousearea/InverseMouseAreaInWindow.qml 2013-05-27 09:51:17 +0000
524@@ -0,0 +1,65 @@
525+/*
526+ * Copyright 2013 Canonical Ltd.
527+ *
528+ * This program is free software; you can redistribute it and/or modify
529+ * it under the terms of the GNU Lesser General Public License as published by
530+ * the Free Software Foundation; version 3.
531+ *
532+ * This program is distributed in the hope that it will be useful,
533+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
534+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
535+ * GNU Lesser General Public License for more details.
536+ *
537+ * You should have received a copy of the GNU Lesser General Public License
538+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
539+ */
540+
541+import QtQuick 2.0
542+import QtQuick.Window 2.0
543+import Ubuntu.Components 0.1
544+
545+Item{
546+ id: root
547+ property string log: ""
548+
549+ Window {
550+ objectName: "isawindow"
551+ width: units.gu(50)
552+ height: units.gu(50)
553+
554+ Item {
555+ id: clickArea
556+ anchors {
557+ left: parent.left
558+ right: parent.right
559+ top: parent.top
560+ }
561+ height: units.gu(10)
562+ Label {
563+ anchors.centerIn: parent
564+ text: "click me"
565+ }
566+ }
567+
568+ Rectangle {
569+ id: rect
570+ color: "red"
571+ anchors {
572+ left: parent.left
573+ right: parent.right
574+ top: clickArea.bottom
575+ bottom: parent.bottom
576+ }
577+ }
578+
579+ InverseMouseArea {
580+ objectName: "ima"
581+ id: ima
582+ anchors.fill: rect
583+ onClicked: {
584+ root.log = "IMA"
585+ rect.color = "green"
586+ }
587+ }
588+ }
589+}
590
591=== modified file 'tests/unit/tst_inversemousearea/InverseMouseAreaPropagateEvents.qml'
592--- tests/unit/tst_inversemousearea/InverseMouseAreaPropagateEvents.qml 2013-04-15 07:49:30 +0000
593+++ tests/unit/tst_inversemousearea/InverseMouseAreaPropagateEvents.qml 2013-05-27 09:51:17 +0000
594@@ -18,6 +18,7 @@
595 import Ubuntu.Components 0.1
596
597 Item {
598+ objectName: "root"
599 width: 100
600 height: 100
601
602
603=== modified file 'tests/unit/tst_inversemousearea/SensingAreaError.qml'
604--- tests/unit/tst_inversemousearea/SensingAreaError.qml 2013-05-24 05:01:32 +0000
605+++ tests/unit/tst_inversemousearea/SensingAreaError.qml 2013-05-27 09:51:17 +0000
606@@ -19,6 +19,7 @@
607
608 Item {
609 id: root
610+ objectName: "root"
611 width: units.gu(40)
612 height: units.gu(40)
613
614
615=== modified file 'tests/unit/tst_inversemousearea/tst_inversemousearea.pro'
616--- tests/unit/tst_inversemousearea/tst_inversemousearea.pro 2013-05-24 05:22:02 +0000
617+++ tests/unit/tst_inversemousearea/tst_inversemousearea.pro 2013-05-27 09:51:17 +0000
618@@ -5,4 +5,5 @@
619 OTHER_FILES += \
620 InverseMouseAreaPropagateEvents.qml \
621 InverseMouseAreaDoNotPropagateEvents.qml \
622- SensingAreaError.qml
623+ SensingAreaError.qml \
624+ InverseMouseAreaInWindow.qml
625
626=== modified file 'tests/unit/tst_inversemousearea/tst_inversemouseareatest.cpp'
627--- tests/unit/tst_inversemousearea/tst_inversemouseareatest.cpp 2013-05-24 05:22:02 +0000
628+++ tests/unit/tst_inversemousearea/tst_inversemouseareatest.cpp 2013-05-27 09:51:17 +0000
629@@ -142,6 +142,17 @@
630 QCOMPARE(quickView->rootObject()->property("log").toString(), QString("IMA"));
631 }
632
633+ void testCase_InverseMouseAreInWindow()
634+ {
635+ InverseMouseAreaType *area = testArea("InverseMouseAreaInWindow.qml");
636+ QVERIFY(area);
637+ quickView->show();
638+
639+ QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(20, 10));
640+ QTest::waitForEvents();
641+ QCOMPARE(quickView->rootObject()->property("log").toString(), QString("IMA"));
642+ }
643+
644 };
645
646 QTEST_MAIN(tst_InverseMouseAreaTest)
647
648=== modified file 'themes/Ambiance/qmltheme/default.qmltheme'
649--- themes/Ambiance/qmltheme/default.qmltheme 2013-05-14 13:33:39 +0000
650+++ themes/Ambiance/qmltheme/default.qmltheme 2013-05-27 09:51:17 +0000
651@@ -216,7 +216,7 @@
652 }
653 .dialog .background {
654 dim: true;
655- color: QuickUtils.rootObject.width > units.gu(60) ? Qt.rgba(0, 0, 0, 0.6) : Qt.rgba(0, 0, 0, 0.9);
656+ color: item.width > units.gu(60) ? Qt.rgba(0, 0, 0, 0.6) : Qt.rgba(0, 0, 0, 0.9);
657 opacity: 1.0;
658 }
659 .dialog .foreground {
660@@ -225,7 +225,7 @@
661 margins: units.gu(4);
662 itemSpacing: units.gu(2);
663 radius: "medium";
664- visible: QuickUtils.rootObject.width > units.gu(60);
665+ visible: item.dismissArea.width > units.gu(60);
666 color: visible ? Qt.rgba(0, 0, 0, 0.7) : "transparent";
667 }
668 .dialog .foreground .title {

Subscribers

People subscribed via source and target branches

to status/vote changes: