22
22
import SystemSettings 1.0
23
23
import Ubuntu.Components 0.1
24
24
import Ubuntu.Components.ListItems 0.1 as ListItem
25
import MeeGo.QOfono 0.2
28
title: i18n.tr("Carrier")
29
29
objectName: "chooseCarrierPage"
31
31
property var netReg
32
property variant operators: netReg.operators
33
property bool scanning: netReg.scanning
32
property var operators: []
33
property bool scanning: false
34
34
property variant operatorNames
35
35
property variant operatorStatus
37
Component.onCompleted: buildLists();
42
if (netReg.status === "registered")
45
onNetworkOperatorsChanged: buildLists();
46
onScanFinished: scanning = false;
49
console.warn ("onScanError: " + message);
42
53
function buildLists()
44
56
var oN = new Array();
45
57
var oS = new Array();
46
for (var i in operators)
48
if (operators[i].status == "forbidden")
58
for (var i = 0; i < netReg.networkOperators.length; i++) {
59
var tempOp = netOp.createObject(parent, {"operatorPath": netReg.networkOperators[i]});
60
if (tempOp.status === "forbidden")
50
oN.push(operators[i].name);
51
oS.push(operators[i].status);
63
oS.push(tempOp.status);
53
66
curOp = oS.indexOf("current");
54
67
operatorNames = oN;
55
68
operatorStatus = oS;
58
ListItem.ItemSelector {
60
objectName: "carrierSelector"
62
/* FIXME: This is disabled since it is currently a
64
* enabled: cellularDataControl.checked
69
onSelectedIndexChanged: {
70
operators[selectedIndex].registerOp();
74
ListItem.SingleControl {
75
anchors.bottom: parent.bottom
77
objectName: "refreshButton"
78
width: parent.width - units.gu(4)
79
text: i18n.tr("Refresh")
80
onTriggered: netReg.scan()
86
anchors.centerIn: parent
92
top: activityIndicator.bottom
93
topMargin: units.gu(2)
94
horizontalCenter: activityIndicator.horizontalCenter
96
text: i18n.tr("Searching")
97
visible: activityIndicator.running
70
carrierSelector.selectedIndex = curOp;
75
OfonoNetworkOperator {
77
if (error === OfonoNetworkOperator.InProgressError) {
78
console.warn("registerComplete failed with error: " + errorString);
79
} else if (error !== OfonoNetworkOperator.NoError) {
80
console.warn("registerComplete failed with error: " + errorString + " Falling back to default");
81
netReg.registration();
89
contentWidth: parent.width
90
contentHeight: parent.height
91
boundsBehavior: (contentHeight > parent.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
94
anchors.left: parent.left
95
anchors.right: parent.right
97
ListItem.ItemSelector {
99
objectName: "autoChooseCarrierSelector"
101
enabled: netReg.mode !== "auto-only"
102
text: i18n.tr("Choose carrier:")
103
model: [i18n.tr("Automatically"), i18n.tr("Manually")]
104
selectedIndex: netReg.mode === "manual" ? 1 : 0
105
onSelectedIndexChanged: {
106
if (selectedIndex === 0)
107
netReg.registration();
111
ListItem.ItemSelector {
113
objectName: "carrierSelector"
115
enabled: chooseCarrier.selectedIndex === 1
117
onSelectedIndexChanged: {
118
if ((selectedIndex !== curOp) && operators[selectedIndex]) {
119
operators[selectedIndex].registerOperator();
125
ListItem.SingleControl {
126
anchors.bottom: parent.bottom
128
objectName: "refreshButton"
129
width: parent.width - units.gu(4)
130
text: i18n.tr("Refresh")
131
enabled: (netReg.status !== "searching") && (netReg.status !== "denied")
140
id: activityIndicator
141
anchors.centerIn: parent
147
top: activityIndicator.bottom
148
topMargin: units.gu(2)
149
horizontalCenter: activityIndicator.horizontalCenter
151
text: i18n.tr("Searching")
152
visible: activityIndicator.running