@@ -1,5 +1,5 @@
2− * Copyright 2013-2014 Canonical Ltd.
2+ * Copyright 2013-2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -25,26 +25,47 @@ PageStack {
27 property var submenuIndex: undefined
27 property var submenuIndex: undefined
28− property string context
29 property QtObject menuModel: null
28 property QtObject menuModel: null
29+ property Component factory
31 Connections {
31 Connections {
32 target: root.menuModel
33 target: root.menuModel
34+ property bool ready: false
34 // fix async creation with signal from model before it's finished.
36 // fix async creation with signal from model before it's finished.
35− onRowsInserted: root.reset()
37+ onRowsInserted: {
38+ if (submenuIndex !== undefined && first <= submenuIndex) {
36− onRowsRemoved: root.reset()
42+ onRowsRemoved: {
43+ if (submenuIndex !== undefined && first <= submenuIndex) {
37− onModelReset: root.reset()
47+ onModelReset: {
48+ if (root.submenuIndex !== undefined) {
40 Component.onCompleted: {
54 Component.onCompleted: {
41− reset();
55+ reset(true);
56+ dynamicChanges.ready = true;
44− function reset() {
59+ function reset(clearModel) {
46− var model = submenuIndex == undefined ? menuModel : menuModel.submenu(submenuIndex)
62+ var model = submenuIndex == undefined ? menuModel : menuModel.submenu(submenuIndex)
47− push(pageComponent, { "menuModel": model });
64+ push(pageComponent, { "menuModel": model });
67+ root.currentPage.reset();
50 Component {
71 Component {
@@ -56,13 +77,12 @@ PageStack {
56 property alias title: backLabel.title
77 property alias title: backLabel.title
57 property bool isSubmenu: false
78 property bool isSubmenu: false
59− MenuItemFactory {
80+ function reset() {
60− id: factory
81+ mainMenu.positionViewAtBeginning();
61− context: root.context
62− rootModel: root.menuModel ? root.menuModel : null
63− menuModel: mainMenu.model ? mainMenu.model : null
84+ property QtObject factory: root.factory.createObject(page, { menuModel: page.menuModel } )
66 header: PageHeader {
86 header: PageHeader {
67 id: backLabel
87 id: backLabel
68 visible: page.isSubmenu
88 visible: page.isSubmenu
@@ -151,7 +171,7 @@ PageStack {
151 visible: status == Loader.Ready
171 visible: status == Loader.Ready
153 property int modelIndex: index
173 property int modelIndex: index
154− sourceComponent: factory.load(model)
174+ sourceComponent: page.factory.load(model)
156 onLoaded: {
176 onLoaded: {
157 if (item.hasOwnProperty("selected")) {
177 if (item.hasOwnProperty("selected")) {
@@ -174,7 +194,7 @@ PageStack {
174 if (model.hasSubmenu) {
194 if (model.hasSubmenu) {
175 root.push(pageComponent, {
195 root.push(pageComponent, {
176 "isSubmenu": true,
196 "isSubmenu": true,
177− "title": model.label,
197+ "title": model.label.replace(/_|&/, ""),
178 "menuModel": page.menuModel.submenu(modelIndex)
198 "menuModel": page.menuModel.submenu(modelIndex)
@@ -202,10 +222,4 @@ PageStack {
208−// menuStack.reset();
209−// mainMenu.positionViewAtBeginning();