on xenial help sign in
Don't preview if a null response is returned from "scope.preview(result)"
ea74b64Marcus Tomlinson
qml/Dash/CardGrid.qml+1−1
@@ -74,7 +74,7 @@ DashRenderer {
74 Connections {
74 Connections {
75 target: loader.item
75 target: loader.item
76 onClicked: root.clicked(index, result, loader.item, model)
76 onClicked: root.clicked(index, result, loader.item, model)
77− onPressAndHold: root.pressAndHold(index, model)
77+ onPressAndHold: root.pressAndHold(index, result, model)
78 }
78 }
79 }
79 }
80 }
80 }
qml/Dash/DashRenderer.qml+2−1
@@ -47,6 +47,7 @@ Item {
47
47
48 /// Emitted when the user pressed and held on an item
48 /// Emitted when the user pressed and held on an item
49 /// @param index is the index of the held item
49 /// @param index is the index of the held item
50+ /// @param result result model of the cliked item, used for activation
50 /// @param itemModel model of the item
51 /// @param itemModel model of the item
51− signal pressAndHold(int index, var itemModel)
52+ signal pressAndHold(int index, var result, var itemModel)
52}
53}
qml/Dash/GenericScopeView.qml+16−5
@@ -66,17 +66,25 @@ FocusScope {
66 // so it's not implemented
66 // so it's not implemented
67 scope.activate(result)
67 scope.activate(result)
68 } else {
68 } else {
69+ var previewStack = scope.preview(result);
70+ if (previewStack)
71+ {
69− openPreview(index, resultsModel, limitedCategoryItemCount);
72+ openPreview(index, resultsModel, limitedCategoryItemCount, previewStack);
73+ }
70 }
74 }
71 }
75 }
72
76
73− function itemPressedAndHeld(index, itemModel, resultsModel, limitedCategoryItemCount) {
77+ function itemPressedAndHeld(index, result, itemModel, resultsModel, limitedCategoryItemCount) {
74 if (itemModel.uri.indexOf("scope://") !== 0) {
78 if (itemModel.uri.indexOf("scope://") !== 0) {
79+ var previewStack = scope.preview(result);
80+ if (previewStack)
81+ {
75− openPreview(index, resultsModel, limitedCategoryItemCount);
82+ openPreview(index, resultsModel, limitedCategoryItemCount, previewStack);
83+ }
76 }
84 }
77 }
85 }
78
86
79− function openPreview(index, resultsModel, limitedCategoryItemCount) {
87+ function openPreview(index, resultsModel, limitedCategoryItemCount, previewStack) {
80 if (limitedCategoryItemCount > 0) {
88 if (limitedCategoryItemCount > 0) {
81 previewLimitModel.model = resultsModel;
89 previewLimitModel.model = resultsModel;
82 previewLimitModel.limit = limitedCategoryItemCount;
90 previewLimitModel.limit = limitedCategoryItemCount;
@@ -86,6 +94,7 @@ FocusScope {
86 }
94 }
87 subPageLoader.initialIndex = -1;
95 subPageLoader.initialIndex = -1;
88 subPageLoader.initialIndex = index;
96 subPageLoader.initialIndex = index;
97+ subPageLoader.previewModel = previewStack.getPreviewModel(0);
89 subPageLoader.openSubPage("preview");
98 subPageLoader.openSubPage("preview");
90 }
99 }
91
100
@@ -270,7 +279,7 @@ FocusScope {
270 }
279 }
271
280
272 onPressAndHold: {
281 onPressAndHold: {
273− scopeView.itemPressedAndHeld(index, itemModel, target.model, categoryItemCount());
282+ scopeView.itemPressedAndHeld(index, result, itemModel, target.model, categoryItemCount());
274 }
283 }
275
284
276 function categoryItemCount() {
285 function categoryItemCount() {
@@ -519,6 +528,7 @@ FocusScope {
519 property var scopeStyle: scopeView.scopeStyle
528 property var scopeStyle: scopeView.scopeStyle
520 property int initialIndex: -1
529 property int initialIndex: -1
521 property var model: null
530 property var model: null
531+ property var previewModel: null
522
532
523 readonly property bool processing: item && item.processing || false
533 readonly property bool processing: item && item.processing || false
524 readonly property int count: item && item.count || 0
534 readonly property int count: item && item.count || 0
@@ -549,6 +559,7 @@ FocusScope {
549 item.open = Qt.binding(function() { return subPageLoader.open; } )
559 item.open = Qt.binding(function() { return subPageLoader.open; } )
550 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
560 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
551 item.model = Qt.binding(function() { return subPageLoader.model; } )
561 item.model = Qt.binding(function() { return subPageLoader.model; } )
562+ item.previewModel = Qt.binding(function() { return subPageLoader.previewModel; } )
552 }
563 }
553 open = true;
564 open = true;
554 }
565 }
qml/Dash/PreviewListView.qml+2−4
@@ -26,6 +26,7 @@ Item {
26 property int initialIndex: -1
26 property int initialIndex: -1
27 property var scope: null
27 property var scope: null
28 property var scopeStyle: null
28 property var scopeStyle: null
29+ property var previewModel: null
29
30
30 property alias showSignatureLine: header.showSignatureLine
31 property alias showSignatureLine: header.showSignatureLine
31
32
@@ -98,10 +99,7 @@ Item {
98
99
99 isCurrent: ListView.isCurrentItem
100 isCurrent: ListView.isCurrentItem
100
101
101− previewModel: {
102+ previewModel: root.previewModel
102− var previewStack = root.scope.preview(result);
103− return previewStack.getPreviewModel(0);
104− }
105 scopeStyle: root.scopeStyle
103 scopeStyle: root.scopeStyle
106 }
104 }
107 }
105 }