X-Git-Url: http://git.maemo.org/git/?p=vicar;a=blobdiff_plain;f=src%2Fvicar-config-qml%2Fqml%2Fvicarconfigqml%2Faddrulesheet.qml;fp=src%2Fvicar-config-qml%2Fqml%2Fvicarconfigqml%2Faddrulesheet.qml;h=321950e6819657eb0aef94316101a0a3c2b852a6;hp=0000000000000000000000000000000000000000;hb=74800375ecf7f41e290cf7cc7fa9ee8b230be68e;hpb=89f0017e6a73945ea83247472a6fa07d6ee536b5 diff --git a/src/vicar-config-qml/qml/vicarconfigqml/addrulesheet.qml b/src/vicar-config-qml/qml/vicarconfigqml/addrulesheet.qml new file mode 100644 index 0000000..321950e --- /dev/null +++ b/src/vicar-config-qml/qml/vicarconfigqml/addrulesheet.qml @@ -0,0 +1,146 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 +import "Library/js/DBUtility.js" as DBUtility + +Sheet{ + id: screen + acceptButtonText: qsTr("Done") + rejectButtonText: qsTr("Cancel") + + signal sheetDestroyed() + + property int ruleID:0 + property string numberpattern:"" + property string gatewaynumber:"" + property string dtmfformat:"" + property int numberFormatIndex:0 + property string dtmfprefix: "" + property string dtmfsuffix: "" + + Component.onCompleted: { + if (ruleID != 0){ + var ruleObj = DBUtility.getRuleByID(ruleID); + if (ruleObj !== null){ + numberpattern = ruleObj.numberpattern; + gatewaynumber = ruleObj.gatewaynumber; + dtmfformat = ruleObj.dtmfformat; + var i; + for (i = 0; i < numberFormatModel.count; i++){ + if (numberFormatModel.get(i).name == dtmfformat) { + numberFormatIndex = i; + break; + } + } + dtmfprefix = ruleObj.dtmfprefix; + dtmfsuffix = ruleObj.dtmfsuffix; + } + } + } + + Component.onDestruction: { + console.log("OnDestruction"); + sheetDestroyed(); + } + + ListModel { + id: numberFormatModel + ListElement { name: "" } + ListElement { name: "+" } + ListElement { name: "00" } + ListElement { name: "011" } + } + + SelectionDialog { + id: numberFormatDialog + titleText: "Number Format" + width: container.width + selectedIndex: numberFormatIndex + model: numberFormatModel + } + + content: Flickable { + id: container + anchors.fill: parent + anchors.leftMargin: 10 + anchors.topMargin: 10 + flickableDirection: Flickable.VerticalFlick + + Column { + id: col + width: parent.width + spacing: 10 + Label { text: (ruleID != 0)? qsTr("Edit Rule"):qsTr("Add Rule"); font.bold: true; } + Label { text: qsTr("For numbers starting with:") } + TextField { + id: numberStartingWith + anchors { left: parent.left; right: parent.right; } + //height: implicitHeight + inputMethodHints: Qt.ImhDialableCharactersOnly | Qt.ImhNoPredictiveText + text: screen.numberpattern + } + Label { text: qsTr("Route call via:") } + TextField { + id: gatewayNumber + anchors { left: parent.left; right: parent.right; } + //height: implicitHeight + inputMethodHints: Qt.ImhDialableCharactersOnly | Qt.ImhNoPredictiveText + text: screen.gatewaynumber + } + + Label { text: qsTr("Dial number in this format:") } + + Button { + anchors { horizontalCenter: parent.horizontalCenter } + //height: implicitHeight + text: "Change Format" + onClicked: { + numberFormatDialog.open(); + } + } + + Rectangle { + width: parent.width + height: 30 + color: "lightgray" + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: numberFormatDialog.selectedIndex >= 0 ? numberFormatDialog.model.get(numberFormatDialog.selectedIndex).name : "None" + font.pixelSize: 16 + //font.bold: true + } + } + + Label { text: qsTr("Include this tone before dialing:") } + TextField { + id: dtmfPrefix + anchors { left: parent.left; right: parent.right; } + height: implicitHeight + inputMethodHints: Qt.ImhDialableCharactersOnly | Qt.ImhNoPredictiveText + } + + Label { text: qsTr("Include this tone after dialing:") } + TextField { + id: dtmfSuffix + anchors { left: parent.left; right: parent.right; } + height: implicitHeight + inputMethodHints: Qt.ImhDialableCharactersOnly | Qt.ImhNoPredictiveText + } + } + } + onAccepted: { + //id, numberpattern, gatewaynumber, dtmfformat, dtmfprefix, dtmfsuffix + var ruleObj = new Object(); + ruleObj.id = ruleID; + ruleObj.numberpattern = numberStartingWith.text; + ruleObj.gatewaynumber = gatewayNumber.text; + ruleObj.dtmfformat = numberFormatDialog.model.get(numberFormatDialog.selectedIndex).name; + ruleObj.dtmfprefix = dtmfPrefix.text; + ruleObj.dtmfsuffix = dtmfSuffix.text; + if (ruleID != 0) + DBUtility.updateRule(ruleID,ruleObj); + else + DBUtility.addRule(ruleObj); + destroy(); + } + onRejected: destroy(); +}