Merge lp:~aacid/unity/hud-result-highlighting into lp:unity/phablet

Proposed by Albert Astals Cid
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
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: mp+163115@code.launchpad.net

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-3ubuntu1~raring1~test2 to properly see it working

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:665
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://code.launchpad.net/~aacid/unity/hud-result-highlighting/+merge/159841/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity-phablet-ci/877/
Executed test runs:
    FAILURE: http://s-jenkins:8080/job/unity-phablet-qmluitests/806/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-raring-armhf-ci/753/console
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-raring-i386-ci/757/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/unity-phablet-ci/877/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

161 + {text: "Pastel", highlights: [1, 1, 3, 4], result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">te</font>l"},
162 + {text: "Pastel", highlights: [1, 1, 3, 5], result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">tel</font>"},
163 + {text: "Pastel", highlights: [0, 0, 3, 5], result: "<font color=\"#ffffff\">P</font>as<font color=\"#ffffff\">tel</font>"},
164 + {text: "Pastel", highlights: [5, 5], result: "Paste<font color=\"#ffffff\">l</font>"},
165 + {text: "Two Words", highlights: [1, 2, 5, 5], result: "T<font color=\"#ffffff\">wo</font> W<font color=\"#ffffff\">o</font>rds"}

That's too long even to launchpad's diff viewer

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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) {

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

in Hud/ResultList.qml:

78 + internalModel.append({"name": itemData.column_1, "highlights": itemData.column_2, "context": itemData.column_3, "contextHighlights": itemData.column_4})

That's ridiculously long.

Revision history for this message
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)

review: Approve
Revision history for this message
Albert Astals Cid (aacid) wrote :
Revision history for this message
Gerry Boland (gerboland) wrote :

Functional test checks out, code looks fine too.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Hud/Result.qml'
--- Hud/Result.qml 2013-02-12 11:54:44 +0000
+++ Hud/Result.qml 2013-05-09 14:58:29 +0000
@@ -18,8 +18,38 @@
18import Ubuntu.Components 0.118import Ubuntu.Components 0.1
1919
20Item {20Item {
21 property alias contextSnippetText: contextSnippetLabel.text21 property string contextSnippetText
22 property alias nameText: actionLabel.text22 property variant contextSnippetHighlights
23 property string nameText
24 property variant nameHighlights
25
26 function highlightedText(text, highlights) {
27 var hText = "";
28 var nextIndexToProcess = 0;
29 if (highlights && highlights.length % 2 == 0) {
30 for (var i = 0; i < highlights.length - 1; i += 2) {
31 var highlightStart = highlights[i];
32 var highlightEnd = highlights[i + 1];
33 if (highlightEnd < highlightStart)
34 continue;
35 if (highlightStart < nextIndexToProcess)
36 continue;
37 if (highlightStart != nextIndexToProcess) {
38 // Prev non marked text
39 hText += text.substr(nextIndexToProcess, highlightStart - nextIndexToProcess);
40 }
41
42 // Marked text
43 hText += "<font color=\"#ffffff\">" + text.substr(highlightStart, highlightEnd - highlightStart + 1) + "</font>";
44 nextIndexToProcess = highlightEnd + 1;
45 }
46 }
47 if (nextIndexToProcess != text.length) {
48 // End non marked text
49 hText += text.substr(nextIndexToProcess);
50 }
51 return hText;
52 }
2353
24 Label {54 Label {
25 id: actionLabel55 id: actionLabel
@@ -29,9 +59,10 @@
29 anchors.verticalCenter: parent.verticalCenter59 anchors.verticalCenter: parent.verticalCenter
30 width: parent.width / 260 width: parent.width / 2
31 fontSize: "medium"61 fontSize: "medium"
32 color: "white"
33 elide: Text.ElideRight62 elide: Text.ElideRight
34 maximumLineCount: 163 maximumLineCount: 1
64 text: highlightedText(nameText, nameHighlights)
65 color: "#80ffffff"
35 }66 }
3667
37 Label {68 Label {
@@ -44,9 +75,10 @@
44 anchors.rightMargin: units.gu(1)75 anchors.rightMargin: units.gu(1)
45 anchors.verticalCenter: parent.verticalCenter76 anchors.verticalCenter: parent.verticalCenter
46 fontSize: "small"77 fontSize: "small"
47 color: "white"
48 opacity: 0.578 opacity: 0.5
49 elide: Text.ElideRight79 elide: Text.ElideRight
50 maximumLineCount: 280 maximumLineCount: 2
81 text: highlightedText(contextSnippetText, contextSnippetHighlights)
82 color: "#80ffffff"
51 }83 }
52}84}
5385
=== modified file 'Hud/ResultList.qml'
--- Hud/ResultList.qml 2013-04-05 11:03:11 +0000
+++ Hud/ResultList.qml 2013-05-09 14:58:29 +0000
@@ -49,7 +49,7 @@
49 internalModel.clear()49 internalModel.clear()
50 for (var i = 0; i < 5 && i < model.count; ++i) {50 for (var i = 0; i < 5 && i < model.count; ++i) {
51 var itemData = model.get(i)51 var itemData = model.get(i)
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})
53 }53 }
54 }54 }
5555
@@ -87,7 +87,9 @@
87 anchors.right: parent.right87 anchors.right: parent.right
8888
89 nameText: name89 nameText: name
90 nameHighlights: highlights
90 contextSnippetText: context91 contextSnippetText: context
92 contextSnippetHighlights: contextHighlights
91 }93 }
9294
93 BorderImage {95 BorderImage {
9496
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2013-05-01 19:30:22 +0000
+++ tests/qmltests/CMakeLists.txt 2013-05-09 14:58:29 +0000
@@ -51,6 +51,7 @@
51add_qml_test(Dash/People PeopleFilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})51add_qml_test(Dash/People PeopleFilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
52add_qml_test(Greeter Greeter)52add_qml_test(Greeter Greeter)
53add_qml_test(Hud Hud)53add_qml_test(Hud Hud)
54add_qml_test(Hud Result)
54add_qml_test(Launcher Launcher)55add_qml_test(Launcher Launcher)
55add_qml_test(Panel IndicatorRow)56add_qml_test(Panel IndicatorRow)
56add_qml_test(Panel Indicators)57add_qml_test(Panel Indicators)
5758
=== added file 'tests/qmltests/Hud/tst_Result.qml'
--- tests/qmltests/Hud/tst_Result.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Hud/tst_Result.qml 2013-05-09 14:58:29 +0000
@@ -0,0 +1,98 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtTest 1.0
19import ".."
20import "../../../Hud"
21import Unity.Test 0.1 as UT
22
23Rectangle {
24 width: 600
25 height: 600
26 color: "black"
27 Column {
28 anchors.fill: parent
29 Repeater {
30 model: test.test_highlightedText_data().length
31 Result {
32 width: parent.width
33 height: units.gu(4)
34 nameText: test.test_highlightedText_data()[index].text
35 nameHighlights: test.test_highlightedText_data()[index].highlights
36 }
37 }
38 }
39
40 UT.UnityTestCase {
41 name: "Result"
42 id: test
43
44 Result {
45 id: result
46 }
47
48 function test_highlightedText_data() {
49 return [
50 {
51 text: "Copy",
52 highlights: [],
53 result: "Copy"
54 },
55 {
56 text: "Copy",
57 highlights: [0, 0],
58 result: "<font color=\"#ffffff\">C</font>opy"
59 },
60 {
61 text: "Copy",
62 highlights: [1, 1],
63 result: "C<font color=\"#ffffff\">o</font>py"
64 },
65 {
66 text: "Pastel",
67 highlights: [1, 1, 3, 4],
68 result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">te</font>l"
69 },
70 {
71 text: "Pastel",
72 highlights: [1, 1, 3, 5],
73 result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">tel</font>"
74 },
75 {
76 text: "Pastel",
77 highlights: [0, 0, 3, 5],
78 result: "<font color=\"#ffffff\">P</font>as<font color=\"#ffffff\">tel</font>"
79 },
80 {
81 text: "Pastel",
82 highlights: [5, 5],
83 result: "Paste<font color=\"#ffffff\">l</font>"
84 },
85 {
86 text: "Two Words",
87 highlights: [1, 2, 5, 5],
88 result: "T<font color=\"#ffffff\">wo</font> W<font color=\"#ffffff\">o</font>rds"
89 }
90 ]
91 }
92
93 function test_highlightedText(data) {
94 var hText = result.highlightedText(data.text, data.highlights);
95 compare(hText, data.result);
96 }
97 }
98}

Subscribers

People subscribed via source and target branches