@@ -34,8 +34,6 @@ FocusScope {
3434 property bool enableHeightBehaviorOnNextCreation: false
3535 property var categoryView: categoryView
3636 property bool showPageHeader: true
37− property var clickOverride: null
38− property var pressAndHoldOverride: null
3937 readonly property alias previewShown: previewListView.open
4038
4139 property var scopeStyle: ScopeStyle {
@@ -66,6 +64,34 @@ FocusScope {
6664 previewListView.open = false;
6765 }
6866
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)
73+ } else {
74+ openPreview(index, resultsModel, limitedCategoryItemCount);
75+ }
76+ }
77+
78+ function itemPressedAndHeld(index, resultsModel, limitedCategoryItemCount) {
79+ openPreview(index, resultsModel, limitedCategoryItemCount);
80+ }
81+
82+ function openPreview(index, resultsModel, limitedCategoryItemCount) {
83+ if (limitedCategoryItemCount > 0) {
84+ previewLimitModel.model = resultsModel;
85+ previewLimitModel.limit = limitedCategoryItemCount;
86+ previewListView.model = previewLimitModel;
87+ } else {
88+ previewListView.model = resultsModel;
89+ }
90+ previewListView.currentIndex = -1;
91+ previewListView.currentIndex = index;
92+ previewListView.open = true;
93+ }
94+
6995 Binding {
7096 target: scope
7197 property: "isActive"
@@ -238,40 +264,19 @@ FocusScope {
238264 Connections {
239265 target: rendererLoader.item
240266 onClicked: {
241− if (scopeView.clickOverride) {
242− scopeView.clickOverride(index, result, item, itemModel);
243− return;
244− }
245−
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)
251− } else {
252− openPreview(index);
253− }
267+ scopeView.itemClicked(index, result, item, itemModel, target.model, categoryItemCount());
254268 }
255269
256270 onPressAndHold: {
257− if (scopeView.pressAndHoldOverride) {
258− scopeView.pressAndHoldOverride(index);
259− } else {
260− openPreview(index);
261− }
271+ scopeView.itemPressedAndHeld(index, target.model, categoryItemCount());
262272 }
263273
264− function openPreview(index) {
274+ function categoryItemCount() {
275+ var categoryItemCount = -1;
265276 if (!rendererLoader.expanded && !seeAllLabel.visible && target.collapsedItemCount > 0) {
266− previewLimitModel.model = target.model;
267− previewLimitModel.limit = target.collapsedItemCount;
268− previewListView.model = previewLimitModel;
269− } else {
270− previewListView.model = target.model;
277+ categoryItemCount = target.collapsedItemCount;
271278 }
272− previewListView.currentIndex = -1;
273− previewListView.currentIndex = index;
274− previewListView.open = true;
279+ return categoryItemCount;
275280 }
276281 }
277282 Connections {