--- /dev/null
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import "Library/js/DBUtility.js" as DBUtility
+import "Library/js/CoreLogic.js" as Core
+
+Page {
+ tools: commonTools
+ id: mainPage
+
+ Component.onCompleted: {
+ DBUtility.initialize();
+ Core.loadRules();
+ }
+
+ function reload(){
+ Core.loadRules();
+ }
+
+ Rectangle{
+ id: headerRect
+ anchors.top:parent.top
+ width: parent.width ; height: parent.height/10
+ color: "grey"
+ opacity: 0.6
+
+ Text {
+ id: titleText
+ anchors.centerIn: parent //#cccccc
+ font.pointSize: 16; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "black"; style: Text.Raised; styleColor: "black"
+ font.bold: true
+ text: qsTr("VICaR - Rules")
+ }
+ }
+
+ Loader
+ {
+ id: uiLoader
+ anchors {top: headerRect.bottom; bottom: parent.bottom}
+ width: parent.width
+ }
+
+ ListModel{
+ id: rulesModel
+ }
+
+
+ Component {
+ id: rulesComponent
+ Item {
+ ListView {
+ id: rulesView
+ model: rulesModel
+ anchors.fill: parent
+ delegate:ruleDelegate
+ }
+ }
+ }
+
+ Component {
+ id: ruleDelegate
+ Item{
+ width: uiLoader.width
+ height: 40
+ Text {
+ width: parent.width
+ font.pointSize: 16; horizontalAlignment: Text.AlignLeft; elide: Text.ElideLeft; color: "black"; style: Text.Raised; styleColor: "black"
+ text: "For #s starting with "+numberpattern+ ", use "+gatewaynumber;
+ }
+ MouseArea{
+ anchors.fill: parent
+ onPressAndHold: {
+ ruleContextMenu.ruleID = id;
+ console.log("Setting Rule ID as "+id);
+ ruleContextMenu.open();
+ }
+ }
+ }
+ }
+
+ ContextMenu{
+ id: ruleContextMenu
+ property int ruleID:0
+
+ MenuLayout{
+ MenuItem {
+ text: qsTr("Edit");
+ onClicked: {
+ Core.editRule(ruleContextMenu.ruleID);
+ }
+ }
+ MenuItem {
+ text: qsTr("Delete");
+ onClicked: {
+ DBUtility.removeRule(ruleContextMenu.ruleID);
+ Core.loadRules();
+ }
+ }
+ }
+ }
+
+ Component{
+ id: blankComponent
+ Item {
+ Label {
+ id: label
+ anchors.centerIn: parent
+ text: qsTr("Add rules for call routing.")
+ visible: true
+ }
+ }
+ }
+}