~jonas-drange/ubuntu-system-settings/filepicker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * Copyright (C) 2014 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 * Ken Vandine <ken.vandine@canonical.com>
 * Jonas G. Drange <jonas.drange@canonical.com>
 *
*/
import QtQuick 2.4
import GSettings 1.0
import SystemSettings 1.0
import Ubuntu.Components 1.3
import Ubuntu.Components.ListItems 1.3 as ListItem

Column {

    property var sims

    Repeater {
        model: sims

        Column {

            anchors { left: parent.left; right: parent.right }

            SettingsItemTitle { text: sims[index].title }

            ListItem.Standard {
                objectName: "callWaitSim" + index
                text: i18n.tr("Call waiting")
                progression: true
                onClicked: pageStack.addPageToNextColumn(root,
                    Qt.resolvedUrl("CallWaiting.qml"), {
                        sim: sims[index],
                        headerTitle: sims[index].title
                    }
                )
            }

            ListItem.SingleValue {
                objectName: "callFwdSim" + index
                text: i18n.tr("Call forwarding")
                progression: true
                value: sims[index].getCallForwardingSummary()
                onClicked: pageStack.addPageToNextColumn(root,
                    Qt.resolvedUrl("CallForwarding.qml"), {
                        sim: sims[index],
                        headerTitle: sims[index].title
                    }
                )
            }

            ListItem.Standard {
                objectName: "simServicesSim" + index
                text: i18n.tr("Services")
                progression: true
                enabled: {
                    var num;
                    var map = sims[index].simMng.serviceNumbers;
                    var nums = false;
                    for(num in map) {
                        if (map.hasOwnProperty(num)) {
                            nums = true;
                            break;
                        }
                    }
                    return sims[index].simMng.present && nums;
                }
                showDivider: false
                onClicked: pageStack.addPageToNextColumn(root,
                    Qt.resolvedUrl("Services.qml"), {
                        carrierString: sims[index].netReg.name,
                        sim: sims[index].simMng,
                        headerTitle: sims[index].title
                    }
                )
            }

            ListItem.Divider {
                visible: index !== (sims.length - 1)
            }

            Binding {
                target: sims[index]
                property: "name"
                value: phoneSettings.simNames[modemsSorted[index]]
            }
        }
    }

    GSettings {
        id: phoneSettings
        schema.id: "com.ubuntu.phone"
        Component.onCompleted: {
            // set default names
            var simNames = phoneSettings.simNames;
            var m0 = sims[0].path
            var m1 = sims[1].path
            if (!simNames[m0]) {
                simNames[m0] = "SIM 1";
            }
            if (!simNames[m1]) {
                simNames[m1] = "SIM 2";
            }
            phoneSettings.simNames = simNames;
        }
    }
}