on xenial help sign in
Implement CategoryResults based on DeeFilterModel
commit0a01fee98263c805d5a247fe3f9ff4f08f0a50b2 authorMichal Hruby <michal.mhr@gmail.com> dateFri 28 Jun 2013, 17:12 (13 years ago) parent7386fbb
11 files changed+233−202
Dash/GenericScopeView.qml+2−2 plugins/Unity/CMakeLists.txt+1−2 plugins/Unity/categories.cpp+39−27 plugins/Unity/categories.h+10−15 plugins/Unity/categoryfilter.cpp−45 plugins/Unity/categoryfilter.h−48 plugins/Unity/categoryresults.cpp+81 plugins/Unity/categoryresults.h+68 plugins/Unity/plugin.cpp+2−2 plugins/Unity/scope.cpp+22−51 plugins/Unity/scope.h+8−10
Dash/GenericScopeView.qml+2−2
@@ -72,10 +72,10 @@ ScopeView {
7272 delegate: Tile {
7373 width: filtergrid.cellWidth
7474 height: filtergrid.cellHeight
75− text: column_5 ? column_5 : "" // FIXME: this shouldn't be necessary
75+ text: title ? title : "" // FIXME: this shouldn't be necessary
7676 imageWidth: units.gu(11)
7777 imageHeight: units.gu(16)
78− source: column_1 ? IconUtil.from_gicon(column_1) : "" // FIXME: ditto
78+ source: icon ? IconUtil.from_gicon(icon) : "" // FIXME: ditto
7979 }
8080 }
8181 }
plugins/Unity/CMakeLists.txt+1−2
@@ -12,11 +12,10 @@ include_directories(
1212)
1313
1414set(QMLPLUGIN_SRC
15− ../Utils/qsortfilterproxymodelqml.cpp # FIXME evaluate a more generic approach for using other plugins
1615 scope.cpp
1716 scopes.cpp
1817 categories.cpp
19− categoryfilter.cpp
18+ categoryresults.cpp
2019 plugin.cpp
2120 bottombarvisibilitycommunicatorshell.cpp
2221 launchermodel.cpp
plugins/Unity/categories.cpp+39−27
@@ -19,11 +19,10 @@
1919
2020// self
2121#include "categories.h"
22−#include "categoryfilter.h"
22+#include "categoryresults.h"
2323
2424Categories::Categories(QObject* parent)
2525 : DeeListModel(parent)
26− , m_resultModel(0)
2726{
2827 // FIXME: need to clean up unused filters on countChanged
2928 m_roles[Categories::RoleId] = "id";
@@ -45,42 +44,57 @@ Categories::Categories(QObject* parent)
4544
4645Categories::~Categories()
4746{
48− qDeleteAll(m_filters);
4947}
5048
51−CategoryFilter*
49+DeeListModel*
5250Categories::getFilter(int index) const
5351{
5452 if (!m_filters.contains(index)) {
55− CategoryFilter* filter = new CategoryFilter();
56− connect(filter, SIGNAL(countChanged()), this, SLOT(onCountChanged()));
57− filter->setModel(m_resultModel);
58− filter->setIndex(index);
53+ auto results = std::make_shared<CategoryResults> ();
54+ results->setCategoryIndex(index);
55+ connect(results.get(), SIGNAL(countChanged()), this, SLOT(onCountChanged()));
5956
60− m_filters.insert(index, filter);
57+ unsigned cat_index = static_cast<unsigned>(index);
58+ auto unity_results = m_unityScope->GetResultsForCategory(cat_index);
59+ results->setModel(unity_results->model());
60+
61+ m_filters.insert(index, results);
6162 }
6263
63− return m_filters[index];
64+ return m_filters[index].get();
65+}
66+
67+void Categories::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
68+{
69+ m_timerFilters.clear();
70+ m_filters.clear();
71+
72+ setModel(model);
6473}
6574
6675void
67−Categories::setResultModel(DeeListModel* model)
76+Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
6877{
69− if (model != m_resultModel) {
70− m_resultModel = model;
78+ m_unityScope = scope;
7179
80+ // no need to call this, we'll get notified
81+ //setModel(m_unityScope->categories()->model());
82+
83+ m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged));
84+
85+ /*
86+ if (model != m_resultModel) {
7287 Q_FOREACH(CategoryFilter* filter, m_filters) {
7388 filter->setModel(m_resultModel);
7489 }
75−
76− Q_EMIT resultModelChanged(m_resultModel);
7790 }
91+ */
7892}
7993
8094void
8195Categories::onCountChanged()
8296{
83− CategoryFilter* filter = qobject_cast<CategoryFilter*>(sender());
97+ DeeListModel* filter = qobject_cast<DeeListModel*>(sender());
8498 if (filter) {
8599 m_timerFilters << filter;
86100 m_timer.start();
@@ -92,8 +106,9 @@ Categories::onEmitCountChanged()
92106{
93107 QVector<int> roles;
94108 roles.append(Categories::RoleCount);
95− Q_FOREACH(CategoryFilter* filter, m_timerFilters) {
96− QModelIndex changedIndex = index(filter->index());
109+ Q_FOREACH(DeeListModel* results, m_timerFilters) {
110+ auto cat_results = qobject_cast<CategoryResults*>(results);
111+ QModelIndex changedIndex = index(cat_results->categoryIndex());
97112 Q_EMIT dataChanged(changedIndex, changedIndex, roles);
98113 }
99114 m_timerFilters.clear();
@@ -116,25 +131,22 @@ Categories::data(const QModelIndex& index, int role) const
116131 case RoleId:
117132 return QVariant::fromValue(index.row());
118133 case RoleName:
119− return QVariant::fromValue(DeeListModel::data(index, 1)); //DISPLAY_NAME
134+ return DeeListModel::data(index, 1); //DISPLAY_NAME
120135 case RoleIcon:
121− return QVariant::fromValue(DeeListModel::data(index, 2)); //ICON_HINT
136+ return DeeListModel::data(index, 2); //ICON_HINT
122137 case RoleRenderer:
123− return QVariant::fromValue(DeeListModel::data(index, 3)); //RENDERER_NAME
138+ return DeeListModel::data(index, 3); //RENDERER_NAME
124139 case RoleContentType:
125140 {
126− auto hints = QVariant::fromValue(DeeListModel::data(index, 4)).toHash();
141+ auto hints = DeeListModel::data(index, 4).toHash();
127142 return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
128143 }
129144 case RoleHints:
130− return QVariant::fromValue(DeeListModel::data(index, 4)); //HINTS
145+ return DeeListModel::data(index, 4); //HINTS
131146 case RoleResults:
132147 return QVariant::fromValue(getFilter(index.row()));
133148 case RoleCount:
134− {
135− CategoryFilter* filter = getFilter(index.row());
136− return QVariant::fromValue(filter->rowCount());
137− }
149+ return QVariant::fromValue(getFilter(index.row())->rowCount());
138150 default:
139151 return QVariant();
140152 }
plugins/Unity/categories.h+10−15
@@ -21,22 +21,21 @@
2121#ifndef CATEGORIES_H
2222#define CATEGORIES_H
2323
24+// unity-core
25+#include <UnityCore/Scope.h>
26+
2427// dee-qt
2528#include "deelistmodel.h"
2629
2730#include <QSet>
2831#include <QTimer>
2932
30−class CategoryFilter;
31−
3233class Categories : public DeeListModel
3334{
3435 Q_OBJECT
3536
3637 Q_ENUMS(Roles)
3738
38− Q_PROPERTY(DeeListModel* resultModel READ resultModel WRITE setResultModel NOTIFY resultModelChanged)
39−
4039public:
4140 explicit Categories(QObject* parent = 0);
4241 ~Categories();
@@ -56,27 +55,23 @@ public:
5655
5756 QHash<int, QByteArray> roleNames() const;
5857
59− /* getters */
60− DeeListModel* resultModel() { return m_resultModel; }
61−
6258 /* setters */
63− void setResultModel(DeeListModel*);
64−
65−Q_SIGNALS:
66− void resultModelChanged(DeeListModel*);
59+ void setUnityScope(const unity::dash::Scope::Ptr& scope);
6760
6861private Q_SLOTS:
6962 void onCountChanged();
7063 void onEmitCountChanged();
7164
7265private:
73− CategoryFilter* getFilter(int index) const;
66+ void onCategoriesModelChanged(unity::glib::Object<DeeModel> model);
67+
68+ DeeListModel* getFilter(int index) const;
7469
70+ unity::dash::Scope::Ptr m_unityScope;
7571 QTimer m_timer;
76− QSet<CategoryFilter*> m_timerFilters;
72+ QSet<DeeListModel*> m_timerFilters;
7773 QHash<int, QByteArray> m_roles;
78− DeeListModel* m_resultModel;
79− mutable QMap<int, CategoryFilter*> m_filters;
74+ mutable QMap<int, std::shared_ptr<DeeListModel>> m_filters;
8075};
8176
8277#endif // CATEGORIES_H
plugins/Unity/categoryfilter.cppdeleted−45
@@ -1,45 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#include "categoryfilter.h"
21−
22−int const CATEGORY_COLUMN = 2;
23−
24−CategoryFilter::CategoryFilter(QObject* parent)
25− : QSortFilterProxyModelQML(parent)
26− , m_index(-1)
27−{
28− setDynamicSortFilter(true);
29− setFilterRole(CATEGORY_COLUMN);
30− setFilterRegExp(QString("^%1$").arg(m_index));
31−}
32−
33−int CategoryFilter::index() const
34−{
35− return m_index;
36−}
37−
38−void CategoryFilter::setIndex(int index)
39−{
40− if (index != m_index) {
41− m_index = index;
42− setFilterRegExp(QString("^%1$").arg(m_index));
43− Q_EMIT indexChanged(m_index);
44− }
45−}
plugins/Unity/categoryfilter.hdeleted−48
@@ -1,48 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License as published by
9− * the Free Software Foundation; version 3.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License
17− * along with this program. If not, see <http://www.gnu.org/licenses/>.
18− */
19−
20−#ifndef CATEGORY_FILTER_H
21−#define CATEGORY_FILTER_H
22−
23−// Utils
24−#include "plugins/Utils/qsortfilterproxymodelqml.h"
25−
26−class CategoryFilter : public QSortFilterProxyModelQML
27−{
28− Q_OBJECT
29−
30− Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged)
31−
32−public:
33− explicit CategoryFilter(QObject* parent = 0);
34−
35− /* getters */
36− int index() const;
37−
38− /* setters */
39− void setIndex(int index);
40−
41−Q_SIGNALS:
42− void indexChanged(int index);
43−
44−private:
45− int m_index;
46−};
47−
48−#endif // CATEGORY_FILTER_H
plugins/Unity/categoryresults.cppnew file+81
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Michał Sawicz <michal.sawicz@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+// self
21+#include "categoryresults.h"
22+
23+CategoryResults::CategoryResults(QObject* parent)
24+ : DeeListModel(parent)
25+ , m_category_index(-1)
26+{
27+ m_roles[CategoryResults::RoleUri] = "uri";
28+ m_roles[CategoryResults::RoleIconHint] = "icon";
29+ m_roles[CategoryResults::RoleMimetype] = "mimetype";
30+ m_roles[CategoryResults::RoleTitle] = "title";
31+ m_roles[CategoryResults::RoleComment] = "comment";
32+ m_roles[CategoryResults::RoleDndUri] = "dnd_uri";
33+}
34+
35+CategoryResults::~CategoryResults()
36+{
37+}
38+
39+int CategoryResults::categoryIndex() const
40+{
41+ return m_category_index;
42+}
43+
44+void CategoryResults::setCategoryIndex(int index)
45+{
46+ if (m_category_index != index) {
47+ m_category_index = index;
48+ Q_EMIT categoryIndexChanged(m_category_index);
49+ }
50+}
51+
52+QHash<int, QByteArray>
53+CategoryResults::roleNames() const
54+{
55+ return m_roles;
56+}
57+
58+QVariant
59+CategoryResults::data(const QModelIndex& index, int role) const
60+{
61+ if (!index.isValid()) {
62+ return QVariant();
63+ }
64+
65+ switch (role) {
66+ case RoleUri:
67+ return DeeListModel::data(index, 0);
68+ case RoleIconHint:
69+ return DeeListModel::data(index, 1);
70+ case RoleMimetype:
71+ return DeeListModel::data(index, 4);
72+ case RoleTitle:
73+ return DeeListModel::data(index, 5);
74+ case RoleComment:
75+ return DeeListModel::data(index, 6);
76+ case RoleDndUri:
77+ return DeeListModel::data(index, 7);
78+ default:
79+ return QVariant();
80+ }
81+}
plugins/Unity/categoryresults.hnew file+68
@@ -0,0 +1,68 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Michał Sawicz <michal.sawicz@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+
21+#ifndef CATEGORY_RESULTS_H
22+#define CATEGORY_RESULTS_H
23+
24+// dee-qt
25+#include "deelistmodel.h"
26+
27+class CategoryResults : public DeeListModel
28+{
29+ Q_OBJECT
30+
31+ Q_ENUMS(Roles)
32+
33+ Q_PROPERTY(int categoryIndex READ categoryIndex WRITE setCategoryIndex NOTIFY categoryIndexChanged)
34+
35+public:
36+ explicit CategoryResults(QObject* parent = 0);
37+ ~CategoryResults();
38+
39+ enum Roles {
40+ RoleUri,
41+ RoleIconHint,
42+ //RoleCategory, // not needed
43+ //RoleResultType, // not needed
44+ RoleMimetype,
45+ RoleTitle,
46+ RoleComment,
47+ RoleDndUri
48+ };
49+
50+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
51+
52+ QHash<int, QByteArray> roleNames() const;
53+
54+ /* getters */
55+ int categoryIndex() const;
56+
57+ /* setters */
58+ void setCategoryIndex(int index);
59+
60+Q_SIGNALS:
61+ void categoryIndexChanged(int index);
62+
63+private:
64+ QHash<int, QByteArray> m_roles;
65+ int m_category_index;
66+};
67+
68+#endif // CATEGORY_RESULTS_H
plugins/Unity/plugin.cpp+2−2
@@ -27,7 +27,7 @@
2727#include "scope.h"
2828#include "scopes.h"
2929#include "categories.h"
30−#include "categoryfilter.h"
30+#include "categoryresults.h"
3131#include "bottombarvisibilitycommunicatorshell.h"
3232#include "launchermodel.h"
3333
@@ -43,7 +43,7 @@ void UnityPlugin::registerTypes(const char *uri)
4343 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
4444 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
4545 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
46− qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter");
46+ qmlRegisterType<CategoryResults>(uri, 0, 1, "CategoryResults");
4747 qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");
4848 qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel");
4949 qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create new Launcher Items in QML. Get them from the LauncherModel.");
plugins/Unity/scope.cpp+22−51
@@ -31,10 +31,8 @@
3131Scope::Scope(QObject *parent) :
3232 QObject(parent)
3333{
34− m_results = new DeeListModel(this);
35− m_categories = new Categories(this);
36−
37− m_categories->setResultModel(m_results);
34+ m_results.reset(new DeeListModel(this));
35+ m_categories.reset(new Categories(this));
3836}
3937
4038QString Scope::id() const
@@ -77,14 +75,9 @@ bool Scope::connected() const
7775 return m_unityScope->connected();
7876}
7977
80−DeeListModel* Scope::results() const
81−{
82− return m_results;
83−}
84−
8578Categories* Scope::categories() const
8679{
87− return m_categories;
80+ return m_categories.get();
8881}
8982
9083QString Scope::searchQuery() const
@@ -97,6 +90,11 @@ QString Scope::noResultsHint() const
9790 return m_noResultsHint;
9891}
9992
93+QString Scope::formFactor() const
94+{
95+ return m_formFactor;
96+}
97+
10098void Scope::setSearchQuery(const QString& search_query)
10199{
102100 /* Checking for m_searchQuery.isNull() which returns true only when the string
@@ -118,6 +116,16 @@ void Scope::setNoResultsHint(const QString& hint) {
118116 }
119117}
120118
119+void Scope::setFormFactor(const QString& form_factor) {
120+ if (form_factor != m_formFactor) {
121+ m_formFactor = form_factor;
122+ if (m_unityScope) {
123+ m_unityScope->form_factor = m_formFactor.toStdString();
124+ }
125+ Q_EMIT formFactorChanged();
126+ }
127+}
128+
121129void Scope::activate(const QString& /*uri*/)
122130{
123131 // TODO:
@@ -171,18 +179,11 @@ void Scope::setUnityScope(const unity::dash::Scope::Ptr& scope)
171179{
172180 m_unityScope = scope;
173181
174− if (QString::fromStdString(m_unityScope->results()->swarm_name) == QString(":local")) {
175− m_results->setModel(m_unityScope->results()->model());
176− } else {
177− m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
178− }
179−
180− if (QString::fromStdString(m_unityScope->categories()->swarm_name) == QString(":local")) {
181− m_categories->setModel(m_unityScope->categories()->model());
182− } else {
183− m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
184− }
182+ // TODO: do we even need this?
183+ m_results->setModel(m_unityScope->results()->model());
184+ m_categories->setUnityScope(m_unityScope);
185185
186+ m_unityScope->form_factor = m_formFactor.toStdString();
186187 /* Property change signals */
187188 m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged));
188189 m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged));
@@ -192,12 +193,7 @@ void Scope::setUnityScope(const unity::dash::Scope::Ptr& scope)
192193 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
193194 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
194195 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
195− m_unityScope->results.changed.connect(sigc::mem_fun(this, &Scope::onResultsChanged));
196− m_unityScope->results()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onResultsSwarmNameChanged));
197196 m_unityScope->results()->model.changed.connect(sigc::mem_fun(this, &Scope::onResultsModelChanged));
198− m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesModelChanged));
199− m_unityScope->categories.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesChanged));
200− m_unityScope->categories()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesSwarmNameChanged));
201197 /* Signals forwarding */
202198 connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));
203199
@@ -226,36 +222,11 @@ void Scope::synchronizeStates()
226222 }
227223}
228224
229−void Scope::onResultsSwarmNameChanged(const std::string& /* swarm_name */)
230−{
231− m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
232−}
233−
234−void Scope::onResultsChanged(const unity::dash::Results::Ptr& /* results */)
235−{
236− m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
237−}
238−
239225void Scope::onResultsModelChanged(unity::glib::Object<DeeModel> /* model */)
240226{
241227 m_results->setModel(m_unityScope->results()->model());
242228}
243229
244−void Scope::onCategoriesSwarmNameChanged(const std::string& /* swarm_name */)
245−{
246− m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
247−}
248−
249−void Scope::onCategoriesChanged(const unity::dash::Categories::Ptr& /* categories */)
250−{
251− m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
252−}
253−
254−void Scope::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
255−{
256− m_categories->setModel(model);
257−}
258−
259230void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints)
260231{
261232 QString hint;
plugins/Unity/scope.h+8−10
@@ -32,7 +32,7 @@
3232// dee-qt
3333#include "deelistmodel.h"
3434
35−class Categories;
35+#include "categories.h"
3636
3737class Scope : public QObject
3838{
@@ -46,11 +46,11 @@ class Scope : public QObject
4646 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
4747 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
4848 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
49− Q_PROPERTY(DeeListModel* results READ results NOTIFY resultsChanged)
5049 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
5150
5251 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
5352 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
53+ Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
5454
5555public:
5656 explicit Scope(QObject *parent = 0);
@@ -64,14 +64,15 @@ public:
6464 bool visible() const;
6565 QString shortcut() const;
6666 bool connected() const;
67− DeeListModel* results() const;
6867 Categories* categories() const;
6968 QString searchQuery() const;
7069 QString noResultsHint() const;
70+ QString formFactor() const;
7171
7272 /* setters */
7373 void setSearchQuery(const QString& search_query);
7474 void setNoResultsHint(const QString& hint);
75+ void setFormFactor(const QString& form_factor);
7576
7677 Q_INVOKABLE void activate(const QString& uri);
7778 void setUnityScope(const unity::dash::Scope::Ptr& scope);
@@ -88,32 +89,29 @@ Q_SIGNALS:
8889 void visibleChanged(bool);
8990 void shortcutChanged(const std::string&);
9091 void connectedChanged(bool);
91− void resultsChanged();
9292 void categoriesChanged();
9393 void searchFinished(const std::string&, unity::glib::HintsMap const&, unity::glib::Error const&);
9494 void searchQueryChanged();
9595 void noResultsHintChanged();
96+ void formFactorChanged();
9697
9798private Q_SLOTS:
9899 void synchronizeStates();
99100 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);
100101
101102private:
102− void onResultsSwarmNameChanged(const std::string&);
103− void onResultsChanged(const unity::dash::Results::Ptr&);
104103 void onResultsModelChanged(unity::glib::Object<DeeModel>);
105− void onCategoriesSwarmNameChanged(const std::string&);
106104 void onCategoriesModelChanged(unity::glib::Object<DeeModel>);
107− void onCategoriesChanged(const unity::dash::Categories::Ptr&);
108105
109106 void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const&);
110107 void fallbackActivate(const QString& uri);
111108
112109 unity::dash::Scope::Ptr m_unityScope;
113− DeeListModel* m_results;
114− Categories* m_categories;
110+ std::unique_ptr<DeeListModel> m_results;
111+ std::unique_ptr<Categories> m_categories;
115112 QString m_searchQuery;
116113 QString m_noResultsHint;
114+ QString m_formFactor;
117115};
118116
119117Q_DECLARE_METATYPE(Scope*)