on xenial help sign in
Renamed Lens/Lenses to Scope/Scopes.
38257faPawel Stolowski
plugins/Unity/lens.cpp+79−79
@@ -28,7 +28,7 @@
28
28
29#include <libintl.h>
29#include <libintl.h>
30
30
31−Lens::Lens(QObject *parent) :
31+Scope::Scope(QObject *parent) :
32 QObject(parent)
32 QObject(parent)
33{
33{
34 m_results = new DeeListModel(this);
34 m_results = new DeeListModel(this);
@@ -37,77 +37,77 @@ Lens::Lens(QObject *parent) :
37 m_categories->setResultModel(m_results);
37 m_categories->setResultModel(m_results);
38}
38}
39
39
40−QString Lens::id() const
40+QString Scope::id() const
41{
41{
42− return QString::fromStdString(m_unityLens->id());
42+ return QString::fromStdString(m_unityScope->id());
43}
43}
44
44
45−QString Lens::name() const
45+QString Scope::name() const
46{
46{
47− return QString::fromStdString(m_unityLens->name());
47+ return QString::fromStdString(m_unityScope->name());
48}
48}
49
49
50−QString Lens::iconHint() const
50+QString Scope::iconHint() const
51{
51{
52− return QString::fromStdString(m_unityLens->icon_hint());
52+ return QString::fromStdString(m_unityScope->icon_hint());
53}
53}
54
54
55−QString Lens::description() const
55+QString Scope::description() const
56{
56{
57− return QString::fromStdString(m_unityLens->description());
57+ return QString::fromStdString(m_unityScope->description());
58}
58}
59
59
60−QString Lens::searchHint() const
60+QString Scope::searchHint() const
61{
61{
62− return QString::fromStdString(m_unityLens->search_hint());
62+ return QString::fromStdString(m_unityScope->search_hint());
63}
63}
64
64
65−bool Lens::visible() const
65+bool Scope::visible() const
66{
66{
67− return m_unityLens->visible();
67+ return m_unityScope->visible();
68}
68}
69
69
70−QString Lens::shortcut() const
70+QString Scope::shortcut() const
71{
71{
72− return QString::fromStdString(m_unityLens->shortcut());
72+ return QString::fromStdString(m_unityScope->shortcut());
73}
73}
74
74
75−bool Lens::connected() const
75+bool Scope::connected() const
76{
76{
77− return m_unityLens->connected();
77+ return m_unityScope->connected();
78}
78}
79
79
80−DeeListModel* Lens::results() const
80+DeeListModel* Scope::results() const
81{
81{
82 return m_results;
82 return m_results;
83}
83}
84
84
85−Categories* Lens::categories() const
85+Categories* Scope::categories() const
86{
86{
87 return m_categories;
87 return m_categories;
88}
88}
89
89
90−Lens::ViewType Lens::viewType() const
90+Scope::ViewType Scope::viewType() const
91{
91{
92− return (Lens::ViewType) m_unityLens->view_type();
92+ return (Scope::ViewType) m_unityScope->view_type();
93}
93}
94
94
95−QString Lens::searchQuery() const
95+QString Scope::searchQuery() const
96{
96{
97 return m_searchQuery;
97 return m_searchQuery;
98}
98}
99
99
100−QString Lens::noResultsHint() const
100+QString Scope::noResultsHint() const
101{
101{
102 return m_noResultsHint;
102 return m_noResultsHint;
103}
103}
104
104
105−void Lens::setViewType(const Lens::ViewType& viewType)
105+void Scope::setViewType(const Scope::ViewType& viewType)
106{
106{
107− m_unityLens->view_type = (unity::dash::ScopeViewType) viewType;
107+ m_unityScope->view_type = (unity::dash::ScopeViewType) viewType;
108}
108}
109
109
110−void Lens::setSearchQuery(const QString& search_query)
110+void Scope::setSearchQuery(const QString& search_query)
111{
111{
112 /* Checking for m_searchQuery.isNull() which returns true only when the string
112 /* Checking for m_searchQuery.isNull() which returns true only when the string
113 has never been set is necessary because when search_query is the empty
113 has never been set is necessary because when search_query is the empty
@@ -116,31 +116,31 @@ void Lens::setSearchQuery(const QString& search_query)
116 */
116 */
117 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
117 if (m_searchQuery.isNull() || search_query != m_searchQuery) {
118 m_searchQuery = search_query;
118 m_searchQuery = search_query;
119− m_unityLens->Search(search_query.toStdString(), sigc::mem_fun(this, &Lens::searchFinished));
119+ m_unityScope->Search(search_query.toStdString(), sigc::mem_fun(this, &Scope::searchFinished));
120 Q_EMIT searchQueryChanged();
120 Q_EMIT searchQueryChanged();
121 }
121 }
122}
122}
123
123
124−void Lens::setNoResultsHint(const QString& hint) {
124+void Scope::setNoResultsHint(const QString& hint) {
125 if (hint != m_noResultsHint) {
125 if (hint != m_noResultsHint) {
126 m_noResultsHint = hint;
126 m_noResultsHint = hint;
127 Q_EMIT noResultsHintChanged();
127 Q_EMIT noResultsHintChanged();
128 }
128 }
129}
129}
130
130
131−void Lens::activate(const QString& uri)
131+void Scope::activate(const QString& uri)
132{
132{
133−// m_unityLens->Activate(QByteArray::fromPercentEncoding(uri.toUtf8()).constData()); FIXME pawel
133+// m_unityScope->Activate(QByteArray::fromPercentEncoding(uri.toUtf8()).constData()); FIXME pawel
134}
134}
135
135
136−void Lens::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const&)
136+void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const&)
137{
137{
138 if (type == unity::dash::NOT_HANDLED) {
138 if (type == unity::dash::NOT_HANDLED) {
139 fallbackActivate(QString::fromStdString(result.uri));
139 fallbackActivate(QString::fromStdString(result.uri));
140 }
140 }
141}
141}
142
142
143−void Lens::fallbackActivate(const QString& uri)
143+void Scope::fallbackActivate(const QString& uri)
144{
144{
145 /* FIXME: stripping all content before the first column because for some
145 /* FIXME: stripping all content before the first column because for some
146 reason the lenses give uri with junk content at their beginning.
146 reason the lenses give uri with junk content at their beginning.
@@ -174,110 +174,110 @@ void Lens::fallbackActivate(const QString& uri)
174 QDesktopServices::openUrl(url);
174 QDesktopServices::openUrl(url);
175}
175}
176
176
177−void Lens::setUnityLens(const unity::dash::Scope::Ptr& lens)
177+void Scope::setUnityScope(const unity::dash::Scope::Ptr& lens)
178{
178{
179− m_unityLens = lens;
179+ m_unityScope = lens;
180
180
181− if (QString::fromStdString(m_unityLens->results()->swarm_name) == QString(":local")) {
181+ if (QString::fromStdString(m_unityScope->results()->swarm_name) == QString(":local")) {
182− m_results->setModel(m_unityLens->results()->model());
182+ m_results->setModel(m_unityScope->results()->model());
183 } else {
183 } else {
184− m_results->setName(QString::fromStdString(m_unityLens->results()->swarm_name));
184+ m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
185 }
185 }
186
186
187− if (QString::fromStdString(m_unityLens->categories()->swarm_name) == QString(":local")) {
187+ if (QString::fromStdString(m_unityScope->categories()->swarm_name) == QString(":local")) {
188− m_categories->setModel(m_unityLens->categories()->model());
188+ m_categories->setModel(m_unityScope->categories()->model());
189 } else {
189 } else {
190− m_categories->setName(QString::fromStdString(m_unityLens->categories()->swarm_name));
190+ m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
191 }
191 }
192
192
193 /* Property change signals */
193 /* Property change signals */
194− m_unityLens->id.changed.connect(sigc::mem_fun(this, &Lens::idChanged));
194+ m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged));
195− m_unityLens->name.changed.connect(sigc::mem_fun(this, &Lens::nameChanged));
195+ m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged));
196− m_unityLens->icon_hint.changed.connect(sigc::mem_fun(this, &Lens::iconHintChanged));
196+ m_unityScope->icon_hint.changed.connect(sigc::mem_fun(this, &Scope::iconHintChanged));
197− m_unityLens->description.changed.connect(sigc::mem_fun(this, &Lens::descriptionChanged));
197+ m_unityScope->description.changed.connect(sigc::mem_fun(this, &Scope::descriptionChanged));
198− m_unityLens->search_hint.changed.connect(sigc::mem_fun(this, &Lens::searchHintChanged));
198+ m_unityScope->search_hint.changed.connect(sigc::mem_fun(this, &Scope::searchHintChanged));
199− m_unityLens->visible.changed.connect(sigc::mem_fun(this, &Lens::visibleChanged));
199+ m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
200− m_unityLens->shortcut.changed.connect(sigc::mem_fun(this, &Lens::shortcutChanged));
200+ m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
201− m_unityLens->connected.changed.connect(sigc::mem_fun(this, &Lens::connectedChanged));
201+ m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
202− m_unityLens->results.changed.connect(sigc::mem_fun(this, &Lens::onResultsChanged));
202+ m_unityScope->results.changed.connect(sigc::mem_fun(this, &Scope::onResultsChanged));
203− m_unityLens->results()->swarm_name.changed.connect(sigc::mem_fun(this, &Lens::onResultsSwarmNameChanged));
203+ m_unityScope->results()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onResultsSwarmNameChanged));
204− m_unityLens->results()->model.changed.connect(sigc::mem_fun(this, &Lens::onResultsModelChanged));
204+ m_unityScope->results()->model.changed.connect(sigc::mem_fun(this, &Scope::onResultsModelChanged));
205− m_unityLens->categories()->model.changed.connect(sigc::mem_fun(this, &Lens::onCategoriesModelChanged));
205+ m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesModelChanged));
206− m_unityLens->categories.changed.connect(sigc::mem_fun(this, &Lens::onCategoriesChanged));
206+ m_unityScope->categories.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesChanged));
207− m_unityLens->categories()->swarm_name.changed.connect(sigc::mem_fun(this, &Lens::onCategoriesSwarmNameChanged));
207+ m_unityScope->categories()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesSwarmNameChanged));
208− m_unityLens->view_type.changed.connect(sigc::mem_fun(this, &Lens::onViewTypeChanged));
208+ m_unityScope->view_type.changed.connect(sigc::mem_fun(this, &Scope::onViewTypeChanged));
209
209
210 /* Signals forwarding */
210 /* Signals forwarding */
211 connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));
211 connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));
212
212
213 /* FIXME: signal should be forwarded instead of calling the handler directly */
213 /* FIXME: signal should be forwarded instead of calling the handler directly */
214− m_unityLens->activated.connect(sigc::mem_fun(this, &Lens::onActivated));
214+ m_unityScope->activated.connect(sigc::mem_fun(this, &Scope::onActivated));
215
215
216− /* Synchronize local states with m_unityLens right now and whenever
216+ /* Synchronize local states with m_unityScope right now and whenever
217− m_unityLens becomes connected */
217+ m_unityScope becomes connected */
218 /* FIXME: should emit change notification signals for all properties */
218 /* FIXME: should emit change notification signals for all properties */
219 connect(this, SIGNAL(connectedChanged(bool)), SLOT(synchronizeStates()));
219 connect(this, SIGNAL(connectedChanged(bool)), SLOT(synchronizeStates()));
220 synchronizeStates();
220 synchronizeStates();
221}
221}
222
222
223−unity::dash::Scope::Ptr Lens::unityLens() const
223+unity::dash::Scope::Ptr Scope::unityScope() const
224{
224{
225− return m_unityLens;
225+ return m_unityScope;
226}
226}
227
227
228−void Lens::synchronizeStates()
228+void Scope::synchronizeStates()
229{
229{
230 if (connected()) {
230 if (connected()) {
231− /* Forward local states to m_unityLens */
231+ /* Forward local states to m_unityScope */
232 if (!m_searchQuery.isNull()) {
232 if (!m_searchQuery.isNull()) {
233− m_unityLens->Search(m_searchQuery.toStdString());
233+ m_unityScope->Search(m_searchQuery.toStdString());
234 }
234 }
235 }
235 }
236}
236}
237
237
238−void Lens::onResultsSwarmNameChanged(const std::string& /* swarm_name */)
238+void Scope::onResultsSwarmNameChanged(const std::string& /* swarm_name */)
239{
239{
240− m_results->setName(QString::fromStdString(m_unityLens->results()->swarm_name));
240+ m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
241}
241}
242
242
243−void Lens::onResultsChanged(const unity::dash::Results::Ptr& /* results */)
243+void Scope::onResultsChanged(const unity::dash::Results::Ptr& /* results */)
244{
244{
245− m_results->setName(QString::fromStdString(m_unityLens->results()->swarm_name));
245+ m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
246}
246}
247
247
248−void Lens::onResultsModelChanged(unity::glib::Object<DeeModel> model)
248+void Scope::onResultsModelChanged(unity::glib::Object<DeeModel> model)
249{
249{
250− m_results->setModel(m_unityLens->results()->model());
250+ m_results->setModel(m_unityScope->results()->model());
251}
251}
252
252
253−void Lens::onCategoriesSwarmNameChanged(const std::string& /* swarm_name */)
253+void Scope::onCategoriesSwarmNameChanged(const std::string& /* swarm_name */)
254{
254{
255− m_categories->setName(QString::fromStdString(m_unityLens->categories()->swarm_name));
255+ m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
256}
256}
257
257
258−void Lens::onCategoriesChanged(const unity::dash::Categories::Ptr& /* categories */)
258+void Scope::onCategoriesChanged(const unity::dash::Categories::Ptr& /* categories */)
259{
259{
260 qWarning() << "categories changed!";
260 qWarning() << "categories changed!";
261− m_categories->setName(QString::fromStdString(m_unityLens->categories()->swarm_name));
261+ m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
262}
262}
263
263
264−void Lens::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
264+void Scope::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
265{
265{
266 qWarning() << "categories model changed!";
266 qWarning() << "categories model changed!";
267 m_categories->setModel(model);
267 m_categories->setModel(model);
268}
268}
269
269
270−void Lens::onViewTypeChanged(unity::dash::ScopeViewType viewType)
270+void Scope::onViewTypeChanged(unity::dash::ScopeViewType viewType)
271{
271{
272− Q_EMIT viewTypeChanged( (Lens::ViewType) viewType);
272+ Q_EMIT viewTypeChanged( (Scope::ViewType) viewType);
273}
273}
274
274
275−void Lens::onSearchFinished(const std::string &query, unity::glib::HintsMap const &hints)
275+void Scope::onSearchFinished(const std::string &query, unity::glib::HintsMap const &hints)
276{
276{
277 QString hint;
277 QString hint;
278
278
279− qWarning() << "Result count:" << id() << m_unityLens->results()->count() << QString::fromStdString(m_unityLens->results()->swarm_name) << m_categories->rowCount();
279+ qWarning() << "Result count:" << id() << m_unityScope->results()->count() << QString::fromStdString(m_unityScope->results()->swarm_name) << m_categories->rowCount();
280− if (!m_unityLens->results()->count()) {
280+ if (!m_unityScope->results()->count()) {
281 unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");
281 unity::glib::HintsMap::const_iterator it = hints.find("no-results-hint");
282 if (it != hints.end()) {
282 if (it != hints.end()) {
283 hint = QString::fromStdString(it->second.GetString());
283 hint = QString::fromStdString(it->second.GetString());
plugins/Unity/lens.h+9−9
@@ -17,8 +17,8 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
18 */
19
19
20−#ifndef LENS_H
20+#ifndef SCOPE_H
21−#define LENS_H
21+#define SCOPE_H
22
22
23// Qt
23// Qt
24#include <QObject>
24#include <QObject>
@@ -35,7 +35,7 @@
35
35
36class Categories;
36class Categories;
37
37
38−class Lens : public QObject
38+class Scope : public QObject
39{
39{
40 Q_OBJECT
40 Q_OBJECT
41 Q_ENUMS(ViewType)
41 Q_ENUMS(ViewType)
@@ -56,7 +56,7 @@ class Lens : public QObject
56 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
56 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
57
57
58public:
58public:
59− explicit Lens(QObject *parent = 0);
59+ explicit Scope(QObject *parent = 0);
60
60
61 enum ViewType {
61 enum ViewType {
62 Hidden,
62 Hidden,
@@ -86,8 +86,8 @@ public:
86 void setNoResultsHint(const QString& hint);
86 void setNoResultsHint(const QString& hint);
87
87
88 Q_INVOKABLE void activate(const QString& uri);
88 Q_INVOKABLE void activate(const QString& uri);
89− void setUnityLens(const unity::dash::Scope::Ptr& lens);
89+ void setUnityScope(const unity::dash::Scope::Ptr& scope);
90− unity::dash::Scope::Ptr unityLens() const;
90+ unity::dash::Scope::Ptr unityScope() const;
91
91
92Q_SIGNALS:
92Q_SIGNALS:
93 void idChanged(const std::string&);
93 void idChanged(const std::string&);
@@ -123,13 +123,13 @@ private:
123 void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const&);
123 void onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const&);
124 void fallbackActivate(const QString& uri);
124 void fallbackActivate(const QString& uri);
125
125
126− unity::dash::Scope::Ptr m_unityLens;
126+ unity::dash::Scope::Ptr m_unityScope;
127 DeeListModel* m_results;
127 DeeListModel* m_results;
128 Categories* m_categories;
128 Categories* m_categories;
129 QString m_searchQuery;
129 QString m_searchQuery;
130 QString m_noResultsHint;
130 QString m_noResultsHint;
131};
131};
132
132
133−Q_DECLARE_METATYPE(Lens*)
133+Q_DECLARE_METATYPE(Scope*)
134
134
135−#endif // LENS_H
135+#endif // SCOPE_H
plugins/Unity/lenses.cpp+59−65
@@ -28,37 +28,34 @@
28#include <QtCore/QStringList>
28#include <QtCore/QStringList>
29#include <QtGui/QKeySequence>
29#include <QtGui/QKeySequence>
30
30
31−Lenses::Lenses(QObject *parent)
31+Scopes::Scopes(QObject *parent)
32 : QAbstractListModel(parent)
32 : QAbstractListModel(parent)
33− , m_unityLenses(std::make_shared<unity::dash::GSettingsScopes>())
33+ , m_unityScopes(std::make_shared<unity::dash::GSettingsScopes>())
34−/* , m_homeLens(std::make_shared<unity::dash::HomeLens>(QString::fromUtf8(dgettext("unity", "Home")).toStdString(),
35− QString::fromUtf8(dgettext("unity", "Home screen")).toStdString(),
36− QString::fromUtf8(dgettext("unity", "Search")).toStdString()))*/
37 , m_loaded(false)
34 , m_loaded(false)
38{
35{
39− m_roles[Lenses::RoleLens] = "lens";
36+ m_roles[Scopes::RoleLens] = "lens";
40− m_roles[Lenses::RoleId] = "id";
37+ m_roles[Scopes::RoleId] = "id";
41− m_roles[Lenses::RoleVisible] = "visible";
38+ m_roles[Scopes::RoleVisible] = "visible";
42−
39+
43− m_unityLenses->scope_added.connect(sigc::mem_fun(this, &Lenses::onScopeAdded));
40+ m_unityScopes->scope_added.connect(sigc::mem_fun(this, &Scopes::onScopeAdded));
44− m_unityLenses->scope_removed.connect(sigc::mem_fun(this, &Lenses::onScopeRemoved));
41+ m_unityScopes->scope_removed.connect(sigc::mem_fun(this, &Scopes::onScopeRemoved));
45− m_unityLenses->scopes_reordered.connect(sigc::mem_fun(this, &Lenses::onScopesReordered));
42+ m_unityScopes->scopes_reordered.connect(sigc::mem_fun(this, &Scopes::onScopesReordered));
46− m_unityLenses->LoadScopes();
43+ m_unityScopes->LoadScopes();
47}
44}
48
45
49−QHash<int, QByteArray> Lenses::roleNames() const
46+QHash<int, QByteArray> Scopes::roleNames() const
50{
47{
51 return m_roles;
48 return m_roles;
52}
49}
53
50
54−int Lenses::rowCount(const QModelIndex& parent) const
51+int Scopes::rowCount(const QModelIndex& parent) const
55{
52{
56 Q_UNUSED(parent)
53 Q_UNUSED(parent)
57
54
58− return m_lenses.count();
55+ return m_scopes.count();
59}
56}
60
57
61−QVariant Lenses::data(const QModelIndex& index, int role) const
58+QVariant Scopes::data(const QModelIndex& index, int role) const
62{
59{
63 Q_UNUSED(role)
60 Q_UNUSED(role)
64
61
@@ -66,45 +63,45 @@ QVariant Lenses::data(const QModelIndex& index, int role) const
66 return QVariant();
63 return QVariant();
67 }
64 }
68
65
69− Lens* lens = m_lenses.at(index.row());
66+ Scope* scope = m_scopes.at(index.row());
70
67
71− if (role == Lenses::RoleLens) {
68+ if (role == Scopes::RoleLens) {
72− return QVariant::fromValue(lens);
69+ return QVariant::fromValue(scope);
73− } else if (role == Lenses::RoleId) {
70+ } else if (role == Scopes::RoleId) {
74− return QVariant::fromValue(lens->id());
71+ return QVariant::fromValue(scope->id());
75− } else if (role == Lenses::RoleVisible) {
72+ } else if (role == Scopes::RoleVisible) {
76− return QVariant::fromValue(lens->visible());
73+ return QVariant::fromValue(scope->visible());
77 } else {
74 } else {
78 return QVariant();
75 return QVariant();
79 }
76 }
80}
77}
81
78
82−QVariant Lenses::get(int row) const
79+QVariant Scopes::get(int row) const
83{
80{
84 return data(QAbstractListModel::index(row), 0);
81 return data(QAbstractListModel::index(row), 0);
85}
82}
86
83
87−QVariant Lenses::get(const QString& lens_id) const
84+QVariant Scopes::get(const QString& scope_id) const
88{
85{
89− Q_FOREACH(Lens* lens, m_lenses) {
86+ Q_FOREACH(Scope* scope, m_scopes) {
90− if (lens->id() == lens_id) {
87+ if (scope->id() == scope_id) {
91− return QVariant::fromValue(lens);
88+ return QVariant::fromValue(scope);
92 }
89 }
93 }
90 }
94
91
95 return QVariant();
92 return QVariant();
96}
93}
97
94
98−bool Lenses::loaded() const
95+bool Scopes::loaded() const
99{
96{
100 return m_loaded;
97 return m_loaded;
101}
98}
102
99
103−void Lenses::onScopeAdded(const unity::dash::Scope::Ptr& scope, int position)
100+void Scopes::onScopeAdded(const unity::dash::Scope::Ptr& scope, int position)
104{
101{
105− int index = m_lenses.count();
102+ int index = m_scopes.count();
106 beginInsertRows(QModelIndex(), index, index);
103 beginInsertRows(QModelIndex(), index, index);
107− addUnityLens(scope);
104+ addUnityScope(scope);
108 endInsertRows();
105 endInsertRows();
109
106
110 // FIXME: do only once after all loaded?
107 // FIXME: do only once after all loaded?
@@ -112,79 +109,76 @@ void Lenses::onScopeAdded(const unity::dash::Scope::Ptr& scope, int position)
112 Q_EMIT loadedChanged(m_loaded);
109 Q_EMIT loadedChanged(m_loaded);
113}
110}
114
111
115−void Lenses::onScopeRemoved(const unity::dash::Scope::Ptr& scope)
112+void Scopes::onScopeRemoved(const unity::dash::Scope::Ptr& scope)
116{
113{
117 //TODO
114 //TODO
118}
115}
119
116
120−void Lenses::onScopesReordered(const unity::dash::Scopes::ScopeList& scopes)
117+void Scopes::onScopesReordered(const unity::dash::Scopes::ScopeList& scopes)
121{
118{
122 //TODO
119 //TODO
123}
120}
124
121
125−void Lenses::loadMocks()
122+void Scopes::loadMocks()
126{
123{
127 /* FIXME: this is temporary code that is required on mobile to order
124 /* FIXME: this is temporary code that is required on mobile to order
128 the lenses according to the design.
125 the lenses according to the design.
129 */
126 */
130− QStringList staticLenses;
127+ QStringList staticScopes;
131− staticLenses << "mockmusic.lens" << "people.lens" << "home.lens" << "applications.lens" << "mockvideos.lens";
128+ staticScopes << "mockmusic.lens" << "people.lens" << "home.lens" << "applications.lens" << "mockvideos.lens";
132
129
133 // not all the lenses are guaranteed to go into the model (only if their UnitCore counterparts exist);
130 // not all the lenses are guaranteed to go into the model (only if their UnitCore counterparts exist);
134 // so build up a list of the valid ones, then add them later.
131 // so build up a list of the valid ones, then add them later.
135− QList<unity::dash::Scope::Ptr> added_lenses;
132+ QList<unity::dash::Scope::Ptr> added_scopes;
136
133
137 // add statically ordered lenses
134 // add statically ordered lenses
138− Q_FOREACH(QString lensId, staticLenses) {
135+ Q_FOREACH(QString lensId, staticScopes) {
139− unity::dash::Scope::Ptr lens = m_unityLenses->GetScope(lensId.toStdString());
136+ unity::dash::Scope::Ptr lens = m_unityScopes->GetScope(lensId.toStdString());
140 if (lens != NULL) {
137 if (lens != NULL) {
141− added_lenses << lens;
138+ added_scopes << lens;
142 }
139 }
143 }
140 }
144
141
145 // add remaining lenses
142 // add remaining lenses
146− unity::dash::Scopes::ScopeList lensesList = m_unityLenses->GetScopes();
143+ unity::dash::Scopes::ScopeList scopesList = m_unityScopes->GetScopes();
147− for(auto it = lensesList.begin(); it != lensesList.end(); ++it) {
144+ for(auto it = scopesList.begin(); it != scopesList.end(); ++it) {
148− unity::dash::Scope::Ptr lens = (*it);
145+ unity::dash::Scope::Ptr scope = (*it);
149− if (!staticLenses.contains(QString::fromStdString(lens->id))) {
146+ if (!staticScopes.contains(QString::fromStdString(scope->id))) {
150− added_lenses << lens;
147+ added_scopes << scope;
151 }
148 }
152 }
149 }
153
150
154− if (added_lenses.count() > 0) {
151+ if (added_scopes.count() > 0) {
155 int index = rowCount();
152 int index = rowCount();
156− beginInsertRows(QModelIndex(), index, index+added_lenses.count()-1);
153+ beginInsertRows(QModelIndex(), index, index+added_scopes.count()-1);
157− Q_FOREACH(unity::dash::Scope::Ptr lens, added_lenses) {
154+ Q_FOREACH(unity::dash::Scope::Ptr scope, added_scopes) {
158− addUnityLens(lens);
155+ addUnityScope(scope);
159 }
156 }
160 endInsertRows();
157 endInsertRows();
161 }
158 }
162
159
163 m_loaded = true;
160 m_loaded = true;
164 Q_EMIT loadedChanged(m_loaded);
161 Q_EMIT loadedChanged(m_loaded);
165−
166− // listen to dynamically added lenses
167− //m_homeLens->lens_added.connect(sigc::mem_fun(this, &Lenses::onLensAdded)); //FIXME
168}
162}
169
163
170−void Lenses::onLensPropertyChanged()
164+void Scopes::onScopePropertyChanged()
171{
165{
172− QModelIndex lensIndex = index(m_lenses.indexOf(qobject_cast<Lens*>(sender())));
166+ QModelIndex scopeIndex = index(m_scopes.indexOf(qobject_cast<Scope*>(sender())));
173− Q_EMIT dataChanged(lensIndex, lensIndex);
167+ Q_EMIT dataChanged(scopeIndex, scopeIndex);
174}
168}
175
169
176−void Lenses::addUnityLens(const unity::dash::Scope::Ptr& unity_lens)
170+void Scopes::addUnityScope(const unity::dash::Scope::Ptr& unity_scope)
177{
171{
178− Lens* lens = new Lens(this);
172+ Scope* scope = new Scope(this);
179− lens->setUnityLens(unity_lens);
173+ scope->setUnityScope(unity_scope);
180 /* DOCME */
174 /* DOCME */
181− QObject::connect(lens, SIGNAL(visibleChanged(bool)), this, SLOT(onLensPropertyChanged()));
175+ QObject::connect(scope, SIGNAL(visibleChanged(bool)), this, SLOT(onLensPropertyChanged()));
182− m_lenses.append(lens);
176+ m_scopes.append(scope);
183}
177}
184
178
185−void Lenses::removeUnityLens(int index)
179+void Scopes::removeUnityScope(int index)
186{
180{
187− Lens* lens = m_lenses.takeAt(index);
181+ Scope* scope = m_scopes.takeAt(index);
188
182
189− delete lens;
183+ delete scope;
190}
184}
plugins/Unity/lenses.h+14−14
@@ -17,8 +17,8 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
18 */
19
19
20−#ifndef LENSES_H
20+#ifndef SCOPES_H
21−#define LENSES_H
21+#define SCOPES_H
22
22
23// Qt
23// Qt
24#include <QAbstractListModel>
24#include <QAbstractListModel>
@@ -32,14 +32,14 @@ namespace unity
32{
32{
33namespace dash
33namespace dash
34{
34{
35−class Lenses;
35+class Scopes;
36}
36}
37}
37}
38
38
39class Hotkey;
39class Hotkey;
40−class Lens;
40+class Scope;
41
41
42−class Lenses : public QAbstractListModel
42+class Scopes : public QAbstractListModel
43{
43{
44 Q_OBJECT
44 Q_OBJECT
45
45
@@ -48,8 +48,8 @@ class Lenses : public QAbstractListModel
48 Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
48 Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
49
49
50public:
50public:
51− explicit Lenses(QObject *parent = 0);
51+ explicit Scopes(QObject *parent = 0);
52− ~Lenses() = default;
52+ ~Scopes() = default;
53
53
54 enum Roles {
54 enum Roles {
55 RoleLens,
55 RoleLens,
@@ -68,25 +68,25 @@ public:
68 bool loaded() const;
68 bool loaded() const;
69
69
70Q_SIGNALS:
70Q_SIGNALS:
71− void activateLensRequested(const QString& lens_id);
71+ void activateScopeRequested(const QString& scope_id);
72 void loadedChanged(bool loaded);
72 void loadedChanged(bool loaded);
73
73
74private Q_SLOTS:
74private Q_SLOTS:
75 void loadMocks();
75 void loadMocks();
76− void onScopeAdded(const unity::dash::Scope::Ptr& lens, int position);
76+ void onScopeAdded(const unity::dash::Scope::Ptr& scope, int position);
77 void onScopeRemoved(const unity::dash::Scope::Ptr& scope);
77 void onScopeRemoved(const unity::dash::Scope::Ptr& scope);
78 void onScopesReordered(const unity::dash::Scopes::ScopeList& scopes);
78 void onScopesReordered(const unity::dash::Scopes::ScopeList& scopes);
79− void onLensPropertyChanged();
79+ void onScopePropertyChanged();
80
80
81private:
81private:
82 unity::dash::GSettingsScopesReader::Ptr m_scopesReader;
82 unity::dash::GSettingsScopesReader::Ptr m_scopesReader;
83− unity::dash::Scopes::Ptr m_unityLenses;
83+ unity::dash::Scopes::Ptr m_unityScopes;
84− QList<Lens*> m_lenses;
84+ QList<Scope*> m_scopes;
85 QHash<int, QByteArray> m_roles;
85 QHash<int, QByteArray> m_roles;
86 bool m_loaded;
86 bool m_loaded;
87
87
88− void addUnityLens(const unity::dash::Scope::Ptr& unity_lens);
88+ void addUnityScope(const unity::dash::Scope::Ptr& unity_scope);
89− void removeUnityLens(int index);
89+ void removeUnityScope(int index);
90};
90};
91
91
92#endif // LENSES_H
92#endif // LENSES_H
plugins/Unity/plugin.cpp+2−2
@@ -40,8 +40,8 @@ static const char* DBUS_SERVICE = "com.canonical.Shell.BottomBarVisibilityCommun
40void UnityPlugin::registerTypes(const char *uri)
40void UnityPlugin::registerTypes(const char *uri)
41{
41{
42 Q_ASSERT(uri == QLatin1String("Unity"));
42 Q_ASSERT(uri == QLatin1String("Unity"));
43− qmlRegisterType<Lens>(uri, 0, 1, "Lens");
43+ qmlRegisterType<Scope>(uri, 0, 1, "Lens");
44− qmlRegisterType<Lenses>(uri, 0, 1, "Lenses");
44+ qmlRegisterType<Scopes>(uri, 0, 1, "Lenses");
45 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
45 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
46 qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter");
46 qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter");
47 qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");
47 qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");