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

Proposed by Albert Astals Cid
Status: Superseded
Proposed branch: lp:~aacid/unity/hud-result-highlighting
Merge into: lp:unity/phablet
Diff against target: 186 lines (+107/-5)
5 files modified
Hud/Result.qml (+36/-4)
Hud/ResultList.qml (+3/-1)
debian/control (+1/-0)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Hud/tst_Result.qml (+66/-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 Needs Fixing
Unity Team Pending
Review via email: mp+159841@code.launchpad.net

This proposal has been superseded by a proposal from 2013-05-09.

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 :

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 :
review: Needs Fixing (continuous-integration)
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: Needs Fixing (continuous-integration)
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: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Hud/Result.qml'
2--- Hud/Result.qml 2013-02-12 11:54:44 +0000
3+++ Hud/Result.qml 2013-05-09 09:16:24 +0000
4@@ -18,8 +18,38 @@
5 import Ubuntu.Components 0.1
6
7 Item {
8- property alias contextSnippetText: contextSnippetLabel.text
9- property alias nameText: actionLabel.text
10+ property string contextSnippetText
11+ property variant contextSnippetHighlights
12+ property string nameText
13+ property variant nameHighlights
14+
15+ function highlightedText(text, highlights) {
16+ var hText = "";
17+ var nextIndexToProcess = 0;
18+ if (highlights && highlights.length % 2 == 0) {
19+ for (var i = 0; i < highlights.length; i += 2) {
20+ var highlightStart = highlights[i];
21+ var highlightEnd = highlights[i + 1];
22+ if (highlightEnd < highlightStart)
23+ continue;
24+ if (highlightStart < nextIndexToProcess)
25+ continue;
26+ if (highlightStart != nextIndexToProcess) {
27+ // Prev non marked text
28+ hText += text.substr(nextIndexToProcess, highlightStart - nextIndexToProcess);
29+ }
30+
31+ // Marked text
32+ hText += "<font color=\"#ffffff\">" + text.substr(highlightStart, highlightEnd - highlightStart + 1) + "</font>";
33+ nextIndexToProcess = highlightEnd + 1;
34+ }
35+ }
36+ if (nextIndexToProcess != text.length) {
37+ // End non marked text
38+ hText += text.substr(nextIndexToProcess);
39+ }
40+ return hText;
41+ }
42
43 Label {
44 id: actionLabel
45@@ -29,9 +59,10 @@
46 anchors.verticalCenter: parent.verticalCenter
47 width: parent.width / 2
48 fontSize: "medium"
49- color: "white"
50 elide: Text.ElideRight
51 maximumLineCount: 1
52+ text: highlightedText(nameText, nameHighlights)
53+ color: "#80ffffff"
54 }
55
56 Label {
57@@ -44,9 +75,10 @@
58 anchors.rightMargin: units.gu(1)
59 anchors.verticalCenter: parent.verticalCenter
60 fontSize: "small"
61- color: "white"
62 opacity: 0.5
63 elide: Text.ElideRight
64 maximumLineCount: 2
65+ text: highlightedText(contextSnippetText, contextSnippetHighlights)
66+ color: "#80ffffff"
67 }
68 }
69
70=== modified file 'Hud/ResultList.qml'
71--- Hud/ResultList.qml 2013-04-05 11:03:11 +0000
72+++ Hud/ResultList.qml 2013-05-09 09:16:24 +0000
73@@ -49,7 +49,7 @@
74 internalModel.clear()
75 for (var i = 0; i < 5 && i < model.count; ++i) {
76 var itemData = model.get(i)
77- internalModel.append({"name": itemData.column_1, "context": itemData.column_3})
78+ internalModel.append({"name": itemData.column_1, "highlights": itemData.column_2, "context": itemData.column_3, "contextHighlights": itemData.column_4})
79 }
80 }
81
82@@ -87,7 +87,9 @@
83 anchors.right: parent.right
84
85 nameText: name
86+ nameHighlights: highlights
87 contextSnippetText: context
88+ contextSnippetHighlights: contextHighlights
89 }
90
91 BorderImage {
92
93=== modified file 'debian/control'
94--- debian/control 2013-05-03 21:43:49 +0000
95+++ debian/control 2013-05-09 09:16:24 +0000
96@@ -21,6 +21,7 @@
97 python3,
98 qt5-default,
99 qtbase5-dev,
100+ qtbase5-private-dev,
101 qtdeclarative5-dev,
102 qtdeclarative5-dev-tools,
103 qtdeclarative5-qtquick2-plugin,
104
105=== modified file 'tests/qmltests/CMakeLists.txt'
106--- tests/qmltests/CMakeLists.txt 2013-05-01 19:30:22 +0000
107+++ tests/qmltests/CMakeLists.txt 2013-05-09 09:16:24 +0000
108@@ -51,6 +51,7 @@
109 add_qml_test(Dash/People PeopleFilterGrid IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${CMAKE_CURRENT_SOURCE_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
110 add_qml_test(Greeter Greeter)
111 add_qml_test(Hud Hud)
112+add_qml_test(Hud Result)
113 add_qml_test(Launcher Launcher)
114 add_qml_test(Panel IndicatorRow)
115 add_qml_test(Panel Indicators)
116
117=== added file 'tests/qmltests/Hud/tst_Result.qml'
118--- tests/qmltests/Hud/tst_Result.qml 1970-01-01 00:00:00 +0000
119+++ tests/qmltests/Hud/tst_Result.qml 2013-05-09 09:16:24 +0000
120@@ -0,0 +1,66 @@
121+/*
122+ * Copyright 2013 Canonical Ltd.
123+ *
124+ * This program is free software; you can redistribute it and/or modify
125+ * it under the terms of the GNU General Public License as published by
126+ * the Free Software Foundation; version 3.
127+ *
128+ * This program is distributed in the hope that it will be useful,
129+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
130+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
131+ * GNU General Public License for more details.
132+ *
133+ * You should have received a copy of the GNU General Public License
134+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
135+ */
136+
137+import QtQuick 2.0
138+import QtTest 1.0
139+import ".."
140+import "../../../Hud"
141+import Unity.Test 0.1 as UT
142+
143+Rectangle {
144+ width: 600
145+ height: 600
146+ color: "black"
147+ Column {
148+ anchors.fill: parent
149+ Repeater {
150+ model: test.test_highlightedText_data().length
151+ Result {
152+ width: parent.width
153+ height: units.gu(4)
154+ nameText: test.test_highlightedText_data()[index].text
155+ nameHighlights: test.test_highlightedText_data()[index].highlights
156+ }
157+ }
158+ }
159+
160+ UT.UnityTestCase {
161+ name: "Result"
162+ id: test
163+
164+ Result {
165+ id: result
166+ }
167+
168+ function test_highlightedText_data() {
169+ return [
170+ {text: "Copy", highlights: [], result: "Copy"},
171+ {text: "Copy", highlights: [0, 0], result: "<font color=\"#ffffff\">C</font>opy"},
172+ {text: "Copy", highlights: [1, 1], result: "C<font color=\"#ffffff\">o</font>py"},
173+ {text: "Pastel", highlights: [1, 1, 3, 4], result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">te</font>l"},
174+ {text: "Pastel", highlights: [1, 1, 3, 5], result: "P<font color=\"#ffffff\">a</font>s<font color=\"#ffffff\">tel</font>"},
175+ {text: "Pastel", highlights: [0, 0, 3, 5], result: "<font color=\"#ffffff\">P</font>as<font color=\"#ffffff\">tel</font>"},
176+ {text: "Pastel", highlights: [5, 5], result: "Paste<font color=\"#ffffff\">l</font>"},
177+ {text: "Two Words", highlights: [1, 2, 5, 5], result: "T<font color=\"#ffffff\">wo</font> W<font color=\"#ffffff\">o</font>rds"}
178+ ]
179+ }
180+
181+ function test_highlightedText(data) {
182+ var hText = result.highlightedText(data.text, data.highlights);
183+ compare(hText, data.result);
184+ }
185+ }
186+}

Subscribers

People subscribed via source and target branches