on xenial help sign in
Expose rendererHint to shell.

Approved by PS Jenkins bot, Michał Sawicz, Andrea Cimitan.

commit0be01836d5b11b4bc0628903291c1ef4a85819b0 authorMichal Hruby <michal.mhr@gmail.com> dateFri 4 Oct 2013, 01:12 (13 years ago) parenta1c9f9a2d839af
7 files changed+32−3
Dash/GenericScopeView.qml+2−2 plugins/Unity/categories.cpp+6 plugins/Unity/categories.h+1 plugins/Unity/categoryresults.cpp+14 plugins/Unity/categoryresults.h+2−1 tests/mocks/Unity/fake_categories.cpp+6 tests/mocks/Unity/fake_categories.h+1
Dash/GenericScopeView.qml+2−2
@@ -86,7 +86,7 @@ ScopeView {
8686 right: parent.right
8787 }
8888
89− source: getRenderer(model.renderer, model.contentType)
89+ source: getRenderer(model.renderer, model.contentType, model.rendererHint)
9090
9191 onLoaded: {
9292 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
@@ -200,7 +200,7 @@ ScopeView {
200200 }
201201 }
202202
203− function getRenderer(rendererId, contentType) {
203+ function getRenderer(rendererId, contentType, rendererHint) {
204204 if (rendererId == "default") {
205205 rendererId = getDefaultRendererId(contentType);
206206 }
plugins/Unity/categories.cpp+6
@@ -40,6 +40,7 @@ Categories::Categories(QObject* parent)
4040 m_roles[Categories::RoleIcon] = "icon";
4141 m_roles[Categories::RoleRenderer] = "renderer";
4242 m_roles[Categories::RoleContentType] = "contentType";
43+ m_roles[Categories::RoleRendererHint] = "rendererHint";
4344 m_roles[Categories::RoleProgressSource] = "progressSource";
4445 m_roles[Categories::RoleHints] = "hints";
4546 m_roles[Categories::RoleResults] = "results";
@@ -209,6 +210,11 @@ Categories::data(const QModelIndex& index, int role) const
209210 auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
210211 return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
211212 }
213+ case RoleRendererHint:
214+ {
215+ auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
216+ return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString());
217+ }
212218 case RoleProgressSource:
213219 {
214220 auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
plugins/Unity/categories.h+1
@@ -47,6 +47,7 @@ public:
4747 RoleIcon,
4848 RoleRenderer,
4949 RoleContentType,
50+ RoleRendererHint,
5051 RoleProgressSource,
5152 RoleHints,
5253 RoleResults,
plugins/Unity/categoryresults.cpp+14
@@ -46,6 +46,7 @@ CategoryResults::CategoryResults(QObject* parent)
4646 m_roles[CategoryResults::RoleComment] = "comment";
4747 m_roles[CategoryResults::RoleDndUri] = "dndUri";
4848 m_roles[CategoryResults::RoleMetadata] = "metadata";
49+ m_roles[CategoryResults::RoleRendererHints] = "rendererHints";
4950}
5051
5152int CategoryResults::categoryIndex() const
@@ -100,6 +101,19 @@ CategoryResults::data(const QModelIndex& index, int role) const
100101 return DeeListModel::data(index, ResultsColumn::DND_URI);
101102 case RoleMetadata:
102103 return DeeListModel::data(index, ResultsColumn::METADATA);
104+ case RoleRendererHints:
105+ {
106+ QVariantHash hash(DeeListModel::data(index, ResultsColumn::METADATA).toHash());
107+ if (hash.contains("content")) {
108+ QVariantMap hints;
109+ QVariantHash innerHash(hash["content"].toHash());
110+ if (innerHash.contains("scope_disabled")) {
111+ hints["scope_disabled"] = innerHash["scope_disabled"];
112+ }
113+ return hints.empty() ? QVariant() : QVariant::fromValue(hints);
114+ }
115+ return QVariant();
116+ }
103117 default:
104118 return QVariant();
105119 }
plugins/Unity/categoryresults.h+2−1
@@ -43,7 +43,8 @@ public:
4343 RoleTitle,
4444 RoleComment,
4545 RoleDndUri,
46− RoleMetadata
46+ RoleMetadata,
47+ RoleRendererHints
4748 };
4849
4950 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
tests/mocks/Unity/fake_categories.cpp+6
@@ -42,6 +42,7 @@ Categories::Categories(QObject* parent)
4242 m_roles[Categories::RoleIcon] = "icon";
4343 m_roles[Categories::RoleRenderer] = "renderer";
4444 m_roles[Categories::RoleContentType] = "contentType";
45+ m_roles[Categories::RoleRendererHint] = "rendererHint";
4546 m_roles[Categories::RoleHints] = "hints";
4647 m_roles[Categories::RoleResults] = "results";
4748 m_roles[Categories::RoleCount] = "count";
@@ -229,6 +230,11 @@ Categories::data(const QModelIndex& index, int role) const
229230 auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
230231 return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
231232 }
233+ case RoleRendererHint:
234+ {
235+ auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
236+ return hints.contains("renderer-hint") ? hints["renderer-hint"] : QVariant(QString());
237+ }
232238 case RoleHints:
233239 return DeeListModel::data(index, CategoryColumn::HINTS);
234240 case RoleResults:
tests/mocks/Unity/fake_categories.h+1
@@ -39,6 +39,7 @@ public:
3939 RoleIcon,
4040 RoleRenderer,
4141 RoleContentType,
42+ RoleRendererHint,
4243 RoleHints,
4344 RoleResults,
4445 RoleCount