Merge lp:~stolowski/unity-scope-click/sort-departments into lp:unity-scope-click/devel

Proposed by Paweł Stołowski
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 405
Merged at revision: 408
Proposed branch: lp:~stolowski/unity-scope-click/sort-departments
Merge into: lp:unity-scope-click/devel
Prerequisite: lp:~stolowski/unity-scope-click/no-empty-departments
Diff against target: 84 lines (+21/-3)
3 files modified
scope/clickapps/apps-query.cpp (+13/-1)
scope/clickstore/store-query.cpp (+6/-0)
scope/tests/test_apps_query.cpp (+2/-2)
To merge this branch: bzr merge lp:~stolowski/unity-scope-click/sort-departments
Reviewer Review Type Date Requested Status
dobey (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+230141@code.launchpad.net

Commit message

Sort departments alphabetically.

Description of the change

Sort departments alphabetically.

To post a comment you must log in.
403. By Paweł Stołowski

Use locale-sensitive sort.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
404. By Paweł Stołowski

Merged no-empty-departments.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Needs Fixing
405. By Paweł Stołowski

Removed commented line.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scope/clickapps/apps-query.cpp'
2--- scope/clickapps/apps-query.cpp 2014-08-18 13:44:42 +0000
3+++ scope/clickapps/apps-query.cpp 2014-08-18 13:44:43 +0000
4@@ -40,6 +40,7 @@
5 #include <unity/scopes/Department.h>
6
7 #include <vector>
8+#include <locale>
9
10 #include <click/click-i18n.h>
11 #include "apps-query.h"
12@@ -317,6 +318,8 @@
13 auto name = current_dep_id == "" ? all_dept_name : impl->depts_db->get_department_name(current_dep_id, locales);
14 unity::scopes::Department::SPtr current = unity::scopes::Department::create(current_dep_id, query(), name);
15
16+ unity::scopes::DepartmentList children;
17+
18 // attach subdepartments to it
19 for (auto const& subdep: impl->depts_db->get_children_departments(current_dep_id))
20 {
21@@ -356,7 +359,7 @@
22 name = impl->depts_db->get_department_name(subdep.id, locales);
23 unity::scopes::Department::SPtr dep = unity::scopes::Department::create(subdep.id, query(), name);
24 dep->set_has_subdepartments(subdep.has_children);
25- current->add_subdepartment(dep);
26+ children.push_back(dep);
27 }
28 catch (const std::exception &e)
29 {
30@@ -365,6 +368,15 @@
31 }
32 }
33
34+ if (children.size() > 0)
35+ {
36+ const std::locale loc("");
37+ children.sort([&loc](const unity::scopes::Department::SCPtr &d1, const unity::scopes::Department::SCPtr &d2) -> bool {
38+ return loc(d1->label(), d2->label()) > 0;
39+ });
40+ current->set_subdepartments(children);
41+ }
42+
43 // if current is not the top, then gets its parent
44 if (current_dep_id != "")
45 {
46
47=== modified file 'scope/clickstore/store-query.cpp'
48--- scope/clickstore/store-query.cpp 2014-08-01 05:12:28 +0000
49+++ scope/clickstore/store-query.cpp 2014-08-18 13:44:43 +0000
50@@ -48,6 +48,7 @@
51 #include<set>
52 #include<sstream>
53 #include <cassert>
54+#include <locale>
55
56 #include <QLocale>
57
58@@ -215,6 +216,11 @@
59 departments.push_back(department);
60 }
61
62+ const std::locale loc("");
63+ departments.sort([&loc](const unity::scopes::Department::SCPtr &d1, const unity::scopes::Department::SCPtr &d2) -> bool {
64+ return loc(d1->label(), d2->label()) > 0;
65+ });
66+
67 if (current_dep_id != "")
68 {
69 auto curr_dpt = impl->department_lookup.get_department_info(current_dep_id);
70
71=== modified file 'scope/tests/test_apps_query.cpp'
72--- scope/tests/test_apps_query.cpp 2014-08-18 13:44:42 +0000
73+++ scope/tests/test_apps_query.cpp 2014-08-18 13:44:43 +0000
74@@ -242,9 +242,9 @@
75 EXPECT_CALL(*depts_db, is_descendant_of_department(_, _)).Times(AnyNumber());
76 EXPECT_CALL(*depts_db, get_children_departments("")).WillOnce(Return(
77 std::list<click::DepartmentsDb::DepartmentInfo>({
78- {"games", true},
79 {"video", true},
80- {"books", true}
81+ {"books", true},
82+ {"games", true}
83 }))
84 );
85

Subscribers

People subscribed via source and target branches

to all changes: