Merge lp:~mhr3/unity8/use-dee-filtermodel into lp:unity8
- use-dee-filtermodel
- Merge into trunk
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 |
Related bugs: |
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).
- 49. By Michal Hruby
-
Fix column references
PS Jenkins bot (ps-jenkins) wrote : | # |
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?
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:49
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
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...
- 50. By Michal Hruby
-
Clean up unnecessary methods
- 51. By Michal Hruby
-
Make things safe
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:51
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 52. By Michal Hruby
-
Add more result set fields
- 53. By Michal Hruby
-
Merge trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:53
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:53
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Michał Sawicz (saviq) wrote : | # |
tests/qmltests/
- 54. By Michal Hruby
-
Fix whitespace
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:54
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 55. By Michal Hruby
-
Merge trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:55
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michał Sawicz (saviq) wrote : | # |
9 + text: title ? title : "" // FIXME: this shouldn't be necessary
13 + source: icon ? IconUtil.
text: title and source: IconUtil.
=====
53 Categories:
54 {
55 - qDeleteAll(
56 }
Can probably go away completely?
=====
60 Categories:
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:
86 +{
87 + m_updatedCatego
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:
95 +Categories:
96 {
97 - if (model != m_resultModel) {
98 - m_resultModel = model;
99 -
100 - Q_FOREACH(
101 - filter-
102 - }
103 -
104 - Q_EMIT resultModelChan
105 - }
106 + m_unityScope = scope;
107 +
108 + // no need to call this, we'll get notified
109 + //setModel(
110 +
111 + m_unityScope-
112 }
You need to make sure to emit QAbstractListMo
=====
108 + // no need to call this, we'll get notified
109 + //setModel(
Will the changed signal be emitted even when the categories model settled before?
=====
132 + Q_FOREACH(int cat_index, m_updatedCatego
Please use camelCase and ideally no abreviations - categoryIndex.
=====
133 + if (m_results[
Is this really needed? Will there ever be a case like this?
=====
147 + return DeeListModel:
150 + return DeeListModel:
153 + return DeeListModel:
157 + auto hints = DeeListModel:
162 + return DeeListModel:
Are those not available as enums somewhere?
=====
232 - QSet<CategoryFi
233 + QSet<int> m_updatedCatego
Why did you go for ints here?
=====
Can you update the Authors headers? I wonder if we should drop them altogether...
=====
381 + m_roles[
dndUri please.
=====
385 +CategoryResult
386 +{
387 +}
Why the empty destructor?
=====
417 + return DeeListModel:
418 + case RoleIconHint:
419 + return DeeListModel:
420 + case RoleCategory:
421 + return DeeListModel:
422 + case RoleMimetype:
423 + return DeeListModel:
424 + case RoleTitle:
425 + return DeeLis...
- 56. By Michal Hruby
-
Fix issues brought up in review
- 57. By Michal Hruby
-
Few more fixes
Michal Hruby (mhr3) wrote : | # |
> text: title and source: IconUtil.
> FIXMEs can go away.
Fixed.
> 53 Categories:
> 54 {
> 55 - qDeleteAll(
> 56 }
>
> Can probably go away completely?
Now that it's proper parent, yes.
> 60 Categories:
>
> 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 QAbstractListMo
> ::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(
>
> 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_updatedCatego
>
> Please use camelCase and ideally no abreviations - categoryIndex.
Changed.
> 133 + if (m_results[
>
> 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<CategoryFi
> 233 + QSet<int> m_updatedCatego
>
> 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[
>
> dndUri please.
Changed.
> 385 +CategoryResult
> 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
>
> Should probably qmlRegisterUncr
Fixed.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:56
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:57
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 58. By Michal Hruby
-
Fix a typo
Michał Sawicz (saviq) wrote : | # |
OK good for me now, letting mzanetti look at the tests.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:58
http://
Executed test runs:
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
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?
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:57
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michael Zanetti (mzanetti) wrote : | # |
To resolve the conflicts, the stuff in /tests/
Michael Zanetti (mzanetti) wrote : | # |
> To resolve the conflicts, the stuff in /tests/
> moved to /tests/mocks/
Scratch that... Surprisingly it merges them over on its own.
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.
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.
Preview Diff
1 | === modified file 'Dash/GenericScopeView.qml' | |||
2 | --- Dash/GenericScopeView.qml 2013-06-27 14:56:17 +0000 | |||
3 | +++ Dash/GenericScopeView.qml 2013-07-05 12:05:30 +0000 | |||
4 | @@ -72,10 +72,10 @@ | |||
5 | 72 | delegate: Tile { | 72 | delegate: Tile { |
6 | 73 | width: filtergrid.cellWidth | 73 | width: filtergrid.cellWidth |
7 | 74 | height: filtergrid.cellHeight | 74 | height: filtergrid.cellHeight |
9 | 75 | text: column_5 ? column_5 : "" // FIXME: this shouldn't be necessary | 75 | text: title |
10 | 76 | imageWidth: units.gu(11) | 76 | imageWidth: units.gu(11) |
11 | 77 | imageHeight: units.gu(16) | 77 | imageHeight: units.gu(16) |
13 | 78 | source: column_1 ? IconUtil.from_gicon(column_1) : "" // FIXME: ditto | 78 | source: IconUtil.from_gicon(icon) |
14 | 79 | } | 79 | } |
15 | 80 | } | 80 | } |
16 | 81 | } | 81 | } |
17 | 82 | 82 | ||
18 | === modified file 'plugins/Unity/CMakeLists.txt' | |||
19 | --- plugins/Unity/CMakeLists.txt 2013-07-04 10:34:48 +0000 | |||
20 | +++ plugins/Unity/CMakeLists.txt 2013-07-05 12:05:30 +0000 | |||
21 | @@ -12,11 +12,10 @@ | |||
22 | 12 | ) | 12 | ) |
23 | 13 | 13 | ||
24 | 14 | set(QMLPLUGIN_SRC | 14 | set(QMLPLUGIN_SRC |
25 | 15 | ../Utils/qsortfilterproxymodelqml.cpp # FIXME evaluate a more generic approach for using other plugins | ||
26 | 16 | scope.cpp | 15 | scope.cpp |
27 | 17 | scopes.cpp | 16 | scopes.cpp |
28 | 18 | categories.cpp | 17 | categories.cpp |
30 | 19 | categoryfilter.cpp | 18 | categoryresults.cpp |
31 | 20 | plugin.cpp | 19 | plugin.cpp |
32 | 21 | bottombarvisibilitycommunicatorshell.cpp | 20 | bottombarvisibilitycommunicatorshell.cpp |
33 | 22 | launchermodel.cpp | 21 | launchermodel.cpp |
34 | 23 | 22 | ||
35 | === modified file 'plugins/Unity/categories.cpp' | |||
36 | --- plugins/Unity/categories.cpp 2013-06-25 15:59:20 +0000 | |||
37 | +++ plugins/Unity/categories.cpp 2013-07-05 12:05:30 +0000 | |||
38 | @@ -3,6 +3,7 @@ | |||
39 | 3 | * | 3 | * |
40 | 4 | * Authors: | 4 | * Authors: |
41 | 5 | * Michał Sawicz <michal.sawicz@canonical.com> | 5 | * Michał Sawicz <michal.sawicz@canonical.com> |
42 | 6 | * Michal Hruby <michal.hruby@canonical.com> | ||
43 | 6 | * | 7 | * |
44 | 7 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
45 | 8 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
46 | @@ -19,18 +20,25 @@ | |||
47 | 19 | 20 | ||
48 | 20 | // self | 21 | // self |
49 | 21 | #include "categories.h" | 22 | #include "categories.h" |
51 | 22 | #include "categoryfilter.h" | 23 | #include "categoryresults.h" |
52 | 24 | |||
53 | 25 | // TODO: use something from libunity once it's public | ||
54 | 26 | enum CategoryColumn { | ||
55 | 27 | ID, | ||
56 | 28 | DISPLAY_NAME, | ||
57 | 29 | ICON_HINT, | ||
58 | 30 | RENDERER_NAME, | ||
59 | 31 | HINTS | ||
60 | 32 | }; | ||
61 | 23 | 33 | ||
62 | 24 | Categories::Categories(QObject* parent) | 34 | Categories::Categories(QObject* parent) |
63 | 25 | : DeeListModel(parent) | 35 | : DeeListModel(parent) |
64 | 26 | , m_resultModel(0) | ||
65 | 27 | { | 36 | { |
66 | 28 | // FIXME: need to clean up unused filters on countChanged | ||
67 | 29 | m_roles[Categories::RoleId] = "id"; | 37 | m_roles[Categories::RoleId] = "id"; |
68 | 30 | m_roles[Categories::RoleName] = "name"; | 38 | m_roles[Categories::RoleName] = "name"; |
69 | 31 | m_roles[Categories::RoleIcon] = "icon"; | 39 | m_roles[Categories::RoleIcon] = "icon"; |
70 | 32 | m_roles[Categories::RoleRenderer] = "renderer"; | 40 | m_roles[Categories::RoleRenderer] = "renderer"; |
72 | 33 | m_roles[Categories::RoleContentType] = "content_type"; | 41 | m_roles[Categories::RoleContentType] = "contentType"; |
73 | 34 | m_roles[Categories::RoleHints] = "hints"; | 42 | m_roles[Categories::RoleHints] = "hints"; |
74 | 35 | m_roles[Categories::RoleResults] = "results"; | 43 | m_roles[Categories::RoleResults] = "results"; |
75 | 36 | m_roles[Categories::RoleCount] = "count"; | 44 | m_roles[Categories::RoleCount] = "count"; |
76 | @@ -40,49 +48,57 @@ | |||
77 | 40 | // change of the search term harder to reproduce | 48 | // change of the search term harder to reproduce |
78 | 41 | m_timer.setSingleShot(true); | 49 | m_timer.setSingleShot(true); |
79 | 42 | m_timer.setInterval(50); | 50 | m_timer.setInterval(50); |
101 | 43 | connect(&m_timer, SIGNAL(timeout()), this, SLOT(onEmitCountChanged())); | 51 | connect(&m_timer, &QTimer::timeout, this, &Categories::onEmitCountChanged); |
102 | 44 | } | 52 | } |
103 | 45 | 53 | ||
104 | 46 | Categories::~Categories() | 54 | DeeListModel* |
105 | 47 | { | 55 | Categories::getResults(int index) const |
106 | 48 | qDeleteAll(m_filters); | 56 | { |
107 | 49 | } | 57 | if (!m_results.contains(index)) { |
108 | 50 | 58 | CategoryResults* results = new CategoryResults(const_cast<Categories*>(this)); | |
109 | 51 | CategoryFilter* | 59 | results->setCategoryIndex(index); |
110 | 52 | Categories::getFilter(int index) const | 60 | connect(results, &DeeListModel::countChanged, this, &Categories::onCountChanged); |
111 | 53 | { | 61 | |
112 | 54 | if (!m_filters.contains(index)) { | 62 | unsigned categoryIndex = static_cast<unsigned>(index); |
113 | 55 | CategoryFilter* filter = new CategoryFilter(); | 63 | auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex); |
114 | 56 | connect(filter, SIGNAL(countChanged()), this, SLOT(onCountChanged())); | 64 | results->setModel(unity_results->model()); |
115 | 57 | filter->setModel(m_resultModel); | 65 | |
116 | 58 | filter->setIndex(index); | 66 | m_results.insert(index, results); |
117 | 59 | 67 | } | |
118 | 60 | m_filters.insert(index, filter); | 68 | |
119 | 61 | } | 69 | return m_results[index]; |
120 | 62 | 70 | } | |
121 | 63 | return m_filters[index]; | 71 | |
122 | 72 | void Categories::onCategoriesModelChanged(unity::glib::Object<DeeModel> model) | ||
123 | 73 | { | ||
124 | 74 | m_updatedCategories.clear(); | ||
125 | 75 | // FIXME: this might destroy the renderer view and re-create it, optimize? | ||
126 | 76 | Q_FOREACH(DeeListModel* model, m_results) { | ||
127 | 77 | delete model; | ||
128 | 78 | } | ||
129 | 79 | m_results.clear(); | ||
130 | 80 | setModel(model); | ||
131 | 64 | } | 81 | } |
132 | 65 | 82 | ||
133 | 66 | void | 83 | void |
135 | 67 | Categories::setResultModel(DeeListModel* model) | 84 | Categories::setUnityScope(const unity::dash::Scope::Ptr& scope) |
136 | 68 | { | 85 | { |
146 | 69 | if (model != m_resultModel) { | 86 | m_unityScope = scope; |
147 | 70 | m_resultModel = model; | 87 | |
148 | 71 | 88 | // no need to call this, we'll get notified | |
149 | 72 | Q_FOREACH(CategoryFilter* filter, m_filters) { | 89 | //setModel(m_unityScope->categories()->model()); |
150 | 73 | filter->setModel(m_resultModel); | 90 | |
151 | 74 | } | 91 | m_categoriesChangedConnection.disconnect(); |
152 | 75 | 92 | m_categoriesChangedConnection = | |
153 | 76 | Q_EMIT resultModelChanged(m_resultModel); | 93 | m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Categories::onCategoriesModelChanged)); |
145 | 77 | } | ||
154 | 78 | } | 94 | } |
155 | 79 | 95 | ||
156 | 80 | void | 96 | void |
157 | 81 | Categories::onCountChanged() | 97 | Categories::onCountChanged() |
158 | 82 | { | 98 | { |
162 | 83 | CategoryFilter* filter = qobject_cast<CategoryFilter*>(sender()); | 99 | CategoryResults* results = qobject_cast<CategoryResults*>(sender()); |
163 | 84 | if (filter) { | 100 | if (results) { |
164 | 85 | m_timerFilters << filter; | 101 | m_updatedCategories << results->categoryIndex(); |
165 | 86 | m_timer.start(); | 102 | m_timer.start(); |
166 | 87 | } | 103 | } |
167 | 88 | } | 104 | } |
168 | @@ -92,11 +108,12 @@ | |||
169 | 92 | { | 108 | { |
170 | 93 | QVector<int> roles; | 109 | QVector<int> roles; |
171 | 94 | roles.append(Categories::RoleCount); | 110 | roles.append(Categories::RoleCount); |
174 | 95 | Q_FOREACH(CategoryFilter* filter, m_timerFilters) { | 111 | Q_FOREACH(int categoryIndex, m_updatedCategories) { |
175 | 96 | QModelIndex changedIndex = index(filter->index()); | 112 | if (!m_results.contains(categoryIndex)) continue; |
176 | 113 | QModelIndex changedIndex = index(categoryIndex); | ||
177 | 97 | Q_EMIT dataChanged(changedIndex, changedIndex, roles); | 114 | Q_EMIT dataChanged(changedIndex, changedIndex, roles); |
178 | 98 | } | 115 | } |
180 | 99 | m_timerFilters.clear(); | 116 | m_updatedCategories.clear(); |
181 | 100 | } | 117 | } |
182 | 101 | 118 | ||
183 | 102 | QHash<int, QByteArray> | 119 | QHash<int, QByteArray> |
184 | @@ -116,25 +133,22 @@ | |||
185 | 116 | case RoleId: | 133 | case RoleId: |
186 | 117 | return QVariant::fromValue(index.row()); | 134 | return QVariant::fromValue(index.row()); |
187 | 118 | case RoleName: | 135 | case RoleName: |
189 | 119 | return QVariant::fromValue(DeeListModel::data(index, 1)); //DISPLAY_NAME | 136 | return DeeListModel::data(index, CategoryColumn::DISPLAY_NAME); |
190 | 120 | case RoleIcon: | 137 | case RoleIcon: |
192 | 121 | return QVariant::fromValue(DeeListModel::data(index, 2)); //ICON_HINT | 138 | return DeeListModel::data(index, CategoryColumn::ICON_HINT); |
193 | 122 | case RoleRenderer: | 139 | case RoleRenderer: |
195 | 123 | return QVariant::fromValue(DeeListModel::data(index, 3)); //RENDERER_NAME | 140 | return DeeListModel::data(index, CategoryColumn::RENDERER_NAME); |
196 | 124 | case RoleContentType: | 141 | case RoleContentType: |
197 | 125 | { | 142 | { |
199 | 126 | auto hints = QVariant::fromValue(DeeListModel::data(index, 4)).toHash(); | 143 | auto hints = DeeListModel::data(index, CategoryColumn::HINTS).toHash(); |
200 | 127 | return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default")); | 144 | return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default")); |
201 | 128 | } | 145 | } |
202 | 129 | case RoleHints: | 146 | case RoleHints: |
204 | 130 | return QVariant::fromValue(DeeListModel::data(index, 4)); //HINTS | 147 | return DeeListModel::data(index, CategoryColumn::HINTS); |
205 | 131 | case RoleResults: | 148 | case RoleResults: |
207 | 132 | return QVariant::fromValue(getFilter(index.row())); | 149 | return QVariant::fromValue(getResults(index.row())); |
208 | 133 | case RoleCount: | 150 | case RoleCount: |
213 | 134 | { | 151 | return QVariant::fromValue(getResults(index.row())->rowCount()); |
210 | 135 | CategoryFilter* filter = getFilter(index.row()); | ||
211 | 136 | return QVariant::fromValue(filter->rowCount()); | ||
212 | 137 | } | ||
214 | 138 | default: | 152 | default: |
215 | 139 | return QVariant(); | 153 | return QVariant(); |
216 | 140 | } | 154 | } |
217 | 141 | 155 | ||
218 | === modified file 'plugins/Unity/categories.h' | |||
219 | --- plugins/Unity/categories.h 2013-06-25 15:39:10 +0000 | |||
220 | +++ plugins/Unity/categories.h 2013-07-05 12:05:30 +0000 | |||
221 | @@ -3,6 +3,7 @@ | |||
222 | 3 | * | 3 | * |
223 | 4 | * Authors: | 4 | * Authors: |
224 | 5 | * Michał Sawicz <michal.sawicz@canonical.com> | 5 | * Michał Sawicz <michal.sawicz@canonical.com> |
225 | 6 | * Michal Hruby <michal.hruby@canonical.com> | ||
226 | 6 | * | 7 | * |
227 | 7 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
228 | 8 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
229 | @@ -21,25 +22,24 @@ | |||
230 | 21 | #ifndef CATEGORIES_H | 22 | #ifndef CATEGORIES_H |
231 | 22 | #define CATEGORIES_H | 23 | #define CATEGORIES_H |
232 | 23 | 24 | ||
233 | 25 | // unity-core | ||
234 | 26 | #include <UnityCore/Scope.h> | ||
235 | 27 | |||
236 | 24 | // dee-qt | 28 | // dee-qt |
237 | 25 | #include "deelistmodel.h" | 29 | #include "deelistmodel.h" |
238 | 26 | 30 | ||
239 | 31 | #include <QPointer> | ||
240 | 27 | #include <QSet> | 32 | #include <QSet> |
241 | 28 | #include <QTimer> | 33 | #include <QTimer> |
242 | 29 | 34 | ||
243 | 30 | class CategoryFilter; | ||
244 | 31 | |||
245 | 32 | class Categories : public DeeListModel | 35 | class Categories : public DeeListModel |
246 | 33 | { | 36 | { |
247 | 34 | Q_OBJECT | 37 | Q_OBJECT |
248 | 35 | 38 | ||
249 | 36 | Q_ENUMS(Roles) | 39 | Q_ENUMS(Roles) |
250 | 37 | 40 | ||
251 | 38 | Q_PROPERTY(DeeListModel* resultModel READ resultModel WRITE setResultModel NOTIFY resultModelChanged) | ||
252 | 39 | |||
253 | 40 | public: | 41 | public: |
254 | 41 | explicit Categories(QObject* parent = 0); | 42 | explicit Categories(QObject* parent = 0); |
255 | 42 | ~Categories(); | ||
256 | 43 | 43 | ||
257 | 44 | enum Roles { | 44 | enum Roles { |
258 | 45 | RoleId, | 45 | RoleId, |
259 | @@ -56,27 +56,24 @@ | |||
260 | 56 | 56 | ||
261 | 57 | QHash<int, QByteArray> roleNames() const; | 57 | QHash<int, QByteArray> roleNames() const; |
262 | 58 | 58 | ||
263 | 59 | /* getters */ | ||
264 | 60 | DeeListModel* resultModel() { return m_resultModel; } | ||
265 | 61 | |||
266 | 62 | /* setters */ | 59 | /* setters */ |
271 | 63 | void setResultModel(DeeListModel*); | 60 | void setUnityScope(const unity::dash::Scope::Ptr& scope); |
268 | 64 | |||
269 | 65 | Q_SIGNALS: | ||
270 | 66 | void resultModelChanged(DeeListModel*); | ||
272 | 67 | 61 | ||
273 | 68 | private Q_SLOTS: | 62 | private Q_SLOTS: |
274 | 69 | void onCountChanged(); | 63 | void onCountChanged(); |
275 | 70 | void onEmitCountChanged(); | 64 | void onEmitCountChanged(); |
276 | 71 | 65 | ||
277 | 72 | private: | 66 | private: |
280 | 73 | CategoryFilter* getFilter(int index) const; | 67 | void onCategoriesModelChanged(unity::glib::Object<DeeModel> model); |
281 | 74 | 68 | ||
282 | 69 | DeeListModel* getResults(int index) const; | ||
283 | 70 | |||
284 | 71 | unity::dash::Scope::Ptr m_unityScope; | ||
285 | 75 | QTimer m_timer; | 72 | QTimer m_timer; |
287 | 76 | QSet<CategoryFilter*> m_timerFilters; | 73 | QSet<int> m_updatedCategories; |
288 | 77 | QHash<int, QByteArray> m_roles; | 74 | QHash<int, QByteArray> m_roles; |
291 | 78 | DeeListModel* m_resultModel; | 75 | mutable QMap<int, DeeListModel*> m_results; |
292 | 79 | mutable QMap<int, CategoryFilter*> m_filters; | 76 | sigc::connection m_categoriesChangedConnection; |
293 | 80 | }; | 77 | }; |
294 | 81 | 78 | ||
295 | 82 | #endif // CATEGORIES_H | 79 | #endif // CATEGORIES_H |
296 | 83 | 80 | ||
297 | === removed file 'plugins/Unity/categoryfilter.cpp' | |||
298 | --- plugins/Unity/categoryfilter.cpp 2013-06-05 22:03:08 +0000 | |||
299 | +++ plugins/Unity/categoryfilter.cpp 1970-01-01 00:00:00 +0000 | |||
300 | @@ -1,45 +0,0 @@ | |||
301 | 1 | /* | ||
302 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
303 | 3 | * | ||
304 | 4 | * Authors: | ||
305 | 5 | * Michał Sawicz <michal.sawicz@canonical.com> | ||
306 | 6 | * | ||
307 | 7 | * This program is free software; you can redistribute it and/or modify | ||
308 | 8 | * it under the terms of the GNU General Public License as published by | ||
309 | 9 | * the Free Software Foundation; version 3. | ||
310 | 10 | * | ||
311 | 11 | * This program is distributed in the hope that it will be useful, | ||
312 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
313 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
314 | 14 | * GNU General Public License for more details. | ||
315 | 15 | * | ||
316 | 16 | * You should have received a copy of the GNU General Public License | ||
317 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
318 | 18 | */ | ||
319 | 19 | |||
320 | 20 | #include "categoryfilter.h" | ||
321 | 21 | |||
322 | 22 | int const CATEGORY_COLUMN = 2; | ||
323 | 23 | |||
324 | 24 | CategoryFilter::CategoryFilter(QObject* parent) | ||
325 | 25 | : QSortFilterProxyModelQML(parent) | ||
326 | 26 | , m_index(-1) | ||
327 | 27 | { | ||
328 | 28 | setDynamicSortFilter(true); | ||
329 | 29 | setFilterRole(CATEGORY_COLUMN); | ||
330 | 30 | setFilterRegExp(QString("^%1$").arg(m_index)); | ||
331 | 31 | } | ||
332 | 32 | |||
333 | 33 | int CategoryFilter::index() const | ||
334 | 34 | { | ||
335 | 35 | return m_index; | ||
336 | 36 | } | ||
337 | 37 | |||
338 | 38 | void CategoryFilter::setIndex(int index) | ||
339 | 39 | { | ||
340 | 40 | if (index != m_index) { | ||
341 | 41 | m_index = index; | ||
342 | 42 | setFilterRegExp(QString("^%1$").arg(m_index)); | ||
343 | 43 | Q_EMIT indexChanged(m_index); | ||
344 | 44 | } | ||
345 | 45 | } | ||
346 | 46 | 0 | ||
347 | === removed file 'plugins/Unity/categoryfilter.h' | |||
348 | --- plugins/Unity/categoryfilter.h 2013-06-05 22:03:08 +0000 | |||
349 | +++ plugins/Unity/categoryfilter.h 1970-01-01 00:00:00 +0000 | |||
350 | @@ -1,48 +0,0 @@ | |||
351 | 1 | /* | ||
352 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
353 | 3 | * | ||
354 | 4 | * Authors: | ||
355 | 5 | * Michał Sawicz <michal.sawicz@canonical.com> | ||
356 | 6 | * | ||
357 | 7 | * This program is free software; you can redistribute it and/or modify | ||
358 | 8 | * it under the terms of the GNU General Public License as published by | ||
359 | 9 | * the Free Software Foundation; version 3. | ||
360 | 10 | * | ||
361 | 11 | * This program is distributed in the hope that it will be useful, | ||
362 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
363 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
364 | 14 | * GNU General Public License for more details. | ||
365 | 15 | * | ||
366 | 16 | * You should have received a copy of the GNU General Public License | ||
367 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
368 | 18 | */ | ||
369 | 19 | |||
370 | 20 | #ifndef CATEGORY_FILTER_H | ||
371 | 21 | #define CATEGORY_FILTER_H | ||
372 | 22 | |||
373 | 23 | // Utils | ||
374 | 24 | #include "plugins/Utils/qsortfilterproxymodelqml.h" | ||
375 | 25 | |||
376 | 26 | class CategoryFilter : public QSortFilterProxyModelQML | ||
377 | 27 | { | ||
378 | 28 | Q_OBJECT | ||
379 | 29 | |||
380 | 30 | Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged) | ||
381 | 31 | |||
382 | 32 | public: | ||
383 | 33 | explicit CategoryFilter(QObject* parent = 0); | ||
384 | 34 | |||
385 | 35 | /* getters */ | ||
386 | 36 | int index() const; | ||
387 | 37 | |||
388 | 38 | /* setters */ | ||
389 | 39 | void setIndex(int index); | ||
390 | 40 | |||
391 | 41 | Q_SIGNALS: | ||
392 | 42 | void indexChanged(int index); | ||
393 | 43 | |||
394 | 44 | private: | ||
395 | 45 | int m_index; | ||
396 | 46 | }; | ||
397 | 47 | |||
398 | 48 | #endif // CATEGORY_FILTER_H | ||
399 | 49 | 0 | ||
400 | === added file 'plugins/Unity/categoryresults.cpp' | |||
401 | --- plugins/Unity/categoryresults.cpp 1970-01-01 00:00:00 +0000 | |||
402 | +++ plugins/Unity/categoryresults.cpp 2013-07-05 12:05:30 +0000 | |||
403 | @@ -0,0 +1,96 @@ | |||
404 | 1 | /* | ||
405 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
406 | 3 | * | ||
407 | 4 | * Authors: | ||
408 | 5 | * Michal Hruby <michal.hruby@canonical.com> | ||
409 | 6 | * | ||
410 | 7 | * This program is free software; you can redistribute it and/or modify | ||
411 | 8 | * it under the terms of the GNU General Public License as published by | ||
412 | 9 | * the Free Software Foundation; version 3. | ||
413 | 10 | * | ||
414 | 11 | * This program is distributed in the hope that it will be useful, | ||
415 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
416 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
417 | 14 | * GNU General Public License for more details. | ||
418 | 15 | * | ||
419 | 16 | * You should have received a copy of the GNU General Public License | ||
420 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
421 | 18 | */ | ||
422 | 19 | |||
423 | 20 | // self | ||
424 | 21 | #include "categoryresults.h" | ||
425 | 22 | |||
426 | 23 | // TODO: use something from libunity once it's public | ||
427 | 24 | enum ResultsColumn { | ||
428 | 25 | URI, | ||
429 | 26 | ICON_HINT, | ||
430 | 27 | CATEGORY, | ||
431 | 28 | RESULT_TYPE, | ||
432 | 29 | MIMETYPE, | ||
433 | 30 | TITLE, | ||
434 | 31 | COMMENT, | ||
435 | 32 | DND_URI, | ||
436 | 33 | METADATA | ||
437 | 34 | }; | ||
438 | 35 | |||
439 | 36 | CategoryResults::CategoryResults(QObject* parent) | ||
440 | 37 | : DeeListModel(parent) | ||
441 | 38 | , m_categoryIndex(-1) | ||
442 | 39 | { | ||
443 | 40 | m_roles[CategoryResults::RoleUri] = "uri"; | ||
444 | 41 | m_roles[CategoryResults::RoleIconHint] = "icon"; | ||
445 | 42 | m_roles[CategoryResults::RoleCategory] = "category"; | ||
446 | 43 | m_roles[CategoryResults::RoleMimetype] = "mimetype"; | ||
447 | 44 | m_roles[CategoryResults::RoleTitle] = "title"; | ||
448 | 45 | m_roles[CategoryResults::RoleComment] = "comment"; | ||
449 | 46 | m_roles[CategoryResults::RoleDndUri] = "dndUri"; | ||
450 | 47 | m_roles[CategoryResults::RoleMetadata] = "metadata"; | ||
451 | 48 | } | ||
452 | 49 | |||
453 | 50 | int CategoryResults::categoryIndex() const | ||
454 | 51 | { | ||
455 | 52 | return m_categoryIndex; | ||
456 | 53 | } | ||
457 | 54 | |||
458 | 55 | void CategoryResults::setCategoryIndex(int index) | ||
459 | 56 | { | ||
460 | 57 | if (m_categoryIndex != index) { | ||
461 | 58 | m_categoryIndex = index; | ||
462 | 59 | Q_EMIT categoryIndexChanged(m_categoryIndex); | ||
463 | 60 | } | ||
464 | 61 | } | ||
465 | 62 | |||
466 | 63 | QHash<int, QByteArray> | ||
467 | 64 | CategoryResults::roleNames() const | ||
468 | 65 | { | ||
469 | 66 | return m_roles; | ||
470 | 67 | } | ||
471 | 68 | |||
472 | 69 | QVariant | ||
473 | 70 | CategoryResults::data(const QModelIndex& index, int role) const | ||
474 | 71 | { | ||
475 | 72 | if (!index.isValid()) { | ||
476 | 73 | return QVariant(); | ||
477 | 74 | } | ||
478 | 75 | |||
479 | 76 | switch (role) { | ||
480 | 77 | case RoleUri: | ||
481 | 78 | return DeeListModel::data(index, ResultsColumn::URI); | ||
482 | 79 | case RoleIconHint: | ||
483 | 80 | return DeeListModel::data(index, ResultsColumn::ICON_HINT); | ||
484 | 81 | case RoleCategory: | ||
485 | 82 | return DeeListModel::data(index, ResultsColumn::CATEGORY); | ||
486 | 83 | case RoleMimetype: | ||
487 | 84 | return DeeListModel::data(index, ResultsColumn::MIMETYPE); | ||
488 | 85 | case RoleTitle: | ||
489 | 86 | return DeeListModel::data(index, ResultsColumn::TITLE); | ||
490 | 87 | case RoleComment: | ||
491 | 88 | return DeeListModel::data(index, ResultsColumn::COMMENT); | ||
492 | 89 | case RoleDndUri: | ||
493 | 90 | return DeeListModel::data(index, ResultsColumn::DND_URI); | ||
494 | 91 | case RoleMetadata: | ||
495 | 92 | return DeeListModel::data(index, ResultsColumn::METADATA); | ||
496 | 93 | default: | ||
497 | 94 | return QVariant(); | ||
498 | 95 | } | ||
499 | 96 | } | ||
500 | 0 | 97 | ||
501 | === added file 'plugins/Unity/categoryresults.h' | |||
502 | --- plugins/Unity/categoryresults.h 1970-01-01 00:00:00 +0000 | |||
503 | +++ plugins/Unity/categoryresults.h 2013-07-05 12:05:30 +0000 | |||
504 | @@ -0,0 +1,67 @@ | |||
505 | 1 | /* | ||
506 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
507 | 3 | * | ||
508 | 4 | * Authors: | ||
509 | 5 | * Michal Hruby <michal.hruby@canonical.com> | ||
510 | 6 | * | ||
511 | 7 | * This program is free software; you can redistribute it and/or modify | ||
512 | 8 | * it under the terms of the GNU General Public License as published by | ||
513 | 9 | * the Free Software Foundation; version 3. | ||
514 | 10 | * | ||
515 | 11 | * This program is distributed in the hope that it will be useful, | ||
516 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
517 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
518 | 14 | * GNU General Public License for more details. | ||
519 | 15 | * | ||
520 | 16 | * You should have received a copy of the GNU General Public License | ||
521 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
522 | 18 | */ | ||
523 | 19 | |||
524 | 20 | |||
525 | 21 | #ifndef CATEGORY_RESULTS_H | ||
526 | 22 | #define CATEGORY_RESULTS_H | ||
527 | 23 | |||
528 | 24 | // dee-qt | ||
529 | 25 | #include "deelistmodel.h" | ||
530 | 26 | |||
531 | 27 | class CategoryResults : public DeeListModel | ||
532 | 28 | { | ||
533 | 29 | Q_OBJECT | ||
534 | 30 | |||
535 | 31 | Q_ENUMS(Roles) | ||
536 | 32 | |||
537 | 33 | Q_PROPERTY(int categoryIndex READ categoryIndex WRITE setCategoryIndex NOTIFY categoryIndexChanged) | ||
538 | 34 | |||
539 | 35 | public: | ||
540 | 36 | explicit CategoryResults(QObject* parent = 0); | ||
541 | 37 | |||
542 | 38 | enum Roles { | ||
543 | 39 | RoleUri, | ||
544 | 40 | RoleIconHint, | ||
545 | 41 | RoleCategory, | ||
546 | 42 | RoleMimetype, | ||
547 | 43 | RoleTitle, | ||
548 | 44 | RoleComment, | ||
549 | 45 | RoleDndUri, | ||
550 | 46 | RoleMetadata | ||
551 | 47 | }; | ||
552 | 48 | |||
553 | 49 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | ||
554 | 50 | |||
555 | 51 | QHash<int, QByteArray> roleNames() const; | ||
556 | 52 | |||
557 | 53 | /* getters */ | ||
558 | 54 | int categoryIndex() const; | ||
559 | 55 | |||
560 | 56 | /* setters */ | ||
561 | 57 | void setCategoryIndex(int index); | ||
562 | 58 | |||
563 | 59 | Q_SIGNALS: | ||
564 | 60 | void categoryIndexChanged(int index); | ||
565 | 61 | |||
566 | 62 | private: | ||
567 | 63 | QHash<int, QByteArray> m_roles; | ||
568 | 64 | int m_categoryIndex; | ||
569 | 65 | }; | ||
570 | 66 | |||
571 | 67 | #endif // CATEGORY_RESULTS_H | ||
572 | 0 | 68 | ||
573 | === modified file 'plugins/Unity/plugin.cpp' | |||
574 | --- plugins/Unity/plugin.cpp 2013-06-27 12:02:22 +0000 | |||
575 | +++ plugins/Unity/plugin.cpp 2013-07-05 12:05:30 +0000 | |||
576 | @@ -30,7 +30,7 @@ | |||
577 | 30 | #include "scope.h" | 30 | #include "scope.h" |
578 | 31 | #include "scopes.h" | 31 | #include "scopes.h" |
579 | 32 | #include "categories.h" | 32 | #include "categories.h" |
581 | 33 | #include "categoryfilter.h" | 33 | #include "categoryresults.h" |
582 | 34 | #include "bottombarvisibilitycommunicatorshell.h" | 34 | #include "bottombarvisibilitycommunicatorshell.h" |
583 | 35 | #include "launchermodel.h" | 35 | #include "launchermodel.h" |
584 | 36 | 36 | ||
585 | @@ -49,7 +49,7 @@ | |||
586 | 49 | qmlRegisterType<Scope>(uri, 0, 1, "Scope"); | 49 | qmlRegisterType<Scope>(uri, 0, 1, "Scope"); |
587 | 50 | qmlRegisterType<Scopes>(uri, 0, 1, "Scopes"); | 50 | qmlRegisterType<Scopes>(uri, 0, 1, "Scopes"); |
588 | 51 | qmlRegisterType<Categories>(uri, 0, 1, "Categories"); | 51 | qmlRegisterType<Categories>(uri, 0, 1, "Categories"); |
590 | 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."); |
591 | 53 | qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel"); | 53 | qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel"); |
592 | 54 | qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel"); | 54 | qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel"); |
593 | 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."); |
594 | 56 | 56 | ||
595 | === modified file 'plugins/Unity/scope.cpp' | |||
596 | --- plugins/Unity/scope.cpp 2013-07-02 08:33:11 +0000 | |||
597 | +++ plugins/Unity/scope.cpp 2013-07-05 12:05:30 +0000 | |||
598 | @@ -3,6 +3,7 @@ | |||
599 | 3 | * | 3 | * |
600 | 4 | * Authors: | 4 | * Authors: |
601 | 5 | * Florian Boucault <florian.boucault@canonical.com> | 5 | * Florian Boucault <florian.boucault@canonical.com> |
602 | 6 | * Michal Hruby <michal.hruby@canonical.com> | ||
603 | 6 | * | 7 | * |
604 | 7 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
605 | 8 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
606 | @@ -38,10 +39,7 @@ | |||
607 | 38 | Scope::Scope(QObject *parent) : | 39 | Scope::Scope(QObject *parent) : |
608 | 39 | QObject(parent) | 40 | QObject(parent) |
609 | 40 | { | 41 | { |
614 | 41 | m_results = new DeeListModel(this); | 42 | m_categories.reset(new Categories(this)); |
611 | 42 | m_categories = new Categories(this); | ||
612 | 43 | |||
613 | 44 | m_categories->setResultModel(m_results); | ||
615 | 45 | } | 43 | } |
616 | 46 | 44 | ||
617 | 47 | QString Scope::id() const | 45 | QString Scope::id() const |
618 | @@ -84,14 +82,9 @@ | |||
619 | 84 | return m_unityScope->connected(); | 82 | return m_unityScope->connected(); |
620 | 85 | } | 83 | } |
621 | 86 | 84 | ||
622 | 87 | DeeListModel* Scope::results() const | ||
623 | 88 | { | ||
624 | 89 | return m_results; | ||
625 | 90 | } | ||
626 | 91 | |||
627 | 92 | Categories* Scope::categories() const | 85 | Categories* Scope::categories() const |
628 | 93 | { | 86 | { |
630 | 94 | return m_categories; | 87 | return m_categories.get(); |
631 | 95 | } | 88 | } |
632 | 96 | 89 | ||
633 | 97 | QString Scope::searchQuery() const | 90 | QString Scope::searchQuery() const |
634 | @@ -104,6 +97,11 @@ | |||
635 | 104 | return m_noResultsHint; | 97 | return m_noResultsHint; |
636 | 105 | } | 98 | } |
637 | 106 | 99 | ||
638 | 100 | QString Scope::formFactor() const | ||
639 | 101 | { | ||
640 | 102 | return m_formFactor; | ||
641 | 103 | } | ||
642 | 104 | |||
643 | 107 | void Scope::setSearchQuery(const QString& search_query) | 105 | void Scope::setSearchQuery(const QString& search_query) |
644 | 108 | { | 106 | { |
645 | 109 | /* Checking for m_searchQuery.isNull() which returns true only when the string | 107 | /* Checking for m_searchQuery.isNull() which returns true only when the string |
646 | @@ -125,6 +123,15 @@ | |||
647 | 125 | } | 123 | } |
648 | 126 | } | 124 | } |
649 | 127 | 125 | ||
650 | 126 | void Scope::setFormFactor(const QString& form_factor) { | ||
651 | 127 | if (form_factor != m_formFactor) { | ||
652 | 128 | m_formFactor = form_factor; | ||
653 | 129 | if (m_unityScope) { | ||
654 | 130 | m_unityScope->form_factor = m_formFactor.toStdString(); | ||
655 | 131 | } | ||
656 | 132 | Q_EMIT formFactorChanged(); | ||
657 | 133 | } | ||
658 | 134 | } | ||
659 | 128 | 135 | ||
660 | 129 | unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint, | 136 | unity::dash::LocalResult Scope::createLocalResult(const QVariant &uri, const QVariant &icon_hint, |
661 | 130 | const QVariant &category, const QVariant &result_type, | 137 | const QVariant &category, const QVariant &result_type, |
662 | @@ -237,18 +244,9 @@ | |||
663 | 237 | { | 244 | { |
664 | 238 | m_unityScope = scope; | 245 | m_unityScope = scope; |
665 | 239 | 246 | ||
678 | 240 | if (QString::fromStdString(m_unityScope->results()->swarm_name) == QString(":local")) { | 247 | m_categories->setUnityScope(m_unityScope); |
679 | 241 | m_results->setModel(m_unityScope->results()->model()); | 248 | |
680 | 242 | } else { | 249 | m_unityScope->form_factor = m_formFactor.toStdString(); |
669 | 243 | m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name)); | ||
670 | 244 | } | ||
671 | 245 | |||
672 | 246 | if (QString::fromStdString(m_unityScope->categories()->swarm_name) == QString(":local")) { | ||
673 | 247 | m_categories->setModel(m_unityScope->categories()->model()); | ||
674 | 248 | } else { | ||
675 | 249 | m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name)); | ||
676 | 250 | } | ||
677 | 251 | |||
681 | 252 | /* Property change signals */ | 250 | /* Property change signals */ |
682 | 253 | m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged)); | 251 | m_unityScope->id.changed.connect(sigc::mem_fun(this, &Scope::idChanged)); |
683 | 254 | m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged)); | 252 | m_unityScope->name.changed.connect(sigc::mem_fun(this, &Scope::nameChanged)); |
684 | @@ -258,12 +256,6 @@ | |||
685 | 258 | m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged)); | 256 | m_unityScope->visible.changed.connect(sigc::mem_fun(this, &Scope::visibleChanged)); |
686 | 259 | m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged)); | 257 | m_unityScope->shortcut.changed.connect(sigc::mem_fun(this, &Scope::shortcutChanged)); |
687 | 260 | m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged)); | 258 | m_unityScope->connected.changed.connect(sigc::mem_fun(this, &Scope::connectedChanged)); |
688 | 261 | m_unityScope->results.changed.connect(sigc::mem_fun(this, &Scope::onResultsChanged)); | ||
689 | 262 | m_unityScope->results()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onResultsSwarmNameChanged)); | ||
690 | 263 | m_unityScope->results()->model.changed.connect(sigc::mem_fun(this, &Scope::onResultsModelChanged)); | ||
691 | 264 | m_unityScope->categories()->model.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesModelChanged)); | ||
692 | 265 | m_unityScope->categories.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesChanged)); | ||
693 | 266 | m_unityScope->categories()->swarm_name.changed.connect(sigc::mem_fun(this, &Scope::onCategoriesSwarmNameChanged)); | ||
694 | 267 | /* Signals forwarding */ | 259 | /* Signals forwarding */ |
695 | 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 &))); |
696 | 269 | 261 | ||
697 | @@ -294,36 +286,6 @@ | |||
698 | 294 | } | 286 | } |
699 | 295 | } | 287 | } |
700 | 296 | 288 | ||
701 | 297 | void Scope::onResultsSwarmNameChanged(const std::string& /* swarm_name */) | ||
702 | 298 | { | ||
703 | 299 | m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name)); | ||
704 | 300 | } | ||
705 | 301 | |||
706 | 302 | void Scope::onResultsChanged(const unity::dash::Results::Ptr& /* results */) | ||
707 | 303 | { | ||
708 | 304 | m_results->setName(QString::fromStdString(m_unityScope->results()->swarm_name)); | ||
709 | 305 | } | ||
710 | 306 | |||
711 | 307 | void Scope::onResultsModelChanged(unity::glib::Object<DeeModel> /* model */) | ||
712 | 308 | { | ||
713 | 309 | m_results->setModel(m_unityScope->results()->model()); | ||
714 | 310 | } | ||
715 | 311 | |||
716 | 312 | void Scope::onCategoriesSwarmNameChanged(const std::string& /* swarm_name */) | ||
717 | 313 | { | ||
718 | 314 | m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name)); | ||
719 | 315 | } | ||
720 | 316 | |||
721 | 317 | void Scope::onCategoriesChanged(const unity::dash::Categories::Ptr& /* categories */) | ||
722 | 318 | { | ||
723 | 319 | m_categories->setName(QString::fromStdString(m_unityScope->categories()->swarm_name)); | ||
724 | 320 | } | ||
725 | 321 | |||
726 | 322 | void Scope::onCategoriesModelChanged(unity::glib::Object<DeeModel> model) | ||
727 | 323 | { | ||
728 | 324 | m_categories->setModel(model); | ||
729 | 325 | } | ||
730 | 326 | |||
731 | 327 | void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints) | 289 | void Scope::onSearchFinished(const std::string& /* query */, unity::glib::HintsMap const &hints) |
732 | 328 | { | 290 | { |
733 | 329 | QString hint; | 291 | QString hint; |
734 | 330 | 292 | ||
735 | === modified file 'plugins/Unity/scope.h' | |||
736 | --- plugins/Unity/scope.h 2013-06-26 10:56:43 +0000 | |||
737 | +++ plugins/Unity/scope.h 2013-07-05 12:05:30 +0000 | |||
738 | @@ -32,7 +32,8 @@ | |||
739 | 32 | // dee-qt | 32 | // dee-qt |
740 | 33 | #include "deelistmodel.h" | 33 | #include "deelistmodel.h" |
741 | 34 | 34 | ||
743 | 35 | class Categories; | 35 | #include "categories.h" |
744 | 36 | |||
745 | 36 | class Preview; | 37 | class Preview; |
746 | 37 | 38 | ||
747 | 38 | class Scope : public QObject | 39 | class Scope : public QObject |
748 | @@ -47,11 +48,11 @@ | |||
749 | 47 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) | 48 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) |
750 | 48 | Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged) | 49 | Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged) |
751 | 49 | Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) | 50 | Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) |
752 | 50 | Q_PROPERTY(DeeListModel* results READ results NOTIFY resultsChanged) | ||
753 | 51 | Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged) | 51 | Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged) |
754 | 52 | 52 | ||
755 | 53 | Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged) | 53 | Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged) |
756 | 54 | Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged) | 54 | Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged) |
757 | 55 | Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged) | ||
758 | 55 | 56 | ||
759 | 56 | public: | 57 | public: |
760 | 57 | explicit Scope(QObject *parent = 0); | 58 | explicit Scope(QObject *parent = 0); |
761 | @@ -65,14 +66,15 @@ | |||
762 | 65 | bool visible() const; | 66 | bool visible() const; |
763 | 66 | QString shortcut() const; | 67 | QString shortcut() const; |
764 | 67 | bool connected() const; | 68 | bool connected() const; |
765 | 68 | DeeListModel* results() const; | ||
766 | 69 | Categories* categories() const; | 69 | Categories* categories() const; |
767 | 70 | QString searchQuery() const; | 70 | QString searchQuery() const; |
768 | 71 | QString noResultsHint() const; | 71 | QString noResultsHint() const; |
769 | 72 | QString formFactor() const; | ||
770 | 72 | 73 | ||
771 | 73 | /* setters */ | 74 | /* setters */ |
772 | 74 | void setSearchQuery(const QString& search_query); | 75 | void setSearchQuery(const QString& search_query); |
773 | 75 | void setNoResultsHint(const QString& hint); | 76 | void setNoResultsHint(const QString& hint); |
774 | 77 | void setFormFactor(const QString& form_factor); | ||
775 | 76 | 78 | ||
776 | 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, |
777 | 78 | const QVariant &result_type, const QVariant &mimetype, const QVariant &title, | 80 | const QVariant &result_type, const QVariant &mimetype, const QVariant &title, |
778 | @@ -94,11 +96,11 @@ | |||
779 | 94 | void visibleChanged(bool); | 96 | void visibleChanged(bool); |
780 | 95 | void shortcutChanged(const std::string&); | 97 | void shortcutChanged(const std::string&); |
781 | 96 | void connectedChanged(bool); | 98 | void connectedChanged(bool); |
782 | 97 | void resultsChanged(); | ||
783 | 98 | void categoriesChanged(); | 99 | void categoriesChanged(); |
784 | 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&); |
785 | 100 | void searchQueryChanged(); | 101 | void searchQueryChanged(); |
786 | 101 | void noResultsHintChanged(); | 102 | void noResultsHintChanged(); |
787 | 103 | void formFactorChanged(); | ||
788 | 102 | 104 | ||
789 | 103 | // signals triggered by activate(..) or preview(..) requests. | 105 | // signals triggered by activate(..) or preview(..) requests. |
790 | 104 | void previewReady(Preview *preview); | 106 | void previewReady(Preview *preview); |
791 | @@ -111,12 +113,6 @@ | |||
792 | 111 | void onSearchFinished(const std::string &, unity::glib::HintsMap const &); | 113 | void onSearchFinished(const std::string &, unity::glib::HintsMap const &); |
793 | 112 | 114 | ||
794 | 113 | private: | 115 | private: |
795 | 114 | void onResultsSwarmNameChanged(const std::string&); | ||
796 | 115 | void onResultsChanged(const unity::dash::Results::Ptr&); | ||
797 | 116 | void onResultsModelChanged(unity::glib::Object<DeeModel>); | ||
798 | 117 | void onCategoriesSwarmNameChanged(const std::string&); | ||
799 | 118 | void onCategoriesModelChanged(unity::glib::Object<DeeModel>); | ||
800 | 119 | void onCategoriesChanged(const unity::dash::Categories::Ptr&); | ||
801 | 120 | unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint, | 116 | unity::dash::LocalResult createLocalResult(const QVariant &uri, const QVariant &icon_hint, |
802 | 121 | const QVariant &category, const QVariant &result_type, | 117 | const QVariant &category, const QVariant &result_type, |
803 | 122 | const QVariant &mimetype, const QVariant &title, | 118 | const QVariant &mimetype, const QVariant &title, |
804 | @@ -127,10 +123,10 @@ | |||
805 | 127 | void fallbackActivate(const QString& uri); | 123 | void fallbackActivate(const QString& uri); |
806 | 128 | 124 | ||
807 | 129 | unity::dash::Scope::Ptr m_unityScope; | 125 | unity::dash::Scope::Ptr m_unityScope; |
810 | 130 | DeeListModel* m_results; | 126 | std::unique_ptr<Categories> m_categories; |
809 | 131 | Categories* m_categories; | ||
811 | 132 | QString m_searchQuery; | 127 | QString m_searchQuery; |
812 | 133 | QString m_noResultsHint; | 128 | QString m_noResultsHint; |
813 | 129 | QString m_formFactor; | ||
814 | 134 | }; | 130 | }; |
815 | 135 | 131 | ||
816 | 136 | Q_DECLARE_METATYPE(Scope*) | 132 | Q_DECLARE_METATYPE(Scope*) |
817 | 137 | 133 | ||
818 | === modified file 'tests/mocks/Unity/CMakeLists.txt' | |||
819 | --- tests/mocks/Unity/CMakeLists.txt 2013-06-12 15:03:07 +0000 | |||
820 | +++ tests/mocks/Unity/CMakeLists.txt 2013-07-05 12:05:30 +0000 | |||
821 | @@ -19,11 +19,10 @@ | |||
822 | 19 | add_definitions(-DQT_NO_KEYWORDS) | 19 | add_definitions(-DQT_NO_KEYWORDS) |
823 | 20 | 20 | ||
824 | 21 | set(UnityQML_SOURCES | 21 | set(UnityQML_SOURCES |
828 | 22 | ${CMAKE_SOURCE_DIR}/plugins/Unity/categories.cpp | 22 | ${CMAKE_SOURCE_DIR}/plugins/Unity/categoryresults.cpp |
826 | 23 | ${CMAKE_SOURCE_DIR}/plugins/Unity/categoryfilter.cpp | ||
827 | 24 | ${CMAKE_SOURCE_DIR}/plugins/Utils/qsortfilterproxymodelqml.cpp | ||
829 | 25 | fake_scope.cpp | 23 | fake_scope.cpp |
830 | 26 | fake_scopes.cpp | 24 | fake_scopes.cpp |
831 | 25 | fake_categories.cpp | ||
832 | 27 | fake_unity_plugin.cpp | 26 | fake_unity_plugin.cpp |
833 | 28 | fake_launchermodel.cpp | 27 | fake_launchermodel.cpp |
834 | 29 | ) | 28 | ) |
835 | 30 | 29 | ||
836 | === added file 'tests/mocks/Unity/fake_categories.cpp' | |||
837 | --- tests/mocks/Unity/fake_categories.cpp 1970-01-01 00:00:00 +0000 | |||
838 | +++ tests/mocks/Unity/fake_categories.cpp 2013-07-05 12:05:30 +0000 | |||
839 | @@ -0,0 +1,178 @@ | |||
840 | 1 | /* | ||
841 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
842 | 3 | * | ||
843 | 4 | * This program is free software; you can redistribute it and/or modify | ||
844 | 5 | * it under the terms of the GNU General Public License as published by | ||
845 | 6 | * the Free Software Foundation; version 3. | ||
846 | 7 | * | ||
847 | 8 | * This program is distributed in the hope that it will be useful, | ||
848 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
849 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
850 | 11 | * GNU General Public License for more details. | ||
851 | 12 | * | ||
852 | 13 | * You should have received a copy of the GNU General Public License | ||
853 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
854 | 15 | * | ||
855 | 16 | * Author: Nick Dedekind <nick.dedekind@canonical.com> | ||
856 | 17 | */ | ||
857 | 18 | |||
858 | 19 | // self | ||
859 | 20 | #include "fake_categories.h" | ||
860 | 21 | |||
861 | 22 | // local | ||
862 | 23 | #include "categoryresults.h" | ||
863 | 24 | |||
864 | 25 | #define CATEGORY_COLUMN 2 | ||
865 | 26 | |||
866 | 27 | Categories::Categories(QObject* parent) | ||
867 | 28 | : DeeListModel(parent) | ||
868 | 29 | { | ||
869 | 30 | // FIXME: need to clean up unused filters on countChanged | ||
870 | 31 | m_roles[Categories::RoleId] = "id"; | ||
871 | 32 | m_roles[Categories::RoleName] = "name"; | ||
872 | 33 | m_roles[Categories::RoleIcon] = "icon"; | ||
873 | 34 | m_roles[Categories::RoleRenderer] = "renderer"; | ||
874 | 35 | m_roles[Categories::RoleContentType] = "content_type"; | ||
875 | 36 | m_roles[Categories::RoleHints] = "hints"; | ||
876 | 37 | m_roles[Categories::RoleResults] = "results"; | ||
877 | 38 | m_roles[Categories::RoleCount] = "count"; | ||
878 | 39 | |||
879 | 40 | // TODO This should not be needed but accumulatting the count changes | ||
880 | 41 | // makes the visualization more stable and also makes crashes on fast | ||
881 | 42 | // change of the search term harder to reproduce | ||
882 | 43 | m_timer.setSingleShot(true); | ||
883 | 44 | m_timer.setInterval(50); | ||
884 | 45 | connect(&m_timer, SIGNAL(timeout()), this, SLOT(onEmitCountChanged())); | ||
885 | 46 | } | ||
886 | 47 | |||
887 | 48 | DeeListModel* | ||
888 | 49 | Categories::getFilter(int index) const | ||
889 | 50 | { | ||
890 | 51 | if (!m_filters.contains(index)) { | ||
891 | 52 | auto results = new CategoryResults (); | ||
892 | 53 | results->setCategoryIndex(index); | ||
893 | 54 | connect(results, SIGNAL(countChanged()), this, SLOT(onCountChanged())); | ||
894 | 55 | |||
895 | 56 | unsigned cat_index = static_cast<unsigned>(index); | ||
896 | 57 | auto model = getResultsForCategory(cat_index); | ||
897 | 58 | results->setModel(model); | ||
898 | 59 | |||
899 | 60 | m_filters.insert(index, results); | ||
900 | 61 | } | ||
901 | 62 | |||
902 | 63 | return m_filters[index]; | ||
903 | 64 | } | ||
904 | 65 | |||
905 | 66 | void | ||
906 | 67 | Categories::onCountChanged() | ||
907 | 68 | { | ||
908 | 69 | DeeListModel* filter = qobject_cast<DeeListModel*>(sender()); | ||
909 | 70 | if (filter) { | ||
910 | 71 | m_timerFilters << filter; | ||
911 | 72 | m_timer.start(); | ||
912 | 73 | } | ||
913 | 74 | } | ||
914 | 75 | |||
915 | 76 | void | ||
916 | 77 | Categories::onEmitCountChanged() | ||
917 | 78 | { | ||
918 | 79 | QVector<int> roles; | ||
919 | 80 | roles.append(Categories::RoleCount); | ||
920 | 81 | Q_FOREACH(DeeListModel* results, m_timerFilters) { | ||
921 | 82 | auto cat_results = qobject_cast<CategoryResults*>(results); | ||
922 | 83 | QModelIndex changedIndex = index(cat_results->categoryIndex()); | ||
923 | 84 | Q_EMIT dataChanged(changedIndex, changedIndex, roles); | ||
924 | 85 | } | ||
925 | 86 | m_timerFilters.clear(); | ||
926 | 87 | } | ||
927 | 88 | |||
928 | 89 | QHash<int, QByteArray> | ||
929 | 90 | Categories::roleNames() const | ||
930 | 91 | { | ||
931 | 92 | return m_roles; | ||
932 | 93 | } | ||
933 | 94 | |||
934 | 95 | void Categories::setResultModel(DeeModel* model) | ||
935 | 96 | { | ||
936 | 97 | // FIXME: should ref it | ||
937 | 98 | m_dee_results = model; | ||
938 | 99 | } | ||
939 | 100 | |||
940 | 101 | |||
941 | 102 | static void category_filter_map_func (DeeModel* orig_model, | ||
942 | 103 | DeeFilterModel* filter_model, | ||
943 | 104 | gpointer user_data) | ||
944 | 105 | { | ||
945 | 106 | DeeModelIter* iter; | ||
946 | 107 | DeeModelIter* end; | ||
947 | 108 | unsigned index = GPOINTER_TO_UINT(user_data); | ||
948 | 109 | |||
949 | 110 | iter = dee_model_get_first_iter(orig_model); | ||
950 | 111 | end = dee_model_get_last_iter(orig_model); | ||
951 | 112 | while (iter != end) { | ||
952 | 113 | unsigned category_index = dee_model_get_uint32(orig_model, iter, CATEGORY_COLUMN); | ||
953 | 114 | if (index == category_index) { | ||
954 | 115 | dee_filter_model_append_iter(filter_model, iter); | ||
955 | 116 | } | ||
956 | 117 | iter = dee_model_next(orig_model, iter); | ||
957 | 118 | } | ||
958 | 119 | } | ||
959 | 120 | |||
960 | 121 | static gboolean category_filter_notify_func (DeeModel* orig_model, | ||
961 | 122 | DeeModelIter* orig_iter, | ||
962 | 123 | DeeFilterModel* filter_model, | ||
963 | 124 | gpointer user_data) | ||
964 | 125 | { | ||
965 | 126 | unsigned index = GPOINTER_TO_UINT(user_data); | ||
966 | 127 | unsigned category_index = dee_model_get_uint32(orig_model, orig_iter, CATEGORY_COLUMN); | ||
967 | 128 | |||
968 | 129 | if (index != category_index) | ||
969 | 130 | return FALSE; | ||
970 | 131 | |||
971 | 132 | dee_filter_model_insert_iter_with_original_order(filter_model, orig_iter); | ||
972 | 133 | return TRUE; | ||
973 | 134 | } | ||
974 | 135 | |||
975 | 136 | DeeModel* Categories::getResultsForCategory(unsigned cat_index) const | ||
976 | 137 | { | ||
977 | 138 | DeeFilter filter; | ||
978 | 139 | filter.map_func = category_filter_map_func; | ||
979 | 140 | filter.map_notify = category_filter_notify_func; | ||
980 | 141 | filter.destroy = nullptr; | ||
981 | 142 | filter.userdata = GUINT_TO_POINTER(cat_index); | ||
982 | 143 | |||
983 | 144 | DeeModel* filtered_model = dee_filter_model_new(m_dee_results, &filter); | ||
984 | 145 | return filtered_model; | ||
985 | 146 | } | ||
986 | 147 | |||
987 | 148 | QVariant | ||
988 | 149 | Categories::data(const QModelIndex& index, int role) const | ||
989 | 150 | { | ||
990 | 151 | if (!index.isValid()) { | ||
991 | 152 | return QVariant(); | ||
992 | 153 | } | ||
993 | 154 | |||
994 | 155 | switch (role) { | ||
995 | 156 | case RoleId: | ||
996 | 157 | return QVariant::fromValue(index.row()); | ||
997 | 158 | case RoleName: | ||
998 | 159 | return DeeListModel::data(index, 1); //DISPLAY_NAME | ||
999 | 160 | case RoleIcon: | ||
1000 | 161 | return DeeListModel::data(index, 2); //ICON_HINT | ||
1001 | 162 | case RoleRenderer: | ||
1002 | 163 | return DeeListModel::data(index, 3); //RENDERER_NAME | ||
1003 | 164 | case RoleContentType: | ||
1004 | 165 | { | ||
1005 | 166 | auto hints = DeeListModel::data(index, 4).toHash(); | ||
1006 | 167 | return hints.contains("content-type") ? hints["content-type"] : QVariant(QString("default")); | ||
1007 | 168 | } | ||
1008 | 169 | case RoleHints: | ||
1009 | 170 | return DeeListModel::data(index, 4); //HINTS | ||
1010 | 171 | case RoleResults: | ||
1011 | 172 | return QVariant::fromValue(getFilter(index.row())); | ||
1012 | 173 | case RoleCount: | ||
1013 | 174 | return QVariant::fromValue(getFilter(index.row())->rowCount()); | ||
1014 | 175 | default: | ||
1015 | 176 | return QVariant(); | ||
1016 | 177 | } | ||
1017 | 178 | } | ||
1018 | 0 | 179 | ||
1019 | === added file 'tests/mocks/Unity/fake_categories.h' | |||
1020 | --- tests/mocks/Unity/fake_categories.h 1970-01-01 00:00:00 +0000 | |||
1021 | +++ tests/mocks/Unity/fake_categories.h 2013-07-05 12:05:30 +0000 | |||
1022 | @@ -0,0 +1,69 @@ | |||
1023 | 1 | /* | ||
1024 | 2 | * Copyright (C) 2013 Canonical, Ltd. | ||
1025 | 3 | * | ||
1026 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1027 | 5 | * it under the terms of the GNU General Public License as published by | ||
1028 | 6 | * the Free Software Foundation; version 3. | ||
1029 | 7 | * | ||
1030 | 8 | * This program is distributed in the hope that it will be useful, | ||
1031 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1032 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1033 | 11 | * GNU General Public License for more details. | ||
1034 | 12 | * | ||
1035 | 13 | * You should have received a copy of the GNU General Public License | ||
1036 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1037 | 15 | */ | ||
1038 | 16 | |||
1039 | 17 | #ifndef FAKE_CATEGORIES_H | ||
1040 | 18 | #define FAKE_CATEGORIES_H | ||
1041 | 19 | |||
1042 | 20 | // Qt | ||
1043 | 21 | #include <QObject> | ||
1044 | 22 | #include <QSet> | ||
1045 | 23 | #include <QTimer> | ||
1046 | 24 | |||
1047 | 25 | #include <dee.h> | ||
1048 | 26 | #include <deelistmodel.h> | ||
1049 | 27 | |||
1050 | 28 | class Categories : public DeeListModel | ||
1051 | 29 | { | ||
1052 | 30 | Q_OBJECT | ||
1053 | 31 | |||
1054 | 32 | Q_ENUMS(Roles) | ||
1055 | 33 | |||
1056 | 34 | public: | ||
1057 | 35 | Categories(QObject* parent = 0); | ||
1058 | 36 | enum Roles { | ||
1059 | 37 | RoleId, | ||
1060 | 38 | RoleName, | ||
1061 | 39 | RoleIcon, | ||
1062 | 40 | RoleRenderer, | ||
1063 | 41 | RoleContentType, | ||
1064 | 42 | RoleHints, | ||
1065 | 43 | RoleResults, | ||
1066 | 44 | RoleCount | ||
1067 | 45 | }; | ||
1068 | 46 | |||
1069 | 47 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | ||
1070 | 48 | |||
1071 | 49 | QHash<int, QByteArray> roleNames() const; | ||
1072 | 50 | |||
1073 | 51 | /* setters */ | ||
1074 | 52 | void setResultModel(DeeModel* model); | ||
1075 | 53 | |||
1076 | 54 | private Q_SLOTS: | ||
1077 | 55 | void onCountChanged(); | ||
1078 | 56 | void onEmitCountChanged(); | ||
1079 | 57 | |||
1080 | 58 | private: | ||
1081 | 59 | DeeModel* getResultsForCategory(unsigned index) const; | ||
1082 | 60 | DeeListModel* getFilter(int index) const; | ||
1083 | 61 | |||
1084 | 62 | DeeModel* m_dee_results; | ||
1085 | 63 | QTimer m_timer; | ||
1086 | 64 | QSet<DeeListModel*> m_timerFilters; | ||
1087 | 65 | QHash<int, QByteArray> m_roles; | ||
1088 | 66 | mutable QMap<int, DeeListModel*> m_filters; | ||
1089 | 67 | }; | ||
1090 | 68 | |||
1091 | 69 | #endif // FAKE_CATEGORIES_H | ||
1092 | 0 | 70 | ||
1093 | === modified file 'tests/mocks/Unity/fake_scope.cpp' | |||
1094 | --- tests/mocks/Unity/fake_scope.cpp 2013-06-14 14:08:46 +0000 | |||
1095 | +++ tests/mocks/Unity/fake_scope.cpp 2013-07-05 12:05:30 +0000 | |||
1096 | @@ -26,32 +26,29 @@ | |||
1097 | 26 | // TODO: Implement remaining pieces | 26 | // TODO: Implement remaining pieces |
1098 | 27 | 27 | ||
1099 | 28 | Scope::Scope(QObject* parent) | 28 | Scope::Scope(QObject* parent) |
1104 | 29 | : QObject(parent), | 29 | : QObject(parent) |
1105 | 30 | m_visible(false), | 30 | , m_visible(false) |
1106 | 31 | m_categories(new Categories(this)), | 31 | , m_categories(new Categories(this)) |
1107 | 32 | m_results(new DeeListModel(this)) | 32 | , m_results(new DeeListModel(this)) |
1108 | 33 | { | 33 | { |
1109 | 34 | DeeModel* results_model = create_results_model(4, 30); | ||
1110 | 35 | m_categories->setResultModel(results_model); | ||
1111 | 34 | m_categories->setModel(create_categories_model(4)); | 36 | m_categories->setModel(create_categories_model(4)); |
1115 | 35 | m_results->setModel(create_results_model(4, 30)); | 37 | m_results->setModel(results_model); |
1113 | 36 | |||
1114 | 37 | m_categories->setResultModel(m_results); | ||
1116 | 38 | } | 38 | } |
1117 | 39 | 39 | ||
1128 | 40 | Scope::Scope(QString const& id, | 40 | Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent) |
1129 | 41 | QString const& name, | 41 | : QObject(parent) |
1130 | 42 | bool visible, | 42 | , m_id(id) |
1131 | 43 | QObject* parent) | 43 | , m_name(name) |
1132 | 44 | : QObject(parent), | 44 | , m_visible(visible) |
1133 | 45 | m_id(id), | 45 | , m_categories(new Categories(this)) |
1134 | 46 | m_name(name), | 46 | , m_results(new DeeListModel(this)) |
1125 | 47 | m_visible(visible), | ||
1126 | 48 | m_categories(new Categories(this)), | ||
1127 | 49 | m_results(new DeeListModel(this)) | ||
1135 | 50 | { | 47 | { |
1136 | 48 | DeeModel* results_model = create_results_model(4, 30); | ||
1137 | 49 | m_categories->setResultModel(results_model); | ||
1138 | 51 | m_categories->setModel(create_categories_model(4)); | 50 | m_categories->setModel(create_categories_model(4)); |
1142 | 52 | m_results->setModel(create_results_model(4, 30)); | 51 | m_results->setModel(results_model); |
1140 | 53 | |||
1141 | 54 | m_categories->setResultModel(m_results); | ||
1143 | 55 | } | 52 | } |
1144 | 56 | 53 | ||
1145 | 57 | QString Scope::id() const { | 54 | QString Scope::id() const { |
1146 | @@ -66,6 +63,42 @@ | |||
1147 | 66 | return m_searchQuery; | 63 | return m_searchQuery; |
1148 | 67 | } | 64 | } |
1149 | 68 | 65 | ||
1150 | 66 | QString Scope::iconHint() const { | ||
1151 | 67 | return m_iconHint; | ||
1152 | 68 | } | ||
1153 | 69 | |||
1154 | 70 | QString Scope::description() const { | ||
1155 | 71 | return m_description; | ||
1156 | 72 | } | ||
1157 | 73 | |||
1158 | 74 | QString Scope::searchHint() const { | ||
1159 | 75 | return QString(""); | ||
1160 | 76 | } | ||
1161 | 77 | |||
1162 | 78 | QString Scope::shortcut() const { | ||
1163 | 79 | return QString(""); | ||
1164 | 80 | } | ||
1165 | 81 | |||
1166 | 82 | bool Scope::connected() const { | ||
1167 | 83 | return true; | ||
1168 | 84 | } | ||
1169 | 85 | |||
1170 | 86 | Categories* Scope::categories() const { | ||
1171 | 87 | return m_categories; | ||
1172 | 88 | } | ||
1173 | 89 | |||
1174 | 90 | QString Scope::noResultsHint() const { | ||
1175 | 91 | return m_noResultsHint; | ||
1176 | 92 | } | ||
1177 | 93 | |||
1178 | 94 | QString Scope::formFactor() const { | ||
1179 | 95 | return m_formFactor; | ||
1180 | 96 | } | ||
1181 | 97 | |||
1182 | 98 | bool Scope::visible() const { | ||
1183 | 99 | return m_visible; | ||
1184 | 100 | } | ||
1185 | 101 | |||
1186 | 69 | void Scope::setName(const QString &str) { | 102 | void Scope::setName(const QString &str) { |
1187 | 70 | if (str != m_name) { | 103 | if (str != m_name) { |
1188 | 71 | m_name = str; | 104 | m_name = str; |
1189 | @@ -76,45 +109,47 @@ | |||
1190 | 76 | void Scope::setSearchQuery(const QString &str) { | 109 | void Scope::setSearchQuery(const QString &str) { |
1191 | 77 | if (str != m_searchQuery) { | 110 | if (str != m_searchQuery) { |
1192 | 78 | m_searchQuery = str; | 111 | m_searchQuery = str; |
1203 | 79 | Q_EMIT searchQueryChanged(m_searchQuery); | 112 | Q_EMIT searchQueryChanged(); |
1204 | 80 | } | 113 | } |
1205 | 81 | } | 114 | } |
1206 | 82 | 115 | ||
1207 | 83 | bool Scope::visible() const { | 116 | void Scope::setFormFactor(const QString &str) { |
1208 | 84 | return m_visible; | 117 | if (str != m_formFactor) { |
1209 | 85 | } | 118 | m_formFactor = str; |
1210 | 86 | 119 | Q_EMIT formFactorChanged(); | |
1211 | 87 | Categories* Scope::categories() const { | 120 | } |
1212 | 88 | return m_categories; | 121 | } |
1213 | 122 | |||
1214 | 123 | void Scope::setNoResultsHint(const QString& str) { | ||
1215 | 124 | if (str != m_noResultsHint) { | ||
1216 | 125 | m_noResultsHint = str; | ||
1217 | 126 | Q_EMIT noResultsHintChanged(); | ||
1218 | 127 | } | ||
1219 | 89 | } | 128 | } |
1220 | 90 | 129 | ||
1221 | 91 | static const gchar * categories_model_schema[] = { | 130 | static const gchar * categories_model_schema[] = { |
1227 | 92 | "s", //ID | 131 | "s", //ID |
1228 | 93 | "s", // DISPLAY_NAME | 132 | "s", // DISPLAY_NAME |
1229 | 94 | "s", // ICON_HINT | 133 | "s", // ICON_HINT |
1230 | 95 | "s", // RENDERER_NAME | 134 | "s", // RENDERER_NAME |
1231 | 96 | "a{sv}" // HINTS | 135 | "a{sv}" // HINTS |
1232 | 97 | }; | 136 | }; |
1233 | 98 | 137 | ||
1234 | 99 | 138 | ||
1235 | 100 | DeeModel* create_categories_model(unsigned category_count) { | 139 | DeeModel* create_categories_model(unsigned category_count) { |
1236 | 101 | DeeModel* category_model = dee_sequence_model_new(); | 140 | DeeModel* category_model = dee_sequence_model_new(); |
1237 | 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)); |
1242 | 103 | 142 | GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0); | |
1239 | 104 | GVariantBuilder b; | ||
1240 | 105 | g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); | ||
1241 | 106 | GVariant *hints = g_variant_builder_end(&b); | ||
1243 | 107 | 143 | ||
1244 | 108 | for(unsigned i = 0; i < category_count; ++i) | 144 | for(unsigned i = 0; i < category_count; ++i) |
1245 | 109 | { | 145 | { |
1252 | 110 | dee_model_append(category_model, | 146 | dee_model_append(category_model, |
1253 | 111 | std::to_string(i).c_str(), | 147 | std::to_string(i).c_str(), |
1254 | 112 | ("Category "+std::to_string(i)).c_str(), | 148 | ("Category "+std::to_string(i)).c_str(), |
1255 | 113 | "gtk-apply", | 149 | "gtk-apply", |
1256 | 114 | "grid", | 150 | "grid", |
1257 | 115 | hints); | 151 | hints); |
1258 | 116 | } | 152 | } |
1259 | 117 | g_variant_unref(hints); | ||
1260 | 118 | return category_model; | 153 | return category_model; |
1261 | 119 | } | 154 | } |
1262 | 120 | 155 | ||
1263 | @@ -122,48 +157,44 @@ | |||
1264 | 122 | /* Schema that is used in the DeeModel representing | 157 | /* Schema that is used in the DeeModel representing |
1265 | 123 | the results */ | 158 | the results */ |
1266 | 124 | static const gchar * results_model_schema[] = { | 159 | static const gchar * results_model_schema[] = { |
1276 | 125 | "s", // URI | 160 | "s", // URI |
1277 | 126 | "s", // ICON_HINT | 161 | "s", // ICON_HINT |
1278 | 127 | "u", // CATEGORY | 162 | "u", // CATEGORY |
1279 | 128 | "u", // RESULT_TYPE | 163 | "u", // RESULT_TYPE |
1280 | 129 | "s", // MIMETYPE | 164 | "s", // MIMETYPE |
1281 | 130 | "s", // TITLE | 165 | "s", // TITLE |
1282 | 131 | "s", // COMMENT | 166 | "s", // COMMENT |
1283 | 132 | "s", // DND_URI | 167 | "s", // DND_URI |
1284 | 133 | "a{sv}" // METADATA | 168 | "a{sv}" // METADATA |
1285 | 134 | }; | 169 | }; |
1286 | 135 | 170 | ||
1287 | 136 | static const gchar * icons[] = { | 171 | static const gchar * icons[] = { |
1293 | 137 | "Applications.png", | 172 | "Applications.png", |
1294 | 138 | "Home.png", | 173 | "Home.png", |
1295 | 139 | "Music.png", | 174 | "Music.png", |
1296 | 140 | "People.png", | 175 | "People.png", |
1297 | 141 | "Videos.png", | 176 | "Videos.png", |
1298 | 142 | }; | 177 | }; |
1299 | 143 | 178 | ||
1300 | 144 | DeeModel* create_results_model(unsigned category_count, unsigned result_count) { | 179 | DeeModel* create_results_model(unsigned category_count, unsigned result_count) { |
1301 | 145 | DeeModel* results_model = dee_sequence_model_new(); | 180 | DeeModel* results_model = dee_sequence_model_new(); |
1302 | 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)); |
1307 | 147 | 182 | GVariant* hints = g_variant_new_array(g_variant_type_element(G_VARIANT_TYPE_VARDICT), NULL, 0); | |
1304 | 148 | GVariantBuilder b; | ||
1305 | 149 | g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); | ||
1306 | 150 | GVariant *hints = g_variant_builder_end(&b); | ||
1308 | 151 | 183 | ||
1309 | 152 | for(unsigned i = 0; i < result_count; ++i) | 184 | for(unsigned i = 0; i < result_count; ++i) |
1310 | 153 | { | 185 | { |
1312 | 154 | unsigned category = i % category_count; | 186 | unsigned category = i % category_count; |
1313 | 155 | 187 | ||
1324 | 156 | dee_model_append(results_model, | 188 | dee_model_append(results_model, |
1325 | 157 | ("uri://result."+std::to_string(i)).c_str(), | 189 | ("uri://result."+std::to_string(i)).c_str(), |
1326 | 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(), |
1327 | 159 | category, | 191 | category, |
1328 | 160 | 0, | 192 | 0, |
1329 | 161 | "application/x-desktop", | 193 | "application/x-desktop", |
1330 | 162 | ("Title."+std::to_string(i)).c_str(), | 194 | ("Title."+std::to_string(i)).c_str(), |
1331 | 163 | ("Comment."+std::to_string(i)).c_str(), | 195 | ("Comment."+std::to_string(i)).c_str(), |
1332 | 164 | ("uri://result."+std::to_string(i)).c_str(), | 196 | ("uri://result."+std::to_string(i)).c_str(), |
1333 | 165 | hints); | 197 | hints); |
1334 | 166 | } | 198 | } |
1335 | 167 | g_variant_unref(hints); | ||
1336 | 168 | return results_model; | 199 | return results_model; |
1338 | 169 | } | 200 | } |
1339 | 170 | 201 | ||
1340 | === modified file 'tests/mocks/Unity/fake_scope.h' | |||
1341 | --- tests/mocks/Unity/fake_scope.h 2013-06-12 15:03:07 +0000 | |||
1342 | +++ tests/mocks/Unity/fake_scope.h 2013-07-05 12:05:30 +0000 | |||
1343 | @@ -19,43 +19,75 @@ | |||
1344 | 19 | 19 | ||
1345 | 20 | // Qt | 20 | // Qt |
1346 | 21 | #include <QObject> | 21 | #include <QObject> |
1348 | 22 | #include "categories.h" | 22 | #include "fake_categories.h" |
1349 | 23 | 23 | ||
1350 | 24 | class Scope : public QObject | 24 | class Scope : public QObject |
1351 | 25 | { | 25 | { |
1352 | 26 | Q_OBJECT | 26 | Q_OBJECT |
1353 | 27 | |||
1354 | 27 | Q_PROPERTY(QString id READ id NOTIFY idChanged) | 28 | Q_PROPERTY(QString id READ id NOTIFY idChanged) |
1357 | 28 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) | 29 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) |
1358 | 29 | Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged) | 30 | Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged) |
1359 | 31 | Q_PROPERTY(QString description READ description NOTIFY descriptionChanged) | ||
1360 | 32 | Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged) | ||
1361 | 30 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) | 33 | Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged) |
1362 | 34 | Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged) | ||
1363 | 35 | Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) | ||
1364 | 31 | Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged) | 36 | Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged) |
1365 | 32 | 37 | ||
1366 | 38 | Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged) | ||
1367 | 39 | Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged) | ||
1368 | 40 | Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged) | ||
1369 | 41 | |||
1370 | 33 | public: | 42 | public: |
1371 | 34 | Scope(QObject* parent = 0); | 43 | Scope(QObject* parent = 0); |
1372 | 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); |
1373 | 36 | 45 | ||
1374 | 46 | /* getters */ | ||
1375 | 37 | QString id() const; | 47 | QString id() const; |
1376 | 38 | QString name() const; | 48 | QString name() const; |
1378 | 39 | QString searchQuery() const; | 49 | QString iconHint() const; |
1379 | 50 | QString description() const; | ||
1380 | 51 | QString searchHint() const; | ||
1381 | 40 | bool visible() const; | 52 | bool visible() const; |
1386 | 41 | 53 | QString shortcut() const; | |
1387 | 42 | void setName(const QString &str); | 54 | bool connected() const; |
1384 | 43 | void setSearchQuery(const QString &str); | ||
1385 | 44 | |||
1388 | 45 | Categories* categories() const; | 55 | Categories* categories() const; |
1389 | 56 | QString searchQuery() const; | ||
1390 | 57 | QString noResultsHint() const; | ||
1391 | 58 | QString formFactor() const; | ||
1392 | 59 | |||
1393 | 60 | /* setters */ | ||
1394 | 61 | void setName(const QString& name); | ||
1395 | 62 | void setSearchQuery(const QString& search_query); | ||
1396 | 63 | void setNoResultsHint(const QString& hint); | ||
1397 | 64 | void setFormFactor(const QString& form_factor); | ||
1398 | 46 | 65 | ||
1399 | 47 | Q_SIGNALS: | 66 | Q_SIGNALS: |
1403 | 48 | void idChanged(QString); | 67 | void idChanged(const QString&); |
1404 | 49 | void nameChanged(QString); | 68 | void nameChanged(const QString&); |
1405 | 50 | void searchQueryChanged(QString); | 69 | void iconHintChanged(const QString&); |
1406 | 70 | void descriptionChanged(const QString&); | ||
1407 | 71 | void searchHintChanged(const QString&); | ||
1408 | 51 | void visibleChanged(bool); | 72 | void visibleChanged(bool); |
1409 | 73 | void shortcutChanged(const QString&); | ||
1410 | 74 | void connectedChanged(bool); | ||
1411 | 52 | void categoriesChanged(); | 75 | void categoriesChanged(); |
1412 | 76 | void searchFinished(const QString&); | ||
1413 | 77 | void searchQueryChanged(); | ||
1414 | 78 | void noResultsHintChanged(); | ||
1415 | 79 | void formFactorChanged(); | ||
1416 | 53 | 80 | ||
1417 | 54 | private: | 81 | private: |
1418 | 55 | QString m_id; | 82 | QString m_id; |
1419 | 83 | QString m_iconHint; | ||
1420 | 84 | QString m_description; | ||
1421 | 56 | QString m_name; | 85 | QString m_name; |
1422 | 57 | QString m_searchQuery; | 86 | QString m_searchQuery; |
1423 | 87 | QString m_noResultsHint; | ||
1424 | 88 | QString m_formFactor; | ||
1425 | 58 | bool m_visible; | 89 | bool m_visible; |
1426 | 90 | |||
1427 | 59 | Categories* m_categories; | 91 | Categories* m_categories; |
1428 | 60 | DeeListModel* m_results; | 92 | DeeListModel* m_results; |
1429 | 61 | }; | 93 | }; |
1430 | 62 | 94 | ||
1431 | === modified file 'tests/mocks/Unity/fake_unity_plugin.cpp' | |||
1432 | --- tests/mocks/Unity/fake_unity_plugin.cpp 2013-06-12 15:03:07 +0000 | |||
1433 | +++ tests/mocks/Unity/fake_unity_plugin.cpp 2013-07-05 12:05:30 +0000 | |||
1434 | @@ -21,8 +21,8 @@ | |||
1435 | 21 | 21 | ||
1436 | 22 | // local | 22 | // local |
1437 | 23 | #include "fake_scopes.h" | 23 | #include "fake_scopes.h" |
1440 | 24 | #include "categories.h" | 24 | #include "fake_categories.h" |
1441 | 25 | #include "categoryfilter.h" | 25 | #include "categoryresults.h" |
1442 | 26 | #include "fake_launchermodel.h" | 26 | #include "fake_launchermodel.h" |
1443 | 27 | 27 | ||
1444 | 28 | // External | 28 | // External |
1445 | @@ -40,7 +40,7 @@ | |||
1446 | 40 | qmlRegisterType<Scopes>(uri, 0, 1, "Scopes"); | 40 | qmlRegisterType<Scopes>(uri, 0, 1, "Scopes"); |
1447 | 41 | qmlRegisterType<Scope>(uri, 0, 1, "Scope"); | 41 | qmlRegisterType<Scope>(uri, 0, 1, "Scope"); |
1448 | 42 | qmlRegisterType<Categories>(uri, 0, 1, "Categories"); | 42 | qmlRegisterType<Categories>(uri, 0, 1, "Categories"); |
1450 | 43 | qmlRegisterType<CategoryFilter>(uri, 0, 1, "CategoryFilter"); | 43 | qmlRegisterUncreatableType<CategoryResults>(uri, 0, 1, "CategoryResults", "Can't create"); |
1451 | 44 | qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel"); | 44 | qmlRegisterType<LauncherModel>(uri, 0, 1, "LauncherModel"); |
1452 | 45 | qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create"); | 45 | qmlRegisterUncreatableType<LauncherItem>(uri, 0, 1, "LauncherItem", "Can't create"); |
1453 | 46 | } | 46 | } |
1454 | 47 | 47 | ||
1455 | === modified file 'tests/plugins/Unity/CMakeLists.txt' | |||
1456 | --- tests/plugins/Unity/CMakeLists.txt 2013-06-28 14:01:56 +0000 | |||
1457 | +++ tests/plugins/Unity/CMakeLists.txt 2013-07-05 12:05:30 +0000 | |||
1458 | @@ -21,7 +21,7 @@ | |||
1459 | 21 | add_executable(${_test}Exec ${_test}.cpp previewbindingstest.cpp) | 21 | add_executable(${_test}Exec ${_test}.cpp previewbindingstest.cpp) |
1460 | 22 | qt5_use_modules(${_test}Exec Test Core Qml) | 22 | qt5_use_modules(${_test}Exec Test Core Qml) |
1461 | 23 | set_tests_properties(test${CLASSNAME}${_test} | 23 | set_tests_properties(test${CLASSNAME}${_test} |
1463 | 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}") |
1464 | 25 | 25 | ||
1465 | 26 | target_link_libraries(${_test}Exec | 26 | target_link_libraries(${_test}Exec |
1466 | 27 | Unity-qml | 27 | Unity-qml |
1467 | 28 | 28 | ||
1468 | === modified file 'tests/qmltests/Dash/qml/FakeScopeView.qml' | |||
1469 | --- tests/qmltests/Dash/qml/FakeScopeView.qml 2013-06-13 13:15:36 +0000 | |||
1470 | +++ tests/qmltests/Dash/qml/FakeScopeView.qml 2013-07-05 12:05:30 +0000 | |||
1471 | @@ -107,10 +107,10 @@ | |||
1472 | 107 | Image { | 107 | Image { |
1473 | 108 | width: units.gu(5) | 108 | width: units.gu(5) |
1474 | 109 | height: units.gu(5) | 109 | height: units.gu(5) |
1476 | 110 | source: column_1 | 110 | source: icon |
1477 | 111 | anchors.horizontalCenter: parent.horizontalCenter | 111 | anchors.horizontalCenter: parent.horizontalCenter |
1478 | 112 | } | 112 | } |
1480 | 113 | Text { text: column_4; anchors.horizontalCenter: parent.horizontalCenter } | 113 | Text { text: title; anchors.horizontalCenter: parent.horizontalCenter } |
1481 | 114 | } | 114 | } |
1482 | 115 | } | 115 | } |
1483 | 116 | } | 116 | } |
FAILED: Continuous integration, rev:48 jenkins. qa.ubuntu. com/job/ unity8- ci/23/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- saucy/488/ console jenkins. qa.ubuntu. com/job/ unity-phablet- qmluitests- saucy/274/ console jenkins. qa.ubuntu. com/job/ unity8- saucy-armhf- ci/23/console jenkins. qa.ubuntu. com/job/ unity8- saucy-i386- ci/23/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy/490/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity8- ci/23/rebuild
http://