Merge lp:~stolowski/unity-scopes-shell/single-preview into lp:unity-scopes-shell

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
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://code.launchpad.net/~stolowski/unity-api/single-preview/+merge/286359

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 :

bring back the top warning to debian/control ?

review: Needs Fixing
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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-11-30 09:23:32 +0000
+++ CMakeLists.txt 2016-02-18 15:46:36 +0000
@@ -51,7 +51,7 @@
51find_package(Boost COMPONENTS regex REQUIRED)51find_package(Boost COMPONENTS regex REQUIRED)
5252
53pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=1.0.1)53pkg_check_modules(SCOPESLIB REQUIRED libunity-scopes>=1.0.1)
54pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=9)54pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=10)
5555
56pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt)56pkg_check_modules(GSETTINGSQT REQUIRED gsettings-qt)
57pkg_check_modules(UBUNTU_LOCATION_SERVICE REQUIRED ubuntu-location-service)57pkg_check_modules(UBUNTU_LOCATION_SERVICE REQUIRED ubuntu-location-service)
5858
=== modified file 'debian/HARNESS_VERSION'
--- debian/HARNESS_VERSION 2015-09-17 10:10:40 +0000
+++ debian/HARNESS_VERSION 2016-02-18 15:46:36 +0000
@@ -1,1 +1,1 @@
11.1.012.1.0
22
=== modified file 'debian/control.in'
--- debian/control.in 2015-12-15 15:22:10 +0000
+++ debian/control.in 2016-02-18 15:46:36 +0000
@@ -8,7 +8,7 @@
8 dh-python,8 dh-python,
9 libboost-python-dev,9 libboost-python-dev,
10 libboost-regex-dev,10 libboost-regex-dev,
11 libunity-api-dev (>= 7.105),11 libunity-api-dev (>= 7.107),
12 libunity-scopes-dev (>= 1.0.1~),12 libunity-scopes-dev (>= 1.0.1~),
13 libgsettings-qt-dev (>= 0.1),13 libgsettings-qt-dev (>= 0.1),
14 libqtdbustest1-dev (>= 0.2),14 libqtdbustest1-dev (>= 0.2),
@@ -50,6 +50,7 @@
50 unity-scopes-impl-7,50 unity-scopes-impl-7,
51 unity-scopes-impl-8,51 unity-scopes-impl-8,
52 unity-scopes-impl-9,52 unity-scopes-impl-9,
53 unity-scopes-impl-10,
53Breaks: unity8-private (<< 7.84),54Breaks: unity8-private (<< 7.84),
54 unity8 (<< 8.11)55 unity8 (<< 8.11)
55Replaces: unity8-private (<< 7.84)56Replaces: unity8-private (<< 7.84)
5657
=== modified file 'debian/libscope-harness.symbols.in'
--- debian/libscope-harness.symbols.in 2015-11-11 09:31:48 +0000
+++ debian/libscope-harness.symbols.in 2016-02-18 15:46:36 +0000
@@ -1,4 +1,5 @@
1libscope-harness.so.@HARNESS_SO_VERSION@ libscope-harness@HARNESS_SO_VERSION@ #MINVER#1libscope-harness.so.@HARNESS_SO_VERSION@ libscope-harness@HARNESS_SO_VERSION@ #MINVER#
2 (c++)"unity::scopeharness::view::PreviewView::preview(std::shared_ptr<unity::shell::scopes::PreviewModelInterface>)@Base" 0replaceme
2 (c++)"typeinfo for unity::scopeharness::registry::CustomRegistry@Base" 0.5.4+15.04.20150311.33 (c++)"typeinfo for unity::scopeharness::registry::CustomRegistry@Base" 0.5.4+15.04.20150311.3
3 (c++)"typeinfo for unity::scopeharness::registry::PreExistingRegistry@Base" 0.5.4+15.04.20150311.34 (c++)"typeinfo for unity::scopeharness::registry::PreExistingRegistry@Base" 0.5.4+15.04.20150311.3
4 (c++)"typeinfo for unity::scopeharness::registry::Registry@Base" 0.5.4+15.04.20150311.35 (c++)"typeinfo for unity::scopeharness::registry::Registry@Base" 0.5.4+15.04.20150311.3
@@ -264,7 +265,6 @@
264 (c++)"unity::scopeharness::TestUtils::getFavoriteScopes()@Base" 0.5.4+15.04.20150311.3265 (c++)"unity::scopeharness::TestUtils::getFavoriteScopes()@Base" 0.5.4+15.04.20150311.3
265 (c++)"unity::scopeharness::TestUtils::getFirstResult(unity::shell::scopes::CategoriesInterface*, std::shared_ptr<unity::scopes::Result>&)@Base" 0.5.4+15.04.20150311.3266 (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::performSearch(QSharedPointer<unity::shell::scopes::ScopeInterface>, QString const&)@Base" 0.5.4+15.04.20150311.3267 (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::previewForFirstResult(QSharedPointer<scopes_ng::Scope>, QString const&, QScopedPointer<scopes_ng::PreviewStack, QScopedPointerDeleter<scopes_ng::PreviewStack> >&)@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.3268 (c++)"unity::scopeharness::TestUtils::refreshSearch(QSharedPointer<scopes_ng::Scope>)@Base" 0.5.4+15.04.20150311.3
269 (c++)"unity::scopeharness::TestUtils::setFavouriteScopes(QStringList const&)@Base" 0.5.4+15.04.20150311.3269 (c++)"unity::scopeharness::TestUtils::setFavouriteScopes(QStringList 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.3270 (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
@@ -273,7 +273,6 @@
273 (c++)"unity::scopeharness::TestUtils::waitForSearchFinish(QSharedPointer<unity::shell::scopes::ScopeInterface>)@Base" 0.5.4+15.04.20150311.3273 (c++)"unity::scopeharness::TestUtils::waitForSearchFinish(QSharedPointer<unity::shell::scopes::ScopeInterface>)@Base" 0.5.4+15.04.20150311.3
274 (c++)"unity::scopeharness::view::AbstractView::~AbstractView()@Base" 0.5.4+15.04.20150311.3274 (c++)"unity::scopeharness::view::AbstractView::~AbstractView()@Base" 0.5.4+15.04.20150311.3
275 (c++)"unity::scopeharness::view::PreviewView::columnCount() const@Base" 0.5.4+15.04.20150311.3275 (c++)"unity::scopeharness::view::PreviewView::columnCount() const@Base" 0.5.4+15.04.20150311.3
276 (c++)"unity::scopeharness::view::PreviewView::preview(std::shared_ptr<unity::shell::scopes::PreviewStackInterface>)@Base" 0.5.4+15.04.20150311.3
277 (c++)"unity::scopeharness::view::PreviewView::~PreviewView()@Base" 0.5.4+15.04.20150311.3276 (c++)"unity::scopeharness::view::PreviewView::~PreviewView()@Base" 0.5.4+15.04.20150311.3
278 (c++)"unity::scopeharness::view::PreviewView::PreviewView()@Base" 0.5.4+15.04.20150311.3277 (c++)"unity::scopeharness::view::PreviewView::PreviewView()@Base" 0.5.4+15.04.20150311.3
279 (c++)"unity::scopeharness::view::PreviewView::refresh()@Base" 0.5.4+15.04.20150311.3278 (c++)"unity::scopeharness::view::PreviewView::refresh()@Base" 0.5.4+15.04.20150311.3
280279
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2015-10-21 10:47:17 +0000
+++ po/POTFILES.in 2016-02-18 15:46:36 +0000
@@ -14,6 +14,7 @@
14tests/data/mock-scope-departments-flipflop/mock-scope-departments-flipflop.cpp14tests/data/mock-scope-departments-flipflop/mock-scope-departments-flipflop.cpp
15tests/data/mock-scope/mock-scope.cpp15tests/data/mock-scope/mock-scope.cpp
16tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp16tests/data/mock-scope-double-nav/mock-scope-double-nav.cpp
17tests/data/mock-scope-manyresults/mock-scope-manyresults.cpp
17tests/settingstest.cpp18tests/settingstest.cpp
18src/scope-harness/registry/system-registry.cpp19src/scope-harness/registry/system-registry.cpp
19src/scope-harness/registry/pre-existing-registry.cpp20src/scope-harness/registry/pre-existing-registry.cpp
@@ -72,11 +73,11 @@
72src/Unity/scopes.cpp73src/Unity/scopes.cpp
73src/Unity/settingsmodel.cpp74src/Unity/settingsmodel.cpp
74src/Unity/utils.cpp75src/Unity/utils.cpp
76src/Unity/resultsmap.cpp
75src/Unity/locationservice.cpp77src/Unity/locationservice.cpp
76src/Unity/ubuntulocationservice.cpp78src/Unity/ubuntulocationservice.cpp
77src/Unity/iconutils.cpp79src/Unity/iconutils.cpp
78src/Unity/department.cpp80src/Unity/department.cpp
79src/Unity/previewstack.cpp
80src/Unity/categories.cpp81src/Unity/categories.cpp
81src/Unity/overviewresults.cpp82src/Unity/overviewresults.cpp
82src/Unity/resultsmodel.cpp83src/Unity/resultsmodel.cpp
@@ -125,7 +126,6 @@
125src/Unity/plugin.h126src/Unity/plugin.h
126src/Unity/department.h127src/Unity/department.h
127src/Unity/scope.h128src/Unity/scope.h
128src/Unity/previewstack.h
129src/Unity/logintoaccount.h129src/Unity/logintoaccount.h
130src/Unity/overviewcategories.h130src/Unity/overviewcategories.h
131src/Unity/locationservice.h131src/Unity/locationservice.h
@@ -133,6 +133,7 @@
133src/Unity/settingsmodel.h133src/Unity/settingsmodel.h
134src/Unity/resultsmodel.h134src/Unity/resultsmodel.h
135src/Unity/geoip.h135src/Unity/geoip.h
136src/Unity/resultsmap.h
136src/Unity/collectors.h137src/Unity/collectors.h
137src/Unity/previewwidgetmodel.h138src/Unity/previewwidgetmodel.h
138src/Unity/categories.h139src/Unity/categories.h
139140
=== modified file 'src/Unity/CMakeLists.txt'
--- src/Unity/CMakeLists.txt 2015-10-21 10:47:17 +0000
+++ src/Unity/CMakeLists.txt 2016-02-18 15:46:36 +0000
@@ -27,7 +27,6 @@
27 overviewresults.cpp27 overviewresults.cpp
28 overviewscope.cpp28 overviewscope.cpp
29 previewmodel.cpp29 previewmodel.cpp
30 previewstack.cpp
31 previewwidgetmodel.cpp30 previewwidgetmodel.cpp
32 resultsmap.cpp31 resultsmap.cpp
33 resultsmodel.cpp32 resultsmodel.cpp
@@ -43,7 +42,6 @@
43 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h42 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
44 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h43 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h
45 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h44 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
46 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
47 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h45 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
48 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h46 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
49 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h47 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
5048
=== modified file 'src/Unity/collectors.h'
--- src/Unity/collectors.h 2015-10-05 12:29:55 +0000
+++ src/Unity/collectors.h 2016-02-18 15:46:36 +0000
@@ -71,7 +71,7 @@
71public:71public:
72 static const QEvent::Type eventType;72 static const QEvent::Type eventType;
7373
74 enum Type { SEARCH, PREVIEW, ACTIVATION };74 enum Type { SEARCH = QEvent::User, PREVIEW, ACTIVATION };
7575
76 PushEvent(Type event_type, const std::shared_ptr<CollectorBase>& collector);76 PushEvent(Type event_type, const std::shared_ptr<CollectorBase>& collector);
77 Type type();77 Type type();
7878
=== modified file 'src/Unity/plugin.cpp'
--- src/Unity/plugin.cpp 2015-10-28 08:41:55 +0000
+++ src/Unity/plugin.cpp 2016-02-18 15:46:36 +0000
@@ -29,7 +29,6 @@
29#include "categories.h"29#include "categories.h"
30#include "department.h"30#include "department.h"
31#include "resultsmodel.h"31#include "resultsmodel.h"
32#include "previewstack.h"
33#include "previewmodel.h"32#include "previewmodel.h"
34#include "previewwidgetmodel.h"33#include "previewwidgetmodel.h"
35#include "settingsmodel.h"34#include "settingsmodel.h"
@@ -48,9 +47,8 @@
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."));
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."));
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."));
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."));
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."));
53 qmlRegisterUncreatableType<unity::shell::scopes::PreviewStackInterface>(uri, 0, 2, "PreviewStack", QStringLiteral("Can't create new PreviewStack in QML. Get them from Scope instance."));
54}52}
5553
56void UnityPlugin::initializeEngine(QQmlEngine *engine, const char *uri)54void UnityPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
5755
=== modified file 'src/Unity/previewmodel.cpp'
--- src/Unity/previewmodel.cpp 2015-09-28 08:41:08 +0000
+++ src/Unity/previewmodel.cpp 2016-02-18 15:46:36 +0000
@@ -27,12 +27,16 @@
27#include "previewwidgetmodel.h"27#include "previewwidgetmodel.h"
28#include "resultsmodel.h"28#include "resultsmodel.h"
29#include "utils.h"29#include "utils.h"
30#include "logintoaccount.h"
3031
31// Qt32// Qt
32#include <QJsonDocument>33#include <QJsonDocument>
33#include <QJsonObject>34#include <QJsonObject>
34#include <QJsonValue>35#include <QJsonValue>
3536
37#include <unity/scopes/Scope.h>
38#include <unity/scopes/ActionMetadata.h>
39
36namespace scopes_ng40namespace scopes_ng
37{41{
3842
@@ -45,11 +49,24 @@
45 m_delayedClear(false),49 m_delayedClear(false),
46 m_widgetColumnCount(1)50 m_widgetColumnCount(1)
47{51{
52 connect(this, &PreviewModel::triggered, this, &PreviewModel::widgetTriggered);
53
48 // we have one column by default54 // we have one column by default
49 PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);55 PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
50 m_previewWidgetModels.append(columnModel);56 m_previewWidgetModels.append(columnModel);
51}57}
5258
59PreviewModel::~PreviewModel()
60{
61 if (m_listener) {
62 m_listener->invalidate();
63 }
64
65 if (m_lastActivation) {
66 m_lastActivation->invalidate();
67 }
68}
69
53void PreviewModel::setResult(std::shared_ptr<scopes::Result> const& result)70void PreviewModel::setResult(std::shared_ptr<scopes::Result> const& result)
54{71{
55 m_previewedResult = result;72 m_previewedResult = result;
@@ -64,6 +81,9 @@
64 case PushEvent::PREVIEW:81 case PushEvent::PREVIEW:
65 processPreviewChunk(pushEvent);82 processPreviewChunk(pushEvent);
66 return true;83 return true;
84 case PushEvent::ACTIVATION:
85 processActionResponse(pushEvent);
86 return true;
67 default:87 default:
68 qWarning("PreviewModel: Unhandled PushEvent type");88 qWarning("PreviewModel: Unhandled PushEvent type");
69 break;89 break;
@@ -73,6 +93,18 @@
73 return unity::shell::scopes::PreviewModelInterface::event(ev);93 return unity::shell::scopes::PreviewModelInterface::event(ev);
74}94}
7595
96void PreviewModel::setAssociatedScope(scopes_ng::Scope* scope, QUuid const& session_id, QString const& userAgent)
97{
98 m_associatedScope = scope;
99 m_session_id = session_id;
100 m_userAgent = userAgent;
101}
102
103scopes_ng::Scope* PreviewModel::associatedScope() const
104{
105 return m_associatedScope;
106}
107
76void PreviewModel::processPreviewChunk(PushEvent* pushEvent)108void PreviewModel::processPreviewChunk(PushEvent* pushEvent)
77{109{
78 CollectorBase::Status status;110 CollectorBase::Status status;
@@ -178,6 +210,26 @@
178 return m_loaded;210 return m_loaded;
179}211}
180212
213void PreviewModel::loadForResult(scopes::Result::SPtr const& result)
214{
215 m_previewedResult = result;
216 if (m_listener) {
217 m_listener->invalidate(); // TODO: is this needed?
218 }
219
220 dispatchPreview();
221}
222
223unity::scopes::Result::SPtr PreviewModel::previewedResult() const
224{
225 return m_previewedResult;
226}
227
228void PreviewModel::update(unity::scopes::PreviewWidgetList const& widgets)
229{
230 updateWidgetDefinitions(widgets);
231}
232
181bool PreviewModel::processingAction() const233bool PreviewModel::processingAction() const
182{234{
183 return m_processingAction;235 return m_processingAction;
@@ -439,4 +491,151 @@
439 }491 }
440}492}
441493
494void PreviewModel::dispatchPreview(scopes::Variant const& extra_data)
495{
496 // TODO: figure out if the result can produce a preview without sending a request to the scope
497 // if (m_previewedResult->has_early_preview()) { ... }
498 try {
499 auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy();
500
501 QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone"));
502 scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString());
503 if (!extra_data.is_null()) {
504 metadata.set_scope_data(extra_data);
505 }
506 if (!m_session_id.isNull()) {
507 metadata["session-id"] = uuidToString(m_session_id).toStdString();
508 }
509 if (!m_userAgent.isEmpty()) {
510 metadata["user-agent"] = m_userAgent.toStdString();
511 }
512
513 std::shared_ptr<PreviewDataReceiver> listener(new PreviewDataReceiver(this));
514 // invalidate previous listener (if any); TODO: is this needed?
515 if (m_listener) {
516 m_listener->invalidate();
517 }
518 m_listener = listener;
519
520 m_lastPreviewQuery = proxy->preview(*(m_previewedResult.get()), metadata, listener);
521 } catch (std::exception& e) {
522 qWarning("Caught an error from preview(): %s", e.what());
523 } catch (...) {
524 qWarning("Caught an error from preview()");
525 }
526}
527
528void PreviewModel::widgetTriggered(QString const& widgetId, QString const& actionId, QVariantMap const& data)
529{
530 auto action = [this, widgetId, actionId, data]() {
531 try {
532 auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy();
533
534 QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone"));
535 scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString());
536 metadata.set_scope_data(qVariantToScopeVariant(data));
537
538 if (m_lastActivation) {
539 m_lastActivation->invalidate();
540 }
541 std::shared_ptr<ActivationReceiver> listener(new ActivationReceiver(this, m_previewedResult));
542 m_lastActivation = listener;
543
544 setProcessingAction(true);
545
546 // FIXME: don't block
547 proxy->perform_action(*(m_previewedResult.get()), metadata, widgetId.toStdString(), actionId.toStdString(), listener);
548 } catch (std::exception& e) {
549 qWarning("Caught an error from perform_action(%s, %s): %s", widgetId.toStdString().c_str(), actionId.toStdString().c_str(), e.what());
550 } catch (...) {
551 qWarning("Caught an error from perform_action()");
552 }
553 };
554
555 PreviewWidgetData* widgetData = getWidgetData(widgetId);
556 if (widgetData != nullptr) {
557 QString wtype = widgetData->type;
558 auto uriAction = [this, wtype, data, action]() {
559 if ((wtype == QLatin1String("actions") || wtype == QLatin1String("icon-actions")) && data.contains(QStringLiteral("uri"))) {
560 if (m_associatedScope) {
561 m_associatedScope->activateUri(data.value(QStringLiteral("uri")).toString());
562 return;
563 }
564 }
565 action();
566 };
567
568 if (m_associatedScope && widgetData->data.contains(QStringLiteral("online_account_details")))
569 {
570 QVariantMap details = widgetData->data.value(QStringLiteral("online_account_details")).toMap();
571 if (details.contains(QStringLiteral("service_name")) &&
572 details.contains(QStringLiteral("service_type")) &&
573 details.contains(QStringLiteral("provider_name")) &&
574 details.contains(QStringLiteral("login_passed_action")) &&
575 details.contains(QStringLiteral("login_failed_action")))
576 {
577 LoginToAccount *login = new LoginToAccount(details.contains(QStringLiteral("scope_id")) ? details.value(QStringLiteral("scope_id")).toString() : QLatin1String(""),
578 details.value(QStringLiteral("service_name")).toString(),
579 details.value(QStringLiteral("service_type")).toString(),
580 details.value(QStringLiteral("provider_name")).toString(),
581 details.value(QStringLiteral("login_passed_action")).toInt(),
582 details.value(QStringLiteral("login_failed_action")).toInt(),
583 this);
584 connect(login, SIGNAL(searchInProgress(bool)), m_associatedScope, SLOT(setSearchInProgress(bool)));
585 connect(login, &LoginToAccount::finished, [this, login, uriAction](bool, int action_code_index) {
586 if (action_code_index >= 0 && action_code_index <= scopes::OnlineAccountClient::LastActionCode_)
587 {
588 scopes::OnlineAccountClient::PostLoginAction action_code = static_cast<scopes::OnlineAccountClient::PostLoginAction>(action_code_index);
589 switch (action_code)
590 {
591 case scopes::OnlineAccountClient::DoNothing:
592 return;
593 case scopes::OnlineAccountClient::InvalidateResults:
594 m_associatedScope->invalidateResults();
595 return;
596 default:
597 break;
598 }
599 }
600 uriAction();
601 login->deleteLater();
602 });
603 login->loginToAccount();
604 return; // main execution ends here
605 }
606 } else {
607 uriAction();
608 }
609 } else {
610 qWarning("Action triggered for unknown widget \"%s\"", widgetId.toStdString().c_str());
611 }
612}
613
614void PreviewModel::processActionResponse(PushEvent* pushEvent)
615{
616 std::shared_ptr<scopes::ActivationResponse> response;
617 scopes::Result::SPtr result;
618 QString categoryId;
619 pushEvent->collectActivationResponse(response, result, categoryId);
620 if (!response) return;
621
622 switch (response->status()) {
623 case scopes::ActivationResponse::ShowPreview:
624 // replace current preview
625 setDelayedClear();
626 // the preview is marked as processing action, leave the flag on until the preview is updated
627 dispatchPreview(scopes::Variant(response->scope_data()));
628 break;
629 // TODO: case to nest preview (once such API is available)
630 default:
631 if (m_associatedScope) {
632 m_associatedScope->handleActivation(response, result);
633 }
634
635 setProcessingAction(false);
636 break;
637 }
638}
639
640
442} // namespace scopes_ng641} // namespace scopes_ng
443642
=== modified file 'src/Unity/previewmodel.h'
--- src/Unity/previewmodel.h 2015-08-14 12:29:16 +0000
+++ src/Unity/previewmodel.h 2016-02-18 15:46:36 +0000
@@ -29,11 +29,14 @@
29#include <QMultiMap>29#include <QMultiMap>
30#include <QStringList>30#include <QStringList>
31#include <QPointer>31#include <QPointer>
32#include <QUuid>
3233
33#include <unity/scopes/PreviewWidget.h>34#include <unity/scopes/PreviewWidget.h>
34#include <unity/scopes/Result.h>35#include <unity/scopes/Result.h>
35#include <unity/scopes/ColumnLayout.h>36#include <unity/scopes/ColumnLayout.h>
3637
38#include "collectors.h"
39
37namespace scopes_ng40namespace scopes_ng
38{41{
3942
@@ -60,6 +63,7 @@
6063
61public:64public:
62 explicit PreviewModel(QObject* parent = 0);65 explicit PreviewModel(QObject* parent = 0);
66 ~PreviewModel();
6367
64 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;68 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
65 int rowCount(const QModelIndex& parent = QModelIndex()) const override;69 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
@@ -80,7 +84,18 @@
8084
81 void updateWidgetDefinitions(unity::scopes::PreviewWidgetList const&);85 void updateWidgetDefinitions(unity::scopes::PreviewWidgetList const&);
8286
87 void loadForResult(unity::scopes::Result::SPtr const&);
88 void update(unity::scopes::PreviewWidgetList const&);
89
90 void setAssociatedScope(scopes_ng::Scope*, QUuid const&, QString const&);
91 scopes_ng::Scope* associatedScope() const;
92 unity::scopes::Result::SPtr previewedResult() const;
93
94private Q_SLOTS:
95 void widgetTriggered(QString const&, QString const&, QVariantMap const&);
96
83private:97private:
98 void processActionResponse(PushEvent* pushEvent);
84 void addWidgetDefinitions(unity::scopes::PreviewWidgetList const&);99 void addWidgetDefinitions(unity::scopes::PreviewWidgetList const&);
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);
86 void processPreviewChunk(PushEvent* pushEvent);101 void processPreviewChunk(PushEvent* pushEvent);
@@ -89,6 +104,7 @@
89 PreviewWidgetModel* createExpandableWidgetModel(unity::scopes::PreviewWidget const&, PreviewWidgetData &);104 PreviewWidgetModel* createExpandableWidgetModel(unity::scopes::PreviewWidget const&, PreviewWidgetData &);
90 void addWidgetToColumnModel(QSharedPointer<PreviewWidgetData> const&);105 void addWidgetToColumnModel(QSharedPointer<PreviewWidgetData> const&);
91 void processComponents(QHash<QString, QString> const& components, QVariantMap& out_attributes);106 void processComponents(QHash<QString, QString> const& components, QVariantMap& out_attributes);
107 void dispatchPreview(unity::scopes::Variant const& extra_data = unity::scopes::Variant());
92108
93 bool m_loaded;109 bool m_loaded;
94 bool m_processingAction;110 bool m_processingAction;
@@ -100,7 +116,13 @@
100 QList<QSharedPointer<PreviewWidgetData>> m_previewWidgets;116 QList<QSharedPointer<PreviewWidgetData>> m_previewWidgets;
101 QMultiMap<QString, PreviewWidgetData*> m_dataToWidgetMap;117 QMultiMap<QString, PreviewWidgetData*> m_dataToWidgetMap;
102118
119 unity::scopes::QueryCtrlProxy m_lastPreviewQuery;
120 QPointer<scopes_ng::Scope> m_associatedScope;
121 QUuid m_session_id;
122 QString m_userAgent;
103 std::shared_ptr<unity::scopes::Result> m_previewedResult;123 std::shared_ptr<unity::scopes::Result> m_previewedResult;
124 std::shared_ptr<ScopeDataReceiverBase> m_listener;
125 std::shared_ptr<ScopeDataReceiverBase> m_lastActivation;
104};126};
105127
106} // namespace scopes_ng128} // namespace scopes_ng
107129
=== removed file 'src/Unity/previewstack.cpp'
--- src/Unity/previewstack.cpp 2015-10-21 10:47:17 +0000
+++ src/Unity/previewstack.cpp 1970-01-01 00:00:00 +0000
@@ -1,338 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Michał Sawicz <michal.sawicz@canonical.com>
6 * Michal Hruby <michal.hruby@canonical.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 3.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21// self
22#include "previewstack.h"
23
24// local
25#include "previewmodel.h"
26#include "scope.h"
27#include "utils.h"
28#include "logintoaccount.h"
29
30// Qt
31#include <QLocale>
32#include <QJsonDocument>
33#include <QJsonObject>
34#include <QJsonValue>
35#include <QUuid>
36#include <QPointer>
37
38#include <unity/scopes/ActionMetadata.h>
39#include <unity/scopes/Scope.h>
40
41namespace scopes_ng
42{
43
44using namespace unity;
45
46PreviewStack::PreviewStack(QObject* parent)
47 : unity::shell::scopes::PreviewStackInterface(parent)
48 , m_widgetColumnCount(1), m_activePreview(nullptr)
49{
50}
51
52PreviewStack::~PreviewStack()
53{
54 for (auto it = m_listeners.begin(); it != m_listeners.end(); ++it) {
55 auto listener = it.value().lock();
56 if (listener) listener->invalidate();
57 }
58
59 if (m_lastActivation) {
60 m_lastActivation->invalidate();
61 }
62}
63
64bool PreviewStack::event(QEvent* ev)
65{
66 if (ev->type() == PushEvent::eventType) {
67 PushEvent* pushEvent = static_cast<PushEvent*>(ev);
68
69 switch (pushEvent->type()) {
70 case PushEvent::ACTIVATION:
71 processActionResponse(pushEvent);
72 return true;
73 default:
74 qWarning("PreviewStack: Unhandled PushEvent type");
75 break;
76 }
77 }
78
79 return unity::shell::scopes::PreviewStackInterface::event(ev);
80}
81
82void PreviewStack::setAssociatedScope(scopes_ng::Scope* scope, QUuid const& session_id, QString const& userAgent)
83{
84 m_associatedScope = scope;
85 m_session_id = session_id;
86 m_userAgent = userAgent;
87}
88
89scopes_ng::Scope* PreviewStack::associatedScope() const
90{
91 return m_associatedScope;
92}
93
94void PreviewStack::loadForResult(scopes::Result::SPtr const& result)
95{
96 m_previewedResult = result;
97
98 beginResetModel();
99
100 // invalidate all listeners
101 for (auto it = m_listeners.begin(); it != m_listeners.end(); ++it) {
102 auto listener = it.value().lock();
103 if (listener) listener->invalidate();
104 }
105 // clear any previews
106 while (!m_previews.empty()) {
107 delete m_previews.takeFirst();
108 }
109 // create active preview
110 m_activePreview = new PreviewModel(this);
111 m_activePreview->setResult(m_previewedResult);
112 connect(m_activePreview, &PreviewModel::triggered, this, &PreviewStack::widgetTriggered);
113 m_previews.append(m_activePreview);
114
115 endResetModel();
116
117 dispatchPreview();
118}
119
120void PreviewStack::update(unity::scopes::PreviewWidgetList const& widgets)
121{
122 if (m_activePreview == nullptr) {
123 return;
124 }
125 m_activePreview->updateWidgetDefinitions(widgets);
126}
127
128void PreviewStack::dispatchPreview(scopes::Variant const& extra_data)
129{
130 // TODO: figure out if the result can produce a preview without sending a request to the scope
131 // if (m_previewedResult->has_early_preview()) { ... }
132 try {
133 auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy();
134
135 QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone"));
136 scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString());
137 if (!extra_data.is_null()) {
138 metadata.set_scope_data(extra_data);
139 }
140 if (!m_session_id.isNull()) {
141 metadata["session-id"] = uuidToString(m_session_id).toStdString();
142 }
143 if (!m_userAgent.isEmpty()) {
144 metadata["user-agent"] = m_userAgent.toStdString();
145 }
146
147 std::shared_ptr<PreviewDataReceiver> listener(new PreviewDataReceiver(m_activePreview));
148 std::weak_ptr<ScopeDataReceiverBase> wl(listener);
149 // invalidate previous listener (if any)
150 auto prev_listener = m_listeners.take(m_activePreview).lock();
151 if (prev_listener) prev_listener->invalidate();
152 m_listeners[m_activePreview] = wl;
153
154 m_lastPreviewQuery = proxy->preview(*(m_previewedResult.get()), metadata, listener);
155 } catch (std::exception& e) {
156 qWarning("Caught an error from preview(): %s", e.what());
157 } catch (...) {
158 qWarning("Caught an error from preview()");
159 }
160}
161
162void PreviewStack::widgetTriggered(QString const& widgetId, QString const& actionId, QVariantMap const& data)
163{
164 auto action = [this, widgetId, actionId, data]() {
165 try {
166 auto proxy = m_associatedScope ? m_associatedScope->proxy_for_result(m_previewedResult) : m_previewedResult->target_scope_proxy();
167
168 QString formFactor(m_associatedScope ? m_associatedScope->formFactor() : QStringLiteral("phone"));
169 scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), formFactor.toStdString());
170 metadata.set_scope_data(qVariantToScopeVariant(data));
171
172 if (m_lastActivation) {
173 m_lastActivation->invalidate();
174 }
175 std::shared_ptr<ActivationReceiver> listener(new ActivationReceiver(this, m_previewedResult));
176 m_lastActivation = listener;
177
178 // should be always coming from active preview
179 if (m_activePreview) {
180 m_activePreview->setProcessingAction(true);
181 }
182
183 // FIXME: don't block
184 proxy->perform_action(*(m_previewedResult.get()), metadata, widgetId.toStdString(), actionId.toStdString(), listener);
185 } catch (std::exception& e) {
186 qWarning("Caught an error from perform_action(%s, %s): %s", widgetId.toStdString().c_str(), actionId.toStdString().c_str(), e.what());
187 } catch (...) {
188 qWarning("Caught an error from perform_action()");
189 }
190 };
191
192 PreviewModel* previewModel = qobject_cast<scopes_ng::PreviewModel*>(sender());
193 if (previewModel != nullptr) {
194 PreviewWidgetData* widgetData = previewModel->getWidgetData(widgetId);
195 if (widgetData != nullptr) {
196 QString wtype = widgetData->type;
197 auto uriAction = [this, wtype, data, action]() {
198 if ((wtype == QLatin1String("actions") || wtype == QLatin1String("icon-actions")) && data.contains(QStringLiteral("uri"))) {
199 if (m_associatedScope) {
200 m_associatedScope->activateUri(data.value(QStringLiteral("uri")).toString());
201 return;
202 }
203 }
204 action();
205 };
206
207 if (m_associatedScope && widgetData->data.contains(QStringLiteral("online_account_details")))
208 {
209 QVariantMap details = widgetData->data.value(QStringLiteral("online_account_details")).toMap();
210 if (details.contains(QStringLiteral("service_name")) &&
211 details.contains(QStringLiteral("service_type")) &&
212 details.contains(QStringLiteral("provider_name")) &&
213 details.contains(QStringLiteral("login_passed_action")) &&
214 details.contains(QStringLiteral("login_failed_action")))
215 {
216 LoginToAccount *login = new LoginToAccount(details.contains(QStringLiteral("scope_id")) ? details.value(QStringLiteral("scope_id")).toString() : QLatin1String(""),
217 details.value(QStringLiteral("service_name")).toString(),
218 details.value(QStringLiteral("service_type")).toString(),
219 details.value(QStringLiteral("provider_name")).toString(),
220 details.value(QStringLiteral("login_passed_action")).toInt(),
221 details.value(QStringLiteral("login_failed_action")).toInt(),
222 this);
223 connect(login, SIGNAL(searchInProgress(bool)), m_associatedScope, SLOT(setSearchInProgress(bool)));
224 connect(login, &LoginToAccount::finished, [this, login, uriAction](bool, int action_code_index) {
225 if (action_code_index >= 0 && action_code_index <= scopes::OnlineAccountClient::LastActionCode_)
226 {
227 scopes::OnlineAccountClient::PostLoginAction action_code = static_cast<scopes::OnlineAccountClient::PostLoginAction>(action_code_index);
228 switch (action_code)
229 {
230 case scopes::OnlineAccountClient::DoNothing:
231 return;
232 case scopes::OnlineAccountClient::InvalidateResults:
233 m_associatedScope->invalidateResults();
234 return;
235 default:
236 break;
237 }
238 }
239 uriAction();
240 login->deleteLater();
241 });
242 login->loginToAccount();
243 return; // main execution ends here
244 }
245 } else {
246 uriAction();
247 }
248 } else {
249 qWarning("Action triggered for unknown widget \"%s\"", widgetId.toStdString().c_str());
250 }
251 } else {
252 action();
253 }
254}
255
256void PreviewStack::processActionResponse(PushEvent* pushEvent)
257{
258 std::shared_ptr<scopes::ActivationResponse> response;
259 scopes::Result::SPtr result;
260 QString categoryId;
261 pushEvent->collectActivationResponse(response, result, categoryId);
262 if (!response) return;
263
264 switch (response->status()) {
265 case scopes::ActivationResponse::ShowPreview:
266 // replace current preview
267 m_activePreview->setDelayedClear();
268 // the preview is marked as processing action, leave the flag on until the preview is updated
269 dispatchPreview(scopes::Variant(response->scope_data()));
270 break;
271 // TODO: case to nest preview (once such API is available)
272 default:
273 if (m_associatedScope) {
274 m_associatedScope->handleActivation(response, result);
275 }
276
277 if (m_activePreview) {
278 m_activePreview->setProcessingAction(false);
279 }
280 break;
281 }
282}
283
284void PreviewStack::setWidgetColumnCount(int columnCount)
285{
286 if (m_widgetColumnCount != columnCount) {
287 m_widgetColumnCount = columnCount;
288 // set on all previews
289 for (int i = 0; i < m_previews.size(); i++) {
290 m_previews[i]->setWidgetColumnCount(columnCount);
291 }
292 Q_EMIT widgetColumnCountChanged();
293 }
294}
295
296int PreviewStack::widgetColumnCount() const
297{
298 return m_widgetColumnCount;
299}
300
301int PreviewStack::rowCount(const QModelIndex&) const
302{
303 return m_previews.size();
304}
305
306unity::scopes::Result::SPtr PreviewStack::previewedResult() const
307{
308 return m_previewedResult;
309}
310
311unity::shell::scopes::PreviewModelInterface* PreviewStack::getPreviewModel(int index) const
312{
313 if (index >= m_previews.size()) {
314 return nullptr;
315 }
316
317 return m_previews.at(index);
318}
319
320QVariant PreviewStack::data(const QModelIndex& index, int role) const
321{
322 int row = index.row();
323 if (row >= m_previews.size())
324 {
325 qWarning() << "PreviewStack::data - invalid index" << row << "size"
326 << m_previews.size();
327 return QVariant();
328 }
329
330 switch (role) {
331 case RolePreviewModel:
332 return QVariant::fromValue(m_previews.at(index.row()));
333 default:
334 return QVariant();
335 }
336}
337
338} // namespace scopes_ng
3390
=== removed file 'src/Unity/previewstack.h'
--- src/Unity/previewstack.h 2015-08-14 12:29:16 +0000
+++ src/Unity/previewstack.h 1970-01-01 00:00:00 +0000
@@ -1,94 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * Authors:
5 * Michał Sawicz <michal.sawicz@canonical.com>
6 * Michal Hruby <michal.hruby@canonical.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 3.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22#ifndef NG_PREVIEW_STACK_H
23#define NG_PREVIEW_STACK_H
24
25#include <unity/shell/scopes/PreviewStackInterface.h>
26
27#include <QSet>
28#include <QSharedPointer>
29#include <QMultiMap>
30#include <QPointer>
31#include <QUuid>
32
33#include <unity/scopes/PreviewWidget.h>
34#include <unity/scopes/Result.h>
35
36#include "collectors.h"
37
38namespace scopes_ng
39{
40
41class PreviewModel;
42class Scope;
43
44class Q_DECL_EXPORT PreviewStack : public unity::shell::scopes::PreviewStackInterface
45{
46 Q_OBJECT
47
48public:
49 explicit PreviewStack(QObject* parent = 0);
50 virtual ~PreviewStack();
51
52 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
53 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
54
55 virtual bool event(QEvent* ev) override;
56
57 Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const override;
58
59 void loadForResult(unity::scopes::Result::SPtr const&);
60 void update(unity::scopes::PreviewWidgetList const&);
61
62 void setWidgetColumnCount(int columnCount) override;
63 int widgetColumnCount() const override;
64 void setAssociatedScope(scopes_ng::Scope*, QUuid const&, QString const&);
65 scopes_ng::Scope* associatedScope() const;
66 unity::scopes::Result::SPtr previewedResult() const;
67
68private Q_SLOTS:
69 void widgetTriggered(QString const&, QString const&, QVariantMap const&);
70
71private:
72 void processActionResponse(PushEvent* pushEvent);
73
74 void dispatchPreview(unity::scopes::Variant const& extra_data = unity::scopes::Variant());
75
76 int m_widgetColumnCount;
77 QList<PreviewModel*> m_previews;
78 PreviewModel* m_activePreview;
79 QPointer<scopes_ng::Scope> m_associatedScope;
80
81 unity::scopes::QueryCtrlProxy m_lastPreviewQuery;
82 QMap<PreviewModel*, std::weak_ptr<ScopeDataReceiverBase>> m_listeners;
83 std::shared_ptr<ScopeDataReceiverBase> m_lastActivation;
84
85 unity::scopes::Result::SPtr m_previewedResult;
86 QUuid m_session_id;
87 QString m_userAgent;
88};
89
90} // namespace scopes_ng
91
92Q_DECLARE_METATYPE(scopes_ng::PreviewStack*)
93
94#endif // NG_PREVIEW_STACK_H
950
=== modified file 'src/Unity/scope.cpp'
--- src/Unity/scope.cpp 2015-11-30 09:23:32 +0000
+++ src/Unity/scope.cpp 2016-02-18 15:46:36 +0000
@@ -23,7 +23,7 @@
23// local23// local
24#include "categories.h"24#include "categories.h"
25#include "collectors.h"25#include "collectors.h"
26#include "previewstack.h"26#include "previewmodel.h"
27#include "locationservice.h"27#include "locationservice.h"
28#include "utils.h"28#include "utils.h"
29#include "scopes.h"29#include "scopes.h"
@@ -83,6 +83,7 @@
83 , m_formFactor(QStringLiteral("phone"))83 , m_formFactor(QStringLiteral("phone"))
84 , m_isActive(false)84 , m_isActive(false)
85 , m_searchInProgress(false)85 , m_searchInProgress(false)
86 , m_activationInProgress(false)
86 , m_resultsDirty(false)87 , m_resultsDirty(false)
87 , m_delayedSearchProcessing(false)88 , m_delayedSearchProcessing(false)
88 , m_hasNavigation(false)89 , m_hasNavigation(false)
@@ -207,6 +208,8 @@
207208
208void Scope::handleActivation(std::shared_ptr<scopes::ActivationResponse> const& response, scopes::Result::SPtr const& result, QString const& categoryId)209void Scope::handleActivation(std::shared_ptr<scopes::ActivationResponse> const& response, scopes::Result::SPtr const& result, QString const& categoryId)
209{210{
211 setActivationInProgress(false);
212
210 switch (response->status()) {213 switch (response->status()) {
211 case scopes::ActivationResponse::NotHandled:214 case scopes::ActivationResponse::NotHandled:
212 activateUri(QString::fromStdString(result->uri()));215 activateUri(QString::fromStdString(result->uri()));
@@ -270,15 +273,15 @@
270273
271void Scope::handlePreviewUpdate(unity::scopes::Result::SPtr const& result, unity::scopes::PreviewWidgetList const& widgets)274void Scope::handlePreviewUpdate(unity::scopes::Result::SPtr const& result, unity::scopes::PreviewWidgetList const& widgets)
272{275{
273 for (auto stack: m_previewStacks) {276 for (auto model: m_previewModels) {
274 auto previewedResult = stack->previewedResult();277 auto previewedResult = model->previewedResult();
275278
276 if (result == nullptr) {279 if (result == nullptr) {
277 qWarning() << "handlePreviewUpdate: result is null";280 qWarning() << "handlePreviewUpdate: result is null";
278 return;281 return;
279 }282 }
280 if (previewedResult != nullptr && *result == *previewedResult) {283 if (previewedResult != nullptr && *result == *previewedResult) {
281 stack->update(widgets);284 model->update(widgets);
282 }285 }
283 }286 }
284}287}
@@ -675,6 +678,14 @@
675 }678 }
676}679}
677680
681void Scope::setActivationInProgress(bool activationInProgress)
682{
683 if (m_activationInProgress != activationInProgress) {
684 m_activationInProgress = activationInProgress;
685 Q_EMIT activationInProgressChanged();
686 }
687}
688
678void Scope::setStatus(shell::scopes::ScopeInterface::Status status)689void Scope::setStatus(shell::scopes::ScopeInterface::Status status)
679{690{
680 if (m_status != status) {691 if (m_status != status) {
@@ -864,6 +875,11 @@
864 return m_searchInProgress;875 return m_searchInProgress;
865}876}
866877
878bool Scope::activationInProgress() const
879{
880 return m_activationInProgress;
881}
882
867unity::shell::scopes::ScopeInterface::Status Scope::status() const883unity::shell::scopes::ScopeInterface::Status Scope::status() const
868{884{
869 return m_status;885 return m_status;
@@ -1008,12 +1024,12 @@
1008 m_inverseDepartments.erase(it);1024 m_inverseDepartments.erase(it);
1009}1025}
10101026
1011void Scope::previewStackDestroyed(QObject *obj)1027void Scope::previewModelDestroyed(QObject *obj)
1012{1028{
1013 for (auto it = m_previewStacks.begin(); it != m_previewStacks.end(); it++)1029 for (auto it = m_previewModels.begin(); it != m_previewModels.end(); it++)
1014 {1030 {
1015 if (*it == obj) {1031 if (*it == obj) {
1016 m_previewStacks.erase(it);1032 m_previewModels.erase(it);
1017 break;1033 break;
1018 }1034 }
1019 }1035 }
@@ -1205,13 +1221,17 @@
1205 scopes::ActivationListenerBase::SPtr listener(new ActivationReceiver(this, result));1221 scopes::ActivationListenerBase::SPtr listener(new ActivationReceiver(this, result));
1206 m_activationController->setListener(listener);1222 m_activationController->setListener(listener);
12071223
1224 setActivationInProgress(true);
1225
1208 auto proxy = proxy_for_result(result);1226 auto proxy = proxy_for_result(result);
1209 unity::scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), m_formFactor.toStdString());1227 unity::scopes::ActionMetadata metadata(QLocale::system().name().toStdString(), m_formFactor.toStdString());
1210 scopes::QueryCtrlProxy controller = proxy->activate(*(result.get()), metadata, listener);1228 scopes::QueryCtrlProxy controller = proxy->activate(*(result.get()), metadata, listener);
1211 m_activationController->setController(controller);1229 m_activationController->setController(controller);
1212 } catch (std::exception& e) {1230 } catch (std::exception& e) {
1231 setActivationInProgress(false);
1213 qWarning("Caught an error from activate(): %s", e.what());1232 qWarning("Caught an error from activate(): %s", e.what());
1214 } catch (...) {1233 } catch (...) {
1234 setActivationInProgress(false);
1215 qWarning("Caught an error from activate()");1235 qWarning("Caught an error from activate()");
1216 }1236 }
1217 }1237 }
@@ -1282,7 +1302,7 @@
1282 }1302 }
1283}1303}
12841304
1285unity::shell::scopes::PreviewStackInterface* Scope::preview(QVariant const& result_var, QString const& categoryId)1305unity::shell::scopes::PreviewModelInterface* Scope::preview(QVariant const& result_var, QString const& categoryId)
1286{1306{
1287 if (!result_var.canConvert<std::shared_ptr<scopes::Result>>()) {1307 if (!result_var.canConvert<std::shared_ptr<scopes::Result>>()) {
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());
@@ -1300,12 +1320,12 @@
1300 return nullptr;1320 return nullptr;
1301 }1321 }
13021322
1303 PreviewStack* stack = new PreviewStack(nullptr);1323 PreviewModel* previewModel = new PreviewModel(nullptr);
1304 QObject::connect(stack, &QObject::destroyed, this, &Scope::previewStackDestroyed);1324 QObject::connect(previewModel, &QObject::destroyed, this, &Scope::previewModelDestroyed);
1305 m_previewStacks.append(stack);1325 m_previewModels.append(previewModel);
1306 stack->setAssociatedScope(this, m_session_id, m_scopesInstance->userAgentString());1326 previewModel->setAssociatedScope(this, m_session_id, m_scopesInstance->userAgentString());
1307 stack->loadForResult(result);1327 previewModel->loadForResult(result);
1308 return stack;1328 return previewModel;
1309}1329}
13101330
1311void Scope::cancelActivation()1331void Scope::cancelActivation()
13121332
=== modified file 'src/Unity/scope.h'
--- src/Unity/scope.h 2015-11-30 09:23:32 +0000
+++ src/Unity/scope.h 2016-02-18 15:46:36 +0000
@@ -48,7 +48,7 @@
4848
49class Categories;49class Categories;
50class PushEvent;50class PushEvent;
51class PreviewStack;51class PreviewModel;
52class LocationService;52class LocationService;
53class SettingsModel;53class SettingsModel;
54class Scopes;54class Scopes;
@@ -125,6 +125,7 @@
125 bool favorite() const override;125 bool favorite() const override;
126 QString shortcut() const override;126 QString shortcut() const override;
127 bool searchInProgress() const override;127 bool searchInProgress() const override;
128 bool activationInProgress() const override;
128 unity::shell::scopes::ScopeInterface::Status status() const override;129 unity::shell::scopes::ScopeInterface::Status status() const override;
129 unity::shell::scopes::CategoriesInterface* categories() const override;130 unity::shell::scopes::CategoriesInterface* categories() const override;
130 unity::shell::scopes::SettingsModelInterface* settings() const override;131 unity::shell::scopes::SettingsModelInterface* settings() const override;
@@ -148,7 +149,7 @@
148 void setFavorite(const bool) override;149 void setFavorite(const bool) override;
149150
150 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;151 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
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;
152 Q_INVOKABLE void cancelActivation() override;153 Q_INVOKABLE void cancelActivation() override;
153 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;154 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
154 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& id) override;155 Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& id) override;
@@ -177,6 +178,7 @@
177 void invalidateResults();178 void invalidateResults();
178 virtual void dispatchSearch();179 virtual void dispatchSearch();
179 void setSearchInProgress(bool searchInProgress);180 void setSearchInProgress(bool searchInProgress);
181 void setActivationInProgress(bool activationInProgress);
180182
181Q_SIGNALS:183Q_SIGNALS:
182 void resultsDirtyChanged();184 void resultsDirtyChanged();
@@ -189,7 +191,7 @@
189 void flushUpdates(bool finalize = false);191 void flushUpdates(bool finalize = false);
190 void metadataRefreshed();192 void metadataRefreshed();
191 void departmentModelDestroyed(QObject* obj);193 void departmentModelDestroyed(QObject* obj);
192 void previewStackDestroyed(QObject *obj);194 void previewModelDestroyed(QObject *obj);
193195
194protected:196protected:
195 explicit Scope(scopes_ng::Scopes* parent);197 explicit Scope(scopes_ng::Scopes* parent);
@@ -230,6 +232,7 @@
230 std::unique_ptr<unity::scopes::Variant> m_queryUserData;232 std::unique_ptr<unity::scopes::Variant> m_queryUserData;
231 bool m_isActive;233 bool m_isActive;
232 bool m_searchInProgress;234 bool m_searchInProgress;
235 bool m_activationInProgress;
233 bool m_resultsDirty;236 bool m_resultsDirty;
234 bool m_delayedSearchProcessing;237 bool m_delayedSearchProcessing;
235 bool m_hasNavigation;238 bool m_hasNavigation;
@@ -264,7 +267,7 @@
264 QSharedPointer<LocationService> m_locationService;267 QSharedPointer<LocationService> m_locationService;
265 QSharedPointer<LocationService::Token> m_locationToken;268 QSharedPointer<LocationService::Token> m_locationToken;
266 QNetworkConfigurationManager m_network_manager;269 QNetworkConfigurationManager m_network_manager;
267 QList<PreviewStack*> m_previewStacks;270 QList<PreviewModel*> m_previewModels;
268};271};
269272
270} // namespace scopes_ng273} // namespace scopes_ng
271274
=== modified file 'src/scope-harness/internal/preview-widget-arguments.h'
--- src/scope-harness/internal/preview-widget-arguments.h 2015-04-24 13:06:14 +0000
+++ src/scope-harness/internal/preview-widget-arguments.h 2016-02-18 15:46:36 +0000
@@ -31,7 +31,6 @@
31{31{
32 class PreviewWidgetModelInterface;32 class PreviewWidgetModelInterface;
33 class PreviewModelInterface;33 class PreviewModelInterface;
34 class PreviewStackInterface;
35}34}
36}35}
37namespace scopeharness36namespace scopeharness
@@ -54,8 +53,6 @@
54 std::shared_ptr<view::ResultsView> resultsView;53 std::shared_ptr<view::ResultsView> resultsView;
5554
56 std::shared_ptr<view::PreviewView> previewView;55 std::shared_ptr<view::PreviewView> previewView;
57
58 std::shared_ptr<unity::shell::scopes::PreviewStackInterface> previewStack;
59};56};
60}57}
61}58}
6259
=== modified file 'src/scope-harness/preview/preview-widget.cpp'
--- src/scope-harness/preview/preview-widget.cpp 2015-08-20 07:32:49 +0000
+++ src/scope-harness/preview/preview-widget.cpp 2016-02-18 15:46:36 +0000
@@ -23,11 +23,12 @@
23#include <scope-harness/view/results-view.h>23#include <scope-harness/view/results-view.h>
24#include <scope-harness/test-utils.h>24#include <scope-harness/test-utils.h>
2525
26#include <Unity/previewmodel.h>
27
26#include <unity/shell/scopes/PreviewModelInterface.h>28#include <unity/shell/scopes/PreviewModelInterface.h>
27#include <unity/shell/scopes/PreviewWidgetModelInterface.h>29#include <unity/shell/scopes/PreviewWidgetModelInterface.h>
2830
29#include <Unity/utils.h>31#include <Unity/utils.h>
30#include <Unity/previewstack.h>
3132
32#include <QDebug>33#include <QDebug>
33#include <QSignalSpy>34#include <QSignalSpy>
@@ -57,8 +58,6 @@
57 weak_ptr<view::ResultsView> m_resultsView;58 weak_ptr<view::ResultsView> m_resultsView;
5859
59 weak_ptr<view::PreviewView> m_previewView;60 weak_ptr<view::PreviewView> m_previewView;
60
61 std::shared_ptr<unity::shell::scopes::PreviewStackInterface> m_previewStack;
62};61};
6362
64PreviewWidget::PreviewWidget(const internal::PreviewWidgetArguments& arguments) :63PreviewWidget::PreviewWidget(const internal::PreviewWidgetArguments& arguments) :
@@ -69,7 +68,6 @@
69 p->m_index = arguments.index;68 p->m_index = arguments.index;
70 p->m_resultsView = arguments.resultsView;69 p->m_resultsView = arguments.resultsView;
71 p->m_previewView = arguments.previewView;70 p->m_previewView = arguments.previewView;
72 p->m_previewStack = arguments.previewStack;
73}71}
7472
7573
@@ -91,7 +89,6 @@
91 p->m_index = other.p->m_index;89 p->m_index = other.p->m_index;
92 p->m_resultsView = other.p->m_resultsView;90 p->m_resultsView = other.p->m_resultsView;
93 p->m_previewView = other.p->m_previewView;91 p->m_previewView = other.p->m_previewView;
94 p->m_previewStack = other.p->m_previewStack;
95 return *this;92 return *this;
96}93}
9794
@@ -127,9 +124,8 @@
127124
128view::AbstractView::SPtr PreviewWidget::trigger(const string& name, const sc::Variant& v)125view::AbstractView::SPtr PreviewWidget::trigger(const string& name, const sc::Variant& v)
129{126{
130 auto ps = std::dynamic_pointer_cast<ng::PreviewStack>(p->m_previewStack);127 auto ps = dynamic_cast<ng::PreviewModel*>(p->m_previewModel);
131 TestUtils::throwIfNot(bool(ps), "No preview stack");128 TestUtils::throwIfNot(bool(ps->associatedScope()), "Preview model has no associated scope");
132 TestUtils::throwIfNot(bool(ps->associatedScope()), "Preview stack has no associated scope");
133 QSignalSpy showDashSpy(ps->associatedScope(), SIGNAL(showDash()));129 QSignalSpy showDashSpy(ps->associatedScope(), SIGNAL(showDash()));
134130
135 QVariant widgetData;131 QVariant widgetData;
@@ -153,7 +149,7 @@
153 widgetData = ng::scopeVariantToQVariant(v);149 widgetData = ng::scopeVariantToQVariant(v);
154 }150 }
155151
156 Q_EMIT p->m_previewModel->triggered(152 Q_EMIT ps->triggered(
157 QString::fromStdString(id()), QString::fromStdString(name),153 QString::fromStdString(id()), QString::fromStdString(name),
158 widgetData.toMap());154 widgetData.toMap());
159155
160156
=== modified file 'src/scope-harness/results/result.cpp'
--- src/scope-harness/results/result.cpp 2015-11-30 09:23:32 +0000
+++ src/scope-harness/results/result.cpp 2016-02-18 15:46:36 +0000
@@ -23,9 +23,9 @@
23#include <scope-harness/view/results-view.h>23#include <scope-harness/view/results-view.h>
2424
25#include <Unity/resultsmodel.h>25#include <Unity/resultsmodel.h>
26#include <Unity/previewstack.h>
27#include <Unity/scope.h>26#include <Unity/scope.h>
28#include <Unity/utils.h>27#include <Unity/utils.h>
28#include <Unity/previewmodel.h>
2929
30#include <QObject>30#include <QObject>
31#include <QSignalSpy>31#include <QSignalSpy>
@@ -137,7 +137,7 @@
137 // TODO set scope inactive?137 // TODO set scope inactive?
138 auto result = m_resultsModel->data(138 auto result = m_resultsModel->data(
139 m_index, ss::ResultsModelInterface::Roles::RoleResult);139 m_index, ss::ResultsModelInterface::Roles::RoleResult);
140 shared_ptr<ss::PreviewStackInterface> preview(140 shared_ptr<ss::PreviewModelInterface> preview(
141 m_scope->preview(result, m_resultsModel->categoryId()));141 m_scope->preview(result, m_resultsModel->categoryId()));
142 previewView->preview(preview);142 previewView->preview(preview);
143 view = previewView;143 view = previewView;
@@ -161,7 +161,7 @@
161 auto result = m_resultsModel->data(161 auto result = m_resultsModel->data(
162 m_index,162 m_index,
163 ss::ResultsModelInterface::Roles::RoleResult);163 ss::ResultsModelInterface::Roles::RoleResult);
164 shared_ptr<ss::PreviewStackInterface> preview(164 shared_ptr<ss::PreviewModelInterface> preview(
165 m_scope->preview(result, m_resultsModel->categoryId()));165 m_scope->preview(result, m_resultsModel->categoryId()));
166 previewView->preview(preview);166 previewView->preview(preview);
167 view = previewView;167 view = previewView;
@@ -379,7 +379,7 @@
379 }379 }
380380
381 auto previewView = p->m_previewView.lock();381 auto previewView = p->m_previewView.lock();
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()));
383 previewView->preview(preview);383 previewView->preview(preview);
384 return previewView;384 return previewView;
385 }385 }
@@ -418,7 +418,7 @@
418 return nullptr; // nothing happens for scope:// uris418 return nullptr; // nothing happens for scope:// uris
419 }419 }
420 auto previewView = p->m_previewView.lock();420 auto previewView = p->m_previewView.lock();
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()));
422 previewView->preview(preview);422 previewView->preview(preview);
423 return previewView;423 return previewView;
424 }424 }
425425
=== modified file 'src/scope-harness/test-utils.cpp'
--- src/scope-harness/test-utils.cpp 2015-10-27 09:14:07 +0000
+++ src/scope-harness/test-utils.cpp 2016-02-18 15:46:36 +0000
@@ -33,7 +33,6 @@
33#include <Unity/scope.h>33#include <Unity/scope.h>
34#include <Unity/categories.h>34#include <Unity/categories.h>
35#include <Unity/resultsmodel.h>35#include <Unity/resultsmodel.h>
36#include <Unity/previewstack.h>
3736
38namespace sc = unity::scopes;37namespace sc = unity::scopes;
39namespace ng = scopes_ng;38namespace ng = scopes_ng;
@@ -136,18 +135,6 @@
136 QCOMPARE(scope->searchInProgress(), false);135 QCOMPARE(scope->searchInProgress(), false);
137}136}
138137
139bool TestUtils::previewForFirstResult(ng::Scope::Ptr scope, QString const& searchString, QScopedPointer<ng::PreviewStack>& preview_stack)
140{
141 performSearch(scope, searchString);
142
143 unity::scopes::Result::SPtr result;
144 if (!getFirstResult(scope->categories(), result))
145 return false;
146 preview_stack.reset(static_cast<ng::PreviewStack*>(scope->preview(QVariant::fromValue(result), ""))); //FIXME
147
148 return true;
149}
150
151void TestUtils::setFavouriteScopes(const QStringList& cannedQueries)138void TestUtils::setFavouriteScopes(const QStringList& cannedQueries)
152{139{
153 setenv("GSETTINGS_BACKEND", "memory", 1);140 setenv("GSETTINGS_BACKEND", "memory", 1);
154141
=== modified file 'src/scope-harness/test-utils.h'
--- src/scope-harness/test-utils.h 2015-03-10 11:23:01 +0000
+++ src/scope-harness/test-utils.h 2016-02-18 15:46:36 +0000
@@ -57,9 +57,6 @@
57static void waitForSearchFinish(QSharedPointer<shell::scopes::ScopeInterface> scope);57static void waitForSearchFinish(QSharedPointer<shell::scopes::ScopeInterface> scope);
5858
59Q_DECL_EXPORT59Q_DECL_EXPORT
60static bool previewForFirstResult(scopes_ng::Scope::Ptr scope, QString const& searchString, QScopedPointer<scopes_ng::PreviewStack>& preview_stack);
61
62Q_DECL_EXPORT
63static void setFavouriteScopes(const QStringList& cannedQueries);60static void setFavouriteScopes(const QStringList& cannedQueries);
6461
65Q_DECL_EXPORT62Q_DECL_EXPORT
6663
=== modified file 'src/scope-harness/view/preview-view.cpp'
--- src/scope-harness/view/preview-view.cpp 2015-04-24 13:06:14 +0000
+++ src/scope-harness/view/preview-view.cpp 2016-02-18 15:46:36 +0000
@@ -23,7 +23,6 @@
23#include <scope-harness/test-utils.h>23#include <scope-harness/test-utils.h>
2424
25#include <unity/shell/scopes/PreviewModelInterface.h>25#include <unity/shell/scopes/PreviewModelInterface.h>
26#include <unity/shell/scopes/PreviewStackInterface.h>
27#include <unity/shell/scopes/PreviewWidgetModelInterface.h>26#include <unity/shell/scopes/PreviewWidgetModelInterface.h>
2827
2928
@@ -53,7 +52,7 @@
53 {52 {
54 previewWidgets.emplace_back(53 previewWidgets.emplace_back(
55 preview::PreviewWidget(internal::PreviewWidgetArguments54 preview::PreviewWidget(internal::PreviewWidgetArguments
56 { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView, m_previewStack}));55 { previewWidgetModel, previewWidgetModel->index(row), previewModel, m_resultsView.lock(), previewView }));
57 }56 }
5857
59 return preview::PreviewWidgetList(internal::PreviewWidgetListArguments{previewWidgets});58 return preview::PreviewWidgetList(internal::PreviewWidgetListArguments{previewWidgets});
@@ -82,24 +81,23 @@
82 return previewModels;81 return previewModels;
83 }82 }
8483
85 void setPreviewModel(shared_ptr<ss::PreviewStackInterface> previewStack, PreviewView::SPtr previewView)84 void setPreviewModel(shared_ptr<ss::PreviewModelInterface> previewModel, PreviewView::SPtr previewView)
86 {85 {
87 m_previewStack = previewStack;86 m_previewModel = previewModel;
88 updateModels(previewView);87 updateModels(previewView);
89 }88 }
9089
91 void updateModels(PreviewView::SPtr previewView)90 void updateModels(PreviewView::SPtr previewView)
92 {91 {
93 auto previewModel = m_previewStack->getPreviewModel(0);92 m_previewModels = iteratePreviewModel(m_previewModel.get(), previewView);
94 m_previewModels = iteratePreviewModel(previewModel, previewView);
95 }93 }
9694
97 void checkPreviewStack()95 void checkPreviewModel()
98 {96 {
99 TestUtils::throwIfNot(bool(m_previewStack), "");97 TestUtils::throwIfNot(bool(m_previewModel), "");
100 }98 }
10199
102 shared_ptr<ss::PreviewStackInterface> m_previewStack;100 shared_ptr<ss::PreviewModelInterface> m_previewModel;
103101
104 vector<preview::PreviewWidgetList> m_previewModels;102 vector<preview::PreviewWidgetList> m_previewModels;
105103
@@ -116,17 +114,17 @@
116 p->m_resultsView = resultsView;114 p->m_resultsView = resultsView;
117}115}
118116
119void PreviewView::preview(shared_ptr<ss::PreviewStackInterface> previewStack)117void PreviewView::preview(shared_ptr<ss::PreviewModelInterface> previewModel)
120{118{
121 p->setPreviewModel(previewStack,119 p->setPreviewModel(previewModel,
122 dynamic_pointer_cast<PreviewView>(shared_from_this()));120 dynamic_pointer_cast<PreviewView>(shared_from_this()));
123}121}
124122
125void PreviewView::setColumnCount(unsigned int count)123void PreviewView::setColumnCount(unsigned int count)
126{124{
127 p->checkPreviewStack();125 p->checkPreviewModel();
128126
129 p->m_previewStack->setWidgetColumnCount(count);127 p->m_previewModel->setWidgetColumnCount(count);
130 // TODO Wait?128 // TODO Wait?
131 refresh();129 refresh();
132}130}
@@ -138,21 +136,21 @@
138136
139unsigned int PreviewView::columnCount() const137unsigned int PreviewView::columnCount() const
140{138{
141 p->checkPreviewStack();139 p->checkPreviewModel();
142140
143 return p->m_previewStack->widgetColumnCount();141 return p->m_previewModel->widgetColumnCount();
144}142}
145143
146vector<preview::PreviewWidgetList> PreviewView::widgets()144vector<preview::PreviewWidgetList> PreviewView::widgets()
147{145{
148 p->checkPreviewStack();146 p->checkPreviewModel();
149147
150 return p->m_previewModels;148 return p->m_previewModels;
151}149}
152150
153preview::PreviewWidgetList PreviewView::widgetsInColumn(size_t column)151preview::PreviewWidgetList PreviewView::widgetsInColumn(size_t column)
154{152{
155 p->checkPreviewStack();153 p->checkPreviewModel();
156154
157 return p->m_previewModels.at(column);155 return p->m_previewModels.at(column);
158}156}
159157
=== modified file 'src/scope-harness/view/preview-view.h'
--- src/scope-harness/view/preview-view.h 2015-03-10 11:23:01 +0000
+++ src/scope-harness/view/preview-view.h 2016-02-18 15:46:36 +0000
@@ -27,7 +27,7 @@
27{27{
28namespace scopes28namespace scopes
29{29{
30class PreviewStackInterface;30class PreviewModelInterface;
31}31}
32}32}
33namespace scopeharness33namespace scopeharness
@@ -74,7 +74,7 @@
74 friend ScopeHarness;74 friend ScopeHarness;
75 friend preview::PreviewWidget;75 friend preview::PreviewWidget;
7676
77 void preview(std::shared_ptr<shell::scopes::PreviewStackInterface> previewStack);77 void preview(std::shared_ptr<shell::scopes::PreviewModelInterface> previewModel);
7878
79 void setResultsView(std::shared_ptr<ResultsView> resultsView);79 void setResultsView(std::shared_ptr<ResultsView> resultsView);
8080
8181
=== modified file 'tests/overviewtest.cpp'
--- tests/overviewtest.cpp 2016-02-04 15:41:08 +0000
+++ tests/overviewtest.cpp 2016-02-18 15:46:36 +0000
@@ -31,7 +31,6 @@
31#include <categories.h>31#include <categories.h>
32#include <overviewresults.h>32#include <overviewresults.h>
33#include <previewmodel.h>33#include <previewmodel.h>
34#include <previewstack.h>
35#include <previewwidgetmodel.h>34#include <previewwidgetmodel.h>
3635
37#include <scope-harness/registry/pre-existing-registry.h>36#include <scope-harness/registry/pre-existing-registry.h>
3837
=== modified file 'tests/previewtest.cpp'
--- tests/previewtest.cpp 2015-08-14 12:29:16 +0000
+++ tests/previewtest.cpp 2016-02-18 15:46:36 +0000
@@ -29,7 +29,6 @@
29#include <categories.h>29#include <categories.h>
30#include <resultsmodel.h>30#include <resultsmodel.h>
31#include <previewmodel.h>31#include <previewmodel.h>
32#include <previewstack.h>
33#include <previewwidgetmodel.h>32#include <previewwidgetmodel.h>
3433
35#include <scope-harness/matcher/category-matcher.h>34#include <scope-harness/matcher/category-matcher.h>

Subscribers

People subscribed via source and target branches

to all changes: