on xenial help sign in
Expose real category ids and not just indices
e04653cMichal Hruby
Dash/DashApps.qml+1−1
@@ -87,7 +87,7 @@ ScopeView {
87 model: scopeView.scope.categories
87 model: scopeView.scope.categories
88
88
89 delegate: Item {
89 delegate: Item {
90− Component.onCompleted: if (index == 3) scopeView.installedModel = Qt.binding(function() { return model.results; });
90+ Component.onCompleted: if (id == "installed") scopeView.installedModel = Qt.binding(function() { return model.results; });
91 }
91 }
92 }
92 }
93
93
plugins/Unity/categories.cpp+4−1
@@ -42,6 +42,7 @@ Categories::Categories(QObject* parent)
42 m_roles[Categories::RoleHints] = "hints";
42 m_roles[Categories::RoleHints] = "hints";
43 m_roles[Categories::RoleResults] = "results";
43 m_roles[Categories::RoleResults] = "results";
44 m_roles[Categories::RoleCount] = "count";
44 m_roles[Categories::RoleCount] = "count";
45+ m_roles[Categories::RoleCategoryIndex] = "categoryIndex";
45
46
46 // TODO This should not be needed but accumulatting the count changes
47 // TODO This should not be needed but accumulatting the count changes
47 // makes the visualization more stable and also makes crashes on fast
48 // makes the visualization more stable and also makes crashes on fast
@@ -131,7 +132,7 @@ Categories::data(const QModelIndex& index, int role) const
131
132
132 switch (role) {
133 switch (role) {
133 case RoleId:
134 case RoleId:
134− return QVariant::fromValue(index.row());
135+ return DeeListModel::data(index, CategoryColumn::ID);
135 case RoleName:
136 case RoleName:
136 return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME);
137 return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME);
137 case RoleIcon:
138 case RoleIcon:
@@ -149,6 +150,8 @@ Categories::data(const QModelIndex& index, int role) const
149 return QVariant::fromValue(getResults(index.row()));
150 return QVariant::fromValue(getResults(index.row()));
150 case RoleCount:
151 case RoleCount:
151 return QVariant::fromValue(getResults(index.row())->rowCount());
152 return QVariant::fromValue(getResults(index.row())->rowCount());
153+ case RoleCategoryIndex:
154+ return QVariant::fromValue(index.row());
152 default:
155 default:
153 return QVariant();
156 return QVariant();
154 }
157 }
plugins/Unity/categories.h+2−1
@@ -49,7 +49,8 @@ public:
49 RoleContentType,
49 RoleContentType,
50 RoleHints,
50 RoleHints,
51 RoleResults,
51 RoleResults,
52− RoleCount
52+ RoleCount,
53+ RoleCategoryIndex
53 };
54 };
54
55
55 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
56 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
tests/mocks/Unity/fake_categories.cpp+5−2
@@ -32,10 +32,11 @@ Categories::Categories(QObject* parent)
32 m_roles[Categories::RoleName] = "name";
32 m_roles[Categories::RoleName] = "name";
33 m_roles[Categories::RoleIcon] = "icon";
33 m_roles[Categories::RoleIcon] = "icon";
34 m_roles[Categories::RoleRenderer] = "renderer";
34 m_roles[Categories::RoleRenderer] = "renderer";
35− m_roles[Categories::RoleContentType] = "content_type";
35+ m_roles[Categories::RoleContentType] = "contentType";
36 m_roles[Categories::RoleHints] = "hints";
36 m_roles[Categories::RoleHints] = "hints";
37 m_roles[Categories::RoleResults] = "results";
37 m_roles[Categories::RoleResults] = "results";
38 m_roles[Categories::RoleCount] = "count";
38 m_roles[Categories::RoleCount] = "count";
39+ m_roles[Categories::RoleCategoryIndex] = "categoryIndex";
39
40
40 // TODO This should not be needed but accumulatting the count changes
41 // TODO This should not be needed but accumulatting the count changes
41 // makes the visualization more stable and also makes crashes on fast
42 // makes the visualization more stable and also makes crashes on fast
@@ -154,7 +155,7 @@ Categories::data(const QModelIndex& index, int role) const
154
155
155 switch (role) {
156 switch (role) {
156 case RoleId:
157 case RoleId:
157− return QVariant::fromValue(index.row());
158+ return DeeListModel::data(index, 0); //ID
158 case RoleName:
159 case RoleName:
159 return DeeListModel::data(index, 1); //DISPLAY_NAME
160 return DeeListModel::data(index, 1); //DISPLAY_NAME
160 case RoleIcon:
161 case RoleIcon:
@@ -172,6 +173,8 @@ Categories::data(const QModelIndex& index, int role) const
172 return QVariant::fromValue(getFilter(index.row()));
173 return QVariant::fromValue(getFilter(index.row()));
173 case RoleCount:
174 case RoleCount:
174 return QVariant::fromValue(getFilter(index.row())->rowCount());
175 return QVariant::fromValue(getFilter(index.row())->rowCount());
176+ case RoleCategoryIndex:
177+ return QVariant::fromValue(index.row());
175 default:
178 default:
176 return QVariant();
179 return QVariant();
177 }
180 }
tests/mocks/Unity/fake_categories.h+2−1
@@ -41,7 +41,8 @@ public:
41 RoleContentType,
41 RoleContentType,
42 RoleHints,
42 RoleHints,
43 RoleResults,
43 RoleResults,
44− RoleCount
44+ RoleCount,
45+ RoleCategoryIndex
45 };
46 };
46
47
47 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
48 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;