Merge lp:~mhr3/unity8/use-dee-filtermodel into lp:unity8

Proposed by Michal Hruby
Status: Merged
Approved by: Michał Sawicz
Approved revision: 58
Merged at revision: 85
Proposed branch: lp:~mhr3/unity8/use-dee-filtermodel
Merge into: lp:unity8
Diff against target: 1483 lines (+681/-334)
19 files modified
Dash/GenericScopeView.qml (+2/-2)
plugins/Unity/CMakeLists.txt (+1/-2)
plugins/Unity/categories.cpp (+65/-51)
plugins/Unity/categories.h (+14/-17)
plugins/Unity/categoryfilter.cpp (+0/-45)
plugins/Unity/categoryfilter.h (+0/-48)
plugins/Unity/categoryresults.cpp (+96/-0)
plugins/Unity/categoryresults.h (+67/-0)
plugins/Unity/plugin.cpp (+2/-2)
plugins/Unity/scope.cpp (+20/-58)
plugins/Unity/scope.h (+8/-12)
tests/mocks/Unity/CMakeLists.txt (+2/-3)
tests/mocks/Unity/fake_categories.cpp (+178/-0)
tests/mocks/Unity/fake_categories.h (+69/-0)
tests/mocks/Unity/fake_scope.cpp (+108/-77)
tests/mocks/Unity/fake_scope.h (+43/-11)
tests/mocks/Unity/fake_unity_plugin.cpp (+3/-3)
tests/plugins/Unity/CMakeLists.txt (+1/-1)
tests/qmltests/Dash/qml/FakeScopeView.qml (+2/-2)
To merge this branch: bzr merge lp:~mhr3/unity8/use-dee-filtermodel
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Approve
Review via email: mp+171846@code.launchpad.net

Commit message

Implement CategoryResults based on DeeFilterModel.

Description of the change

Stop using Qt's filter model and use the lower level (and hopefully more performant) DeeFilterModel.

Implemented using new CategoryResults class that can be extended with properties we'll require (like renderer size hints).

To post a comment you must log in.
lp:~mhr3/unity8/use-dee-filtermodel updated
49. By Michal Hruby

Fix column references

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

> scope.cpp:123:27: error: 'class unity::dash::Scope' has no member named 'form_factor'

So libunity-core not updated yet?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

> > scope.cpp:123:27: error: 'class unity::dash::Scope' has no member named
> 'form_factor'
>
> So libunity-core not updated yet?

Not in S yet, although it's in trunk...

lp:~mhr3/unity8/use-dee-filtermodel updated
50. By Michal Hruby

Clean up unnecessary methods

51. By Michal Hruby

Make things safe

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~mhr3/unity8/use-dee-filtermodel updated
52. By Michal Hruby

Add more result set fields

53. By Michal Hruby

Merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

tests/qmltests/plugins/Unity/fake_categories.h: bad whitespace in line 33

review: Needs Fixing
lp:~mhr3/unity8/use-dee-filtermodel updated
54. By Michal Hruby

Fix whitespace

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mhr3/unity8/use-dee-filtermodel updated
55. By Michal Hruby

Merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :
Download full text (3.8 KiB)

9 + text: title ? title : "" // FIXME: this shouldn't be necessary

13 + source: icon ? IconUtil.from_gicon(icon) : "" // FIXME: ditto

text: title and source: IconUtil.from_gicon(icon) should be enough now, so the FIXMEs can go away.

=====

53 Categories::~Categories()
54 {
55 - qDeleteAll(m_filters);
56 }

Can probably go away completely?

=====

60 Categories::getFilter(int index) const

getResults instead?

=====

70 + auto results = new CategoryResults;

These should probably be parented to Categories, then, if not deleted in the c'tor.

=====

85 +void Categories::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
86 +{
87 + m_updatedCategories.clear();
88 + // FIXME: this might destroy the renderer view and re-create it, optimize?
89 + m_results.clear();
90 + setModel(model);
91 }
92
93 void
94 -Categories::setResultModel(DeeListModel* model)
95 +Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
96 {
97 - if (model != m_resultModel) {
98 - m_resultModel = model;
99 -
100 - Q_FOREACH(CategoryFilter* filter, m_filters) {
101 - filter->setModel(m_resultModel);
102 - }
103 -
104 - Q_EMIT resultModelChanged(m_resultModel);
105 - }
106 + m_unityScope = scope;
107 +
108 + // no need to call this, we'll get notified
109 + //setModel(m_unityScope->categories()->model());
110 +
111 + m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged));
112 }

You need to make sure to emit QAbstractListModel::beginResetModel and ::endResetModel [1] when applicable. Whether optimization here (the FIXME) makes sense is arguable. We'll really only ever set the model once on start-up, right? Should we not disconnect here from the previous m_unityScope?

=====

108 + // no need to call this, we'll get notified
109 + //setModel(m_unityScope->categories()->model());

Will the changed signal be emitted even when the categories model settled before?

=====

132 + Q_FOREACH(int cat_index, m_updatedCategories) {

Please use camelCase and ideally no abreviations - categoryIndex.

=====

133 + if (m_results[cat_index].isNull()) continue;

Is this really needed? Will there ever be a case like this?

=====

147 + return DeeListModel::data(index, 1); //DISPLAY_NAME

150 + return DeeListModel::data(index, 2); //ICON_HINT

153 + return DeeListModel::data(index, 3); //RENDERER_NAME

157 + auto hints = DeeListModel::data(index, 4).toHash();

162 + return DeeListModel::data(index, 4); //HINTS

Are those not available as enums somewhere?

=====

232 - QSet<CategoryFilter*> m_timerFilters;
233 + QSet<int> m_updatedCategories;

Why did you go for ints here?

=====

Can you update the Authors headers? I wonder if we should drop them altogether...

=====

381 + m_roles[CategoryResults::RoleDndUri] = "dnd_uri";

dndUri please.

=====

385 +CategoryResults::~CategoryResults()
386 +{
387 +}

Why the empty destructor?

=====

417 + return DeeListModel::data(index, 0);
418 + case RoleIconHint:
419 + return DeeListModel::data(index, 1);
420 + case RoleCategory:
421 + return DeeListModel::data(index, 2);
422 + case RoleMimetype:
423 + return DeeListModel::data(index, 4);
424 + case RoleTitle:
425 + return DeeLis...

Read more...

review: Needs Fixing
lp:~mhr3/unity8/use-dee-filtermodel updated
56. By Michal Hruby

Fix issues brought up in review

57. By Michal Hruby

Few more fixes

Revision history for this message
Michal Hruby (mhr3) wrote :

> text: title and source: IconUtil.from_gicon(icon) should be enough now, so the
> FIXMEs can go away.

Fixed.

> 53 Categories::~Categories()
> 54 {
> 55 - qDeleteAll(m_filters);
> 56 }
>
> Can probably go away completely?

Now that it's proper parent, yes.

> 60 Categories::getFilter(int index) const
>
> getResults instead?

Changed.
> 70 + auto results = new CategoryResults;
>
> These should probably be parented to Categories, then, if not deleted in the
> c'tor.

Indeed.

> You need to make sure to emit QAbstractListModel::beginResetModel and
> ::endResetModel [1] when applicable. Whether optimization here (the FIXME)
> makes sense is arguable. We'll really only ever set the model once on start-
> up, right? Should we not disconnect here from the previous m_unityScope?

setModel emits the reset, disconnect added. The categories will change if a scope crashes and is restarted.

> 108 + // no need to call this, we'll get notified
> 109 + //setModel(m_unityScope->categories()->model());
>
> Will the changed signal be emitted even when the categories model settled
> before?

No, let's say such usage is not supported. If categories change, also the results models change, so this handles all the changes well enough.

> 132 + Q_FOREACH(int cat_index, m_updatedCategories) {
>
> Please use camelCase and ideally no abreviations - categoryIndex.

Changed.

> 133 + if (m_results[cat_index].isNull()) continue;
>
> Is this really needed? Will there ever be a case like this?

Now that Categories is parent, no.

> Are those not available as enums somewhere?

Not in any of the includes, added at least enums internally.

> 232 - QSet<CategoryFilter*> m_timerFilters;
> 233 + QSet<int> m_updatedCategories;
>
> Why did you go for ints here?

Because I don't want to be passing a dangling pointer into a timer callback, as the results models might have been deleted in between.

> Can you update the Authors headers? I wonder if we should drop them
> altogether...

Fixed.

> 381 + m_roles[CategoryResults::RoleDndUri] = "dnd_uri";
>
> dndUri please.

Changed.

> 385 +CategoryResults::~CategoryResults()
> 386 +{
> 387 +}
>
> Why the empty destructor?

It's always nice to have it ready :) Removed.

> 506 + int m_category_index;
>
> m_categoryIndex, please.

Changed.

> 528 + qmlRegisterType<CategoryResults>(uri, 0, 1, "CategoryResults");
>
> Should probably qmlRegisterUncreatableType?

Fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mhr3/unity8/use-dee-filtermodel updated
58. By Michal Hruby

Fix a typo

Revision history for this message
Michał Sawicz (saviq) wrote :

OK good for me now, letting mzanetti look at the tests.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Regarding the tests:

So this merge updates the mocks for the existing qml UI tests (very poorly tested btw) which is good.

However, the new code itself is not tested. I guess the reason is because the surrounding and replaced code does not have tests either. Do you think we could add some in this merge or better having another TODO to test the whole scopes+category stuff?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

To resolve the conflicts, the stuff in /tests/qmltests/plugins/ needs to be moved to /tests/mocks/

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> To resolve the conflicts, the stuff in /tests/qmltests/plugins/ needs to be
> moved to /tests/mocks/

Scratch that... Surprisingly it merges them over on its own.

Revision history for this message
Michal Hruby (mhr3) wrote :

> Regarding the tests:
>
> So this merge updates the mocks for the existing qml UI tests (very poorly
> tested btw) which is good.
>
> However, the new code itself is not tested. I guess the reason is because the
> surrounding and replaced code does not have tests either. Do you think we
> could add some in this merge or better having another TODO to test the whole
> scopes+category stuff?

This involves communication with real scopes, so ideally it should talk to real scopes, which means autopilot tests would be ideal. There are multiple branches landing these days that will allow full usage of scopes including activation and previewing, once we have all this and some actual scopes that the device will be running, we should add tests for all these aspects.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> > Regarding the tests:
> >
> > So this merge updates the mocks for the existing qml UI tests (very poorly
> > tested btw) which is good.
> >
> > However, the new code itself is not tested. I guess the reason is because
> the
> > surrounding and replaced code does not have tests either. Do you think we
> > could add some in this merge or better having another TODO to test the whole
> > scopes+category stuff?
>
> This involves communication with real scopes, so ideally it should talk to
> real scopes, which means autopilot tests would be ideal. There are multiple
> branches landing these days that will allow full usage of scopes including
> activation and previewing, once we have all this and some actual scopes that
> the device will be running, we should add tests for all these aspects.

Ok, if this is on the roadmap its fine with me.

The updated mocks for the qmltests look good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Dash/GenericScopeView.qml'
--- Dash/GenericScopeView.qml 2013-06-27 14:56:17 +0000
+++ Dash/GenericScopeView.qml 2013-07-05 12:05:30 +0000
@@ -72,10 +72,10 @@
72 delegate: Tile {72 delegate: Tile {
73 width: filtergrid.cellWidth73 width: filtergrid.cellWidth
74 height: filtergrid.cellHeight74 height: filtergrid.cellHeight
75 text: column_5 ? column_5 : "" // FIXME: this shouldn't be necessary75 text: title
76 imageWidth: units.gu(11)76 imageWidth: units.gu(11)
77 imageHeight: units.gu(16)77 imageHeight: units.gu(16)
78 source: column_1 ? IconUtil.from_gicon(column_1) : "" // FIXME: ditto78 source: IconUtil.from_gicon(icon)
79 }79 }
80 }80 }
81 }81 }
8282
=== modified file 'plugins/Unity/CMakeLists.txt'
--- plugins/Unity/CMakeLists.txt 2013-07-04 10:34:48 +0000
+++ plugins/Unity/CMakeLists.txt 2013-07-05 12:05:30 +0000
@@ -12,11 +12,10 @@
12)12)
1313
14set(QMLPLUGIN_SRC14set(QMLPLUGIN_SRC
15 ../Utils/qsortfilterproxymodelqml.cpp # FIXME evaluate a more generic approach for using other plugins
16 scope.cpp15 scope.cpp
17 scopes.cpp16 scopes.cpp
18 categories.cpp17 categories.cpp
19 categoryfilter.cpp18 categoryresults.cpp
20 plugin.cpp19 plugin.cpp
21 bottombarvisibilitycommunicatorshell.cpp20 bottombarvisibilitycommunicatorshell.cpp
22 launchermodel.cpp21 launchermodel.cpp
2322
=== modified file 'plugins/Unity/categories.cpp'
--- plugins/Unity/categories.cpp 2013-06-25 15:59:20 +0000
+++ plugins/Unity/categories.cpp 2013-07-05 12:05:30 +0000
@@ -3,6 +3,7 @@
3 *3 *
4 * Authors:4 * Authors:
5 * Michał Sawicz <michal.sawicz@canonical.com>5 * Michał Sawicz <michal.sawicz@canonical.com>
6 * Michal Hruby <michal.hruby@canonical.com>
6 *7 *
7 * This program is free software; you can redistribute it and/or modify8 * 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 by9 * it under the terms of the GNU General Public License as published by
@@ -19,18 +20,25 @@
1920
20// self21// self
21#include "categories.h"22#include "categories.h"
22#include "categoryfilter.h"23#include "categoryresults.h"
24
25// TODO: use something from libunity once it's public
26enum CategoryColumn {
27 ID,
28 DISPLAY_NAME,
29 ICON_HINT,
30 RENDERER_NAME,
31 HINTS
32};
2333
24Categories::Categories(QObject* parent)34Categories::Categories(QObject* parent)
25 : DeeListModel(parent)35 : DeeListModel(parent)
26 , m_resultModel(0)
27{36{
28 // FIXME: need to clean up unused filters on countChanged
29 m_roles[Categories::RoleId] = "id";37 m_roles[Categories::RoleId] = "id";
30 m_roles[Categories::RoleName] = "name";38 m_roles[Categories::RoleName] = "name";
31 m_roles[Categories::RoleIcon] = "icon";39 m_roles[Categories::RoleIcon] = "icon";
32 m_roles[Categories::RoleRenderer] = "renderer";40 m_roles[Categories::RoleRenderer] = "renderer";
33 m_roles[Categories::RoleContentType] = "content_type";41 m_roles[Categories::RoleContentType] = "contentType";
34 m_roles[Categories::RoleHints] = "hints";42 m_roles[Categories::RoleHints] = "hints";
35 m_roles[Categories::RoleResults] = "results";43 m_roles[Categories::RoleResults] = "results";
36 m_roles[Categories::RoleCount] = "count";44 m_roles[Categories::RoleCount] = "count";
@@ -40,49 +48,57 @@
40 // change of the search term harder to reproduce48 // change of the search term harder to reproduce
41 m_timer.setSingleShot(true);49 m_timer.setSingleShot(true);
42 m_timer.setInterval(50);50 m_timer.setInterval(50);
43 connect(&m_timer, SIGNAL(timeout()), this, SLOT(onEmitCountChanged()));51 connect(&m_timer, &QTimer::timeout, this, &Categories::onEmitCountChanged);
44}52}
4553
46Categories::~Categories()54DeeListModel*
47{55Categories::getResults(int index) const
48 qDeleteAll(m_filters);56{
49}57 if (!m_results.contains(index)) {
5058 CategoryResults* results = new CategoryResults(const_cast<Categories*>(this));
51CategoryFilter*59 results->setCategoryIndex(index);
52Categories::getFilter(int index) const60 connect(results, &DeeListModel::countChanged, this, &Categories::onCountChanged);
53{61
54 if (!m_filters.contains(index)) {62 unsigned categoryIndex = static_cast<unsigned>(index);
55 CategoryFilter* filter = new CategoryFilter();63 auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex);
56 connect(filter, SIGNAL(countChanged()), this, SLOT(onCountChanged()));64 results->setModel(unity_results->model());
57 filter->setModel(m_resultModel);65
58 filter->setIndex(index);66 m_results.insert(index, results);
5967 }
60 m_filters.insert(index, filter);68
61 }69 return m_results[index];
6270}
63 return m_filters[index];71
72void Categories::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
73{
74 m_updatedCategories.clear();
75 // FIXME: this might destroy the renderer view and re-create it, optimize?
76 Q_FOREACH(DeeListModel* model, m_results) {
77 delete model;
78 }
79 m_results.clear();
80 setModel(model);
64}81}
6582
66void83void
67Categories::setResultModel(DeeListModel* model)84Categories::setUnityScope(const unity::dash::Scope::Ptr& scope)
68{85{
69 if (model != m_resultModel) {86 m_unityScope = scope;
70 m_resultModel = model;87
7188 // no need to call this, we'll get notified
72 Q_FOREACH(CategoryFilter* filter, m_filters) {89 //setModel(m_unityScope->categories()->model());
73 filter->setModel(m_resultModel);90
74 }91 m_categoriesChangedConnection.disconnect();
7592 m_categoriesChangedConnection =
76 Q_EMIT resultModelChanged(m_resultModel);93 m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged));
77 }
78}94}
7995
80void96void
81Categories::onCountChanged()97Categories::onCountChanged()
82{98{
83 CategoryFilter* filter = qobject_cast<CategoryFilter*>(sender());99 CategoryResults* results = qobject_cast<CategoryResults*>(sender());
84 if (filter) {100 if (results) {
85 m_timerFilters << filter;101 m_updatedCategories << results->categoryIndex();
86 m_timer.start();102 m_timer.start();
87 }103 }
88}104}
@@ -92,11 +108,12 @@
92{108{
93 QVector<int> roles;109 QVector<int> roles;
94 roles.append(Categories::RoleCount);110 roles.append(Categories::RoleCount);
95 Q_FOREACH(CategoryFilter* filter, m_timerFilters) {111 Q_FOREACH(int categoryIndex, m_updatedCategories) {
96 QModelIndex changedIndex = index(filter->index());112 if (!m_results.contains(categoryIndex)) continue;
113 QModelIndex changedIndex = index(categoryIndex);
97 Q_EMIT dataChanged(changedIndex, changedIndex, roles);114 Q_EMIT dataChanged(changedIndex, changedIndex, roles);
98 }115 }
99 m_timerFilters.clear();116 m_updatedCategories.clear();
100}117}
101118
102QHash<int, QByteArray>119QHash<int, QByteArray>
@@ -116,25 +133,22 @@
116 case RoleId:133 case RoleId:
117 return QVariant::fromValue(index.row());134 return QVariant::fromValue(index.row());
118 case RoleName:135 case RoleName:
119 return QVariant::fromValue(DeeListModel::data(index, 1)); //DISPLAY_NAME136 return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME);
120 case RoleIcon:137 case RoleIcon:
121 return QVariant::fromValue(DeeListModel::data(index, 2)); //ICON_HINT138 return DeeListModel::data(index, CategoryColumn::ICON_HINT);
122 case RoleRenderer:139 case RoleRenderer:
123 return QVariant::fromValue(DeeListModel::data(index, 3)); //RENDERER_NAME140 return DeeListModel::data(index, CategoryColumn::RENDERER_NAME);
124 case RoleContentType:141 case RoleContentType:
125 {142 {
126 auto hints = QVariant::fromValue(DeeListModel::data(index, 4)).toHash();143 auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash();
127 return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));144 return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
128 }145 }
129 case RoleHints:146 case RoleHints:
130 return QVariant::fromValue(DeeListModel::data(index, 4)); //HINTS147 return DeeListModel::data(index, CategoryColumn::HINTS);
131 case RoleResults:148 case RoleResults:
132 return QVariant::fromValue(getFilter(index.row()));149 return QVariant::fromValue(getResults(index.row()));
133 case RoleCount:150 case RoleCount:
134 {151 return QVariant::fromValue(getResults(index.row())->rowCount());
135 CategoryFilter* filter = getFilter(index.row());
136 return QVariant::fromValue(filter->rowCount());
137 }
138 default:152 default:
139 return QVariant();153 return QVariant();
140 }154 }
141155
=== modified file 'plugins/Unity/categories.h'
--- plugins/Unity/categories.h 2013-06-25 15:39:10 +0000
+++ plugins/Unity/categories.h 2013-07-05 12:05:30 +0000
@@ -3,6 +3,7 @@
3 *3 *
4 * Authors:4 * Authors:
5 * Michał Sawicz <michal.sawicz@canonical.com>5 * Michał Sawicz <michal.sawicz@canonical.com>
6 * Michal Hruby <michal.hruby@canonical.com>
6 *7 *
7 * This program is free software; you can redistribute it and/or modify8 * 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 by9 * it under the terms of the GNU General Public License as published by
@@ -21,25 +22,24 @@
21#ifndef CATEGORIES_H22#ifndef CATEGORIES_H
22#define CATEGORIES_H23#define CATEGORIES_H
2324
25// unity-core
26#include <UnityCore/Scope.h>
27
24// dee-qt28// dee-qt
25#include "deelistmodel.h"29#include "deelistmodel.h"
2630
31#include <QPointer>
27#include <QSet>32#include <QSet>
28#include <QTimer>33#include <QTimer>
2934
30class CategoryFilter;
31
32class Categories : public DeeListModel35class Categories : public DeeListModel
33{36{
34 Q_OBJECT37 Q_OBJECT
3538
36 Q_ENUMS(Roles)39 Q_ENUMS(Roles)
3740
38 Q_PROPERTY(DeeListModel* resultModel READ resultModel WRITE setResultModel NOTIFY resultModelChanged)
39
40public:41public:
41 explicit Categories(QObject* parent = 0);42 explicit Categories(QObject* parent = 0);
42 ~Categories();
4343
44 enum Roles {44 enum Roles {
45 RoleId,45 RoleId,
@@ -56,27 +56,24 @@
5656
57 QHash<int, QByteArray> roleNames() const;57 QHash<int, QByteArray> roleNames() const;
5858
59 /* getters */
60 DeeListModel* resultModel() { return m_resultModel; }
61
62 /* setters */59 /* setters */
63 void setResultModel(DeeListModel*);60 void setUnityScope(const unity::dash::Scope::Ptr& scope);
64
65Q_SIGNALS:
66 void resultModelChanged(DeeListModel*);
6761
68private Q_SLOTS:62private Q_SLOTS:
69 void onCountChanged();63 void onCountChanged();
70 void onEmitCountChanged();64 void onEmitCountChanged();
7165
72private:66private:
73 CategoryFilter* getFilter(int index) const;67 void onCategoriesModelChanged(unity::glib::Object<DeeModel> model);
7468
69 DeeListModel* getResults(int index) const;
70
71 unity::dash::Scope::Ptr m_unityScope;
75 QTimer m_timer;72 QTimer m_timer;
76 QSet<CategoryFilter*> m_timerFilters;73 QSet<int> m_updatedCategories;
77 QHash<int, QByteArray> m_roles;74 QHash<int, QByteArray> m_roles;
78 DeeListModel* m_resultModel;75 mutable QMap<int, DeeListModel*> m_results;
79 mutable QMap<int, CategoryFilter*> m_filters;76 sigc::connection m_categoriesChangedConnection;
80};77};
8178
82#endif // CATEGORIES_H79#endif // CATEGORIES_H
8380
=== removed file 'plugins/Unity/categoryfilter.cpp'
--- plugins/Unity/categoryfilter.cpp 2013-06-05 22:03:08 +0000
+++ plugins/Unity/categoryfilter.cpp 1970-01-01 00:00:00 +0000
@@ -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
22int const CATEGORY_COLUMN = 2;
23
24CategoryFilter::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
33int CategoryFilter::index() const
34{
35 return m_index;
36}
37
38void 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}
460
=== removed file 'plugins/Unity/categoryfilter.h'
--- plugins/Unity/categoryfilter.h 2013-06-05 22:03:08 +0000
+++ plugins/Unity/categoryfilter.h 1970-01-01 00:00:00 +0000
@@ -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
26class CategoryFilter : public QSortFilterProxyModelQML
27{
28 Q_OBJECT
29
30 Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged)
31
32public:
33 explicit CategoryFilter(QObject* parent = 0);
34
35 /* getters */
36 int index() const;
37
38 /* setters */
39 void setIndex(int index);
40
41Q_SIGNALS:
42 void indexChanged(int index);
43
44private:
45 int m_index;
46};
47
48#endif // CATEGORY_FILTER_H
490
=== added file 'plugins/Unity/categoryresults.cpp'
--- plugins/Unity/categoryresults.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/categoryresults.cpp 2013-07-05 12:05:30 +0000
@@ -0,0 +1,96 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Michal Hruby <michal.hruby@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// TODO: use something from libunity once it's public
24enum ResultsColumn {
25 URI,
26 ICON_HINT,
27 CATEGORY,
28 RESULT_TYPE,
29 MIMETYPE,
30 TITLE,
31 COMMENT,
32 DND_URI,
33 METADATA
34};
35
36CategoryResults::CategoryResults(QObject* parent)
37 : DeeListModel(parent)
38 , m_categoryIndex(-1)
39{
40 m_roles[CategoryResults::RoleUri] = "uri";
41 m_roles[CategoryResults::RoleIconHint] = "icon";
42 m_roles[CategoryResults::RoleCategory] = "category";
43 m_roles[CategoryResults::RoleMimetype] = "mimetype";
44 m_roles[CategoryResults::RoleTitle] = "title";
45 m_roles[CategoryResults::RoleComment] = "comment";
46 m_roles[CategoryResults::RoleDndUri] = "dndUri";
47 m_roles[CategoryResults::RoleMetadata] = "metadata";
48}
49
50int CategoryResults::categoryIndex() const
51{
52 return m_categoryIndex;
53}
54
55void CategoryResults::setCategoryIndex(int index)
56{
57 if (m_categoryIndex != index) {
58 m_categoryIndex = index;
59 Q_EMIT categoryIndexChanged(m_categoryIndex);
60 }
61}
62
63QHash<int, QByteArray>
64CategoryResults::roleNames() const
65{
66 return m_roles;
67}
68
69QVariant
70CategoryResults::data(const QModelIndex& index, int role) const
71{
72 if (!index.isValid()) {
73 return QVariant();
74 }
75
76 switch (role) {
77 case RoleUri:
78 return DeeListModel::data(index, ResultsColumn::URI);
79 case RoleIconHint:
80 return DeeListModel::data(index, ResultsColumn::ICON_HINT);
81 case RoleCategory:
82 return DeeListModel::data(index, ResultsColumn::CATEGORY);
83 case RoleMimetype:
84 return DeeListModel::data(index, ResultsColumn::MIMETYPE);
85 case RoleTitle:
86 return DeeListModel::data(index, ResultsColumn::TITLE);
87 case RoleComment:
88 return DeeListModel::data(index, ResultsColumn::COMMENT);
89 case RoleDndUri:
90 return DeeListModel::data(index, ResultsColumn::DND_URI);
91 case RoleMetadata:
92 return DeeListModel::data(index, ResultsColumn::METADATA);
93 default:
94 return QVariant();
95 }
96}
097
=== added file 'plugins/Unity/categoryresults.h'
--- plugins/Unity/categoryresults.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/categoryresults.h 2013-07-05 12:05:30 +0000
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Michal Hruby <michal.hruby@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
27class 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
35public:
36 explicit CategoryResults(QObject* parent = 0);
37
38 enum Roles {
39 RoleUri,
40 RoleIconHint,
41 RoleCategory,
42 RoleMimetype,
43 RoleTitle,
44 RoleComment,
45 RoleDndUri,
46 RoleMetadata
47 };
48
49 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
50
51 QHash<int, QByteArray> roleNames() const;
52
53 /* getters */
54 int categoryIndex() const;
55
56 /* setters */
57 void setCategoryIndex(int index);
58
59Q_SIGNALS:
60 void categoryIndexChanged(int index);
61
62private:
63 QHash<int, QByteArray> m_roles;
64 int m_categoryIndex;
65};
66
67#endif // CATEGORY_RESULTS_H
068
=== modified file 'plugins/Unity/plugin.cpp'
--- plugins/Unity/plugin.cpp 2013-06-27 12:02:22 +0000
+++ plugins/Unity/plugin.cpp 2013-07-05 12:05:30 +0000
@@ -30,7 +30,7 @@
30#include "scope.h"30#include "scope.h"
31#include "scopes.h"31#include "scopes.h"
32#include "categories.h"32#include "categories.h"
33#include "categoryfilter.h"33#include "categoryresults.h"
34#include "bottombarvisibilitycommunicatorshell.h"34#include "bottombarvisibilitycommunicatorshell.h"
35#include "launchermodel.h"35#include "launchermodel.h"
3636
@@ -49,7 +49,7 @@
49 qmlRegisterType<Scope>(uri, 0, 1, "Scope");49 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
50 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");50 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
51 qmlRegisterType<Categories>(uri, 0, 1, "Categories");51 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
52 qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter");52 qmlRegisterUncreatableType<CategoryResults>(uri, 0, 1, "CategoryResults", "Can't create new Category Results in QML. Get them from Categories instance.");
53 qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");53 qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel");
54 qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel");54 qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel");
55 qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create new Launcher Items in QML. Get them from the LauncherModel.");55 qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create new Launcher Items in QML. Get them from the LauncherModel.");
5656
=== modified file 'plugins/Unity/scope.cpp'
--- plugins/Unity/scope.cpp 2013-07-02 08:33:11 +0000
+++ plugins/Unity/scope.cpp 2013-07-05 12:05:30 +0000
@@ -3,6 +3,7 @@
3 *3 *
4 * Authors:4 * Authors:
5 * Florian Boucault <florian.boucault@canonical.com>5 * Florian Boucault <florian.boucault@canonical.com>
6 * Michal Hruby <michal.hruby@canonical.com>
6 *7 *
7 * This program is free software; you can redistribute it and/or modify8 * 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 by9 * it under the terms of the GNU General Public License as published by
@@ -38,10 +39,7 @@
38Scope::Scope(QObject *parent) :39Scope::Scope(QObject *parent) :
39 QObject(parent)40 QObject(parent)
40{41{
41 m_results = new DeeListModel(this);42 m_categories.reset(new Categories(this));
42 m_categories = new Categories(this);
43
44 m_categories->setResultModel(m_results);
45}43}
4644
47QString Scope::id() const45QString Scope::id() const
@@ -84,14 +82,9 @@
84 return m_unityScope->connected();82 return m_unityScope->connected();
85}83}
8684
87DeeListModel* Scope::results() const
88{
89 return m_results;
90}
91
92Categories* Scope::categories() const85Categories* Scope::categories() const
93{86{
94 return m_categories;87 return m_categories.get();
95}88}
9689
97QString Scope::searchQuery() const90QString Scope::searchQuery() const
@@ -104,6 +97,11 @@
104 return m_noResultsHint;97 return m_noResultsHint;
105}98}
10699
100QString Scope::formFactor() const
101{
102 return m_formFactor;
103}
104
107void Scope::setSearchQuery(const QString& search_query)105void Scope::setSearchQuery(const QString& search_query)
108{106{
109 /* Checking for m_searchQuery.isNull() which returns true only when the string107 /* Checking for m_searchQuery.isNull() which returns true only when the string
@@ -125,6 +123,15 @@
125 }123 }
126}124}
127125
126void Scope::setFormFactor(const QString& form_factor) {
127 if (form_factor != m_formFactor) {
128 m_formFactor = form_factor;
129 if (m_unityScope) {
130 m_unityScope->form_factor = m_formFactor.toStdString();
131 }
132 Q_EMIT formFactorChanged();
133 }
134}
128135
129unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,136unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint,
130 const QVariant &category, const QVariant &result_type,137 const QVariant &category, const QVariant &result_type,
@@ -237,18 +244,9 @@
237{244{
238 m_unityScope = scope;245 m_unityScope = scope;
239246
240 if (QString::fromStdString(m_unityScope->results()->swarm_name) == QString(":local")) {247 m_categories->setUnityScope(m_unityScope);
241 m_results->setModel(m_unityScope->results()->model());248
242 } else {249 m_unityScope->form_factor = m_formFactor.toStdString();
243 m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
244 }
245
246 if (QString::fromStdString(m_unityScope->categories()->swarm_name) == QString(":local")) {
247 m_categories->setModel(m_unityScope->categories()->model());
248 } else {
249 m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
250 }
251
252 /* Property change signals */250 /* Property change signals */
253 m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged));251 m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged));
254 m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged));252 m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged));
@@ -258,12 +256,6 @@
258 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));256 m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged));
259 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));257 m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged));
260 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));258 m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged));
261 m_unityScope->results.changed.connect(sigc::mem_fun(this, &Scope::onResultsChanged));
262 m_unityScope->results()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onResultsSwarmNameChanged));
263 m_unityScope->results()->model.changed.connect(sigc::mem_fun(this, &Scope::onResultsModelChanged));
264 m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesModelChanged));
265 m_unityScope->categories.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesChanged));
266 m_unityScope->categories()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesSwarmNameChanged));
267 /* Signals forwarding */259 /* Signals forwarding */
268 connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));260 connect(this, SIGNAL(searchFinished(const std::string &, unity::glib::HintsMap const &, unity::glib::Error const &)), SLOT(onSearchFinished(const std::string &, unity::glib::HintsMap const &)));
269261
@@ -294,36 +286,6 @@
294 }286 }
295}287}
296288
297void Scope::onResultsSwarmNameChanged(const std::string& /* swarm_name */)
298{
299 m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
300}
301
302void Scope::onResultsChanged(const unity::dash::Results::Ptr& /* results */)
303{
304 m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name));
305}
306
307void Scope::onResultsModelChanged(unity::glib::Object<DeeModel> /* model */)
308{
309 m_results->setModel(m_unityScope->results()->model());
310}
311
312void Scope::onCategoriesSwarmNameChanged(const std::string& /* swarm_name */)
313{
314 m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
315}
316
317void Scope::onCategoriesChanged(const unity::dash::Categories::Ptr& /* categories */)
318{
319 m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name));
320}
321
322void Scope::onCategoriesModelChanged(unity::glib::Object<DeeModel> model)
323{
324 m_categories->setModel(model);
325}
326
327void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints)289void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints)
328{290{
329 QString hint;291 QString hint;
330292
=== modified file 'plugins/Unity/scope.h'
--- plugins/Unity/scope.h 2013-06-26 10:56:43 +0000
+++ plugins/Unity/scope.h 2013-07-05 12:05:30 +0000
@@ -32,7 +32,8 @@
32// dee-qt32// dee-qt
33#include "deelistmodel.h"33#include "deelistmodel.h"
3434
35class Categories;35#include "categories.h"
36
36class Preview;37class Preview;
3738
38class Scope : public QObject39class Scope : public QObject
@@ -47,11 +48,11 @@
47 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)48 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
48 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)49 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
49 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)50 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
50 Q_PROPERTY(DeeListModel* results READ results NOTIFY resultsChanged)
51 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)51 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
5252
53 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)53 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
54 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)54 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
55 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
5556
56public:57public:
57 explicit Scope(QObject *parent = 0);58 explicit Scope(QObject *parent = 0);
@@ -65,14 +66,15 @@
65 bool visible() const;66 bool visible() const;
66 QString shortcut() const;67 QString shortcut() const;
67 bool connected() const;68 bool connected() const;
68 DeeListModel* results() const;
69 Categories* categories() const;69 Categories* categories() const;
70 QString searchQuery() const;70 QString searchQuery() const;
71 QString noResultsHint() const;71 QString noResultsHint() const;
72 QString formFactor() const;
7273
73 /* setters */74 /* setters */
74 void setSearchQuery(const QString& search_query);75 void setSearchQuery(const QString& search_query);
75 void setNoResultsHint(const QString& hint);76 void setNoResultsHint(const QString& hint);
77 void setFormFactor(const QString& form_factor);
7678
77 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,79 Q_INVOKABLE void activate(const QVariant &uri, const QVariant &icon_hint, const QVariant &category,
78 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,80 const QVariant &result_type, const QVariant &mimetype, const QVariant &title,
@@ -94,11 +96,11 @@
94 void visibleChanged(bool);96 void visibleChanged(bool);
95 void shortcutChanged(const std::string&);97 void shortcutChanged(const std::string&);
96 void connectedChanged(bool);98 void connectedChanged(bool);
97 void resultsChanged();
98 void categoriesChanged();99 void categoriesChanged();
99 void searchFinished(const std::string&, unity::glib::HintsMap const&, unity::glib::Error const&);100 void searchFinished(const std::string&, unity::glib::HintsMap const&, unity::glib::Error const&);
100 void searchQueryChanged();101 void searchQueryChanged();
101 void noResultsHintChanged();102 void noResultsHintChanged();
103 void formFactorChanged();
102104
103 // signals triggered by activate(..) or preview(..) requests.105 // signals triggered by activate(..) or preview(..) requests.
104 void previewReady(Preview *preview);106 void previewReady(Preview *preview);
@@ -111,12 +113,6 @@
111 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);113 void onSearchFinished(const std::string &, unity::glib::HintsMap const &);
112114
113private:115private:
114 void onResultsSwarmNameChanged(const std::string&);
115 void onResultsChanged(const unity::dash::Results::Ptr&);
116 void onResultsModelChanged(unity::glib::Object<DeeModel>);
117 void onCategoriesSwarmNameChanged(const std::string&);
118 void onCategoriesModelChanged(unity::glib::Object<DeeModel>);
119 void onCategoriesChanged(const unity::dash::Categories::Ptr&);
120 unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint,116 unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint,
121 const QVariant &category, const QVariant &result_type,117 const QVariant &category, const QVariant &result_type,
122 const QVariant &mimetype, const QVariant &title,118 const QVariant &mimetype, const QVariant &title,
@@ -127,10 +123,10 @@
127 void fallbackActivate(const QString& uri);123 void fallbackActivate(const QString& uri);
128124
129 unity::dash::Scope::Ptr m_unityScope;125 unity::dash::Scope::Ptr m_unityScope;
130 DeeListModel* m_results;126 std::unique_ptr<Categories> m_categories;
131 Categories* m_categories;
132 QString m_searchQuery;127 QString m_searchQuery;
133 QString m_noResultsHint;128 QString m_noResultsHint;
129 QString m_formFactor;
134};130};
135131
136Q_DECLARE_METATYPE(Scope*)132Q_DECLARE_METATYPE(Scope*)
137133
=== modified file 'tests/mocks/Unity/CMakeLists.txt'
--- tests/mocks/Unity/CMakeLists.txt 2013-06-12 15:03:07 +0000
+++ tests/mocks/Unity/CMakeLists.txt 2013-07-05 12:05:30 +0000
@@ -19,11 +19,10 @@
19add_definitions(-DQT_NO_KEYWORDS)19add_definitions(-DQT_NO_KEYWORDS)
2020
21set(UnityQML_SOURCES21set(UnityQML_SOURCES
22 ${CMAKE_SOURCE_DIR}/plugins/Unity/categories.cpp22 ${CMAKE_SOURCE_DIR}/plugins/Unity/categoryresults.cpp
23 ${CMAKE_SOURCE_DIR}/plugins/Unity/categoryfilter.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/Utils/qsortfilterproxymodelqml.cpp
25 fake_scope.cpp23 fake_scope.cpp
26 fake_scopes.cpp24 fake_scopes.cpp
25 fake_categories.cpp
27 fake_unity_plugin.cpp26 fake_unity_plugin.cpp
28 fake_launchermodel.cpp27 fake_launchermodel.cpp
29)28)
3029
=== added file 'tests/mocks/Unity/fake_categories.cpp'
--- tests/mocks/Unity/fake_categories.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/fake_categories.cpp 2013-07-05 12:05:30 +0000
@@ -0,0 +1,178 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
17 */
18
19// self
20#include "fake_categories.h"
21
22// local
23#include "categoryresults.h"
24
25#define CATEGORY_COLUMN 2
26
27Categories::Categories(QObject* parent)
28 : DeeListModel(parent)
29{
30 // FIXME: need to clean up unused filters on countChanged
31 m_roles[Categories::RoleId] = "id";
32 m_roles[Categories::RoleName] = "name";
33 m_roles[Categories::RoleIcon] = "icon";
34 m_roles[Categories::RoleRenderer] = "renderer";
35 m_roles[Categories::RoleContentType] = "content_type";
36 m_roles[Categories::RoleHints] = "hints";
37 m_roles[Categories::RoleResults] = "results";
38 m_roles[Categories::RoleCount] = "count";
39
40 // TODO This should not be needed but accumulatting the count changes
41 // makes the visualization more stable and also makes crashes on fast
42 // change of the search term harder to reproduce
43 m_timer.setSingleShot(true);
44 m_timer.setInterval(50);
45 connect(&m_timer, SIGNAL(timeout()), this, SLOT(onEmitCountChanged()));
46}
47
48DeeListModel*
49Categories::getFilter(int index) const
50{
51 if (!m_filters.contains(index)) {
52 auto results = new CategoryResults ();
53 results->setCategoryIndex(index);
54 connect(results, SIGNAL(countChanged()), this, SLOT(onCountChanged()));
55
56 unsigned cat_index = static_cast<unsigned>(index);
57 auto model = getResultsForCategory(cat_index);
58 results->setModel(model);
59
60 m_filters.insert(index, results);
61 }
62
63 return m_filters[index];
64}
65
66void
67Categories::onCountChanged()
68{
69 DeeListModel* filter = qobject_cast<DeeListModel*>(sender());
70 if (filter) {
71 m_timerFilters << filter;
72 m_timer.start();
73 }
74}
75
76void
77Categories::onEmitCountChanged()
78{
79 QVector<int> roles;
80 roles.append(Categories::RoleCount);
81 Q_FOREACH(DeeListModel* results, m_timerFilters) {
82 auto cat_results = qobject_cast<CategoryResults*>(results);
83 QModelIndex changedIndex = index(cat_results->categoryIndex());
84 Q_EMIT dataChanged(changedIndex, changedIndex, roles);
85 }
86 m_timerFilters.clear();
87}
88
89QHash<int, QByteArray>
90Categories::roleNames() const
91{
92 return m_roles;
93}
94
95void Categories::setResultModel(DeeModel* model)
96{
97 // FIXME: should ref it
98 m_dee_results = model;
99}
100
101
102static void category_filter_map_func (DeeModel* orig_model,
103 DeeFilterModel* filter_model,
104 gpointer user_data)
105{
106 DeeModelIter* iter;
107 DeeModelIter* end;
108 unsigned index = GPOINTER_TO_UINT(user_data);
109
110 iter = dee_model_get_first_iter(orig_model);
111 end = dee_model_get_last_iter(orig_model);
112 while (iter != end) {
113 unsigned category_index = dee_model_get_uint32(orig_model, iter, CATEGORY_COLUMN);
114 if (index == category_index) {
115 dee_filter_model_append_iter(filter_model, iter);
116 }
117 iter = dee_model_next(orig_model, iter);
118 }
119}
120
121static gboolean category_filter_notify_func (DeeModel* orig_model,
122 DeeModelIter* orig_iter,
123 DeeFilterModel* filter_model,
124 gpointer user_data)
125{
126 unsigned index = GPOINTER_TO_UINT(user_data);
127 unsigned category_index = dee_model_get_uint32(orig_model, orig_iter, CATEGORY_COLUMN);
128
129 if (index != category_index)
130 return FALSE;
131
132 dee_filter_model_insert_iter_with_original_order(filter_model, orig_iter);
133 return TRUE;
134}
135
136DeeModel* Categories::getResultsForCategory(unsigned cat_index) const
137{
138 DeeFilter filter;
139 filter.map_func = category_filter_map_func;
140 filter.map_notify = category_filter_notify_func;
141 filter.destroy = nullptr;
142 filter.userdata = GUINT_TO_POINTER(cat_index);
143
144 DeeModel* filtered_model = dee_filter_model_new(m_dee_results, &filter);
145 return filtered_model;
146}
147
148QVariant
149Categories::data(const QModelIndex& index, int role) const
150{
151 if (!index.isValid()) {
152 return QVariant();
153 }
154
155 switch (role) {
156 case RoleId:
157 return QVariant::fromValue(index.row());
158 case RoleName:
159 return DeeListModel::data(index, 1); //DISPLAY_NAME
160 case RoleIcon:
161 return DeeListModel::data(index, 2); //ICON_HINT
162 case RoleRenderer:
163 return DeeListModel::data(index, 3); //RENDERER_NAME
164 case RoleContentType:
165 {
166 auto hints = DeeListModel::data(index, 4).toHash();
167 return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default"));
168 }
169 case RoleHints:
170 return DeeListModel::data(index, 4); //HINTS
171 case RoleResults:
172 return QVariant::fromValue(getFilter(index.row()));
173 case RoleCount:
174 return QVariant::fromValue(getFilter(index.row())->rowCount());
175 default:
176 return QVariant();
177 }
178}
0179
=== added file 'tests/mocks/Unity/fake_categories.h'
--- tests/mocks/Unity/fake_categories.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/fake_categories.h 2013-07-05 12:05:30 +0000
@@ -0,0 +1,69 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef FAKE_CATEGORIES_H
18#define FAKE_CATEGORIES_H
19
20// Qt
21#include <QObject>
22#include <QSet>
23#include <QTimer>
24
25#include <dee.h>
26#include <deelistmodel.h>
27
28class Categories : public DeeListModel
29{
30 Q_OBJECT
31
32 Q_ENUMS(Roles)
33
34public:
35 Categories(QObject* parent = 0);
36 enum Roles {
37 RoleId,
38 RoleName,
39 RoleIcon,
40 RoleRenderer,
41 RoleContentType,
42 RoleHints,
43 RoleResults,
44 RoleCount
45 };
46
47 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
48
49 QHash<int, QByteArray> roleNames() const;
50
51 /* setters */
52 void setResultModel(DeeModel* model);
53
54private Q_SLOTS:
55 void onCountChanged();
56 void onEmitCountChanged();
57
58private:
59 DeeModel* getResultsForCategory(unsigned index) const;
60 DeeListModel* getFilter(int index) const;
61
62 DeeModel* m_dee_results;
63 QTimer m_timer;
64 QSet<DeeListModel*> m_timerFilters;
65 QHash<int, QByteArray> m_roles;
66 mutable QMap<int, DeeListModel*> m_filters;
67};
68
69#endif // FAKE_CATEGORIES_H
070
=== modified file 'tests/mocks/Unity/fake_scope.cpp'
--- tests/mocks/Unity/fake_scope.cpp 2013-06-14 14:08:46 +0000
+++ tests/mocks/Unity/fake_scope.cpp 2013-07-05 12:05:30 +0000
@@ -26,32 +26,29 @@
26// TODO: Implement remaining pieces26// TODO: Implement remaining pieces
2727
28Scope::Scope(QObject* parent)28Scope::Scope(QObject* parent)
29: QObject(parent),29 : QObject(parent)
30 m_visible(false),30 , m_visible(false)
31 m_categories(new Categories(this)),31 , m_categories(new Categories(this))
32 m_results(new DeeListModel(this))32 , m_results(new DeeListModel(this))
33{33{
34 DeeModel* results_model = create_results_model(4, 30);
35 m_categories->setResultModel(results_model);
34 m_categories->setModel(create_categories_model(4));36 m_categories->setModel(create_categories_model(4));
35 m_results->setModel(create_results_model(4, 30));37 m_results->setModel(results_model);
36
37 m_categories->setResultModel(m_results);
38}38}
3939
40Scope::Scope(QString const& id,40Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
41 QString const& name,41 : QObject(parent)
42 bool visible,42 , m_id(id)
43 QObject* parent)43 , m_name(name)
44: QObject(parent),44 , m_visible(visible)
45 m_id(id),45 , m_categories(new Categories(this))
46 m_name(name),46 , m_results(new DeeListModel(this))
47 m_visible(visible),
48 m_categories(new Categories(this)),
49 m_results(new DeeListModel(this))
50{47{
48 DeeModel* results_model = create_results_model(4, 30);
49 m_categories->setResultModel(results_model);
51 m_categories->setModel(create_categories_model(4));50 m_categories->setModel(create_categories_model(4));
52 m_results->setModel(create_results_model(4, 30));51 m_results->setModel(results_model);
53
54 m_categories->setResultModel(m_results);
55}52}
5653
57QString Scope::id() const {54QString Scope::id() const {
@@ -66,6 +63,42 @@
66 return m_searchQuery;63 return m_searchQuery;
67}64}
6865
66QString Scope::iconHint() const {
67 return m_iconHint;
68}
69
70QString Scope::description() const {
71 return m_description;
72}
73
74QString Scope::searchHint() const {
75 return QString("");
76}
77
78QString Scope::shortcut() const {
79 return QString("");
80}
81
82bool Scope::connected() const {
83 return true;
84}
85
86Categories* Scope::categories() const {
87 return m_categories;
88}
89
90QString Scope::noResultsHint() const {
91 return m_noResultsHint;
92}
93
94QString Scope::formFactor() const {
95 return m_formFactor;
96}
97
98bool Scope::visible() const {
99 return m_visible;
100}
101
69void Scope::setName(const QString &str) {102void Scope::setName(const QString &str) {
70 if (str != m_name) {103 if (str != m_name) {
71 m_name = str;104 m_name = str;
@@ -76,45 +109,47 @@
76void Scope::setSearchQuery(const QString &str) {109void Scope::setSearchQuery(const QString &str) {
77 if (str != m_searchQuery) {110 if (str != m_searchQuery) {
78 m_searchQuery = str;111 m_searchQuery = str;
79 Q_EMIT searchQueryChanged(m_searchQuery);112 Q_EMIT searchQueryChanged();
80 }113 }
81}114}
82115
83bool Scope::visible() const {116void Scope::setFormFactor(const QString &str) {
84 return m_visible;117 if (str != m_formFactor) {
85}118 m_formFactor = str;
86119 Q_EMIT formFactorChanged();
87Categories* Scope::categories() const {120 }
88 return m_categories;121}
122
123void Scope::setNoResultsHint(const QString& str) {
124 if (str != m_noResultsHint) {
125 m_noResultsHint = str;
126 Q_EMIT noResultsHintChanged();
127 }
89}128}
90129
91static const gchar * categories_model_schema[] = {130static const gchar * categories_model_schema[] = {
92 "s", //ID131 "s", //ID
93 "s", // DISPLAY_NAME132 "s", // DISPLAY_NAME
94 "s", // ICON_HINT133 "s", // ICON_HINT
95 "s", // RENDERER_NAME134 "s", // RENDERER_NAME
96 "a{sv}" // HINTS135 "a{sv}" // HINTS
97};136};
98137
99138
100DeeModel* create_categories_model(unsigned category_count) {139DeeModel* create_categories_model(unsigned category_count) {
101 DeeModel* category_model = dee_sequence_model_new();140 DeeModel* category_model = dee_sequence_model_new();
102 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));141 dee_model_set_schema_full(category_model, categories_model_schema, G_N_ELEMENTS(categories_model_schema));
103142 GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
104 GVariantBuilder b;
105 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
106 GVariant *hints = g_variant_builder_end(&b);
107143
108 for(unsigned i = 0; i < category_count; ++i)144 for(unsigned i = 0; i < category_count; ++i)
109 {145 {
110 dee_model_append(category_model,146 dee_model_append(category_model,
111 std::to_string(i).c_str(),147 std::to_string(i).c_str(),
112 ("Category "+std::to_string(i)).c_str(),148 ("Category "+std::to_string(i)).c_str(),
113 "gtk-apply",149 "gtk-apply",
114 "grid",150 "grid",
115 hints);151 hints);
116 }152 }
117 g_variant_unref(hints);
118 return category_model;153 return category_model;
119}154}
120155
@@ -122,48 +157,44 @@
122/* Schema that is used in the DeeModel representing157/* Schema that is used in the DeeModel representing
123 the results */158 the results */
124static const gchar * results_model_schema[] = {159static const gchar * results_model_schema[] = {
125 "s", // URI160 "s", // URI
126 "s", // ICON_HINT161 "s", // ICON_HINT
127 "u", // CATEGORY162 "u", // CATEGORY
128 "u", // RESULT_TYPE163 "u", // RESULT_TYPE
129 "s", // MIMETYPE164 "s", // MIMETYPE
130 "s", // TITLE165 "s", // TITLE
131 "s", // COMMENT166 "s", // COMMENT
132 "s", // DND_URI167 "s", // DND_URI
133 "a{sv}" // METADATA168 "a{sv}" // METADATA
134};169};
135170
136static const gchar * icons[] = {171static const gchar * icons[] = {
137 "Applications.png",172 "Applications.png",
138 "Home.png",173 "Home.png",
139 "Music.png",174 "Music.png",
140 "People.png",175 "People.png",
141 "Videos.png",176 "Videos.png",
142};177};
143178
144DeeModel* create_results_model(unsigned category_count, unsigned result_count) {179DeeModel* create_results_model(unsigned category_count, unsigned result_count) {
145 DeeModel* results_model = dee_sequence_model_new();180 DeeModel* results_model = dee_sequence_model_new();
146 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));181 dee_model_set_schema_full(results_model, results_model_schema, G_N_ELEMENTS(results_model_schema));
147182 GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0);
148 GVariantBuilder b;
149 g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
150 GVariant *hints = g_variant_builder_end(&b);
151183
152 for(unsigned i = 0; i < result_count; ++i)184 for(unsigned i = 0; i < result_count; ++i)
153 {185 {
154 unsigned category = i % category_count;186 unsigned category = i % category_count;
155187
156 dee_model_append(results_model,188 dee_model_append(results_model,
157 ("uri://result."+std::to_string(i)).c_str(),189 ("uri://result."+std::to_string(i)).c_str(),
158 (shellAppDirectory() + "Dash/graphics/scopeIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),190 (shellAppDirectory() + "Dash/graphics/scopeIcons/" + (icons[i%G_N_ELEMENTS(icons)])).toLatin1().data(),
159 category,191 category,
160 0,192 0,
161 "application/x-desktop",193 "application/x-desktop",
162 ("Title."+std::to_string(i)).c_str(),194 ("Title."+std::to_string(i)).c_str(),
163 ("Comment."+std::to_string(i)).c_str(),195 ("Comment."+std::to_string(i)).c_str(),
164 ("uri://result."+std::to_string(i)).c_str(),196 ("uri://result."+std::to_string(i)).c_str(),
165 hints);197 hints);
166 }198 }
167 g_variant_unref(hints);
168 return results_model;199 return results_model;
169 }200}
170201
=== modified file 'tests/mocks/Unity/fake_scope.h'
--- tests/mocks/Unity/fake_scope.h 2013-06-12 15:03:07 +0000
+++ tests/mocks/Unity/fake_scope.h 2013-07-05 12:05:30 +0000
@@ -19,43 +19,75 @@
1919
20// Qt20// Qt
21#include <QObject>21#include <QObject>
22#include "categories.h"22#include "fake_categories.h"
2323
24class Scope : public QObject24class Scope : public QObject
25{25{
26 Q_OBJECT26 Q_OBJECT
27
27 Q_PROPERTY(QString id READ id NOTIFY idChanged)28 Q_PROPERTY(QString id READ id NOTIFY idChanged)
28 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)29 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
29 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)30 Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
31 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
32 Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
30 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)33 Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
34 Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
35 Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
31 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)36 Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
3237
38 Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
39 Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
40 Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
41
33public:42public:
34 Scope(QObject* parent = 0);43 Scope(QObject* parent = 0);
35 Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0);44 Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0);
3645
46 /* getters */
37 QString id() const;47 QString id() const;
38 QString name() const;48 QString name() const;
39 QString searchQuery() const;49 QString iconHint() const;
50 QString description() const;
51 QString searchHint() const;
40 bool visible() const;52 bool visible() const;
4153 QString shortcut() const;
42 void setName(const QString &str);54 bool connected() const;
43 void setSearchQuery(const QString &str);
44
45 Categories* categories() const;55 Categories* categories() const;
56 QString searchQuery() const;
57 QString noResultsHint() const;
58 QString formFactor() const;
59
60 /* setters */
61 void setName(const QString& name);
62 void setSearchQuery(const QString& search_query);
63 void setNoResultsHint(const QString& hint);
64 void setFormFactor(const QString& form_factor);
4665
47Q_SIGNALS:66Q_SIGNALS:
48 void idChanged(QString);67 void idChanged(const QString&);
49 void nameChanged(QString);68 void nameChanged(const QString&);
50 void searchQueryChanged(QString);69 void iconHintChanged(const QString&);
70 void descriptionChanged(const QString&);
71 void searchHintChanged(const QString&);
51 void visibleChanged(bool);72 void visibleChanged(bool);
73 void shortcutChanged(const QString&);
74 void connectedChanged(bool);
52 void categoriesChanged();75 void categoriesChanged();
76 void searchFinished(const QString&);
77 void searchQueryChanged();
78 void noResultsHintChanged();
79 void formFactorChanged();
5380
54private:81private:
55 QString m_id;82 QString m_id;
83 QString m_iconHint;
84 QString m_description;
56 QString m_name;85 QString m_name;
57 QString m_searchQuery;86 QString m_searchQuery;
87 QString m_noResultsHint;
88 QString m_formFactor;
58 bool m_visible;89 bool m_visible;
90
59 Categories* m_categories;91 Categories* m_categories;
60 DeeListModel* m_results;92 DeeListModel* m_results;
61};93};
6294
=== modified file 'tests/mocks/Unity/fake_unity_plugin.cpp'
--- tests/mocks/Unity/fake_unity_plugin.cpp 2013-06-12 15:03:07 +0000
+++ tests/mocks/Unity/fake_unity_plugin.cpp 2013-07-05 12:05:30 +0000
@@ -21,8 +21,8 @@
2121
22// local22// local
23#include "fake_scopes.h"23#include "fake_scopes.h"
24#include "categories.h"24#include "fake_categories.h"
25#include "categoryfilter.h"25#include "categoryresults.h"
26#include "fake_launchermodel.h"26#include "fake_launchermodel.h"
2727
28// External28// External
@@ -40,7 +40,7 @@
40 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");40 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
41 qmlRegisterType<Scope>(uri, 0, 1, "Scope");41 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
42 qmlRegisterType<Categories>(uri, 0, 1, "Categories");42 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
43 qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter");43 qmlRegisterUncreatableType<CategoryResults>(uri, 0, 1, "CategoryResults", "Can't create");
44 qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel");44 qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel");
45 qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create");45 qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create");
46}46}
4747
=== modified file 'tests/plugins/Unity/CMakeLists.txt'
--- tests/plugins/Unity/CMakeLists.txt 2013-06-28 14:01:56 +0000
+++ tests/plugins/Unity/CMakeLists.txt 2013-07-05 12:05:30 +0000
@@ -21,7 +21,7 @@
21 add_executable(${_test}Exec ${_test}.cpp previewbindingstest.cpp)21 add_executable(${_test}Exec ${_test}.cpp previewbindingstest.cpp)
22 qt5_use_modules(${_test}Exec Test Core Qml)22 qt5_use_modules(${_test}Exec Test Core Qml)
23 set_tests_properties(test${CLASSNAME}${_test}23 set_tests_properties(test${CLASSNAME}${_test}
24 PROPERTIES ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Unity:${LIBUNITYPROTO_LIBRARY_DIRS})24 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Unity:${LIBUNITYPROTO_LIBRARY_DIRS}")
2525
26 target_link_libraries(${_test}Exec26 target_link_libraries(${_test}Exec
27 Unity-qml27 Unity-qml
2828
=== modified file 'tests/qmltests/Dash/qml/FakeScopeView.qml'
--- tests/qmltests/Dash/qml/FakeScopeView.qml 2013-06-13 13:15:36 +0000
+++ tests/qmltests/Dash/qml/FakeScopeView.qml 2013-07-05 12:05:30 +0000
@@ -107,10 +107,10 @@
107 Image {107 Image {
108 width: units.gu(5)108 width: units.gu(5)
109 height: units.gu(5)109 height: units.gu(5)
110 source: column_1110 source: icon
111 anchors.horizontalCenter: parent.horizontalCenter111 anchors.horizontalCenter: parent.horizontalCenter
112 }112 }
113 Text { text: column_4; anchors.horizontalCenter: parent.horizontalCenter }113 Text { text: title; anchors.horizontalCenter: parent.horizontalCenter }
114 }114 }
115 }115 }
116 }116 }

Subscribers

People subscribed via source and target branches