@@ -34,8 +34,6 @@ FocusScope {
34 property bool enableHeightBehaviorOnNextCreation: false
34 property bool enableHeightBehaviorOnNextCreation: false
35 property var categoryView: categoryView
35 property var categoryView: categoryView
36 property bool showPageHeader: true
36 property bool showPageHeader: true
37− property var clickOverride: null
38− property var pressAndHoldOverride: null
39 readonly property alias previewShown: previewListView.open
37 readonly property alias previewShown: previewListView.open
41 property var scopeStyle: ScopeStyle {
39 property var scopeStyle: ScopeStyle {
@@ -66,6 +64,34 @@ FocusScope {
66 previewListView.open = false;
64 previewListView.open = false;
67+ function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount) {
68+ if (scope.id === "scopes" || scope.id == "clickscope") {
69+ // TODO Technically it is possible that calling activate() will make the scope emit
70+ // previewRequested so that we show a preview but there's no scope that does that yet
71+ // so it's not implemented
72+ scope.activate(result)
74+ openPreview(index, resultsModel, limitedCategoryItemCount);
78+ function itemPressedAndHeld(index, resultsModel, limitedCategoryItemCount) {
79+ openPreview(index, resultsModel, limitedCategoryItemCount);
82+ function openPreview(index, resultsModel, limitedCategoryItemCount) {
83+ if (limitedCategoryItemCount > 0) {
84+ previewLimitModel.model = resultsModel;
85+ previewLimitModel.limit = limitedCategoryItemCount;
86+ previewListView.model = previewLimitModel;
88+ previewListView.model = resultsModel;
90+ previewListView.currentIndex = -1;
91+ previewListView.currentIndex = index;
92+ previewListView.open = true;
70 target: scope
96 target: scope
71 property: "isActive"
97 property: "isActive"
@@ -238,40 +264,19 @@ FocusScope {
238 Connections {
264 Connections {
239 target: rendererLoader.item
265 target: rendererLoader.item
240 onClicked: {
266 onClicked: {
241− if (scopeView.clickOverride) {
242− scopeView.clickOverride(index, result, item, itemModel);
267+ scopeView.itemClicked(index, result, item, itemModel, target.model, categoryItemCount());
246− if (scopeView.scope.id === "scopes" || scopeView.scope.id == "clickscope") {
247− // TODO Technically it is possible that calling activate() will make the scope emit
248− // previewRequested so that we show a preview but there's no scope that does that yet
249− // so it's not implemented
250− scopeView.scope.activate(result)
256 onPressAndHold: {
270 onPressAndHold: {
257− if (scopeView.pressAndHoldOverride) {
271+ scopeView.itemPressedAndHeld(index, target.model, categoryItemCount());
258− scopeView.pressAndHoldOverride(index);
264− function openPreview(index) {
274+ function categoryItemCount() {
275+ var categoryItemCount = -1;
265 if (!rendererLoader.expanded && !seeAllLabel.visible && target.collapsedItemCount > 0) {
276 if (!rendererLoader.expanded && !seeAllLabel.visible && target.collapsedItemCount > 0) {
266− previewLimitModel.model = target.model;
267− previewLimitModel.limit = target.collapsedItemCount;
277+ categoryItemCount = target.collapsedItemCount;
268− previewListView.model = previewLimitModel;
270− previewListView.model = target.model;
272− previewListView.currentIndex = -1;
279+ return categoryItemCount;
273− previewListView.currentIndex = index;
274− previewListView.open = true;
277 Connections {
282 Connections {