Merge lp:~diegosarmentero/unity-scope-click/category-templates into lp:unity-scope-click

Proposed by Diego Sarmentero
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 140
Merged at revision: 147
Proposed branch: lp:~diegosarmentero/unity-scope-click/category-templates
Merge into: lp:unity-scope-click
Prerequisite: lp:~jpakkane/unity-scope-click/doubleadd
Diff against target: 121 lines (+55/-9)
1 file modified
scope/click/query.cpp (+55/-9)
To merge this branch: bzr merge lp:~diegosarmentero/unity-scope-click/category-templates
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Alejandro J. Cura (community) Approve
Review via email: mp+206793@code.launchpad.net

This proposal supersedes a proposal from 2014-02-17.

Commit message

- Adding Category templates for normal and search results.

To post a comment you must log in.
140. By Diego Sarmentero

remove aspect radio

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:139
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/~diegosarmentero/unity-scope-click/category-templates/+merge/206793/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity-scope-click-ci/306/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-scope-click-trusty-amd64-ci/207
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-scope-click-trusty-armhf-ci/204
        deb: http://jenkins.qa.ubuntu.com/job/unity-scope-click-trusty-armhf-ci/204/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity-scope-click-ci/306/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scope/click/query.cpp'
2--- scope/click/query.cpp 2014-02-17 16:31:04 +0000
3+++ scope/click/query.cpp 2014-02-17 19:23:21 +0000
4@@ -59,6 +59,42 @@
5
6 namespace
7 {
8+
9+std::string CATEGORY_APPS_DISPLAY = R"(
10+ {
11+ "schema-version" : 1,
12+ "template" : {
13+ "category-layout" : "grid",
14+ "card-size": "small"
15+ },
16+ "components" : {
17+ "title" : "title",
18+ "art" : {
19+ "field": "art"
20+ },
21+ "subtitle" : "publisher"
22+ }
23+ }
24+)";
25+
26+std::string CATEGORY_APPS_SEARCH = R"(
27+ {
28+ "schema-version" : 1,
29+ "template" : {
30+ "category-layout" : "journal",
31+ "card-layout" : "horizontal",
32+ "card-size": "large"
33+ },
34+ "components" : {
35+ "title" : "title",
36+ "art" : {
37+ "field": "art"
38+ },
39+ "subtitle" : "publisher"
40+ }
41+ }
42+)";
43+
44 QNetworkAccessManager* getNetworkAccessManager(qt::core::world::Environment& env)
45 {
46 static qt::HeapAllocatedObject<QNetworkAccessManager> nam = env.allocate<QNetworkAccessManager>(&env);
47@@ -102,8 +138,6 @@
48 reply(reply),
49 replyProxy(replyProxy),
50 installedApplications(installedApplications),
51- categoryRenderer(),
52- category(replyProxy->register_category("appstore", "App Store", "", categoryRenderer)),
53 queryUrl(queryUri) {
54 }
55
56@@ -197,19 +231,25 @@
57 }
58 }
59
60+ void setCategoryTemplate(std::string categoryTemplate) {
61+ scopes::CategoryRenderer categoryRenderer(categoryTemplate);
62+ category = scopes::Category::SCPtr(replyProxy->register_category("appstore", "App Store", "", categoryRenderer));
63+ }
64+
65 private:
66 QNetworkReply* reply;
67 scopes::SearchReplyProxy replyProxy;
68 std::set<std::string> installedApplications;
69- scopes::CategoryRenderer categoryRenderer;
70 scopes::Category::SCPtr category;
71 QUrl queryUrl;
72 };
73 }
74
75-static void push_local_results(scopes::SearchReplyProxy const &replyProxy, std::vector<click::Application> const &apps)
76+static void push_local_results(scopes::SearchReplyProxy const &replyProxy,
77+ std::vector<click::Application> const &apps,
78+ std::string categoryTemplate)
79 {
80- scopes::CategoryRenderer rdr;
81+ scopes::CategoryRenderer rdr(categoryTemplate);
82 auto cat = replyProxy->register_category("local", "My apps", "", rdr);
83
84 for(const auto & a: apps)
85@@ -262,19 +302,24 @@
86 }
87 void click::Query::run(scopes::SearchReplyProxy const& searchReply)
88 {
89+ QString query = QString::fromStdString(impl->query);
90+ std::string categoryTemplate = CATEGORY_APPS_SEARCH;
91+ if (query.isEmpty()) {
92+ categoryTemplate = CATEGORY_APPS_DISPLAY;
93+ }
94 auto localResults = clickInterfaceInstance().find_installed_apps(
95- QString::fromStdString(
96- impl->query));
97+ query);
98
99 push_local_results(
100 searchReply,
101- localResults);
102+ localResults,
103+ categoryTemplate);
104
105 std::set<std::string> locallyInstalledApps;
106 for(const auto& app : localResults)
107 locallyInstalledApps.insert(app.title);
108
109- qt::core::world::enter_with_task([this, searchReply, locallyInstalledApps](qt::core::world::Environment& env)
110+ qt::core::world::enter_with_task([this, searchReply, locallyInstalledApps, categoryTemplate](qt::core::world::Environment& env)
111 {
112 static const QString queryPattern(
113 "https://search.apps.ubuntu.com/api/v1/search?q=%1"
114@@ -286,6 +331,7 @@
115
116 impl->replyWrapper = env.allocate<ReplyWrapper>(networkReply, searchReply, locallyInstalledApps, queryUri, &env);
117 auto rw = env.resolve(impl->replyWrapper);
118+ rw->setCategoryTemplate(categoryTemplate);
119
120 QObject::connect(
121 nam, &QNetworkAccessManager::finished,

Subscribers

People subscribed via source and target branches