on xenial help sign in
Merge previews-in-order
c7add69Alberto Mardegan
qml/Dash/GenericScopeView.qml+21−15
@@ -99,23 +99,25 @@ FocusScope {
99 function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
99 function itemPressedAndHeld(index, result, resultsModel, limitedCategoryItemCount, categoryId) {
100 clearMaybePreviewData();
100 clearMaybePreviewData();
101
101
102− if (scope.preview(result, categoryId)) {
103− openPreview(index, resultsModel, limitedCategoryItemCount, categoryId);
102+ openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId);
104− }
105 }
103 }
106
104
107− function openPreview(index, resultsModel, limitedCategoryItemCount, categoryId) {
105+ function openPreview(result, index, resultsModel, limitedCategoryItemCount, categoryId) {
106+ var previewStack = scope.preview(result, categoryId);
107+ if (previewStack) {
108− if (limitedCategoryItemCount > 0) {
108+ if (limitedCategoryItemCount > 0) {
109− previewLimitModel.model = resultsModel;
109+ previewLimitModel.model = resultsModel;
110− previewLimitModel.limit = limitedCategoryItemCount;
110+ previewLimitModel.limit = limitedCategoryItemCount;
111− subPageLoader.model = previewLimitModel;
111+ subPageLoader.model = previewLimitModel;
112− } else {
112+ } else {
113− subPageLoader.model = resultsModel;
113+ subPageLoader.model = resultsModel;
114+ }
115+ subPageLoader.initialIndex = -1;
116+ subPageLoader.initialIndex = index;
117+ subPageLoader.categoryId = categoryId;
118+ subPageLoader.previewStack = previewStack;
119+ subPageLoader.openSubPage("preview");
114 }
120 }
115− subPageLoader.initialIndex = -1;
116− subPageLoader.initialIndex = index;
117− subPageLoader.categoryId = categoryId;
118− subPageLoader.openSubPage("preview");
119 }
121 }
120
122
121 Binding {
123 Binding {
@@ -163,7 +165,8 @@ FocusScope {
163 onHideDash: subPageLoader.closeSubPage()
165 onHideDash: subPageLoader.closeSubPage()
164 onPreviewRequested: { // (QVariant const& result)
166 onPreviewRequested: { // (QVariant const& result)
165 if (result === scopeView.maybePreviewResult) {
167 if (result === scopeView.maybePreviewResult) {
168+ openPreview(result,
166− openPreview(scopeView.maybePreviewIndex,
169+ scopeView.maybePreviewIndex,
167 scopeView.maybePreviewResultsModel,
170 scopeView.maybePreviewResultsModel,
168 scopeView.maybePreviewLimitedCategoryItemCount,
171 scopeView.maybePreviewLimitedCategoryItemCount,
169 scopeView.maybePreviewCategoryId);
172 scopeView.maybePreviewCategoryId);
@@ -758,6 +761,7 @@ FocusScope {
758 property var scope: scopeView.scope
761 property var scope: scopeView.scope
759 property var scopeStyle: scopeView.scopeStyle
762 property var scopeStyle: scopeView.scopeStyle
760 property int initialIndex: -1
763 property int initialIndex: -1
764+ property var previewStack;
761 property string categoryId
765 property string categoryId
762 property var model: null
766 property var model: null
763
767
@@ -791,6 +795,8 @@ FocusScope {
791 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
795 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
792 item.model = Qt.binding(function() { return subPageLoader.model; } )
796 item.model = Qt.binding(function() { return subPageLoader.model; } )
793 item.categoryId = Qt.binding(function() { return subPageLoader.categoryId; } )
797 item.categoryId = Qt.binding(function() { return subPageLoader.categoryId; } )
798+ item.initialIndexPreviewStack = subPageLoader.previewStack;
799+ subPageLoader.previewStack = null;
794 }
800 }
795 open = true;
801 open = true;
796 }
802 }
qml/Dash/PreviewListView.qml+14−4
@@ -24,9 +24,11 @@ Item {
24 id: root
24 id: root
25
25
26 property int initialIndex: -1
26 property int initialIndex: -1
27+ property var initialIndexPreviewStack: null
27 property var scope: null
28 property var scope: null
28 property var scopeStyle: null
29 property var scopeStyle: null
29 property string categoryId
30 property string categoryId
31+ property bool usedInitialIndex: false
30
32
31 property alias showSignatureLine: header.showSignatureLine
33 property alias showSignatureLine: header.showSignatureLine
32
34
@@ -85,9 +87,9 @@ Item {
85 }
87 }
86
88
87 onModelChanged: {
89 onModelChanged: {
88− if (count > 0 && initialIndex >= 0) {
90+ if (count > 0 && initialIndex >= 0 && !usedInitialIndex) {
91+ usedInitialIndex = true;
89 previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
92 previewListView.positionViewAtIndex(initialIndex, ListView.SnapPosition);
90− initialIndex = -1;
91 }
93 }
92 }
94 }
93
95
@@ -100,8 +102,16 @@ Item {
100 isCurrent: ListView.isCurrentItem
102 isCurrent: ListView.isCurrentItem
101
103
102 previewModel: {
104 previewModel: {
105+ if (root.open) {
106+ if (index === root.initialIndex) {
107+ return root.initialIndexPreviewStack.getPreviewModel(0);
108+ } else {
103− var previewStack = root.scope.preview(result, root.categoryId);
109+ var previewStack = root.scope.preview(result, root.categoryId);
104− return previewStack.getPreviewModel(0);
110+ return previewStack.getPreviewModel(0);
111+ }
112+ } else {
113+ return null;
114+ }
105 }
115 }
106 scopeStyle: root.scopeStyle
116 scopeStyle: root.scopeStyle
107 }
117 }