~aacid/unity8/scopeListPageHeaderScopeStyle

« back to all changes in this revision

Viewing changes to qml/Dash/DashNavigationButton.qml

  • Committer: CI Train Bot
  • Author(s): Albert Astals
  • Date: 2014-12-12 12:27:56 UTC
  • mfrom: (1473.3.4 deparment_jumping)
  • Revision ID: ci-train-bot@canonical.com-20141212122756-62ew7po8imwcv3ho
Make Navigation work when "jumping" to the non root

There's two fixes:
 * If the Navigation we jumped to is a leaf, list the model of the parent
 * If we're going back/left but we're already on index 0 of the list prepend the parent so we can continue going back Fixes: #1343242
Approved by: Michael Zanetti

Show diffs side-by-side

added added

removed removed

Lines of Context:
139
139
                }
140
140
            }
141
141
            onGoBackToParentClicked: {
 
142
                if (navigationListView.currentIndex == 0) {
 
143
                    // This can happen if we jumped to the non root of a deep tree and the user
 
144
                    // is now going back, create space in the list for the list to move "left"
 
145
                    var aux = navigationListView.highlightMoveDuration;
 
146
                    navigationListView.highlightMoveDuration = 0;
 
147
                    navigationModel.insert(0, {"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
 
148
                    navigationListView.currentIndex = navigationListView.currentIndex + 1;
 
149
                    navigationListView.contentX = width * navigationListView.currentIndex;
 
150
                    navigationListView.highlightMoveDuration = aux;
 
151
                }
 
152
 
142
153
                scope.setNavigationState(navigation.parentNavigationId, isAltNavigation);
143
154
                isGoingBack = true;
144
155
                navigationModel.setProperty(navigationListView.currentIndex - 1, "nullifyNavigation", false);
153
164
            }
154
165
        }
155
166
        onContentXChanged: {
 
167
            if (navigationListView.highlightMoveDuration == 0)
 
168
                return;
 
169
 
156
170
            if (contentX == width * navigationListView.currentIndex) {
157
171
                if (isGoingBack) {
158
172
                    navigationModel.remove(navigationListView.currentIndex + 1);
175
189
    }
176
190
 
177
191
    onScopeChanged: {
 
192
        setNewNavigation();
 
193
    }
 
194
 
 
195
    function setNewNavigation() {
178
196
        navigationModel.clear();
179
197
        if (scope && scope[hasNavigation]) {
180
 
            navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
 
198
            var navigation = getNavigation(scope[currentNavigationId]);
 
199
            if (navigation.count > 0) {
 
200
                navigationModel.append({"navigationId": scope[currentNavigationId], "nullifyNavigation": false});
 
201
            } else {
 
202
                navigationModel.append({"navigationId": navigation.parentNavigationId, "nullifyNavigation": false});
 
203
            }
181
204
        }
182
205
    }
183
206
 
186
209
        // This is duplicated since we can't have something based on the dynamic hasNavigation string property
187
210
        onHasNavigationChanged: {
188
211
            if (!root.isAltNavigation) {
189
 
                if (scope.hasNavigation) {
190
 
                    navigationModel.append({"navigationId": scope.currentNavigationId, "nullifyNavigation": false});
191
 
                } else {
192
 
                    navigationModel.clear();
193
 
                }
 
212
                setNewNavigation();
194
213
            }
195
214
        }
196
215
        onHasAltNavigationChanged: {
197
216
            if (root.isAltNavigation) {
198
 
                if (scope.hasAltNavigation) {
199
 
                    navigationModel.append({"navigationId": scope.currentAltNavigationId, "nullifyNavigation": false});
200
 
                } else {
201
 
                    navigationModel.clear();
202
 
                }
 
217
                setNewNavigation();
203
218
            }
204
219
        }
205
220
    }