@@ -72,28 +72,39 @@ FocusScope {
7272 pageHeaderLoader.item.resetSearch()
7373 }
7474
75− function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
76− if (itemModel.uri.indexOf("scope://") === 0 || scope.id === "clickscope" || (scope.id === "videoaggregator" && categoryId === "myvideos-getstarted")) {
77− // TODO Technically it is possible that calling activate() will make the scope emit
78− // previewRequested so that we show a preview but there's no scope that does that yet
79− // so it's not implemented
80− scope.activate(result)
81− } else {
82− if (scope.preview(result)) {
83− openPreview(index, resultsModel, limitedCategoryItemCount);
84− }
85− }
75+ property var maybePreviewResult;
76+ property int maybePreviewIndex;
77+ property var maybePreviewResultsModel;
78+ property int maybePreviewLimitedCategoryItemCount;
79+ property string maybePreviewCategoryId;
80+
81+ function clearMaybePreviewData() {
82+ scopeView.maybePreviewResult = undefined;
83+ scopeView.maybePreviewIndex = -1;
84+ scopeView.maybePreviewResultsModel = undefined;
85+ scopeView.maybePreviewLimitedCategoryItemCount = -1;
86+ scopeView.maybePreviewCategoryId = "";
8687 }
8788
88− function itemPressedAndHeld(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
89− if (itemModel.uri.indexOf("scope://") !== 0 && !(scope.id === "videoaggregator" && categoryId === "myvideos-getstarted")) {
90− if (scope.preview(result)) {
91− openPreview(index, resultsModel, limitedCategoryItemCount);
92− }
89+ function itemClicked(index, result, itemModel, resultsModel, limitedCategoryItemCount, categoryId) {
90+ scopeView.maybePreviewResult = result;
91+ scopeView.maybePreviewIndex = index;
92+ scopeView.maybePreviewResultsModel = resultsModel;
93+ scopeView.maybePreviewLimitedCategoryItemCount = limitedCategoryItemCount;
94+ scopeView.maybePreviewCategoryId = categoryId;
95+
96+ scope.activate(result, categoryId);
97+ }
98+
99+ function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
100+ clearMaybePreviewData();
101+
102+ if (scope.preview(result, categoryId)) {
103+ openPreview(index, resultsModel, limitedCategoryItemCount, categoryId);
93104 }
94105 }
95106
96− function openPreview(index, resultsModel, limitedCategoryItemCount) {
107+ function openPreview(index, resultsModel, limitedCategoryItemCount, categoryId) {
97108 if (limitedCategoryItemCount > 0) {
98109 previewLimitModel.model = resultsModel;
99110 previewLimitModel.limit = limitedCategoryItemCount;
@@ -103,6 +114,7 @@ FocusScope {
103114 }
104115 subPageLoader.initialIndex = -1;
105116 subPageLoader.initialIndex = index;
117+ subPageLoader.categoryId = categoryId;
106118 subPageLoader.openSubPage("preview");
107119 }
108120
@@ -149,6 +161,16 @@ FocusScope {
149161 target: scopeView.scope
150162 onShowDash: subPageLoader.closeSubPage()
151163 onHideDash: subPageLoader.closeSubPage()
164+ onPreviewRequested: { // (QVariant const& result)
165+ if (result === scopeView.maybePreviewResult) {
166+ openPreview(scopeView.maybePreviewIndex,
167+ scopeView.maybePreviewResultsModel,
168+ scopeView.maybePreviewLimitedCategoryItemCount,
169+ scopeView.maybePreviewCategoryId);
170+
171+ clearMaybePreviewData();
172+ }
173+ }
152174 }
153175
154176 Connections {
@@ -357,12 +379,12 @@ FocusScope {
357379
358380 Connections {
359381 target: rendererLoader.item
360− onClicked: {
361− scopeView.itemClicked(index, result, item, itemModel, target.model, categoryItemCount(), baseItem.category);
382+ onClicked: { // (int index, var result, var item, var itemModel)
383+ scopeView.itemClicked(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
362384 }
363385
364− onPressAndHold: {
365− scopeView.itemPressedAndHeld(index, result, itemModel, target.model, categoryItemCount(), baseItem.category);
386+ onPressAndHold: { // (int index, var result, var itemModel)
387+ scopeView.itemPressedAndHeld(index, result, target.model, categoryItemCount(), baseItem.category);
366388 }
367389
368390 function categoryItemCount() {
@@ -736,6 +758,7 @@ FocusScope {
736758 property var scope: scopeView.scope
737759 property var scopeStyle: scopeView.scopeStyle
738760 property int initialIndex: -1
761+ property string categoryId
739762 property var model: null
740763
741764 readonly property bool processing: item && item.processing || false
@@ -767,6 +790,7 @@ FocusScope {
767790 item.open = Qt.binding(function() { return subPageLoader.open; } )
768791 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
769792 item.model = Qt.binding(function() { return subPageLoader.model; } )
793+ item.categoryId = Qt.binding(function() { return subPageLoader.categoryId; } )
770794 }
771795 open = true;
772796 }