~mterry/+junk/u8.2

« back to all changes in this revision

Viewing changes to qml/Panel/IndicatorPage.qml

  • Committer: Michael Terry
  • Date: 2014-11-17 14:56:04 UTC
  • mfrom: (1317.1.118 unity8)
  • Revision ID: michael.terry@canonical.com-20141117145604-96dn9p5nwkifq2f4
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2013 Canonical Ltd.
 
2
 * Copyright 2013-2014 Canonical Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU Lesser General Public License as published by
12
12
 *
13
13
 * You should have received a copy of the GNU Lesser General Public License
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authors:
17
 
 *      Renato Araujo Oliveira Filho <renato@canonical.com>
18
 
 *      Nick Dedekind <nick.dedekind@canonical.com>
19
15
 */
20
16
 
21
17
import QtQuick 2.0
22
18
import Ubuntu.Components 0.1 as Components
23
19
import Unity.Indicators 0.1 as Indicators
24
 
import "../../Components/Flickables" as Flickables
 
20
import "Indicators"
25
21
 
26
22
IndicatorBase {
27
23
    id: main
29
25
    //const
30
26
    property string title: rootActionState.title
31
27
    property alias highlightFollowsCurrentItem : mainMenu.highlightFollowsCurrentItem
 
28
    readonly property alias factory: _factory
32
29
 
33
30
    Indicators.UnityMenuModelStack {
34
31
        id: menuStack
52
49
 
53
50
    Connections {
54
51
        target: menuStack.tail
55
 
        onRowsInserted: {
56
 
            if (menuStack.rootMenu !== menuStack.tail && menuStack.tail.get(0, "type") === rootMenuType) {
57
 
                menuStack.rootMenu = menuStack.tail.submenu(0);
58
 
                menuStack.push(menuStack.rootMenu, 0);
59
 
            }
60
 
        }
61
 
        onModelReset: {
 
52
 
 
53
        // fix async creation with signal from model before it's finished.
 
54
        Component.onCompleted: update();
 
55
        onRowsInserted: update();
 
56
        onModelReset: update();
 
57
 
 
58
        function update() {
62
59
            if (menuStack.rootMenu !== menuStack.tail && menuStack.tail.get(0, "type") === rootMenuType) {
63
60
                menuStack.rootMenu = menuStack.tail.submenu(0);
64
61
                menuStack.push(menuStack.rootMenu, 0);
66
63
        }
67
64
    }
68
65
 
69
 
    Flickables.ListView {
 
66
    ListView {
70
67
        id: mainMenu
71
68
        objectName: "mainMenu"
72
69
        model: menuStack.rootMenu
92
89
 
93
90
        // Only allow flicking if the content doesn't fit on the page
94
91
        interactive: contentHeight > height
95
 
        // FIXME - https://bugreports.qt-project.org/browse/QTBUG-41207
96
 
        boundsBehavior: Flickable.StopAtBounds
97
92
 
98
93
        property int selectedIndex: -1
99
94
        property bool blockCurrentIndexChange: false
123
118
            }
124
119
        }
125
120
 
 
121
        Connections {
 
122
            target: mainMenu.model ? mainMenu.model : null
 
123
            onRowsAboutToBeRemoved: {
 
124
                // track current item deletion.
 
125
                if (mainMenu.selectedIndex >= first && mainMenu.selectedIndex <= last) {
 
126
                    mainMenu.selectedIndex = -1;
 
127
                }
 
128
            }
 
129
        }
 
130
 
126
131
        delegate: Loader {
127
132
            id: loader
128
133
            objectName: "menuItem" + index
170
175
    }
171
176
 
172
177
    MenuItemFactory {
173
 
        id: factory
 
178
        id: _factory
174
179
        rootModel: main.menuModel ? main.menuModel : null
175
180
        menuModel: mainMenu.model ? mainMenu.model : null
176
181
    }