Merge lp:~aacid/unity/hud-result-highlighting into lp:unity/phablet
- hud-result-highlighting
- Merge into phablet
Status: | Merged |
---|---|
Approved by: | Gerry Boland |
Approved revision: | no longer in the source branch. |
Merged at revision: | 667 |
Proposed branch: | lp:~aacid/unity/hud-result-highlighting |
Merge into: | lp:unity/phablet |
Prerequisite: | lp:~aacid/unity/qpa_502 |
Diff against target: |
206 lines (+138/-5) 4 files modified
Hud/Result.qml (+36/-4) Hud/ResultList.qml (+3/-1) tests/qmltests/CMakeLists.txt (+1/-0) tests/qmltests/Hud/tst_Result.qml (+98/-0) |
To merge this branch: | bzr merge lp:~aacid/unity/hud-result-highlighting |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Gerry Boland (community) | Approve | ||
Daniel d'Andrada (community) | Approve | ||
Review via email:
|
This proposal supersedes a proposal from 2013-04-19.
Commit message
Hud Result highlighting
Description of the change
Hud Result highlighting
You need qtcore5 >= 5.0.2+dfsg1-
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:665
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:665
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:666
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:666
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:666
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:667
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel d'Andrada (dandrader) wrote : | # |
161 + {text: "Pastel", highlights: [1, 1, 3, 4], result: "P<font color=\
162 + {text: "Pastel", highlights: [1, 1, 3, 5], result: "P<font color=\
163 + {text: "Pastel", highlights: [0, 0, 3, 5], result: "<font color=\
164 + {text: "Pastel", highlights: [5, 5], result: "Paste<font color=\
165 + {text: "Two Words", highlights: [1, 2, 5, 5], result: "T<font color=\
That's too long even to launchpad's diff viewer
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:668
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel d'Andrada (dandrader) wrote : | # |
19 + for (var i = 0; i < highlights.length; i += 2) {
Even though you have a preceding "if" checking for a even-numbered length, I think it would be safer if you had it like that instead:
for (var i = 0; (i + 1) < highlights.length; i += 2) {
or
for (var i = 0; i < highlights.length - 1; i += 2) {
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:670
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:670
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel d'Andrada (dandrader) wrote : | # |
in Hud/ResultList.qml:
78 + internalModel.
That's ridiculously long.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Daniel d'Andrada (dandrader) wrote : | # |
Otherwise looks good, even though I wasn't able to try it out (don't have that needed qt lib version)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Albert Astals Cid (aacid) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gerry Boland (gerboland) wrote : | # |
Functional test checks out, code looks fine too.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'Hud/Result.qml' | |||
2 | --- Hud/Result.qml 2013-02-12 11:54:44 +0000 | |||
3 | +++ Hud/Result.qml 2013-05-09 14:58:29 +0000 | |||
4 | @@ -18,8 +18,38 @@ | |||
5 | 18 | import Ubuntu.Components 0.1 | 18 | import Ubuntu.Components 0.1 |
6 | 19 | 19 | ||
7 | 20 | Item { | 20 | Item { |
10 | 21 | property alias contextSnippetText: contextSnippetLabel.text | 21 | property string contextSnippetText |
11 | 22 | property alias nameText: actionLabel.text | 22 | property variant contextSnippetHighlights |
12 | 23 | property string nameText | ||
13 | 24 | property variant nameHighlights | ||
14 | 25 | |||
15 | 26 | function highlightedText(text, highlights) { | ||
16 | 27 | var hText = ""; | ||
17 | 28 | var nextIndexToProcess = 0; | ||
18 | 29 | if (highlights && highlights.length % 2 == 0) { | ||
19 | 30 | for (var i = 0; i < highlights.length - 1; i += 2) { | ||
20 | 31 | var highlightStart = highlights[i]; | ||
21 | 32 | var highlightEnd = highlights[i + 1]; | ||
22 | 33 | if (highlightEnd < highlightStart) | ||
23 | 34 | continue; | ||
24 | 35 | if (highlightStart < nextIndexToProcess) | ||
25 | 36 | continue; | ||
26 | 37 | if (highlightStart != nextIndexToProcess) { | ||
27 | 38 | // Prev non marked text | ||
28 | 39 | hText += text.substr(nextIndexToProcess, highlightStart - nextIndexToProcess); | ||
29 | 40 | } | ||
30 | 41 | |||
31 | 42 | // Marked text | ||
32 | 43 | hText += "<font color=\"#ffffff\">" + text.substr(highlightStart, highlightEnd - highlightStart + 1) + "</font>"; | ||
33 | 44 | nextIndexToProcess = highlightEnd + 1; | ||
34 | 45 | } | ||
35 | 46 | } | ||
36 | 47 | if (nextIndexToProcess != text.length) { | ||
37 | 48 | // End non marked text | ||
38 | 49 | hText += text.substr(nextIndexToProcess); | ||
39 | 50 | } | ||
40 | 51 | return hText; | ||
41 | 52 | } | ||
42 | 23 | 53 | ||
43 | 24 | Label { | 54 | Label { |
44 | 25 | id: actionLabel | 55 | id: actionLabel |
45 | @@ -29,9 +59,10 @@ | |||
46 | 29 | anchors.verticalCenter: parent.verticalCenter | 59 | anchors.verticalCenter: parent.verticalCenter |
47 | 30 | width: parent.width / 2 | 60 | width: parent.width / 2 |
48 | 31 | fontSize: "medium" | 61 | fontSize: "medium" |
49 | 32 | color: "white" | ||
50 | 33 | elide: Text.ElideRight | 62 | elide: Text.ElideRight |
51 | 34 | maximumLineCount: 1 | 63 | maximumLineCount: 1 |
52 | 64 | text: highlightedText(nameText, nameHighlights) | ||
53 | 65 | color: "#80ffffff" | ||
54 | 35 | } | 66 | } |
55 | 36 | 67 | ||
56 | 37 | Label { | 68 | Label { |
57 | @@ -44,9 +75,10 @@ | |||
58 | 44 | anchors.rightMargin: units.gu(1) | 75 | anchors.rightMargin: units.gu(1) |
59 | 45 | anchors.verticalCenter: parent.verticalCenter | 76 | anchors.verticalCenter: parent.verticalCenter |
60 | 46 | fontSize: "small" | 77 | fontSize: "small" |
61 | 47 | color: "white" | ||
62 | 48 | opacity: 0.5 | 78 | opacity: 0.5 |
63 | 49 | elide: Text.ElideRight | 79 | elide: Text.ElideRight |
64 | 50 | maximumLineCount: 2 | 80 | maximumLineCount: 2 |
65 | 81 | text: highlightedText(contextSnippetText, contextSnippetHighlights) | ||
66 | 82 | color: "#80ffffff" | ||
67 | 51 | } | 83 | } |
68 | 52 | } | 84 | } |
69 | 53 | 85 | ||
70 | === modified file 'Hud/ResultList.qml' | |||
71 | --- Hud/ResultList.qml 2013-04-05 11:03:11 +0000 | |||
72 | +++ Hud/ResultList.qml 2013-05-09 14:58:29 +0000 | |||
73 | @@ -49,7 +49,7 @@ | |||
74 | 49 | internalModel.clear() | 49 | internalModel.clear() |
75 | 50 | for (var i = 0; i < 5 && i < model.count; ++i) { | 50 | for (var i = 0; i < 5 && i < model.count; ++i) { |
76 | 51 | var itemData = model.get(i) | 51 | var itemData = model.get(i) |
78 | 52 | internalModel.append({"name": itemData.column_1, "context": itemData.column_3}) | 52 | internalModel.append({"name": itemData.column_1, "highlights": itemData.column_2, "context": itemData.column_3, "contextHighlights": itemData.column_4}) |
79 | 53 | } | 53 | } |
80 | 54 | } | 54 | } |
81 | 55 | 55 | ||
82 | @@ -87,7 +87,9 @@ | |||
83 | 87 | anchors.right: parent.right | 87 | anchors.right: parent.right |
84 | 88 | 88 | ||
85 | 89 | nameText: name | 89 | nameText: name |
86 | 90 | nameHighlights: highlights | ||
87 | 90 | contextSnippetText: context | 91 | contextSnippetText: context |
88 | 92 | contextSnippetHighlights: contextHighlights | ||
89 | 91 | } | 93 | } |
90 | 92 | 94 | ||
91 | 93 | BorderImage { | 95 | BorderImage { |
92 | 94 | 96 | ||
93 | === modified file 'tests/qmltests/CMakeLists.txt' | |||
94 | --- tests/qmltests/CMakeLists.txt 2013-05-01 19:30:22 +0000 | |||
95 | +++ tests/qmltests/CMakeLists.txt 2013-05-09 14:58:29 +0000 | |||
96 | @@ -51,6 +51,7 @@ | |||
97 | 51 | add_qml_test(Dash/People PeopleFilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}) | 51 | add_qml_test(Dash/People PeopleFilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}) |
98 | 52 | add_qml_test(Greeter Greeter) | 52 | add_qml_test(Greeter Greeter) |
99 | 53 | add_qml_test(Hud Hud) | 53 | add_qml_test(Hud Hud) |
100 | 54 | add_qml_test(Hud Result) | ||
101 | 54 | add_qml_test(Launcher Launcher) | 55 | add_qml_test(Launcher Launcher) |
102 | 55 | add_qml_test(Panel IndicatorRow) | 56 | add_qml_test(Panel IndicatorRow) |
103 | 56 | add_qml_test(Panel Indicators) | 57 | add_qml_test(Panel Indicators) |
104 | 57 | 58 | ||
105 | === added file 'tests/qmltests/Hud/tst_Result.qml' | |||
106 | --- tests/qmltests/Hud/tst_Result.qml 1970-01-01 00:00:00 +0000 | |||
107 | +++ tests/qmltests/Hud/tst_Result.qml 2013-05-09 14:58:29 +0000 | |||
108 | @@ -0,0 +1,98 @@ | |||
109 | 1 | /* | ||
110 | 2 | * Copyright 2013 Canonical Ltd. | ||
111 | 3 | * | ||
112 | 4 | * This program is free software; you can redistribute it and/or modify | ||
113 | 5 | * it under the terms of the GNU General Public License as published by | ||
114 | 6 | * the Free Software Foundation; version 3. | ||
115 | 7 | * | ||
116 | 8 | * This program is distributed in the hope that it will be useful, | ||
117 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
118 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
119 | 11 | * GNU General Public License for more details. | ||
120 | 12 | * | ||
121 | 13 | * You should have received a copy of the GNU General Public License | ||
122 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
123 | 15 | */ | ||
124 | 16 | |||
125 | 17 | import QtQuick 2.0 | ||
126 | 18 | import QtTest 1.0 | ||
127 | 19 | import ".." | ||
128 | 20 | import "../../../Hud" | ||
129 | 21 | import Unity.Test 0.1 as UT | ||
130 | 22 | |||
131 | 23 | Rectangle { | ||
132 | 24 | width: 600 | ||
133 | 25 | height: 600 | ||
134 | 26 | color: "black" | ||
135 | 27 | Column { | ||
136 | 28 | anchors.fill: parent | ||
137 | 29 | Repeater { | ||
138 | 30 | model: test.test_highlightedText_data().length | ||
139 | 31 | Result { | ||
140 | 32 | width: parent.width | ||
141 | 33 | height: units.gu(4) | ||
142 | 34 | nameText: test.test_highlightedText_data()[index].text | ||
143 | 35 | nameHighlights: test.test_highlightedText_data()[index].highlights | ||
144 | 36 | } | ||
145 | 37 | } | ||
146 | 38 | } | ||
147 | 39 | |||
148 | 40 | UT.UnityTestCase { | ||
149 | 41 | name: "Result" | ||
150 | 42 | id: test | ||
151 | 43 | |||
152 | 44 | Result { | ||
153 | 45 | id: result | ||
154 | 46 | } | ||
155 | 47 | |||
156 | 48 | function test_highlightedText_data() { | ||
157 | 49 | return [ | ||
158 | 50 | { | ||
159 | 51 | text: "Copy", | ||
160 | 52 | highlights: [], | ||
161 | 53 | result: "Copy" | ||
162 | 54 | }, | ||
163 | 55 | { | ||
164 | 56 | text: "Copy", | ||
165 | 57 | highlights: [0, 0], | ||
166 | 58 | result: "<font color=\"#ffffff\">C</font>opy" | ||
167 | 59 | }, | ||
168 | 60 | { | ||
169 | 61 | text: "Copy", | ||
170 | 62 | highlights: [1, 1], | ||
171 | 63 | result: "C<font color=\"#ffffff\">o</font>py" | ||
172 | 64 | }, | ||
173 | 65 | { | ||
174 | 66 | text: "Pastel", | ||
175 | 67 | highlights: [1, 1, 3, 4], | ||
176 | 68 | result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">te</font>l" | ||
177 | 69 | }, | ||
178 | 70 | { | ||
179 | 71 | text: "Pastel", | ||
180 | 72 | highlights: [1, 1, 3, 5], | ||
181 | 73 | result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">tel</font>" | ||
182 | 74 | }, | ||
183 | 75 | { | ||
184 | 76 | text: "Pastel", | ||
185 | 77 | highlights: [0, 0, 3, 5], | ||
186 | 78 | result: "<font color=\"#ffffff\">P</font>as<font color=\"#ffffff\">tel</font>" | ||
187 | 79 | }, | ||
188 | 80 | { | ||
189 | 81 | text: "Pastel", | ||
190 | 82 | highlights: [5, 5], | ||
191 | 83 | result: "Paste<font color=\"#ffffff\">l</font>" | ||
192 | 84 | }, | ||
193 | 85 | { | ||
194 | 86 | text: "Two Words", | ||
195 | 87 | highlights: [1, 2, 5, 5], | ||
196 | 88 | result: "T<font color=\"#ffffff\">wo</font> W<font color=\"#ffffff\">o</font>rds" | ||
197 | 89 | } | ||
198 | 90 | ] | ||
199 | 91 | } | ||
200 | 92 | |||
201 | 93 | function test_highlightedText(data) { | ||
202 | 94 | var hText = result.highlightedText(data.text, data.highlights); | ||
203 | 95 | compare(hText, data.result); | ||
204 | 96 | } | ||
205 | 97 | } | ||
206 | 98 | } |
FAILED: Continuous integration, rev:665 /code.launchpad .net/~aacid/ unity/hud- result- highlighting/ +merge/ 159841/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http:// jenkins. qa.ubuntu. com/job/ unity-phablet- ci/877/ s-jenkins: 8080/job/ unity-phablet- qmluitests/ 806/console jenkins. qa.ubuntu. com/job/ unity-phablet- raring- armhf-ci/ 753/console jenkins. qa.ubuntu. com/job/ unity-phablet- raring- i386-ci/ 757/console
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity-phablet- ci/877/ rebuild
http://