Merge lp:~fboucault/ubuntu-ui-toolkit/support_quotes_in_sci into lp:ubuntu-ui-toolkit

Proposed by Florian Boucault
Status: Merged
Approved by: Gerry Boland
Approved revision: 480
Merged at revision: 479
Proposed branch: lp:~fboucault/ubuntu-ui-toolkit/support_quotes_in_sci
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 55 lines (+16/-4)
4 files modified
modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp (+13/-1)
tests/unit/tst_qquick_image_extension/borderInName.sci (+1/-1)
tests/unit/tst_qquick_image_extension/test@18.sci (+1/-1)
tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp (+1/-1)
To merge this branch: bzr merge lp:~fboucault/ubuntu-ui-toolkit/support_quotes_in_sci
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+162629@code.launchpad.net

Commit message

Support source with quotes in .sci files.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Looks fine, and maintains backward compatibility. Though I question if we should be more strict and poke people to update their .sci files?

One question: why escape the double quote character to get the char? I expected '"' to just work.

480. By Florian Boucault

No need to escape "

Revision history for this message
Florian Boucault (fboucault) wrote :

> Looks fine, and maintains backward compatibility. Though I question if we
> should be more strict and poke people to update their .sci files?
>
> One question: why escape the double quote character to get the char? I
> expected '"' to just work.

Better safe than sorry was the reasoning but you are right, removed escaping.

Revision history for this message
Gerry Boland (gerboland) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp'
2--- modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2012-11-30 17:46:02 +0000
3+++ modules/Ubuntu/Components/plugin/ucqquickimageextension.cpp 2013-05-07 11:23:28 +0000
4@@ -147,5 +147,17 @@
5 // Rewrite the source line by prepending "image://scaling" to the source value
6 QString sciDirectory = QFileInfo(sciFilePath).dir().path() + QDir::separator();
7 QString baseUrl = "image://scaling/" + scaleFactor + "/" + sciDirectory;
8- return source.replace("source: ", "source: " + baseUrl);
9+
10+ // If the source url is between quotes "", remove them
11+ const QChar quote = '"';
12+ const int quoteFirstIndex = source.indexOf(quote);
13+ if (quoteFirstIndex != -1) {
14+ source.remove(quoteFirstIndex, 1);
15+ }
16+ const int quoteLastIndex = source.lastIndexOf(quote);
17+ if (quoteLastIndex != -1) {
18+ source.remove(quoteLastIndex, 1);
19+ }
20+
21+ return source.replace("source: ", "source: " + QString(quote) + baseUrl).append(quote);
22 }
23
24=== modified file 'tests/unit/tst_qquick_image_extension/borderInName.sci'
25--- tests/unit/tst_qquick_image_extension/borderInName.sci 2012-11-19 14:52:16 +0000
26+++ tests/unit/tst_qquick_image_extension/borderInName.sci 2013-05-07 11:23:28 +0000
27@@ -1,4 +1,4 @@
28-source: borderInName.png
29+source: "borderInName.png"
30 border.left: 9
31 border.right: 2
32 border.top: 9
33
34=== modified file 'tests/unit/tst_qquick_image_extension/test@18.sci'
35--- tests/unit/tst_qquick_image_extension/test@18.sci 2012-11-30 17:05:38 +0000
36+++ tests/unit/tst_qquick_image_extension/test@18.sci 2013-05-07 11:23:28 +0000
37@@ -1,4 +1,4 @@
38-source: test@18.png
39+source: "test@18.png"
40 border.left: 9
41 border.right: 2
42 border.top: 9
43
44=== modified file 'tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp'
45--- tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp 2012-11-30 17:10:42 +0000
46+++ tests/unit/tst_qquick_image_extension/tst_qquick_image_extension.cpp 2013-05-07 11:23:28 +0000
47@@ -70,7 +70,7 @@
48
49 QString expected;
50 QTextStream expectedStream(&expected);
51- expectedStream << "source: image://scaling/1/./borderInName.png" << endl;
52+ expectedStream << "source: \"image://scaling/1/./borderInName.png\"" << endl;
53 expectedStream << "border.left: 9" << endl;
54 expectedStream << "border.right: 2" << endl;
55 expectedStream << "border.top: 9" << endl;

Subscribers

People subscribed via source and target branches

to status/vote changes: