Merge lp:~stolowski/unity-scopes-shell/single-preview into lp:unity-scopes-shell
- single-preview
- Merge into trunk
Proposed by
Paweł Stołowski
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~stolowski/unity-scopes-shell/single-preview | ||||
Merge into: | lp:unity-scopes-shell | ||||
Diff against target: |
1456 lines (+299/-517) 23 files modified
CMakeLists.txt (+1/-1) debian/HARNESS_VERSION (+1/-1) debian/control.in (+2/-1) debian/libscope-harness.symbols.in (+1/-2) po/POTFILES.in (+3/-2) src/Unity/CMakeLists.txt (+0/-2) src/Unity/collectors.h (+1/-1) src/Unity/plugin.cpp (+1/-3) src/Unity/previewmodel.cpp (+199/-0) src/Unity/previewmodel.h (+22/-0) src/Unity/previewstack.cpp (+0/-338) src/Unity/previewstack.h (+0/-94) src/Unity/scope.cpp (+34/-14) src/Unity/scope.h (+7/-4) src/scope-harness/internal/preview-widget-arguments.h (+0/-3) src/scope-harness/preview/preview-widget.cpp (+5/-9) src/scope-harness/results/result.cpp (+5/-5) src/scope-harness/test-utils.cpp (+0/-13) src/scope-harness/test-utils.h (+0/-3) src/scope-harness/view/preview-view.cpp (+15/-17) src/scope-harness/view/preview-view.h (+2/-2) tests/overviewtest.cpp (+0/-1) tests/previewtest.cpp (+0/-1) |
||||
To merge this branch: | bzr merge lp:~stolowski/unity-scopes-shell/single-preview | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Albert Astals Cid (community) | Needs Fixing | ||
Review via email: mp+286360@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-02-18.
Commit message
Removed preview stack. Return single preview model from Scope.
Description of the change
Removed preview stack. Return single preview model from Scope.
The corresponding unity api change: https:/
To post a comment you must log in.
- 289. By Paweł Stołowski
-
Merged trunk
- 290. By Paweł Stołowski
-
Require new API
- 291. By Paweł Stołowski
-
Updated scope harness symbols file
Revision history for this message
Albert Astals Cid (aacid) wrote : | # |
Looks good otherwise
- 292. By Paweł Stołowski
-
Reverted accidental change to generated debian/control file
Revision history for this message
Paweł Stołowski (stolowski) wrote : | # |
> bring back the top warning to debian/control ?
Ah, right, this file is generated, I shouldn't have commited it. Fixed, thanks for spotting.
- 293. By Paweł Stołowski
-
Merged activation-progress
- 294. By Paweł Stołowski
-
Debug message when preview model gets destroyed
Unmerged revisions
- 285. By Launchpad Translations on behalf of unity-team
-
Launchpad automatic translations update.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-11-30 09:23:32 +0000 | |||
3 | +++ CMakeLists.txt 2016-02-18 15:46:36 +0000 | |||
4 | @@ -51,7 +51,7 @@ | |||
5 | 51 | find_package(Boost COMPONENTS regex REQUIRED) | 51 | find_package(Boost COMPONENTS regex REQUIRED) |
6 | 52 | 52 | ||
7 | 53 | pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=1.0.1) | 53 | pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=1.0.1) |
9 | 54 | pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=9) | 54 | pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=10) |
10 | 55 | 55 | ||
11 | 56 | pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt) | 56 | pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt) |
12 | 57 | pkg_check_modules(UBUNTU_LOCATION_SERVICE REQUIRED ubuntu-location-service) | 57 | pkg_check_modules(UBUNTU_LOCATION_SERVICE REQUIRED ubuntu-location-service) |
13 | 58 | 58 | ||
14 | === modified file 'debian/HARNESS_VERSION' | |||
15 | --- debian/HARNESS_VERSION 2015-09-17 10:10:40 +0000 | |||
16 | +++ debian/HARNESS_VERSION 2016-02-18 15:46:36 +0000 | |||
17 | @@ -1,1 +1,1 @@ | |||
19 | 1 | 1.1.0 | 1 | 2.1.0 |
20 | 2 | 2 | ||
21 | === modified file 'debian/control.in' | |||
22 | --- debian/control.in 2015-12-15 15:22:10 +0000 | |||
23 | +++ debian/control.in 2016-02-18 15:46:36 +0000 | |||
24 | @@ -8,7 +8,7 @@ | |||
25 | 8 | dh-python, | 8 | dh-python, |
26 | 9 | libboost-python-dev, | 9 | libboost-python-dev, |
27 | 10 | libboost-regex-dev, | 10 | libboost-regex-dev, |
29 | 11 | libunity-api-dev (>= 7.105), | 11 | libunity-api-dev (>= 7.107), |
30 | 12 | libunity-scopes-dev (>= 1.0.1~), | 12 | libunity-scopes-dev (>= 1.0.1~), |
31 | 13 | libgsettings-qt-dev (>= 0.1), | 13 | libgsettings-qt-dev (>= 0.1), |
32 | 14 | libqtdbustest1-dev (>= 0.2), | 14 | libqtdbustest1-dev (>= 0.2), |
33 | @@ -50,6 +50,7 @@ | |||
34 | 50 | unity-scopes-impl-7, | 50 | unity-scopes-impl-7, |
35 | 51 | unity-scopes-impl-8, | 51 | unity-scopes-impl-8, |
36 | 52 | unity-scopes-impl-9, | 52 | unity-scopes-impl-9, |
37 | 53 | unity-scopes-impl-10, | ||
38 | 53 | Breaks: unity8-private (<< 7.84), | 54 | Breaks: unity8-private (<< 7.84), |
39 | 54 | unity8 (<< 8.11) | 55 | unity8 (<< 8.11) |
40 | 55 | Replaces: unity8-private (<< 7.84) | 56 | Replaces: unity8-private (<< 7.84) |
41 | 56 | 57 | ||
42 | === modified file 'debian/libscope-harness.symbols.in' | |||
43 | --- debian/libscope-harness.symbols.in 2015-11-11 09:31:48 +0000 | |||
44 | +++ debian/libscope-harness.symbols.in 2016-02-18 15:46:36 +0000 | |||
45 | @@ -1,4 +1,5 @@ | |||
46 | 1 | libscope-harness.so.@HARNESS_SO_VERSION@ libscope-harness@HARNESS_SO_VERSION@ #MINVER# | 1 | libscope-harness.so.@HARNESS_SO_VERSION@ libscope-harness@HARNESS_SO_VERSION@ #MINVER# |
47 | 2 | (c++)"unity::scopeharness::view::PreviewView::preview(std::shared_ptr<unity::shell::scopes::PreviewModelInterface>)@Base" 0replaceme | ||
48 | 2 | (c++)"typeinfo for unity::scopeharness::registry::CustomRegistry@Base" 0.5.4+15.04.20150311.3 | 3 | (c++)"typeinfo for unity::scopeharness::registry::CustomRegistry@Base" 0.5.4+15.04.20150311.3 |
49 | 3 | (c++)"typeinfo for unity::scopeharness::registry::PreExistingRegistry@Base" 0.5.4+15.04.20150311.3 | 4 | (c++)"typeinfo for unity::scopeharness::registry::PreExistingRegistry@Base" 0.5.4+15.04.20150311.3 |
50 | 4 | (c++)"typeinfo for unity::scopeharness::registry::Registry@Base" 0.5.4+15.04.20150311.3 | 5 | (c++)"typeinfo for unity::scopeharness::registry::Registry@Base" 0.5.4+15.04.20150311.3 |
51 | @@ -264,7 +265,6 @@ | |||
52 | 264 | (c++)"unity::scopeharness::TestUtils::getFavoriteScopes()@Base" 0.5.4+15.04.20150311.3 | 265 | (c++)"unity::scopeharness::TestUtils::getFavoriteScopes()@Base" 0.5.4+15.04.20150311.3 |
53 | 265 | (c++)"unity::scopeharness::TestUtils::getFirstResult(unity::shell::scopes::CategoriesInterface*, std::shared_ptr<unity::scopes::Result>&)@Base" 0.5.4+15.04.20150311.3 | 266 | (c++)"unity::scopeharness::TestUtils::getFirstResult(unity::shell::scopes::CategoriesInterface*, std::shared_ptr<unity::scopes::Result>&)@Base" 0.5.4+15.04.20150311.3 |
54 | 266 | (c++)"unity::scopeharness::TestUtils::performSearch(QSharedPointer<unity::shell::scopes::ScopeInterface>, QString const&)@Base" 0.5.4+15.04.20150311.3 | 267 | (c++)"unity::scopeharness::TestUtils::performSearch(QSharedPointer<unity::shell::scopes::ScopeInterface>, QString const&)@Base" 0.5.4+15.04.20150311.3 |
55 | 267 | (c++)"unity::scopeharness::TestUtils::previewForFirstResult(QSharedPointer<scopes_ng::Scope>, QString const&, QScopedPointer<scopes_ng::PreviewStack, QScopedPointerDeleter<scopes_ng::PreviewStack> >&)@Base" 0.5.4+15.04.20150311.3 | ||
56 | 268 | (c++)"unity::scopeharness::TestUtils::refreshSearch(QSharedPointer<scopes_ng::Scope>)@Base" 0.5.4+15.04.20150311.3 | 268 | (c++)"unity::scopeharness::TestUtils::refreshSearch(QSharedPointer<scopes_ng::Scope>)@Base" 0.5.4+15.04.20150311.3 |
57 | 269 | (c++)"unity::scopeharness::TestUtils::setFavouriteScopes(QStringList const&)@Base" 0.5.4+15.04.20150311.3 | 269 | (c++)"unity::scopeharness::TestUtils::setFavouriteScopes(QStringList const&)@Base" 0.5.4+15.04.20150311.3 |
58 | 270 | (c++)"unity::scopeharness::TestUtils::throwIf(bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.5.4+15.04.20150311.3 | 270 | (c++)"unity::scopeharness::TestUtils::throwIf(bool, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.5.4+15.04.20150311.3 |
59 | @@ -273,7 +273,6 @@ | |||
60 | 273 | (c++)"unity::scopeharness::TestUtils::waitForSearchFinish(QSharedPointer<unity::shell::scopes::ScopeInterface>)@Base" 0.5.4+15.04.20150311.3 | 273 | (c++)"unity::scopeharness::TestUtils::waitForSearchFinish(QSharedPointer<unity::shell::scopes::ScopeInterface>)@Base" 0.5.4+15.04.20150311.3 |
61 | 274 | (c++)"unity::scopeharness::view::AbstractView::~AbstractView()@Base" 0.5.4+15.04.20150311.3 | 274 | (c++)"unity::scopeharness::view::AbstractView::~AbstractView()@Base" 0.5.4+15.04.20150311.3 |
62 | 275 | (c++)"unity::scopeharness::view::PreviewView::columnCount() const@Base" 0.5.4+15.04.20150311.3 | 275 | (c++)"unity::scopeharness::view::PreviewView::columnCount() const@Base" 0.5.4+15.04.20150311.3 |
63 | 276 | (c++)"unity::scopeharness::view::PreviewView::preview(std::shared_ptr<unity::shell::scopes::PreviewStackInterface>)@Base" 0.5.4+15.04.20150311.3 | ||
64 | 277 | (c++)"unity::scopeharness::view::PreviewView::~PreviewView()@Base" 0.5.4+15.04.20150311.3 | 276 | (c++)"unity::scopeharness::view::PreviewView::~PreviewView()@Base" 0.5.4+15.04.20150311.3 |
65 | 278 | (c++)"unity::scopeharness::view::PreviewView::PreviewView()@Base" 0.5.4+15.04.20150311.3 | 277 | (c++)"unity::scopeharness::view::PreviewView::PreviewView()@Base" 0.5.4+15.04.20150311.3 |
66 | 279 | (c++)"unity::scopeharness::view::PreviewView::refresh()@Base" 0.5.4+15.04.20150311.3 | 278 | (c++)"unity::scopeharness::view::PreviewView::refresh()@Base" 0.5.4+15.04.20150311.3 |
67 | 280 | 279 | ||
68 | === modified file 'po/POTFILES.in' | |||
69 | --- po/POTFILES.in 2015-10-21 10:47:17 +0000 | |||
70 | +++ po/POTFILES.in 2016-02-18 15:46:36 +0000 | |||
71 | @@ -14,6 +14,7 @@ | |||
72 | 14 | tests/data/mock-scope-departments-flipflop/mock-scope-departments-flipflop.cpp | 14 | tests/data/mock-scope-departments-flipflop/mock-scope-departments-flipflop.cpp |
73 | 15 | tests/data/mock-scope/mock-scope.cpp | 15 | tests/data/mock-scope/mock-scope.cpp |
74 | 16 | tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp | 16 | tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp |
75 | 17 | tests/data/mock-scope-manyresults/mock-scope-manyresults.cpp | ||
76 | 17 | tests/settingstest.cpp | 18 | tests/settingstest.cpp |
77 | 18 | src/scope-harness/registry/system-registry.cpp | 19 | src/scope-harness/registry/system-registry.cpp |
78 | 19 | src/scope-harness/registry/pre-existing-registry.cpp | 20 | src/scope-harness/registry/pre-existing-registry.cpp |
79 | @@ -72,11 +73,11 @@ | |||
80 | 72 | src/Unity/scopes.cpp | 73 | src/Unity/scopes.cpp |
81 | 73 | src/Unity/settingsmodel.cpp | 74 | src/Unity/settingsmodel.cpp |
82 | 74 | src/Unity/utils.cpp | 75 | src/Unity/utils.cpp |
83 | 76 | src/Unity/resultsmap.cpp | ||
84 | 75 | src/Unity/locationservice.cpp | 77 | src/Unity/locationservice.cpp |
85 | 76 | src/Unity/ubuntulocationservice.cpp | 78 | src/Unity/ubuntulocationservice.cpp |
86 | 77 | src/Unity/iconutils.cpp | 79 | src/Unity/iconutils.cpp |
87 | 78 | src/Unity/department.cpp | 80 | src/Unity/department.cpp |
88 | 79 | src/Unity/previewstack.cpp | ||
89 | 80 | src/Unity/categories.cpp | 81 | src/Unity/categories.cpp |
90 | 81 | src/Unity/overviewresults.cpp | 82 | src/Unity/overviewresults.cpp |
91 | 82 | src/Unity/resultsmodel.cpp | 83 | src/Unity/resultsmodel.cpp |
92 | @@ -125,7 +126,6 @@ | |||
93 | 125 | src/Unity/plugin.h | 126 | src/Unity/plugin.h |
94 | 126 | src/Unity/department.h | 127 | src/Unity/department.h |
95 | 127 | src/Unity/scope.h | 128 | src/Unity/scope.h |
96 | 128 | src/Unity/previewstack.h | ||
97 | 129 | src/Unity/logintoaccount.h | 129 | src/Unity/logintoaccount.h |
98 | 130 | src/Unity/overviewcategories.h | 130 | src/Unity/overviewcategories.h |
99 | 131 | src/Unity/locationservice.h | 131 | src/Unity/locationservice.h |
100 | @@ -133,6 +133,7 @@ | |||
101 | 133 | src/Unity/settingsmodel.h | 133 | src/Unity/settingsmodel.h |
102 | 134 | src/Unity/resultsmodel.h | 134 | src/Unity/resultsmodel.h |
103 | 135 | src/Unity/geoip.h | 135 | src/Unity/geoip.h |
104 | 136 | src/Unity/resultsmap.h | ||
105 | 136 | src/Unity/collectors.h | 137 | src/Unity/collectors.h |
106 | 137 | src/Unity/previewwidgetmodel.h | 138 | src/Unity/previewwidgetmodel.h |
107 | 138 | src/Unity/categories.h | 139 | src/Unity/categories.h |
108 | 139 | 140 | ||
109 | === modified file 'src/Unity/CMakeLists.txt' | |||
110 | --- src/Unity/CMakeLists.txt 2015-10-21 10:47:17 +0000 | |||
111 | +++ src/Unity/CMakeLists.txt 2016-02-18 15:46:36 +0000 | |||
112 | @@ -27,7 +27,6 @@ | |||
113 | 27 | overviewresults.cpp | 27 | overviewresults.cpp |
114 | 28 | overviewscope.cpp | 28 | overviewscope.cpp |
115 | 29 | previewmodel.cpp | 29 | previewmodel.cpp |
116 | 30 | previewstack.cpp | ||
117 | 31 | previewwidgetmodel.cpp | 30 | previewwidgetmodel.cpp |
118 | 32 | resultsmap.cpp | 31 | resultsmap.cpp |
119 | 33 | resultsmodel.cpp | 32 | resultsmodel.cpp |
120 | @@ -43,7 +42,6 @@ | |||
121 | 43 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h | 42 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h |
122 | 44 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h | 43 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h |
123 | 45 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h | 44 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h |
124 | 46 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h | ||
125 | 47 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h | 45 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h |
126 | 48 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h | 46 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h |
127 | 49 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h | 47 | ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h |
128 | 50 | 48 | ||
129 | === modified file 'src/Unity/collectors.h' | |||
130 | --- src/Unity/collectors.h 2015-10-05 12:29:55 +0000 | |||
131 | +++ src/Unity/collectors.h 2016-02-18 15:46:36 +0000 | |||
132 | @@ -71,7 +71,7 @@ | |||
133 | 71 | public: | 71 | public: |
134 | 72 | static const QEvent::Type eventType; | 72 | static const QEvent::Type eventType; |
135 | 73 | 73 | ||
137 | 74 | enum Type { SEARCH, PREVIEW, ACTIVATION }; | 74 | enum Type { SEARCH = QEvent::User, PREVIEW, ACTIVATION }; |
138 | 75 | 75 | ||
139 | 76 | PushEvent(Type event_type, const std::shared_ptr<CollectorBase>& collector); | 76 | PushEvent(Type event_type, const std::shared_ptr<CollectorBase>& collector); |
140 | 77 | Type type(); | 77 | Type type(); |
141 | 78 | 78 | ||
142 | === modified file 'src/Unity/plugin.cpp' | |||
143 | --- src/Unity/plugin.cpp 2015-10-28 08:41:55 +0000 | |||
144 | +++ src/Unity/plugin.cpp 2016-02-18 15:46:36 +0000 | |||
145 | @@ -29,7 +29,6 @@ | |||
146 | 29 | #include "categories.h" | 29 | #include "categories.h" |
147 | 30 | #include "department.h" | 30 | #include "department.h" |
148 | 31 | #include "resultsmodel.h" | 31 | #include "resultsmodel.h" |
149 | 32 | #include "previewstack.h" | ||
150 | 33 | #include "previewmodel.h" | 32 | #include "previewmodel.h" |
151 | 34 | #include "previewwidgetmodel.h" | 33 | #include "previewwidgetmodel.h" |
152 | 35 | #include "settingsmodel.h" | 34 | #include "settingsmodel.h" |
153 | @@ -48,9 +47,8 @@ | |||
154 | 48 | qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", QStringLiteral("Can't create Categories object in QML. Get them from Scope instance.")); | 47 | qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", QStringLiteral("Can't create Categories object in QML. Get them from Scope instance.")); |
155 | 49 | qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", QStringLiteral("Can't create Settings object in QML. Get them from Scope instance.")); | 48 | qmlRegisterUncreatableType<unity::shell::scopes::SettingsModelInterface>(uri, 0, 2, "Settings", QStringLiteral("Can't create Settings object in QML. Get them from Scope instance.")); |
156 | 50 | qmlRegisterUncreatableType<scopes_ng::ResultsModel>(uri, 0, 2, "ResultsModel", QStringLiteral("Can't create new ResultsModel in QML. Get them from Categories instance.")); | 49 | qmlRegisterUncreatableType<scopes_ng::ResultsModel>(uri, 0, 2, "ResultsModel", QStringLiteral("Can't create new ResultsModel in QML. Get them from Categories instance.")); |
158 | 51 | qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", QStringLiteral("Can't create new PreviewModel in QML. Get them from PreviewStack instance.")); | 50 | qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", QStringLiteral("Can't create new PreviewModel in QML. Get them from Scope instance.")); |
159 | 52 | qmlRegisterUncreatableType<scopes_ng::PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", QStringLiteral("Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.")); | 51 | qmlRegisterUncreatableType<scopes_ng::PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", QStringLiteral("Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.")); |
160 | 53 | qmlRegisterUncreatableType<unity::shell::scopes::PreviewStackInterface>(uri, 0, 2, "PreviewStack", QStringLiteral("Can't create new PreviewStack in QML. Get them from Scope instance.")); | ||
161 | 54 | } | 52 | } |
162 | 55 | 53 | ||
163 | 56 | void UnityPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | 54 | void UnityPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
164 | 57 | 55 | ||
165 | === modified file 'src/Unity/previewmodel.cpp' | |||
166 | --- src/Unity/previewmodel.cpp 2015-09-28 08:41:08 +0000 | |||
167 | +++ src/Unity/previewmodel.cpp 2016-02-18 15:46:36 +0000 | |||
168 | @@ -27,12 +27,16 @@ | |||
169 | 27 | #include "previewwidgetmodel.h" | 27 | #include "previewwidgetmodel.h" |
170 | 28 | #include "resultsmodel.h" | 28 | #include "resultsmodel.h" |
171 | 29 | #include "utils.h" | 29 | #include "utils.h" |
172 | 30 | #include "logintoaccount.h" | ||
173 | 30 | 31 | ||
174 | 31 | // Qt | 32 | // Qt |
175 | 32 | #include <QJsonDocument> | 33 | #include <QJsonDocument> |
176 | 33 | #include <QJsonObject> | 34 | #include <QJsonObject> |
177 | 34 | #include <QJsonValue> | 35 | #include <QJsonValue> |
178 | 35 | 36 | ||
179 | 37 | #include <unity/scopes/Scope.h> | ||
180 | 38 | #include <unity/scopes/ActionMetadata.h> | ||
181 | 39 | |||
182 | 36 | namespace scopes_ng | 40 | namespace scopes_ng |
183 | 37 | { | 41 | { |
184 | 38 | 42 | ||
185 | @@ -45,11 +49,24 @@ | |||
186 | 45 | m_delayedClear(false), | 49 | m_delayedClear(false), |
187 | 46 | m_widgetColumnCount(1) | 50 | m_widgetColumnCount(1) |
188 | 47 | { | 51 | { |
189 | 52 | connect(this, &PreviewModel::triggered, this, &PreviewModel::widgetTriggered); | ||
190 | 53 | |||
191 | 48 | // we have one column by default | 54 | // we have one column by default |
192 | 49 | PreviewWidgetModel* columnModel = new PreviewWidgetModel(this); | 55 | PreviewWidgetModel* columnModel = new PreviewWidgetModel(this); |
193 | 50 | m_previewWidgetModels.append(columnModel); | 56 | m_previewWidgetModels.append(columnModel); |
194 | 51 | } | 57 | } |
195 | 52 | 58 | ||
196 | 59 | PreviewModel::~PreviewModel() | ||
197 | 60 | { | ||
198 | 61 | if (m_listener) { | ||
199 | 62 | m_listener->invalidate(); | ||
200 | 63 | } | ||
201 | 64 | |||
202 | 65 | if (m_lastActivation) { | ||
203 | 66 | m_lastActivation->invalidate(); | ||
204 | 67 | } | ||
205 | 68 | } | ||
206 | 69 | |||
207 | 53 | void PreviewModel::setResult(std::shared_ptr<scopes::Result> const& result) | 70 | void PreviewModel::setResult(std::shared_ptr<scopes::Result> const& result) |
208 | 54 | { | 71 | { |
209 | 55 | m_previewedResult = result; | 72 | m_previewedResult = result; |
210 | @@ -64,6 +81,9 @@ | |||
211 | 64 | case PushEvent::PREVIEW: | 81 | case PushEvent::PREVIEW: |
212 | 65 | processPreviewChunk(pushEvent); | 82 | processPreviewChunk(pushEvent); |
213 | 66 | return true; | 83 | return true; |
214 | 84 | case PushEvent::ACTIVATION: | ||
215 | 85 | processActionResponse(pushEvent); | ||
216 | 86 | return true; | ||
217 | 67 | default: | 87 | default: |
218 | 68 | qWarning("PreviewModel: Unhandled PushEvent type"); | 88 | qWarning("PreviewModel: Unhandled PushEvent type"); |
219 | 69 | break; | 89 | break; |
220 | @@ -73,6 +93,18 @@ | |||
221 | 73 | return unity::shell::scopes::PreviewModelInterface::event(ev); | 93 | return unity::shell::scopes::PreviewModelInterface::event(ev); |
222 | 74 | } | 94 | } |
223 | 75 | 95 | ||
224 | 96 | void PreviewModel::setAssociatedScope(scopes_ng::Scope* scope, QUuid const& session_id, QString const& userAgent) | ||
225 | 97 | { | ||
226 | 98 | m_associatedScope = scope; | ||
227 | 99 | m_session_id = session_id; | ||
228 | 100 | m_userAgent = userAgent; | ||
229 | 101 | } | ||
230 | 102 | |||
231 | 103 | scopes_ng::Scope* PreviewModel::associatedScope() const | ||
232 | 104 | { | ||
233 | 105 | return m_associatedScope; | ||
234 | 106 | } | ||
235 | 107 | |||
236 | 76 | void PreviewModel::processPreviewChunk(PushEvent* pushEvent) | 108 | void PreviewModel::processPreviewChunk(PushEvent* pushEvent) |
237 | 77 | { | 109 | { |
238 | 78 | CollectorBase::Status status; | 110 | CollectorBase::Status status; |
239 | @@ -178,6 +210,26 @@ | |||
240 | 178 | return m_loaded; | 210 | return m_loaded; |
241 | 179 | } | 211 | } |
242 | 180 | 212 | ||
243 | 213 | void PreviewModel::loadForResult(scopes::Result::SPtr const& result) | ||
244 | 214 | { | ||
245 | 215 | m_previewedResult = result; | ||
246 | 216 | if (m_listener) { | ||
247 | 217 | m_listener->invalidate(); // TODO: is this needed? | ||
248 | 218 | } | ||
249 | 219 | |||
250 | 220 | dispatchPreview(); | ||
251 | 221 | } | ||
252 | 222 | |||
253 | 223 | unity::scopes::Result::SPtr PreviewModel::previewedResult() const | ||
254 | 224 | { | ||
255 | 225 | return m_previewedResult; | ||
256 | 226 | } | ||
257 | 227 | |||
258 | 228 | void PreviewModel::update(unity::scopes::PreviewWidgetList const& widgets) | ||
259 | 229 | { | ||
260 | 230 | updateWidgetDefinitions(widgets); | ||
261 | 231 | } | ||
262 | 232 | |||
263 | 181 | bool PreviewModel::processingAction() const | 233 | bool PreviewModel::processingAction() const |
264 | 182 | { | 234 | { |
265 | 183 | return m_processingAction; | 235 | return m_processingAction; |
266 | @@ -439,4 +491,151 @@ | |||
267 | 439 | } | 491 | } |
268 | 440 | } | 492 | } |
269 | 441 | 493 | ||
270 | 494 | void PreviewModel::dispatchPreview(scopes::Variant const& extra_data) | ||
271 | 495 | { | ||
272 | 496 | // TODO: figure out if the result can produce a preview without sending a request to the scope | ||
273 | 497 | // if (m_previewedResult->has_early_preview()) { ... } | ||
274 | 498 | try { | ||
275 | 499 | auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy(); | ||
276 | 500 | |||
277 | 501 | QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone")); | ||
278 | 502 | scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString()); | ||
279 | 503 | if (!extra_data.is_null()) { | ||
280 | 504 | metadata.set_scope_data(extra_data); | ||
281 | 505 | } | ||
282 | 506 | if (!m_session_id.isNull()) { | ||
283 | 507 | metadata["session-id"] = uuidToString(m_session_id).toStdString(); | ||
284 | 508 | } | ||
285 | 509 | if (!m_userAgent.isEmpty()) { | ||
286 | 510 | metadata["user-agent"] = m_userAgent.toStdString(); | ||
287 | 511 | } | ||
288 | 512 | |||
289 | 513 | std::shared_ptr<PreviewDataReceiver> listener(new PreviewDataReceiver(this)); | ||
290 | 514 | // invalidate previous listener (if any); TODO: is this needed? | ||
291 | 515 | if (m_listener) { | ||
292 | 516 | m_listener->invalidate(); | ||
293 | 517 | } | ||
294 | 518 | m_listener = listener; | ||
295 | 519 | |||
296 | 520 | m_lastPreviewQuery = proxy->preview(*(m_previewedResult.get()), metadata, listener); | ||
297 | 521 | } catch (std::exception& e) { | ||
298 | 522 | qWarning("Caught an error from preview(): %s", e.what()); | ||
299 | 523 | } catch (...) { | ||
300 | 524 | qWarning("Caught an error from preview()"); | ||
301 | 525 | } | ||
302 | 526 | } | ||
303 | 527 | |||
304 | 528 | void PreviewModel::widgetTriggered(QString const& widgetId, QString const& actionId, QVariantMap const& data) | ||
305 | 529 | { | ||
306 | 530 | auto action = [this, widgetId, actionId, data]() { | ||
307 | 531 | try { | ||
308 | 532 | auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy(); | ||
309 | 533 | |||
310 | 534 | QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone")); | ||
311 | 535 | scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString()); | ||
312 | 536 | metadata.set_scope_data(qVariantToScopeVariant(data)); | ||
313 | 537 | |||
314 | 538 | if (m_lastActivation) { | ||
315 | 539 | m_lastActivation->invalidate(); | ||
316 | 540 | } | ||
317 | 541 | std::shared_ptr<ActivationReceiver> listener(new ActivationReceiver(this, m_previewedResult)); | ||
318 | 542 | m_lastActivation = listener; | ||
319 | 543 | |||
320 | 544 | setProcessingAction(true); | ||
321 | 545 | |||
322 | 546 | // FIXME: don't block | ||
323 | 547 | proxy->perform_action(*(m_previewedResult.get()), metadata, widgetId.toStdString(), actionId.toStdString(), listener); | ||
324 | 548 | } catch (std::exception& e) { | ||
325 | 549 | qWarning("Caught an error from perform_action(%s, %s): %s", widgetId.toStdString().c_str(), actionId.toStdString().c_str(), e.what()); | ||
326 | 550 | } catch (...) { | ||
327 | 551 | qWarning("Caught an error from perform_action()"); | ||
328 | 552 | } | ||
329 | 553 | }; | ||
330 | 554 | |||
331 | 555 | PreviewWidgetData* widgetData = getWidgetData(widgetId); | ||
332 | 556 | if (widgetData != nullptr) { | ||
333 | 557 | QString wtype = widgetData->type; | ||
334 | 558 | auto uriAction = [this, wtype, data, action]() { | ||
335 | 559 | if ((wtype == QLatin1String("actions") || wtype == QLatin1String("icon-actions")) && data.contains(QStringLiteral("uri"))) { | ||
336 | 560 | if (m_associatedScope) { | ||
337 | 561 | m_associatedScope->activateUri(data.value(QStringLiteral("uri")).toString()); | ||
338 | 562 | return; | ||
339 | 563 | } | ||
340 | 564 | } | ||
341 | 565 | action(); | ||
342 | 566 | }; | ||
343 | 567 | |||
344 | 568 | if (m_associatedScope && widgetData->data.contains(QStringLiteral("online_account_details"))) | ||
345 | 569 | { | ||
346 | 570 | QVariantMap details = widgetData->data.value(QStringLiteral("online_account_details")).toMap(); | ||
347 | 571 | if (details.contains(QStringLiteral("service_name")) && | ||
348 | 572 | details.contains(QStringLiteral("service_type")) && | ||
349 | 573 | details.contains(QStringLiteral("provider_name")) && | ||
350 | 574 | details.contains(QStringLiteral("login_passed_action")) && | ||
351 | 575 | details.contains(QStringLiteral("login_failed_action"))) | ||
352 | 576 | { | ||
353 | 577 | LoginToAccount *login = new LoginToAccount(details.contains(QStringLiteral("scope_id")) ? details.value(QStringLiteral("scope_id")).toString() : QLatin1String(""), | ||
354 | 578 | details.value(QStringLiteral("service_name")).toString(), | ||
355 | 579 | details.value(QStringLiteral("service_type")).toString(), | ||
356 | 580 | details.value(QStringLiteral("provider_name")).toString(), | ||
357 | 581 | details.value(QStringLiteral("login_passed_action")).toInt(), | ||
358 | 582 | details.value(QStringLiteral("login_failed_action")).toInt(), | ||
359 | 583 | this); | ||
360 | 584 | connect(login, SIGNAL(searchInProgress(bool)), m_associatedScope, SLOT(setSearchInProgress(bool))); | ||
361 | 585 | connect(login, &LoginToAccount::finished, [this, login, uriAction](bool, int action_code_index) { | ||
362 | 586 | if (action_code_index >= 0 && action_code_index <= scopes::OnlineAccountClient::LastActionCode_) | ||
363 | 587 | { | ||
364 | 588 | scopes::OnlineAccountClient::PostLoginAction action_code = static_cast<scopes::OnlineAccountClient::PostLoginAction>(action_code_index); | ||
365 | 589 | switch (action_code) | ||
366 | 590 | { | ||
367 | 591 | case scopes::OnlineAccountClient::DoNothing: | ||
368 | 592 | return; | ||
369 | 593 | case scopes::OnlineAccountClient::InvalidateResults: | ||
370 | 594 | m_associatedScope->invalidateResults(); | ||
371 | 595 | return; | ||
372 | 596 | default: | ||
373 | 597 | break; | ||
374 | 598 | } | ||
375 | 599 | } | ||
376 | 600 | uriAction(); | ||
377 | 601 | login->deleteLater(); | ||
378 | 602 | }); | ||
379 | 603 | login->loginToAccount(); | ||
380 | 604 | return; // main execution ends here | ||
381 | 605 | } | ||
382 | 606 | } else { | ||
383 | 607 | uriAction(); | ||
384 | 608 | } | ||
385 | 609 | } else { | ||
386 | 610 | qWarning("Action triggered for unknown widget \"%s\"", widgetId.toStdString().c_str()); | ||
387 | 611 | } | ||
388 | 612 | } | ||
389 | 613 | |||
390 | 614 | void PreviewModel::processActionResponse(PushEvent* pushEvent) | ||
391 | 615 | { | ||
392 | 616 | std::shared_ptr<scopes::ActivationResponse> response; | ||
393 | 617 | scopes::Result::SPtr result; | ||
394 | 618 | QString categoryId; | ||
395 | 619 | pushEvent->collectActivationResponse(response, result, categoryId); | ||
396 | 620 | if (!response) return; | ||
397 | 621 | |||
398 | 622 | switch (response->status()) { | ||
399 | 623 | case scopes::ActivationResponse::ShowPreview: | ||
400 | 624 | // replace current preview | ||
401 | 625 | setDelayedClear(); | ||
402 | 626 | // the preview is marked as processing action, leave the flag on until the preview is updated | ||
403 | 627 | dispatchPreview(scopes::Variant(response->scope_data())); | ||
404 | 628 | break; | ||
405 | 629 | // TODO: case to nest preview (once such API is available) | ||
406 | 630 | default: | ||
407 | 631 | if (m_associatedScope) { | ||
408 | 632 | m_associatedScope->handleActivation(response, result); | ||
409 | 633 | } | ||
410 | 634 | |||
411 | 635 | setProcessingAction(false); | ||
412 | 636 | break; | ||
413 | 637 | } | ||
414 | 638 | } | ||
415 | 639 | |||
416 | 640 | |||
417 | 442 | } // namespace scopes_ng | 641 | } // namespace scopes_ng |
418 | 443 | 642 | ||
419 | === modified file 'src/Unity/previewmodel.h' | |||
420 | --- src/Unity/previewmodel.h 2015-08-14 12:29:16 +0000 | |||
421 | +++ src/Unity/previewmodel.h 2016-02-18 15:46:36 +0000 | |||
422 | @@ -29,11 +29,14 @@ | |||
423 | 29 | #include <QMultiMap> | 29 | #include <QMultiMap> |
424 | 30 | #include <QStringList> | 30 | #include <QStringList> |
425 | 31 | #include <QPointer> | 31 | #include <QPointer> |
426 | 32 | #include <QUuid> | ||
427 | 32 | 33 | ||
428 | 33 | #include <unity/scopes/PreviewWidget.h> | 34 | #include <unity/scopes/PreviewWidget.h> |
429 | 34 | #include <unity/scopes/Result.h> | 35 | #include <unity/scopes/Result.h> |
430 | 35 | #include <unity/scopes/ColumnLayout.h> | 36 | #include <unity/scopes/ColumnLayout.h> |
431 | 36 | 37 | ||
432 | 38 | #include "collectors.h" | ||
433 | 39 | |||
434 | 37 | namespace scopes_ng | 40 | namespace scopes_ng |
435 | 38 | { | 41 | { |
436 | 39 | 42 | ||
437 | @@ -60,6 +63,7 @@ | |||
438 | 60 | 63 | ||
439 | 61 | public: | 64 | public: |
440 | 62 | explicit PreviewModel(QObject* parent = 0); | 65 | explicit PreviewModel(QObject* parent = 0); |
441 | 66 | ~PreviewModel(); | ||
442 | 63 | 67 | ||
443 | 64 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | 68 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
444 | 65 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | 69 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
445 | @@ -80,7 +84,18 @@ | |||
446 | 80 | 84 | ||
447 | 81 | void updateWidgetDefinitions(unity::scopes::PreviewWidgetList const&); | 85 | void updateWidgetDefinitions(unity::scopes::PreviewWidgetList const&); |
448 | 82 | 86 | ||
449 | 87 | void loadForResult(unity::scopes::Result::SPtr const&); | ||
450 | 88 | void update(unity::scopes::PreviewWidgetList const&); | ||
451 | 89 | |||
452 | 90 | void setAssociatedScope(scopes_ng::Scope*, QUuid const&, QString const&); | ||
453 | 91 | scopes_ng::Scope* associatedScope() const; | ||
454 | 92 | unity::scopes::Result::SPtr previewedResult() const; | ||
455 | 93 | |||
456 | 94 | private Q_SLOTS: | ||
457 | 95 | void widgetTriggered(QString const&, QString const&, QVariantMap const&); | ||
458 | 96 | |||
459 | 83 | private: | 97 | private: |
460 | 98 | void processActionResponse(PushEvent* pushEvent); | ||
461 | 84 | void addWidgetDefinitions(unity::scopes::PreviewWidgetList const&); | 99 | void addWidgetDefinitions(unity::scopes::PreviewWidgetList const&); |
462 | 85 | void processWidgetDefinitions(unity::scopes::PreviewWidgetList const&, std::function<void(QSharedPointer<PreviewWidgetData>)> const& processFunc); | 100 | void processWidgetDefinitions(unity::scopes::PreviewWidgetList const&, std::function<void(QSharedPointer<PreviewWidgetData>)> const& processFunc); |
463 | 86 | void processPreviewChunk(PushEvent* pushEvent); | 101 | void processPreviewChunk(PushEvent* pushEvent); |
464 | @@ -89,6 +104,7 @@ | |||
465 | 89 | PreviewWidgetModel* createExpandableWidgetModel(unity::scopes::PreviewWidget const&, PreviewWidgetData &); | 104 | PreviewWidgetModel* createExpandableWidgetModel(unity::scopes::PreviewWidget const&, PreviewWidgetData &); |
466 | 90 | void addWidgetToColumnModel(QSharedPointer<PreviewWidgetData> const&); | 105 | void addWidgetToColumnModel(QSharedPointer<PreviewWidgetData> const&); |
467 | 91 | void processComponents(QHash<QString, QString> const& components, QVariantMap& out_attributes); | 106 | void processComponents(QHash<QString, QString> const& components, QVariantMap& out_attributes); |
468 | 107 | void dispatchPreview(unity::scopes::Variant const& extra_data = unity::scopes::Variant()); | ||
469 | 92 | 108 | ||
470 | 93 | bool m_loaded; | 109 | bool m_loaded; |
471 | 94 | bool m_processingAction; | 110 | bool m_processingAction; |
472 | @@ -100,7 +116,13 @@ | |||
473 | 100 | QList<QSharedPointer<PreviewWidgetData>> m_previewWidgets; | 116 | QList<QSharedPointer<PreviewWidgetData>> m_previewWidgets; |
474 | 101 | QMultiMap<QString, PreviewWidgetData*> m_dataToWidgetMap; | 117 | QMultiMap<QString, PreviewWidgetData*> m_dataToWidgetMap; |
475 | 102 | 118 | ||
476 | 119 | unity::scopes::QueryCtrlProxy m_lastPreviewQuery; | ||
477 | 120 | QPointer<scopes_ng::Scope> m_associatedScope; | ||
478 | 121 | QUuid m_session_id; | ||
479 | 122 | QString m_userAgent; | ||
480 | 103 | std::shared_ptr<unity::scopes::Result> m_previewedResult; | 123 | std::shared_ptr<unity::scopes::Result> m_previewedResult; |
481 | 124 | std::shared_ptr<ScopeDataReceiverBase> m_listener; | ||
482 | 125 | std::shared_ptr<ScopeDataReceiverBase> m_lastActivation; | ||
483 | 104 | }; | 126 | }; |
484 | 105 | 127 | ||
485 | 106 | } // namespace scopes_ng | 128 | } // namespace scopes_ng |
486 | 107 | 129 | ||
487 | === removed file 'src/Unity/previewstack.cpp' | |||
488 | --- src/Unity/previewstack.cpp 2015-10-21 10:47:17 +0000 | |||
489 | +++ src/Unity/previewstack.cpp 1970-01-01 00:00:00 +0000 | |||
490 | @@ -1,338 +0,0 @@ | |||
491 | 1 | /* | ||
492 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
493 | 3 | * | ||
494 | 4 | * Authors: | ||
495 | 5 | * Michał Sawicz <michal.sawicz@canonical.com> | ||
496 | 6 | * Michal Hruby <michal.hruby@canonical.com> | ||
497 | 7 | * | ||
498 | 8 | * This program is free software; you can redistribute it and/or modify | ||
499 | 9 | * it under the terms of the GNU General Public License as published by | ||
500 | 10 | * the Free Software Foundation; version 3. | ||
501 | 11 | * | ||
502 | 12 | * This program is distributed in the hope that it will be useful, | ||
503 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
504 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
505 | 15 | * GNU General Public License for more details. | ||
506 | 16 | * | ||
507 | 17 | * You should have received a copy of the GNU General Public License | ||
508 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
509 | 19 | */ | ||
510 | 20 | |||
511 | 21 | // self | ||
512 | 22 | #include "previewstack.h" | ||
513 | 23 | |||
514 | 24 | // local | ||
515 | 25 | #include "previewmodel.h" | ||
516 | 26 | #include "scope.h" | ||
517 | 27 | #include "utils.h" | ||
518 | 28 | #include "logintoaccount.h" | ||
519 | 29 | |||
520 | 30 | // Qt | ||
521 | 31 | #include <QLocale> | ||
522 | 32 | #include <QJsonDocument> | ||
523 | 33 | #include <QJsonObject> | ||
524 | 34 | #include <QJsonValue> | ||
525 | 35 | #include <QUuid> | ||
526 | 36 | #include <QPointer> | ||
527 | 37 | |||
528 | 38 | #include <unity/scopes/ActionMetadata.h> | ||
529 | 39 | #include <unity/scopes/Scope.h> | ||
530 | 40 | |||
531 | 41 | namespace scopes_ng | ||
532 | 42 | { | ||
533 | 43 | |||
534 | 44 | using namespace unity; | ||
535 | 45 | |||
536 | 46 | PreviewStack::PreviewStack(QObject* parent) | ||
537 | 47 | : unity::shell::scopes::PreviewStackInterface(parent) | ||
538 | 48 | , m_widgetColumnCount(1), m_activePreview(nullptr) | ||
539 | 49 | { | ||
540 | 50 | } | ||
541 | 51 | |||
542 | 52 | PreviewStack::~PreviewStack() | ||
543 | 53 | { | ||
544 | 54 | for (auto it = m_listeners.begin(); it != m_listeners.end(); ++it) { | ||
545 | 55 | auto listener = it.value().lock(); | ||
546 | 56 | if (listener) listener->invalidate(); | ||
547 | 57 | } | ||
548 | 58 | |||
549 | 59 | if (m_lastActivation) { | ||
550 | 60 | m_lastActivation->invalidate(); | ||
551 | 61 | } | ||
552 | 62 | } | ||
553 | 63 | |||
554 | 64 | bool PreviewStack::event(QEvent* ev) | ||
555 | 65 | { | ||
556 | 66 | if (ev->type() == PushEvent::eventType) { | ||
557 | 67 | PushEvent* pushEvent = static_cast<PushEvent*>(ev); | ||
558 | 68 | |||
559 | 69 | switch (pushEvent->type()) { | ||
560 | 70 | case PushEvent::ACTIVATION: | ||
561 | 71 | processActionResponse(pushEvent); | ||
562 | 72 | return true; | ||
563 | 73 | default: | ||
564 | 74 | qWarning("PreviewStack: Unhandled PushEvent type"); | ||
565 | 75 | break; | ||
566 | 76 | } | ||
567 | 77 | } | ||
568 | 78 | |||
569 | 79 | return unity::shell::scopes::PreviewStackInterface::event(ev); | ||
570 | 80 | } | ||
571 | 81 | |||
572 | 82 | void PreviewStack::setAssociatedScope(scopes_ng::Scope* scope, QUuid const& session_id, QString const& userAgent) | ||
573 | 83 | { | ||
574 | 84 | m_associatedScope = scope; | ||
575 | 85 | m_session_id = session_id; | ||
576 | 86 | m_userAgent = userAgent; | ||
577 | 87 | } | ||
578 | 88 | |||
579 | 89 | scopes_ng::Scope* PreviewStack::associatedScope() const | ||
580 | 90 | { | ||
581 | 91 | return m_associatedScope; | ||
582 | 92 | } | ||
583 | 93 | |||
584 | 94 | void PreviewStack::loadForResult(scopes::Result::SPtr const& result) | ||
585 | 95 | { | ||
586 | 96 | m_previewedResult = result; | ||
587 | 97 | |||
588 | 98 | beginResetModel(); | ||
589 | 99 | |||
590 | 100 | // invalidate all listeners | ||
591 | 101 | for (auto it = m_listeners.begin(); it != m_listeners.end(); ++it) { | ||
592 | 102 | auto listener = it.value().lock(); | ||
593 | 103 | if (listener) listener->invalidate(); | ||
594 | 104 | } | ||
595 | 105 | // clear any previews | ||
596 | 106 | while (!m_previews.empty()) { | ||
597 | 107 | delete m_previews.takeFirst(); | ||
598 | 108 | } | ||
599 | 109 | // create active preview | ||
600 | 110 | m_activePreview = new PreviewModel(this); | ||
601 | 111 | m_activePreview->setResult(m_previewedResult); | ||
602 | 112 | connect(m_activePreview, &PreviewModel::triggered, this, &PreviewStack::widgetTriggered); | ||
603 | 113 | m_previews.append(m_activePreview); | ||
604 | 114 | |||
605 | 115 | endResetModel(); | ||
606 | 116 | |||
607 | 117 | dispatchPreview(); | ||
608 | 118 | } | ||
609 | 119 | |||
610 | 120 | void PreviewStack::update(unity::scopes::PreviewWidgetList const& widgets) | ||
611 | 121 | { | ||
612 | 122 | if (m_activePreview == nullptr) { | ||
613 | 123 | return; | ||
614 | 124 | } | ||
615 | 125 | m_activePreview->updateWidgetDefinitions(widgets); | ||
616 | 126 | } | ||
617 | 127 | |||
618 | 128 | void PreviewStack::dispatchPreview(scopes::Variant const& extra_data) | ||
619 | 129 | { | ||
620 | 130 | // TODO: figure out if the result can produce a preview without sending a request to the scope | ||
621 | 131 | // if (m_previewedResult->has_early_preview()) { ... } | ||
622 | 132 | try { | ||
623 | 133 | auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy(); | ||
624 | 134 | |||
625 | 135 | QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone")); | ||
626 | 136 | scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString()); | ||
627 | 137 | if (!extra_data.is_null()) { | ||
628 | 138 | metadata.set_scope_data(extra_data); | ||
629 | 139 | } | ||
630 | 140 | if (!m_session_id.isNull()) { | ||
631 | 141 | metadata["session-id"] = uuidToString(m_session_id).toStdString(); | ||
632 | 142 | } | ||
633 | 143 | if (!m_userAgent.isEmpty()) { | ||
634 | 144 | metadata["user-agent"] = m_userAgent.toStdString(); | ||
635 | 145 | } | ||
636 | 146 | |||
637 | 147 | std::shared_ptr<PreviewDataReceiver> listener(new PreviewDataReceiver(m_activePreview)); | ||
638 | 148 | std::weak_ptr<ScopeDataReceiverBase> wl(listener); | ||
639 | 149 | // invalidate previous listener (if any) | ||
640 | 150 | auto prev_listener = m_listeners.take(m_activePreview).lock(); | ||
641 | 151 | if (prev_listener) prev_listener->invalidate(); | ||
642 | 152 | m_listeners[m_activePreview] = wl; | ||
643 | 153 | |||
644 | 154 | m_lastPreviewQuery = proxy->preview(*(m_previewedResult.get()), metadata, listener); | ||
645 | 155 | } catch (std::exception& e) { | ||
646 | 156 | qWarning("Caught an error from preview(): %s", e.what()); | ||
647 | 157 | } catch (...) { | ||
648 | 158 | qWarning("Caught an error from preview()"); | ||
649 | 159 | } | ||
650 | 160 | } | ||
651 | 161 | |||
652 | 162 | void PreviewStack::widgetTriggered(QString const& widgetId, QString const& actionId, QVariantMap const& data) | ||
653 | 163 | { | ||
654 | 164 | auto action = [this, widgetId, actionId, data]() { | ||
655 | 165 | try { | ||
656 | 166 | auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy(); | ||
657 | 167 | |||
658 | 168 | QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone")); | ||
659 | 169 | scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString()); | ||
660 | 170 | metadata.set_scope_data(qVariantToScopeVariant(data)); | ||
661 | 171 | |||
662 | 172 | if (m_lastActivation) { | ||
663 | 173 | m_lastActivation->invalidate(); | ||
664 | 174 | } | ||
665 | 175 | std::shared_ptr<ActivationReceiver> listener(new ActivationReceiver(this, m_previewedResult)); | ||
666 | 176 | m_lastActivation = listener; | ||
667 | 177 | |||
668 | 178 | // should be always coming from active preview | ||
669 | 179 | if (m_activePreview) { | ||
670 | 180 | m_activePreview->setProcessingAction(true); | ||
671 | 181 | } | ||
672 | 182 | |||
673 | 183 | // FIXME: don't block | ||
674 | 184 | proxy->perform_action(*(m_previewedResult.get()), metadata, widgetId.toStdString(), actionId.toStdString(), listener); | ||
675 | 185 | } catch (std::exception& e) { | ||
676 | 186 | qWarning("Caught an error from perform_action(%s, %s): %s", widgetId.toStdString().c_str(), actionId.toStdString().c_str(), e.what()); | ||
677 | 187 | } catch (...) { | ||
678 | 188 | qWarning("Caught an error from perform_action()"); | ||
679 | 189 | } | ||
680 | 190 | }; | ||
681 | 191 | |||
682 | 192 | PreviewModel* previewModel = qobject_cast<scopes_ng::PreviewModel*>(sender()); | ||
683 | 193 | if (previewModel != nullptr) { | ||
684 | 194 | PreviewWidgetData* widgetData = previewModel->getWidgetData(widgetId); | ||
685 | 195 | if (widgetData != nullptr) { | ||
686 | 196 | QString wtype = widgetData->type; | ||
687 | 197 | auto uriAction = [this, wtype, data, action]() { | ||
688 | 198 | if ((wtype == QLatin1String("actions") || wtype == QLatin1String("icon-actions")) && data.contains(QStringLiteral("uri"))) { | ||
689 | 199 | if (m_associatedScope) { | ||
690 | 200 | m_associatedScope->activateUri(data.value(QStringLiteral("uri")).toString()); | ||
691 | 201 | return; | ||
692 | 202 | } | ||
693 | 203 | } | ||
694 | 204 | action(); | ||
695 | 205 | }; | ||
696 | 206 | |||
697 | 207 | if (m_associatedScope && widgetData->data.contains(QStringLiteral("online_account_details"))) | ||
698 | 208 | { | ||
699 | 209 | QVariantMap details = widgetData->data.value(QStringLiteral("online_account_details")).toMap(); | ||
700 | 210 | if (details.contains(QStringLiteral("service_name")) && | ||
701 | 211 | details.contains(QStringLiteral("service_type")) && | ||
702 | 212 | details.contains(QStringLiteral("provider_name")) && | ||
703 | 213 | details.contains(QStringLiteral("login_passed_action")) && | ||
704 | 214 | details.contains(QStringLiteral("login_failed_action"))) | ||
705 | 215 | { | ||
706 | 216 | LoginToAccount *login = new LoginToAccount(details.contains(QStringLiteral("scope_id")) ? details.value(QStringLiteral("scope_id")).toString() : QLatin1String(""), | ||
707 | 217 | details.value(QStringLiteral("service_name")).toString(), | ||
708 | 218 | details.value(QStringLiteral("service_type")).toString(), | ||
709 | 219 | details.value(QStringLiteral("provider_name")).toString(), | ||
710 | 220 | details.value(QStringLiteral("login_passed_action")).toInt(), | ||
711 | 221 | details.value(QStringLiteral("login_failed_action")).toInt(), | ||
712 | 222 | this); | ||
713 | 223 | connect(login, SIGNAL(searchInProgress(bool)), m_associatedScope, SLOT(setSearchInProgress(bool))); | ||
714 | 224 | connect(login, &LoginToAccount::finished, [this, login, uriAction](bool, int action_code_index) { | ||
715 | 225 | if (action_code_index >= 0 && action_code_index <= scopes::OnlineAccountClient::LastActionCode_) | ||
716 | 226 | { | ||
717 | 227 | scopes::OnlineAccountClient::PostLoginAction action_code = static_cast<scopes::OnlineAccountClient::PostLoginAction>(action_code_index); | ||
718 | 228 | switch (action_code) | ||
719 | 229 | { | ||
720 | 230 | case scopes::OnlineAccountClient::DoNothing: | ||
721 | 231 | return; | ||
722 | 232 | case scopes::OnlineAccountClient::InvalidateResults: | ||
723 | 233 | m_associatedScope->invalidateResults(); | ||
724 | 234 | return; | ||
725 | 235 | default: | ||
726 | 236 | break; | ||
727 | 237 | } | ||
728 | 238 | } | ||
729 | 239 | uriAction(); | ||
730 | 240 | login->deleteLater(); | ||
731 | 241 | }); | ||
732 | 242 | login->loginToAccount(); | ||
733 | 243 | return; // main execution ends here | ||
734 | 244 | } | ||
735 | 245 | } else { | ||
736 | 246 | uriAction(); | ||
737 | 247 | } | ||
738 | 248 | } else { | ||
739 | 249 | qWarning("Action triggered for unknown widget \"%s\"", widgetId.toStdString().c_str()); | ||
740 | 250 | } | ||
741 | 251 | } else { | ||
742 | 252 | action(); | ||
743 | 253 | } | ||
744 | 254 | } | ||
745 | 255 | |||
746 | 256 | void PreviewStack::processActionResponse(PushEvent* pushEvent) | ||
747 | 257 | { | ||
748 | 258 | std::shared_ptr<scopes::ActivationResponse> response; | ||
749 | 259 | scopes::Result::SPtr result; | ||
750 | 260 | QString categoryId; | ||
751 | 261 | pushEvent->collectActivationResponse(response, result, categoryId); | ||
752 | 262 | if (!response) return; | ||
753 | 263 | |||
754 | 264 | switch (response->status()) { | ||
755 | 265 | case scopes::ActivationResponse::ShowPreview: | ||
756 | 266 | // replace current preview | ||
757 | 267 | m_activePreview->setDelayedClear(); | ||
758 | 268 | // the preview is marked as processing action, leave the flag on until the preview is updated | ||
759 | 269 | dispatchPreview(scopes::Variant(response->scope_data())); | ||
760 | 270 | break; | ||
761 | 271 | // TODO: case to nest preview (once such API is available) | ||
762 | 272 | default: | ||
763 | 273 | if (m_associatedScope) { | ||
764 | 274 | m_associatedScope->handleActivation(response, result); | ||
765 | 275 | } | ||
766 | 276 | |||
767 | 277 | if (m_activePreview) { | ||
768 | 278 | m_activePreview->setProcessingAction(false); | ||
769 | 279 | } | ||
770 | 280 | break; | ||
771 | 281 | } | ||
772 | 282 | } | ||
773 | 283 | |||
774 | 284 | void PreviewStack::setWidgetColumnCount(int columnCount) | ||
775 | 285 | { | ||
776 | 286 | if (m_widgetColumnCount != columnCount) { | ||
777 | 287 | m_widgetColumnCount = columnCount; | ||
778 | 288 | // set on all previews | ||
779 | 289 | for (int i = 0; i < m_previews.size(); i++) { | ||
780 | 290 | m_previews[i]->setWidgetColumnCount(columnCount); | ||
781 | 291 | } | ||
782 | 292 | Q_EMIT widgetColumnCountChanged(); | ||
783 | 293 | } | ||
784 | 294 | } | ||
785 | 295 | |||
786 | 296 | int PreviewStack::widgetColumnCount() const | ||
787 | 297 | { | ||
788 | 298 | return m_widgetColumnCount; | ||
789 | 299 | } | ||
790 | 300 | |||
791 | 301 | int PreviewStack::rowCount(const QModelIndex&) const | ||
792 | 302 | { | ||
793 | 303 | return m_previews.size(); | ||
794 | 304 | } | ||
795 | 305 | |||
796 | 306 | unity::scopes::Result::SPtr PreviewStack::previewedResult() const | ||
797 | 307 | { | ||
798 | 308 | return m_previewedResult; | ||
799 | 309 | } | ||
800 | 310 | |||
801 | 311 | unity::shell::scopes::PreviewModelInterface* PreviewStack::getPreviewModel(int index) const | ||
802 | 312 | { | ||
803 | 313 | if (index >= m_previews.size()) { | ||
804 | 314 | return nullptr; | ||
805 | 315 | } | ||
806 | 316 | |||
807 | 317 | return m_previews.at(index); | ||
808 | 318 | } | ||
809 | 319 | |||
810 | 320 | QVariant PreviewStack::data(const QModelIndex& index, int role) const | ||
811 | 321 | { | ||
812 | 322 | int row = index.row(); | ||
813 | 323 | if (row >= m_previews.size()) | ||
814 | 324 | { | ||
815 | 325 | qWarning() << "PreviewStack::data - invalid index" << row << "size" | ||
816 | 326 | << m_previews.size(); | ||
817 | 327 | return QVariant(); | ||
818 | 328 | } | ||
819 | 329 | |||
820 | 330 | switch (role) { | ||
821 | 331 | case RolePreviewModel: | ||
822 | 332 | return QVariant::fromValue(m_previews.at(index.row())); | ||
823 | 333 | default: | ||
824 | 334 | return QVariant(); | ||
825 | 335 | } | ||
826 | 336 | } | ||
827 | 337 | |||
828 | 338 | } // namespace scopes_ng | ||
829 | 339 | 0 | ||
830 | === removed file 'src/Unity/previewstack.h' | |||
831 | --- src/Unity/previewstack.h 2015-08-14 12:29:16 +0000 | |||
832 | +++ src/Unity/previewstack.h 1970-01-01 00:00:00 +0000 | |||
833 | @@ -1,94 +0,0 @@ | |||
834 | 1 | /* | ||
835 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
836 | 3 | * | ||
837 | 4 | * Authors: | ||
838 | 5 | * Michał Sawicz <michal.sawicz@canonical.com> | ||
839 | 6 | * Michal Hruby <michal.hruby@canonical.com> | ||
840 | 7 | * | ||
841 | 8 | * This program is free software; you can redistribute it and/or modify | ||
842 | 9 | * it under the terms of the GNU General Public License as published by | ||
843 | 10 | * the Free Software Foundation; version 3. | ||
844 | 11 | * | ||
845 | 12 | * This program is distributed in the hope that it will be useful, | ||
846 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
847 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
848 | 15 | * GNU General Public License for more details. | ||
849 | 16 | * | ||
850 | 17 | * You should have received a copy of the GNU General Public License | ||
851 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
852 | 19 | */ | ||
853 | 20 | |||
854 | 21 | |||
855 | 22 | #ifndef NG_PREVIEW_STACK_H | ||
856 | 23 | #define NG_PREVIEW_STACK_H | ||
857 | 24 | |||
858 | 25 | #include <unity/shell/scopes/PreviewStackInterface.h> | ||
859 | 26 | |||
860 | 27 | #include <QSet> | ||
861 | 28 | #include <QSharedPointer> | ||
862 | 29 | #include <QMultiMap> | ||
863 | 30 | #include <QPointer> | ||
864 | 31 | #include <QUuid> | ||
865 | 32 | |||
866 | 33 | #include <unity/scopes/PreviewWidget.h> | ||
867 | 34 | #include <unity/scopes/Result.h> | ||
868 | 35 | |||
869 | 36 | #include "collectors.h" | ||
870 | 37 | |||
871 | 38 | namespace scopes_ng | ||
872 | 39 | { | ||
873 | 40 | |||
874 | 41 | class PreviewModel; | ||
875 | 42 | class Scope; | ||
876 | 43 | |||
877 | 44 | class Q_DECL_EXPORT PreviewStack : public unity::shell::scopes::PreviewStackInterface | ||
878 | 45 | { | ||
879 | 46 | Q_OBJECT | ||
880 | 47 | |||
881 | 48 | public: | ||
882 | 49 | explicit PreviewStack(QObject* parent = 0); | ||
883 | 50 | virtual ~PreviewStack(); | ||
884 | 51 | |||
885 | 52 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||
886 | 53 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||
887 | 54 | |||
888 | 55 | virtual bool event(QEvent* ev) override; | ||
889 | 56 | |||
890 | 57 | Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const override; | ||
891 | 58 | |||
892 | 59 | void loadForResult(unity::scopes::Result::SPtr const&); | ||
893 | 60 | void update(unity::scopes::PreviewWidgetList const&); | ||
894 | 61 | |||
895 | 62 | void setWidgetColumnCount(int columnCount) override; | ||
896 | 63 | int widgetColumnCount() const override; | ||
897 | 64 | void setAssociatedScope(scopes_ng::Scope*, QUuid const&, QString const&); | ||
898 | 65 | scopes_ng::Scope* associatedScope() const; | ||
899 | 66 | unity::scopes::Result::SPtr previewedResult() const; | ||
900 | 67 | |||
901 | 68 | private Q_SLOTS: | ||
902 | 69 | void widgetTriggered(QString const&, QString const&, QVariantMap const&); | ||
903 | 70 | |||
904 | 71 | private: | ||
905 | 72 | void processActionResponse(PushEvent* pushEvent); | ||
906 | 73 | |||
907 | 74 | void dispatchPreview(unity::scopes::Variant const& extra_data = unity::scopes::Variant()); | ||
908 | 75 | |||
909 | 76 | int m_widgetColumnCount; | ||
910 | 77 | QList<PreviewModel*> m_previews; | ||
911 | 78 | PreviewModel* m_activePreview; | ||
912 | 79 | QPointer<scopes_ng::Scope> m_associatedScope; | ||
913 | 80 | |||
914 | 81 | unity::scopes::QueryCtrlProxy m_lastPreviewQuery; | ||
915 | 82 | QMap<PreviewModel*, std::weak_ptr<ScopeDataReceiverBase>> m_listeners; | ||
916 | 83 | std::shared_ptr<ScopeDataReceiverBase> m_lastActivation; | ||
917 | 84 | |||
918 | 85 | unity::scopes::Result::SPtr m_previewedResult; | ||
919 | 86 | QUuid m_session_id; | ||
920 | 87 | QString m_userAgent; | ||
921 | 88 | }; | ||
922 | 89 | |||
923 | 90 | } // namespace scopes_ng | ||
924 | 91 | |||
925 | 92 | Q_DECLARE_METATYPE(scopes_ng::PreviewStack*) | ||
926 | 93 | |||
927 | 94 | #endif // NG_PREVIEW_STACK_H | ||
928 | 95 | 0 | ||
929 | === modified file 'src/Unity/scope.cpp' | |||
930 | --- src/Unity/scope.cpp 2015-11-30 09:23:32 +0000 | |||
931 | +++ src/Unity/scope.cpp 2016-02-18 15:46:36 +0000 | |||
932 | @@ -23,7 +23,7 @@ | |||
933 | 23 | // local | 23 | // local |
934 | 24 | #include "categories.h" | 24 | #include "categories.h" |
935 | 25 | #include "collectors.h" | 25 | #include "collectors.h" |
937 | 26 | #include "previewstack.h" | 26 | #include "previewmodel.h" |
938 | 27 | #include "locationservice.h" | 27 | #include "locationservice.h" |
939 | 28 | #include "utils.h" | 28 | #include "utils.h" |
940 | 29 | #include "scopes.h" | 29 | #include "scopes.h" |
941 | @@ -83,6 +83,7 @@ | |||
942 | 83 | , m_formFactor(QStringLiteral("phone")) | 83 | , m_formFactor(QStringLiteral("phone")) |
943 | 84 | , m_isActive(false) | 84 | , m_isActive(false) |
944 | 85 | , m_searchInProgress(false) | 85 | , m_searchInProgress(false) |
945 | 86 | , m_activationInProgress(false) | ||
946 | 86 | , m_resultsDirty(false) | 87 | , m_resultsDirty(false) |
947 | 87 | , m_delayedSearchProcessing(false) | 88 | , m_delayedSearchProcessing(false) |
948 | 88 | , m_hasNavigation(false) | 89 | , m_hasNavigation(false) |
949 | @@ -207,6 +208,8 @@ | |||
950 | 207 | 208 | ||
951 | 208 | void Scope::handleActivation(std::shared_ptr<scopes::ActivationResponse> const& response, scopes::Result::SPtr const& result, QString const& categoryId) | 209 | void Scope::handleActivation(std::shared_ptr<scopes::ActivationResponse> const& response, scopes::Result::SPtr const& result, QString const& categoryId) |
952 | 209 | { | 210 | { |
953 | 211 | setActivationInProgress(false); | ||
954 | 212 | |||
955 | 210 | switch (response->status()) { | 213 | switch (response->status()) { |
956 | 211 | case scopes::ActivationResponse::NotHandled: | 214 | case scopes::ActivationResponse::NotHandled: |
957 | 212 | activateUri(QString::fromStdString(result->uri())); | 215 | activateUri(QString::fromStdString(result->uri())); |
958 | @@ -270,15 +273,15 @@ | |||
959 | 270 | 273 | ||
960 | 271 | void Scope::handlePreviewUpdate(unity::scopes::Result::SPtr const& result, unity::scopes::PreviewWidgetList const& widgets) | 274 | void Scope::handlePreviewUpdate(unity::scopes::Result::SPtr const& result, unity::scopes::PreviewWidgetList const& widgets) |
961 | 272 | { | 275 | { |
964 | 273 | for (auto stack: m_previewStacks) { | 276 | for (auto model: m_previewModels) { |
965 | 274 | auto previewedResult = stack->previewedResult(); | 277 | auto previewedResult = model->previewedResult(); |
966 | 275 | 278 | ||
967 | 276 | if (result == nullptr) { | 279 | if (result == nullptr) { |
968 | 277 | qWarning() << "handlePreviewUpdate: result is null"; | 280 | qWarning() << "handlePreviewUpdate: result is null"; |
969 | 278 | return; | 281 | return; |
970 | 279 | } | 282 | } |
971 | 280 | if (previewedResult != nullptr && *result == *previewedResult) { | 283 | if (previewedResult != nullptr && *result == *previewedResult) { |
973 | 281 | stack->update(widgets); | 284 | model->update(widgets); |
974 | 282 | } | 285 | } |
975 | 283 | } | 286 | } |
976 | 284 | } | 287 | } |
977 | @@ -675,6 +678,14 @@ | |||
978 | 675 | } | 678 | } |
979 | 676 | } | 679 | } |
980 | 677 | 680 | ||
981 | 681 | void Scope::setActivationInProgress(bool activationInProgress) | ||
982 | 682 | { | ||
983 | 683 | if (m_activationInProgress != activationInProgress) { | ||
984 | 684 | m_activationInProgress = activationInProgress; | ||
985 | 685 | Q_EMIT activationInProgressChanged(); | ||
986 | 686 | } | ||
987 | 687 | } | ||
988 | 688 | |||
989 | 678 | void Scope::setStatus(shell::scopes::ScopeInterface::Status status) | 689 | void Scope::setStatus(shell::scopes::ScopeInterface::Status status) |
990 | 679 | { | 690 | { |
991 | 680 | if (m_status != status) { | 691 | if (m_status != status) { |
992 | @@ -864,6 +875,11 @@ | |||
993 | 864 | return m_searchInProgress; | 875 | return m_searchInProgress; |
994 | 865 | } | 876 | } |
995 | 866 | 877 | ||
996 | 878 | bool Scope::activationInProgress() const | ||
997 | 879 | { | ||
998 | 880 | return m_activationInProgress; | ||
999 | 881 | } | ||
1000 | 882 | |||
1001 | 867 | unity::shell::scopes::ScopeInterface::Status Scope::status() const | 883 | unity::shell::scopes::ScopeInterface::Status Scope::status() const |
1002 | 868 | { | 884 | { |
1003 | 869 | return m_status; | 885 | return m_status; |
1004 | @@ -1008,12 +1024,12 @@ | |||
1005 | 1008 | m_inverseDepartments.erase(it); | 1024 | m_inverseDepartments.erase(it); |
1006 | 1009 | } | 1025 | } |
1007 | 1010 | 1026 | ||
1009 | 1011 | void Scope::previewStackDestroyed(QObject *obj) | 1027 | void Scope::previewModelDestroyed(QObject *obj) |
1010 | 1012 | { | 1028 | { |
1012 | 1013 | for (auto it = m_previewStacks.begin(); it != m_previewStacks.end(); it++) | 1029 | for (auto it = m_previewModels.begin(); it != m_previewModels.end(); it++) |
1013 | 1014 | { | 1030 | { |
1014 | 1015 | if (*it == obj) { | 1031 | if (*it == obj) { |
1016 | 1016 | m_previewStacks.erase(it); | 1032 | m_previewModels.erase(it); |
1017 | 1017 | break; | 1033 | break; |
1018 | 1018 | } | 1034 | } |
1019 | 1019 | } | 1035 | } |
1020 | @@ -1205,13 +1221,17 @@ | |||
1021 | 1205 | scopes::ActivationListenerBase::SPtr listener(new ActivationReceiver(this, result)); | 1221 | scopes::ActivationListenerBase::SPtr listener(new ActivationReceiver(this, result)); |
1022 | 1206 | m_activationController->setListener(listener); | 1222 | m_activationController->setListener(listener); |
1023 | 1207 | 1223 | ||
1024 | 1224 | setActivationInProgress(true); | ||
1025 | 1225 | |||
1026 | 1208 | auto proxy = proxy_for_result(result); | 1226 | auto proxy = proxy_for_result(result); |
1027 | 1209 | unity::scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), m_formFactor.toStdString()); | 1227 | unity::scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), m_formFactor.toStdString()); |
1028 | 1210 | scopes::QueryCtrlProxy controller = proxy->activate(*(result.get()), metadata, listener); | 1228 | scopes::QueryCtrlProxy controller = proxy->activate(*(result.get()), metadata, listener); |
1029 | 1211 | m_activationController->setController(controller); | 1229 | m_activationController->setController(controller); |
1030 | 1212 | } catch (std::exception& e) { | 1230 | } catch (std::exception& e) { |
1031 | 1231 | setActivationInProgress(false); | ||
1032 | 1213 | qWarning("Caught an error from activate(): %s", e.what()); | 1232 | qWarning("Caught an error from activate(): %s", e.what()); |
1033 | 1214 | } catch (...) { | 1233 | } catch (...) { |
1034 | 1234 | setActivationInProgress(false); | ||
1035 | 1215 | qWarning("Caught an error from activate()"); | 1235 | qWarning("Caught an error from activate()"); |
1036 | 1216 | } | 1236 | } |
1037 | 1217 | } | 1237 | } |
1038 | @@ -1282,7 +1302,7 @@ | |||
1039 | 1282 | } | 1302 | } |
1040 | 1283 | } | 1303 | } |
1041 | 1284 | 1304 | ||
1043 | 1285 | unity::shell::scopes::PreviewStackInterface* Scope::preview(QVariant const& result_var, QString const& categoryId) | 1305 | unity::shell::scopes::PreviewModelInterface* Scope::preview(QVariant const& result_var, QString const& categoryId) |
1044 | 1286 | { | 1306 | { |
1045 | 1287 | if (!result_var.canConvert<std::shared_ptr<scopes::Result>>()) { | 1307 | if (!result_var.canConvert<std::shared_ptr<scopes::Result>>()) { |
1046 | 1288 | qWarning("Cannot preview, unable to convert %s to Result", result_var.typeName()); | 1308 | qWarning("Cannot preview, unable to convert %s to Result", result_var.typeName()); |
1047 | @@ -1300,12 +1320,12 @@ | |||
1048 | 1300 | return nullptr; | 1320 | return nullptr; |
1049 | 1301 | } | 1321 | } |
1050 | 1302 | 1322 | ||
1057 | 1303 | PreviewStack* stack = new PreviewStack(nullptr); | 1323 | PreviewModel* previewModel = new PreviewModel(nullptr); |
1058 | 1304 | QObject::connect(stack, &QObject::destroyed, this, &Scope::previewStackDestroyed); | 1324 | QObject::connect(previewModel, &QObject::destroyed, this, &Scope::previewModelDestroyed); |
1059 | 1305 | m_previewStacks.append(stack); | 1325 | m_previewModels.append(previewModel); |
1060 | 1306 | stack->setAssociatedScope(this, m_session_id, m_scopesInstance->userAgentString()); | 1326 | previewModel->setAssociatedScope(this, m_session_id, m_scopesInstance->userAgentString()); |
1061 | 1307 | stack->loadForResult(result); | 1327 | previewModel->loadForResult(result); |
1062 | 1308 | return stack; | 1328 | return previewModel; |
1063 | 1309 | } | 1329 | } |
1064 | 1310 | 1330 | ||
1065 | 1311 | void Scope::cancelActivation() | 1331 | void Scope::cancelActivation() |
1066 | 1312 | 1332 | ||
1067 | === modified file 'src/Unity/scope.h' | |||
1068 | --- src/Unity/scope.h 2015-11-30 09:23:32 +0000 | |||
1069 | +++ src/Unity/scope.h 2016-02-18 15:46:36 +0000 | |||
1070 | @@ -48,7 +48,7 @@ | |||
1071 | 48 | 48 | ||
1072 | 49 | class Categories; | 49 | class Categories; |
1073 | 50 | class PushEvent; | 50 | class PushEvent; |
1075 | 51 | class PreviewStack; | 51 | class PreviewModel; |
1076 | 52 | class LocationService; | 52 | class LocationService; |
1077 | 53 | class SettingsModel; | 53 | class SettingsModel; |
1078 | 54 | class Scopes; | 54 | class Scopes; |
1079 | @@ -125,6 +125,7 @@ | |||
1080 | 125 | bool favorite() const override; | 125 | bool favorite() const override; |
1081 | 126 | QString shortcut() const override; | 126 | QString shortcut() const override; |
1082 | 127 | bool searchInProgress() const override; | 127 | bool searchInProgress() const override; |
1083 | 128 | bool activationInProgress() const override; | ||
1084 | 128 | unity::shell::scopes::ScopeInterface::Status status() const override; | 129 | unity::shell::scopes::ScopeInterface::Status status() const override; |
1085 | 129 | unity::shell::scopes::CategoriesInterface* categories() const override; | 130 | unity::shell::scopes::CategoriesInterface* categories() const override; |
1086 | 130 | unity::shell::scopes::SettingsModelInterface* settings() const override; | 131 | unity::shell::scopes::SettingsModelInterface* settings() const override; |
1087 | @@ -148,7 +149,7 @@ | |||
1088 | 148 | void setFavorite(const bool) override; | 149 | void setFavorite(const bool) override; |
1089 | 149 | 150 | ||
1090 | 150 | Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override; | 151 | Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override; |
1092 | 151 | Q_INVOKABLE unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result, QString const& categoryId) override; | 152 | Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* preview(QVariant const& result, QString const& categoryId) override; |
1093 | 152 | Q_INVOKABLE void cancelActivation() override; | 153 | Q_INVOKABLE void cancelActivation() override; |
1094 | 153 | Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override; | 154 | Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override; |
1095 | 154 | Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& id) override; | 155 | Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& id) override; |
1096 | @@ -177,6 +178,7 @@ | |||
1097 | 177 | void invalidateResults(); | 178 | void invalidateResults(); |
1098 | 178 | virtual void dispatchSearch(); | 179 | virtual void dispatchSearch(); |
1099 | 179 | void setSearchInProgress(bool searchInProgress); | 180 | void setSearchInProgress(bool searchInProgress); |
1100 | 181 | void setActivationInProgress(bool activationInProgress); | ||
1101 | 180 | 182 | ||
1102 | 181 | Q_SIGNALS: | 183 | Q_SIGNALS: |
1103 | 182 | void resultsDirtyChanged(); | 184 | void resultsDirtyChanged(); |
1104 | @@ -189,7 +191,7 @@ | |||
1105 | 189 | void flushUpdates(bool finalize = false); | 191 | void flushUpdates(bool finalize = false); |
1106 | 190 | void metadataRefreshed(); | 192 | void metadataRefreshed(); |
1107 | 191 | void departmentModelDestroyed(QObject* obj); | 193 | void departmentModelDestroyed(QObject* obj); |
1109 | 192 | void previewStackDestroyed(QObject *obj); | 194 | void previewModelDestroyed(QObject *obj); |
1110 | 193 | 195 | ||
1111 | 194 | protected: | 196 | protected: |
1112 | 195 | explicit Scope(scopes_ng::Scopes* parent); | 197 | explicit Scope(scopes_ng::Scopes* parent); |
1113 | @@ -230,6 +232,7 @@ | |||
1114 | 230 | std::unique_ptr<unity::scopes::Variant> m_queryUserData; | 232 | std::unique_ptr<unity::scopes::Variant> m_queryUserData; |
1115 | 231 | bool m_isActive; | 233 | bool m_isActive; |
1116 | 232 | bool m_searchInProgress; | 234 | bool m_searchInProgress; |
1117 | 235 | bool m_activationInProgress; | ||
1118 | 233 | bool m_resultsDirty; | 236 | bool m_resultsDirty; |
1119 | 234 | bool m_delayedSearchProcessing; | 237 | bool m_delayedSearchProcessing; |
1120 | 235 | bool m_hasNavigation; | 238 | bool m_hasNavigation; |
1121 | @@ -264,7 +267,7 @@ | |||
1122 | 264 | QSharedPointer<LocationService> m_locationService; | 267 | QSharedPointer<LocationService> m_locationService; |
1123 | 265 | QSharedPointer<LocationService::Token> m_locationToken; | 268 | QSharedPointer<LocationService::Token> m_locationToken; |
1124 | 266 | QNetworkConfigurationManager m_network_manager; | 269 | QNetworkConfigurationManager m_network_manager; |
1126 | 267 | QList<PreviewStack*> m_previewStacks; | 270 | QList<PreviewModel*> m_previewModels; |
1127 | 268 | }; | 271 | }; |
1128 | 269 | 272 | ||
1129 | 270 | } // namespace scopes_ng | 273 | } // namespace scopes_ng |
1130 | 271 | 274 | ||
1131 | === modified file 'src/scope-harness/internal/preview-widget-arguments.h' | |||
1132 | --- src/scope-harness/internal/preview-widget-arguments.h 2015-04-24 13:06:14 +0000 | |||
1133 | +++ src/scope-harness/internal/preview-widget-arguments.h 2016-02-18 15:46:36 +0000 | |||
1134 | @@ -31,7 +31,6 @@ | |||
1135 | 31 | { | 31 | { |
1136 | 32 | class PreviewWidgetModelInterface; | 32 | class PreviewWidgetModelInterface; |
1137 | 33 | class PreviewModelInterface; | 33 | class PreviewModelInterface; |
1138 | 34 | class PreviewStackInterface; | ||
1139 | 35 | } | 34 | } |
1140 | 36 | } | 35 | } |
1141 | 37 | namespace scopeharness | 36 | namespace scopeharness |
1142 | @@ -54,8 +53,6 @@ | |||
1143 | 54 | std::shared_ptr<view::ResultsView> resultsView; | 53 | std::shared_ptr<view::ResultsView> resultsView; |
1144 | 55 | 54 | ||
1145 | 56 | std::shared_ptr<view::PreviewView> previewView; | 55 | std::shared_ptr<view::PreviewView> previewView; |
1146 | 57 | |||
1147 | 58 | std::shared_ptr<unity::shell::scopes::PreviewStackInterface> previewStack; | ||
1148 | 59 | }; | 56 | }; |
1149 | 60 | } | 57 | } |
1150 | 61 | } | 58 | } |
1151 | 62 | 59 | ||
1152 | === modified file 'src/scope-harness/preview/preview-widget.cpp' | |||
1153 | --- src/scope-harness/preview/preview-widget.cpp 2015-08-20 07:32:49 +0000 | |||
1154 | +++ src/scope-harness/preview/preview-widget.cpp 2016-02-18 15:46:36 +0000 | |||
1155 | @@ -23,11 +23,12 @@ | |||
1156 | 23 | #include <scope-harness/view/results-view.h> | 23 | #include <scope-harness/view/results-view.h> |
1157 | 24 | #include <scope-harness/test-utils.h> | 24 | #include <scope-harness/test-utils.h> |
1158 | 25 | 25 | ||
1159 | 26 | #include <Unity/previewmodel.h> | ||
1160 | 27 | |||
1161 | 26 | #include <unity/shell/scopes/PreviewModelInterface.h> | 28 | #include <unity/shell/scopes/PreviewModelInterface.h> |
1162 | 27 | #include <unity/shell/scopes/PreviewWidgetModelInterface.h> | 29 | #include <unity/shell/scopes/PreviewWidgetModelInterface.h> |
1163 | 28 | 30 | ||
1164 | 29 | #include <Unity/utils.h> | 31 | #include <Unity/utils.h> |
1165 | 30 | #include <Unity/previewstack.h> | ||
1166 | 31 | 32 | ||
1167 | 32 | #include <QDebug> | 33 | #include <QDebug> |
1168 | 33 | #include <QSignalSpy> | 34 | #include <QSignalSpy> |
1169 | @@ -57,8 +58,6 @@ | |||
1170 | 57 | weak_ptr<view::ResultsView> m_resultsView; | 58 | weak_ptr<view::ResultsView> m_resultsView; |
1171 | 58 | 59 | ||
1172 | 59 | weak_ptr<view::PreviewView> m_previewView; | 60 | weak_ptr<view::PreviewView> m_previewView; |
1173 | 60 | |||
1174 | 61 | std::shared_ptr<unity::shell::scopes::PreviewStackInterface> m_previewStack; | ||
1175 | 62 | }; | 61 | }; |
1176 | 63 | 62 | ||
1177 | 64 | PreviewWidget::PreviewWidget(const internal::PreviewWidgetArguments& arguments) : | 63 | PreviewWidget::PreviewWidget(const internal::PreviewWidgetArguments& arguments) : |
1178 | @@ -69,7 +68,6 @@ | |||
1179 | 69 | p->m_index = arguments.index; | 68 | p->m_index = arguments.index; |
1180 | 70 | p->m_resultsView = arguments.resultsView; | 69 | p->m_resultsView = arguments.resultsView; |
1181 | 71 | p->m_previewView = arguments.previewView; | 70 | p->m_previewView = arguments.previewView; |
1182 | 72 | p->m_previewStack = arguments.previewStack; | ||
1183 | 73 | } | 71 | } |
1184 | 74 | 72 | ||
1185 | 75 | 73 | ||
1186 | @@ -91,7 +89,6 @@ | |||
1187 | 91 | p->m_index = other.p->m_index; | 89 | p->m_index = other.p->m_index; |
1188 | 92 | p->m_resultsView = other.p->m_resultsView; | 90 | p->m_resultsView = other.p->m_resultsView; |
1189 | 93 | p->m_previewView = other.p->m_previewView; | 91 | p->m_previewView = other.p->m_previewView; |
1190 | 94 | p->m_previewStack = other.p->m_previewStack; | ||
1191 | 95 | return *this; | 92 | return *this; |
1192 | 96 | } | 93 | } |
1193 | 97 | 94 | ||
1194 | @@ -127,9 +124,8 @@ | |||
1195 | 127 | 124 | ||
1196 | 128 | view::AbstractView::SPtr PreviewWidget::trigger(const string& name, const sc::Variant& v) | 125 | view::AbstractView::SPtr PreviewWidget::trigger(const string& name, const sc::Variant& v) |
1197 | 129 | { | 126 | { |
1201 | 130 | auto ps = std::dynamic_pointer_cast<ng::PreviewStack>(p->m_previewStack); | 127 | auto ps = dynamic_cast<ng::PreviewModel*>(p->m_previewModel); |
1202 | 131 | TestUtils::throwIfNot(bool(ps), "No preview stack"); | 128 | TestUtils::throwIfNot(bool(ps->associatedScope()), "Preview model has no associated scope"); |
1200 | 132 | TestUtils::throwIfNot(bool(ps->associatedScope()), "Preview stack has no associated scope"); | ||
1203 | 133 | QSignalSpy showDashSpy(ps->associatedScope(), SIGNAL(showDash())); | 129 | QSignalSpy showDashSpy(ps->associatedScope(), SIGNAL(showDash())); |
1204 | 134 | 130 | ||
1205 | 135 | QVariant widgetData; | 131 | QVariant widgetData; |
1206 | @@ -153,7 +149,7 @@ | |||
1207 | 153 | widgetData = ng::scopeVariantToQVariant(v); | 149 | widgetData = ng::scopeVariantToQVariant(v); |
1208 | 154 | } | 150 | } |
1209 | 155 | 151 | ||
1211 | 156 | Q_EMIT p->m_previewModel->triggered( | 152 | Q_EMIT ps->triggered( |
1212 | 157 | QString::fromStdString(id()), QString::fromStdString(name), | 153 | QString::fromStdString(id()), QString::fromStdString(name), |
1213 | 158 | widgetData.toMap()); | 154 | widgetData.toMap()); |
1214 | 159 | 155 | ||
1215 | 160 | 156 | ||
1216 | === modified file 'src/scope-harness/results/result.cpp' | |||
1217 | --- src/scope-harness/results/result.cpp 2015-11-30 09:23:32 +0000 | |||
1218 | +++ src/scope-harness/results/result.cpp 2016-02-18 15:46:36 +0000 | |||
1219 | @@ -23,9 +23,9 @@ | |||
1220 | 23 | #include <scope-harness/view/results-view.h> | 23 | #include <scope-harness/view/results-view.h> |
1221 | 24 | 24 | ||
1222 | 25 | #include <Unity/resultsmodel.h> | 25 | #include <Unity/resultsmodel.h> |
1223 | 26 | #include <Unity/previewstack.h> | ||
1224 | 27 | #include <Unity/scope.h> | 26 | #include <Unity/scope.h> |
1225 | 28 | #include <Unity/utils.h> | 27 | #include <Unity/utils.h> |
1226 | 28 | #include <Unity/previewmodel.h> | ||
1227 | 29 | 29 | ||
1228 | 30 | #include <QObject> | 30 | #include <QObject> |
1229 | 31 | #include <QSignalSpy> | 31 | #include <QSignalSpy> |
1230 | @@ -137,7 +137,7 @@ | |||
1231 | 137 | // TODO set scope inactive? | 137 | // TODO set scope inactive? |
1232 | 138 | auto result = m_resultsModel->data( | 138 | auto result = m_resultsModel->data( |
1233 | 139 | m_index, ss::ResultsModelInterface::Roles::RoleResult); | 139 | m_index, ss::ResultsModelInterface::Roles::RoleResult); |
1235 | 140 | shared_ptr<ss::PreviewStackInterface> preview( | 140 | shared_ptr<ss::PreviewModelInterface> preview( |
1236 | 141 | m_scope->preview(result, m_resultsModel->categoryId())); | 141 | m_scope->preview(result, m_resultsModel->categoryId())); |
1237 | 142 | previewView->preview(preview); | 142 | previewView->preview(preview); |
1238 | 143 | view = previewView; | 143 | view = previewView; |
1239 | @@ -161,7 +161,7 @@ | |||
1240 | 161 | auto result = m_resultsModel->data( | 161 | auto result = m_resultsModel->data( |
1241 | 162 | m_index, | 162 | m_index, |
1242 | 163 | ss::ResultsModelInterface::Roles::RoleResult); | 163 | ss::ResultsModelInterface::Roles::RoleResult); |
1244 | 164 | shared_ptr<ss::PreviewStackInterface> preview( | 164 | shared_ptr<ss::PreviewModelInterface> preview( |
1245 | 165 | m_scope->preview(result, m_resultsModel->categoryId())); | 165 | m_scope->preview(result, m_resultsModel->categoryId())); |
1246 | 166 | previewView->preview(preview); | 166 | previewView->preview(preview); |
1247 | 167 | view = previewView; | 167 | view = previewView; |
1248 | @@ -379,7 +379,7 @@ | |||
1249 | 379 | } | 379 | } |
1250 | 380 | 380 | ||
1251 | 381 | auto previewView = p->m_previewView.lock(); | 381 | auto previewView = p->m_previewView.lock(); |
1253 | 382 | shared_ptr<ss::PreviewStackInterface> preview(p->m_scope->preview(result_var, p->m_resultsModel->categoryId())); | 382 | shared_ptr<ss::PreviewModelInterface> preview(p->m_scope->preview(result_var, p->m_resultsModel->categoryId())); |
1254 | 383 | previewView->preview(preview); | 383 | previewView->preview(preview); |
1255 | 384 | return previewView; | 384 | return previewView; |
1256 | 385 | } | 385 | } |
1257 | @@ -418,7 +418,7 @@ | |||
1258 | 418 | return nullptr; // nothing happens for scope:// uris | 418 | return nullptr; // nothing happens for scope:// uris |
1259 | 419 | } | 419 | } |
1260 | 420 | auto previewView = p->m_previewView.lock(); | 420 | auto previewView = p->m_previewView.lock(); |
1262 | 421 | shared_ptr<ss::PreviewStackInterface> preview(p->m_scope->preview(result_var, p->m_resultsModel->categoryId())); | 421 | shared_ptr<ss::PreviewModelInterface> preview(p->m_scope->preview(result_var, p->m_resultsModel->categoryId())); |
1263 | 422 | previewView->preview(preview); | 422 | previewView->preview(preview); |
1264 | 423 | return previewView; | 423 | return previewView; |
1265 | 424 | } | 424 | } |
1266 | 425 | 425 | ||
1267 | === modified file 'src/scope-harness/test-utils.cpp' | |||
1268 | --- src/scope-harness/test-utils.cpp 2015-10-27 09:14:07 +0000 | |||
1269 | +++ src/scope-harness/test-utils.cpp 2016-02-18 15:46:36 +0000 | |||
1270 | @@ -33,7 +33,6 @@ | |||
1271 | 33 | #include <Unity/scope.h> | 33 | #include <Unity/scope.h> |
1272 | 34 | #include <Unity/categories.h> | 34 | #include <Unity/categories.h> |
1273 | 35 | #include <Unity/resultsmodel.h> | 35 | #include <Unity/resultsmodel.h> |
1274 | 36 | #include <Unity/previewstack.h> | ||
1275 | 37 | 36 | ||
1276 | 38 | namespace sc = unity::scopes; | 37 | namespace sc = unity::scopes; |
1277 | 39 | namespace ng = scopes_ng; | 38 | namespace ng = scopes_ng; |
1278 | @@ -136,18 +135,6 @@ | |||
1279 | 136 | QCOMPARE(scope->searchInProgress(), false); | 135 | QCOMPARE(scope->searchInProgress(), false); |
1280 | 137 | } | 136 | } |
1281 | 138 | 137 | ||
1282 | 139 | bool TestUtils::previewForFirstResult(ng::Scope::Ptr scope, QString const& searchString, QScopedPointer<ng::PreviewStack>& preview_stack) | ||
1283 | 140 | { | ||
1284 | 141 | performSearch(scope, searchString); | ||
1285 | 142 | |||
1286 | 143 | unity::scopes::Result::SPtr result; | ||
1287 | 144 | if (!getFirstResult(scope->categories(), result)) | ||
1288 | 145 | return false; | ||
1289 | 146 | preview_stack.reset(static_cast<ng::PreviewStack*>(scope->preview(QVariant::fromValue(result), ""))); //FIXME | ||
1290 | 147 | |||
1291 | 148 | return true; | ||
1292 | 149 | } | ||
1293 | 150 | |||
1294 | 151 | void TestUtils::setFavouriteScopes(const QStringList& cannedQueries) | 138 | void TestUtils::setFavouriteScopes(const QStringList& cannedQueries) |
1295 | 152 | { | 139 | { |
1296 | 153 | setenv("GSETTINGS_BACKEND", "memory", 1); | 140 | setenv("GSETTINGS_BACKEND", "memory", 1); |
1297 | 154 | 141 | ||
1298 | === modified file 'src/scope-harness/test-utils.h' | |||
1299 | --- src/scope-harness/test-utils.h 2015-03-10 11:23:01 +0000 | |||
1300 | +++ src/scope-harness/test-utils.h 2016-02-18 15:46:36 +0000 | |||
1301 | @@ -57,9 +57,6 @@ | |||
1302 | 57 | static void waitForSearchFinish(QSharedPointer<shell::scopes::ScopeInterface> scope); | 57 | static void waitForSearchFinish(QSharedPointer<shell::scopes::ScopeInterface> scope); |
1303 | 58 | 58 | ||
1304 | 59 | Q_DECL_EXPORT | 59 | Q_DECL_EXPORT |
1305 | 60 | static bool previewForFirstResult(scopes_ng::Scope::Ptr scope, QString const& searchString, QScopedPointer<scopes_ng::PreviewStack>& preview_stack); | ||
1306 | 61 | |||
1307 | 62 | Q_DECL_EXPORT | ||
1308 | 63 | static void setFavouriteScopes(const QStringList& cannedQueries); | 60 | static void setFavouriteScopes(const QStringList& cannedQueries); |
1309 | 64 | 61 | ||
1310 | 65 | Q_DECL_EXPORT | 62 | Q_DECL_EXPORT |
1311 | 66 | 63 | ||
1312 | === modified file 'src/scope-harness/view/preview-view.cpp' | |||
1313 | --- src/scope-harness/view/preview-view.cpp 2015-04-24 13:06:14 +0000 | |||
1314 | +++ src/scope-harness/view/preview-view.cpp 2016-02-18 15:46:36 +0000 | |||
1315 | @@ -23,7 +23,6 @@ | |||
1316 | 23 | #include <scope-harness/test-utils.h> | 23 | #include <scope-harness/test-utils.h> |
1317 | 24 | 24 | ||
1318 | 25 | #include <unity/shell/scopes/PreviewModelInterface.h> | 25 | #include <unity/shell/scopes/PreviewModelInterface.h> |
1319 | 26 | #include <unity/shell/scopes/PreviewStackInterface.h> | ||
1320 | 27 | #include <unity/shell/scopes/PreviewWidgetModelInterface.h> | 26 | #include <unity/shell/scopes/PreviewWidgetModelInterface.h> |
1321 | 28 | 27 | ||
1322 | 29 | 28 | ||
1323 | @@ -53,7 +52,7 @@ | |||
1324 | 53 | { | 52 | { |
1325 | 54 | previewWidgets.emplace_back( | 53 | previewWidgets.emplace_back( |
1326 | 55 | preview::PreviewWidget(internal::PreviewWidgetArguments | 54 | preview::PreviewWidget(internal::PreviewWidgetArguments |
1328 | 56 | { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView, m_previewStack})); | 55 | { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView })); |
1329 | 57 | } | 56 | } |
1330 | 58 | 57 | ||
1331 | 59 | return preview::PreviewWidgetList(internal::PreviewWidgetListArguments{previewWidgets}); | 58 | return preview::PreviewWidgetList(internal::PreviewWidgetListArguments{previewWidgets}); |
1332 | @@ -82,24 +81,23 @@ | |||
1333 | 82 | return previewModels; | 81 | return previewModels; |
1334 | 83 | } | 82 | } |
1335 | 84 | 83 | ||
1337 | 85 | void setPreviewModel(shared_ptr<ss::PreviewStackInterface> previewStack, PreviewView::SPtr previewView) | 84 | void setPreviewModel(shared_ptr<ss::PreviewModelInterface> previewModel, PreviewView::SPtr previewView) |
1338 | 86 | { | 85 | { |
1340 | 87 | m_previewStack = previewStack; | 86 | m_previewModel = previewModel; |
1341 | 88 | updateModels(previewView); | 87 | updateModels(previewView); |
1342 | 89 | } | 88 | } |
1343 | 90 | 89 | ||
1344 | 91 | void updateModels(PreviewView::SPtr previewView) | 90 | void updateModels(PreviewView::SPtr previewView) |
1345 | 92 | { | 91 | { |
1348 | 93 | auto previewModel = m_previewStack->getPreviewModel(0); | 92 | m_previewModels = iteratePreviewModel(m_previewModel.get(), previewView); |
1347 | 94 | m_previewModels = iteratePreviewModel(previewModel, previewView); | ||
1349 | 95 | } | 93 | } |
1350 | 96 | 94 | ||
1352 | 97 | void checkPreviewStack() | 95 | void checkPreviewModel() |
1353 | 98 | { | 96 | { |
1355 | 99 | TestUtils::throwIfNot(bool(m_previewStack), ""); | 97 | TestUtils::throwIfNot(bool(m_previewModel), ""); |
1356 | 100 | } | 98 | } |
1357 | 101 | 99 | ||
1359 | 102 | shared_ptr<ss::PreviewStackInterface> m_previewStack; | 100 | shared_ptr<ss::PreviewModelInterface> m_previewModel; |
1360 | 103 | 101 | ||
1361 | 104 | vector<preview::PreviewWidgetList> m_previewModels; | 102 | vector<preview::PreviewWidgetList> m_previewModels; |
1362 | 105 | 103 | ||
1363 | @@ -116,17 +114,17 @@ | |||
1364 | 116 | p->m_resultsView = resultsView; | 114 | p->m_resultsView = resultsView; |
1365 | 117 | } | 115 | } |
1366 | 118 | 116 | ||
1368 | 119 | void PreviewView::preview(shared_ptr<ss::PreviewStackInterface> previewStack) | 117 | void PreviewView::preview(shared_ptr<ss::PreviewModelInterface> previewModel) |
1369 | 120 | { | 118 | { |
1371 | 121 | p->setPreviewModel(previewStack, | 119 | p->setPreviewModel(previewModel, |
1372 | 122 | dynamic_pointer_cast<PreviewView>(shared_from_this())); | 120 | dynamic_pointer_cast<PreviewView>(shared_from_this())); |
1373 | 123 | } | 121 | } |
1374 | 124 | 122 | ||
1375 | 125 | void PreviewView::setColumnCount(unsigned int count) | 123 | void PreviewView::setColumnCount(unsigned int count) |
1376 | 126 | { | 124 | { |
1378 | 127 | p->checkPreviewStack(); | 125 | p->checkPreviewModel(); |
1379 | 128 | 126 | ||
1381 | 129 | p->m_previewStack->setWidgetColumnCount(count); | 127 | p->m_previewModel->setWidgetColumnCount(count); |
1382 | 130 | // TODO Wait? | 128 | // TODO Wait? |
1383 | 131 | refresh(); | 129 | refresh(); |
1384 | 132 | } | 130 | } |
1385 | @@ -138,21 +136,21 @@ | |||
1386 | 138 | 136 | ||
1387 | 139 | unsigned int PreviewView::columnCount() const | 137 | unsigned int PreviewView::columnCount() const |
1388 | 140 | { | 138 | { |
1390 | 141 | p->checkPreviewStack(); | 139 | p->checkPreviewModel(); |
1391 | 142 | 140 | ||
1393 | 143 | return p->m_previewStack->widgetColumnCount(); | 141 | return p->m_previewModel->widgetColumnCount(); |
1394 | 144 | } | 142 | } |
1395 | 145 | 143 | ||
1396 | 146 | vector<preview::PreviewWidgetList> PreviewView::widgets() | 144 | vector<preview::PreviewWidgetList> PreviewView::widgets() |
1397 | 147 | { | 145 | { |
1399 | 148 | p->checkPreviewStack(); | 146 | p->checkPreviewModel(); |
1400 | 149 | 147 | ||
1401 | 150 | return p->m_previewModels; | 148 | return p->m_previewModels; |
1402 | 151 | } | 149 | } |
1403 | 152 | 150 | ||
1404 | 153 | preview::PreviewWidgetList PreviewView::widgetsInColumn(size_t column) | 151 | preview::PreviewWidgetList PreviewView::widgetsInColumn(size_t column) |
1405 | 154 | { | 152 | { |
1407 | 155 | p->checkPreviewStack(); | 153 | p->checkPreviewModel(); |
1408 | 156 | 154 | ||
1409 | 157 | return p->m_previewModels.at(column); | 155 | return p->m_previewModels.at(column); |
1410 | 158 | } | 156 | } |
1411 | 159 | 157 | ||
1412 | === modified file 'src/scope-harness/view/preview-view.h' | |||
1413 | --- src/scope-harness/view/preview-view.h 2015-03-10 11:23:01 +0000 | |||
1414 | +++ src/scope-harness/view/preview-view.h 2016-02-18 15:46:36 +0000 | |||
1415 | @@ -27,7 +27,7 @@ | |||
1416 | 27 | { | 27 | { |
1417 | 28 | namespace scopes | 28 | namespace scopes |
1418 | 29 | { | 29 | { |
1420 | 30 | class PreviewStackInterface; | 30 | class PreviewModelInterface; |
1421 | 31 | } | 31 | } |
1422 | 32 | } | 32 | } |
1423 | 33 | namespace scopeharness | 33 | namespace scopeharness |
1424 | @@ -74,7 +74,7 @@ | |||
1425 | 74 | friend ScopeHarness; | 74 | friend ScopeHarness; |
1426 | 75 | friend preview::PreviewWidget; | 75 | friend preview::PreviewWidget; |
1427 | 76 | 76 | ||
1429 | 77 | void preview(std::shared_ptr<shell::scopes::PreviewStackInterface> previewStack); | 77 | void preview(std::shared_ptr<shell::scopes::PreviewModelInterface> previewModel); |
1430 | 78 | 78 | ||
1431 | 79 | void setResultsView(std::shared_ptr<ResultsView> resultsView); | 79 | void setResultsView(std::shared_ptr<ResultsView> resultsView); |
1432 | 80 | 80 | ||
1433 | 81 | 81 | ||
1434 | === modified file 'tests/overviewtest.cpp' | |||
1435 | --- tests/overviewtest.cpp 2016-02-04 15:41:08 +0000 | |||
1436 | +++ tests/overviewtest.cpp 2016-02-18 15:46:36 +0000 | |||
1437 | @@ -31,7 +31,6 @@ | |||
1438 | 31 | #include <categories.h> | 31 | #include <categories.h> |
1439 | 32 | #include <overviewresults.h> | 32 | #include <overviewresults.h> |
1440 | 33 | #include <previewmodel.h> | 33 | #include <previewmodel.h> |
1441 | 34 | #include <previewstack.h> | ||
1442 | 35 | #include <previewwidgetmodel.h> | 34 | #include <previewwidgetmodel.h> |
1443 | 36 | 35 | ||
1444 | 37 | #include <scope-harness/registry/pre-existing-registry.h> | 36 | #include <scope-harness/registry/pre-existing-registry.h> |
1445 | 38 | 37 | ||
1446 | === modified file 'tests/previewtest.cpp' | |||
1447 | --- tests/previewtest.cpp 2015-08-14 12:29:16 +0000 | |||
1448 | +++ tests/previewtest.cpp 2016-02-18 15:46:36 +0000 | |||
1449 | @@ -29,7 +29,6 @@ | |||
1450 | 29 | #include <categories.h> | 29 | #include <categories.h> |
1451 | 30 | #include <resultsmodel.h> | 30 | #include <resultsmodel.h> |
1452 | 31 | #include <previewmodel.h> | 31 | #include <previewmodel.h> |
1453 | 32 | #include <previewstack.h> | ||
1454 | 33 | #include <previewwidgetmodel.h> | 32 | #include <previewwidgetmodel.h> |
1455 | 34 | 33 | ||
1456 | 35 | #include <scope-harness/matcher/category-matcher.h> | 34 | #include <scope-harness/matcher/category-matcher.h> |
bring back the top warning to debian/control ?