Merge lp:~stolowski/unity8/category-reordering into lp:unity8
- category-reordering
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Albert Astals Cid |
Approved revision: | 253 |
Merged at revision: | 416 |
Proposed branch: | lp:~stolowski/unity8/category-reordering |
Merge into: | lp:unity8 |
Diff against target: |
194 lines (+80/-18) 2 files modified
plugins/Unity/categories.cpp (+70/-17) plugins/Unity/categories.h (+10/-1) |
To merge this branch: | bzr merge lp:~stolowski/unity8/category-reordering |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Review via email: mp+189263@code.launchpad.net |
Commit message
Handle category_
Description of the change
Handle category_
WARNING! It needs a hotfix for Qt proposed here: https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
- 248. By Paweł Stołowski
-
Removed unneeded include.
- 249. By Paweł Stołowski
-
Merged trunk.
Albert Astals Cid (aacid) wrote : | # |
We don't use
const int mappedIndex = m_categoryOrder
for anything so we can save the lookup :-)
Albert Astals Cid (aacid) wrote : | # |
Also
std::vector<
parameter should be const & as discussed on IRC
- 250. By Paweł Stołowski
-
Act on review commetns.
- 251. By Paweł Stołowski
-
Fixed RoleRendererHint index.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:249
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 252. By Paweł Stołowski
-
Fixed beginMoveRows.
- 253. By Paweł Stołowski
-
Clear category order vector on categories model reset.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:252
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:253
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
UNSTABLE: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Looks good now
Preview Diff
1 | === modified file 'plugins/Unity/categories.cpp' | |||
2 | --- plugins/Unity/categories.cpp 2013-10-02 13:02:16 +0000 | |||
3 | +++ plugins/Unity/categories.cpp 2013-10-09 11:01:57 +0000 | |||
4 | @@ -90,9 +90,37 @@ | |||
5 | 90 | delete model; | 90 | delete model; |
6 | 91 | } | 91 | } |
7 | 92 | m_results.clear(); | 92 | m_results.clear(); |
8 | 93 | m_categoryOrder.clear(); | ||
9 | 94 | |||
10 | 93 | setModel(model); | 95 | setModel(model); |
11 | 94 | } | 96 | } |
12 | 95 | 97 | ||
13 | 98 | void Categories::onCategoryOrderChanged(const std::vector<unsigned int>& cat_order) | ||
14 | 99 | { | ||
15 | 100 | for (unsigned int pos = 0; pos<cat_order.size(); pos++) | ||
16 | 101 | { | ||
17 | 102 | unsigned int cat = cat_order[pos]; | ||
18 | 103 | const int old_pos = m_categoryOrder.indexOf(cat); | ||
19 | 104 | |||
20 | 105 | if (old_pos < 0) { | ||
21 | 106 | qWarning() << "No such category index:" << cat; | ||
22 | 107 | continue; | ||
23 | 108 | } | ||
24 | 109 | |||
25 | 110 | if (static_cast<int>(pos) != old_pos) { | ||
26 | 111 | int target_pos = pos; | ||
27 | 112 | if (target_pos > old_pos) | ||
28 | 113 | target_pos++; | ||
29 | 114 | const bool status = beginMoveRows(QModelIndex(), old_pos, old_pos, QModelIndex(), target_pos); | ||
30 | 115 | if (status) | ||
31 | 116 | m_categoryOrder.move(old_pos, pos); | ||
32 | 117 | else | ||
33 | 118 | qWarning() << "beginMoveRows failed:" << old_pos << target_pos; | ||
34 | 119 | endMoveRows(); | ||
35 | 120 | } | ||
36 | 121 | } | ||
37 | 122 | } | ||
38 | 123 | |||
39 | 96 | void | 124 | void |
40 | 97 | Categories::setUnityScope(const unity::dash::Scope::Ptr& scope) | 125 | Categories::setUnityScope(const unity::dash::Scope::Ptr& scope) |
41 | 98 | { | 126 | { |
42 | @@ -101,9 +129,9 @@ | |||
43 | 101 | // no need to call this, we'll get notified | 129 | // no need to call this, we'll get notified |
44 | 102 | //setModel(m_unityScope->categories()->model()); | 130 | //setModel(m_unityScope->categories()->model()); |
45 | 103 | 131 | ||
49 | 104 | m_categoriesChangedConnection.disconnect(); | 132 | m_signals.disconnectAll(); |
50 | 105 | m_categoriesChangedConnection = | 133 | m_signals << m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged)); |
51 | 106 | m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged)); | 134 | m_signals << m_unityScope->category_order.changed.connect(sigc::mem_fun(this, &Categories::onCategoryOrderChanged)); |
52 | 107 | } | 135 | } |
53 | 108 | 136 | ||
54 | 109 | void | 137 | void |
55 | @@ -111,7 +139,9 @@ | |||
56 | 111 | { | 139 | { |
57 | 112 | CategoryResults* results = qobject_cast<CategoryResults*>(sender()); | 140 | CategoryResults* results = qobject_cast<CategoryResults*>(sender()); |
58 | 113 | if (results) { | 141 | if (results) { |
60 | 114 | m_updatedCategories << results->categoryIndex(); | 142 | if (!m_updatedCategories.contains(results->categoryIndex())) { |
61 | 143 | m_updatedCategories << results->categoryIndex(); | ||
62 | 144 | } | ||
63 | 115 | m_timer.start(); | 145 | m_timer.start(); |
64 | 116 | } | 146 | } |
65 | 117 | } | 147 | } |
66 | @@ -142,7 +172,8 @@ | |||
67 | 142 | roles.append(Categories::RoleCount); | 172 | roles.append(Categories::RoleCount); |
68 | 143 | Q_FOREACH(int categoryIndex, m_updatedCategories) { | 173 | Q_FOREACH(int categoryIndex, m_updatedCategories) { |
69 | 144 | if (!m_results.contains(categoryIndex)) continue; | 174 | if (!m_results.contains(categoryIndex)) continue; |
71 | 145 | QModelIndex changedIndex = index(categoryIndex); | 175 | const int realIndex = m_categoryOrder.indexOf(categoryIndex); |
72 | 176 | const QModelIndex changedIndex = index(realIndex); | ||
73 | 146 | Q_EMIT dataChanged(changedIndex, changedIndex, roles); | 177 | Q_EMIT dataChanged(changedIndex, changedIndex, roles); |
74 | 147 | } | 178 | } |
75 | 148 | m_updatedCategories.clear(); | 179 | m_updatedCategories.clear(); |
76 | @@ -196,48 +227,70 @@ | |||
77 | 196 | return QVariant(); | 227 | return QVariant(); |
78 | 197 | } | 228 | } |
79 | 198 | 229 | ||
80 | 230 | if (m_categoryOrder.size() != rowCount()) | ||
81 | 231 | { | ||
82 | 232 | // populate category order vector with 0..n | ||
83 | 233 | m_categoryOrder.clear(); | ||
84 | 234 | const unsigned int lim = rowCount(); | ||
85 | 235 | for (unsigned int i = 0; i<lim; i++) { | ||
86 | 236 | m_categoryOrder.append(i); | ||
87 | 237 | } | ||
88 | 238 | } | ||
89 | 239 | |||
90 | 240 | int realRow = index.row(); | ||
91 | 241 | if (index.row() < m_categoryOrder.size()) { | ||
92 | 242 | realRow = m_categoryOrder[index.row()]; | ||
93 | 243 | } else { | ||
94 | 244 | qWarning() << "Invalid index" << index.row(); | ||
95 | 245 | return QVariant(); | ||
96 | 246 | } | ||
97 | 247 | |||
98 | 248 | const QModelIndex realIndex = createIndex(realRow, index.column()); | ||
99 | 249 | |||
100 | 199 | switch (role) { | 250 | switch (role) { |
101 | 200 | case RoleCategoryId: | 251 | case RoleCategoryId: |
103 | 201 | return DeeListModel::data(index, CategoryColumn::ID); | 252 | return DeeListModel::data(realIndex, CategoryColumn::ID); |
104 | 202 | case RoleName: | 253 | case RoleName: |
106 | 203 | return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME); | 254 | return DeeListModel::data(realIndex, CategoryColumn::DISPLAY_NAME); |
107 | 204 | case RoleIcon: | 255 | case RoleIcon: |
109 | 205 | return DeeListModel::data(index, CategoryColumn::ICON_HINT); | 256 | return DeeListModel::data(realIndex, CategoryColumn::ICON_HINT); |
110 | 206 | case RoleRenderer: | 257 | case RoleRenderer: |
112 | 207 | return DeeListModel::data(index, CategoryColumn::RENDERER_NAME); | 258 | return DeeListModel::data(realIndex, CategoryColumn::RENDERER_NAME); |
113 | 208 | case RoleContentType: | 259 | case RoleContentType: |
114 | 209 | { | 260 | { |
116 | 210 | auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash(); | 261 | auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash(); |
117 | 211 | return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default")); | 262 | return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default")); |
118 | 212 | } | 263 | } |
119 | 213 | case RoleRendererHint: | 264 | case RoleRendererHint: |
120 | 214 | { | 265 | { |
122 | 215 | auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash(); | 266 | auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash(); |
123 | 216 | return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString()); | 267 | return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString()); |
124 | 217 | } | 268 | } |
125 | 218 | case RoleProgressSource: | 269 | case RoleProgressSource: |
126 | 219 | { | 270 | { |
128 | 220 | auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash(); | 271 | auto hints = DeeListModel::data(realIndex, CategoryColumn::HINTS).toHash(); |
129 | 221 | return hints.contains("progress-source") ? hints["progress-source"] : QVariant(); | 272 | return hints.contains("progress-source") ? hints["progress-source"] : QVariant(); |
130 | 222 | } | 273 | } |
131 | 223 | case RoleHints: | 274 | case RoleHints: |
133 | 224 | return DeeListModel::data(index, CategoryColumn::HINTS); | 275 | return DeeListModel::data(realIndex, CategoryColumn::HINTS); |
134 | 225 | case RoleResults: | 276 | case RoleResults: |
135 | 226 | if (m_overriddenCategories.size() > 0) | 277 | if (m_overriddenCategories.size() > 0) |
136 | 227 | { | 278 | { |
138 | 228 | auto id = DeeListModel::data(index, CategoryColumn::ID).toString(); | 279 | auto id = DeeListModel::data(realIndex, CategoryColumn::ID).toString(); |
139 | 229 | if (m_overriddenCategories.find(id) != m_overriddenCategories.end()) | 280 | if (m_overriddenCategories.find(id) != m_overriddenCategories.end()) |
140 | 230 | return QVariant::fromValue(m_overriddenCategories[id]); | 281 | return QVariant::fromValue(m_overriddenCategories[id]); |
141 | 231 | } | 282 | } |
143 | 232 | return QVariant::fromValue(getResults(index.row())); | 283 | return QVariant::fromValue(getResults(realRow)); |
144 | 233 | case RoleCount: | 284 | case RoleCount: |
145 | 234 | if (m_overriddenCategories.size() > 0) | 285 | if (m_overriddenCategories.size() > 0) |
146 | 235 | { | 286 | { |
148 | 236 | auto id = DeeListModel::data(index, CategoryColumn::ID).toString(); | 287 | auto id = DeeListModel::data(realIndex, CategoryColumn::ID).toString(); |
149 | 237 | if (m_overriddenCategories.find(id) != m_overriddenCategories.end()) | 288 | if (m_overriddenCategories.find(id) != m_overriddenCategories.end()) |
150 | 289 | { | ||
151 | 238 | return QVariant::fromValue(m_overriddenCategories[id]->rowCount()); | 290 | return QVariant::fromValue(m_overriddenCategories[id]->rowCount()); |
152 | 291 | } | ||
153 | 239 | } | 292 | } |
155 | 240 | return QVariant::fromValue(getResults(index.row())->rowCount()); | 293 | return QVariant::fromValue(getResults(realRow)->rowCount()); |
156 | 241 | default: | 294 | default: |
157 | 242 | return QVariant(); | 295 | return QVariant(); |
158 | 243 | } | 296 | } |
159 | 244 | 297 | ||
160 | === modified file 'plugins/Unity/categories.h' | |||
161 | --- plugins/Unity/categories.h 2013-10-02 13:02:16 +0000 | |||
162 | +++ plugins/Unity/categories.h 2013-10-09 11:01:57 +0000 | |||
163 | @@ -32,6 +32,9 @@ | |||
164 | 32 | #include <QSet> | 32 | #include <QSet> |
165 | 33 | #include <QTimer> | 33 | #include <QTimer> |
166 | 34 | 34 | ||
167 | 35 | // local | ||
168 | 36 | #include "signalslist.h" | ||
169 | 37 | |||
170 | 35 | class Categories : public DeeListModel | 38 | class Categories : public DeeListModel |
171 | 36 | { | 39 | { |
172 | 37 | Q_OBJECT | 40 | Q_OBJECT |
173 | @@ -71,6 +74,7 @@ | |||
174 | 71 | 74 | ||
175 | 72 | private: | 75 | private: |
176 | 73 | void onCategoriesModelChanged(unity::glib::Object<DeeModel> model); | 76 | void onCategoriesModelChanged(unity::glib::Object<DeeModel> model); |
177 | 77 | void onCategoryOrderChanged(const std::vector<unsigned int>& cat_order); | ||
178 | 74 | 78 | ||
179 | 75 | DeeListModel* getResults(int index) const; | 79 | DeeListModel* getResults(int index) const; |
180 | 76 | 80 | ||
181 | @@ -80,7 +84,12 @@ | |||
182 | 80 | QHash<int, QByteArray> m_roles; | 84 | QHash<int, QByteArray> m_roles; |
183 | 81 | QMap<QString, QAbstractItemModel*> m_overriddenCategories; | 85 | QMap<QString, QAbstractItemModel*> m_overriddenCategories; |
184 | 82 | mutable QMap<int, DeeListModel*> m_results; | 86 | mutable QMap<int, DeeListModel*> m_results; |
186 | 83 | sigc::connection m_categoriesChangedConnection; | 87 | SignalsList m_signals; |
187 | 88 | |||
188 | 89 | /* Category order array contains indices of actual categories in the underlying DeeListModel. | ||
189 | 90 | It's used internally to reflect category order reported by scope. | ||
190 | 91 | */ | ||
191 | 92 | mutable QList<unsigned int> m_categoryOrder; | ||
192 | 84 | }; | 93 | }; |
193 | 85 | 94 | ||
194 | 86 | #endif // CATEGORIES_H | 95 | #endif // CATEGORIES_H |
PASSED: Continuous integration, rev:247 jenkins. qa.ubuntu. com/job/ unity8- ci/1258/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- saucy/4528 jenkins. qa.ubuntu. com/job/ generic- mediumtests- touch/2311 jenkins. qa.ubuntu. com/job/ unity-phablet- qmluitests- saucy/2090 jenkins. qa.ubuntu. com/job/ unity8- saucy-amd64- ci/281 jenkins. qa.ubuntu. com/job/ unity8- saucy-armhf- ci/1258 jenkins. qa.ubuntu. com/job/ unity8- saucy-armhf- ci/1258/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ unity8- saucy-i386- ci/1257 jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-saucy/ 812 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-amd64/ 403 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-amd64/ 403/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-armhf/ 2313 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy-armhf/ 2313/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- maguro/ 1986 jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/2001
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity8- ci/1258/ rebuild
http://