examples/QtQuick/alarmserver/qml/qml_symbian_alarmserver/mainwindow.qml

00001 import QtQuick 1.0
00002 import com.nokia.symbian 1.0
00003 import "alarmserver.js" as AlarmServer
00004 
00005 // Main window for the example.
00006 ApplicationWindow{
00007     id: mainWindow
00008 
00009     ToolBarLayout {
00010         id: commonTools
00011         ToolButton {
00012             flat: true
00013             iconSource: "toolbar_back.svg"
00014             onClicked: Qt.quit()
00015         }
00016         ToolButton {
00017             flat: true
00018             iconSource: "toolbar_options.svg"
00019         }
00020     }
00021 
00022     Page{
00023         id: page
00024         tools: commonTools
00025         anchors.fill: parent
00026 
00027         // Label to set the current time.
00028         Text{
00029             id:systemTime
00030             anchors.top: parent.top
00031             text: "Time :" + alarmServer.getCurrentTime()
00032             color: "white"
00033             font.bold: true
00034         }
00035 
00036         // Label to set the current date.
00037         Text{
00038             id:systemDate
00039             anchors.left: systemTime.right
00040             anchors.leftMargin: 10
00041             text: "Date :" + alarmServer.getCurrentDate()
00042             color: "white"
00043             font.bold: true
00044         }
00045 
00046         // Label to set the title text for the list view.
00047         Text{
00048             id:titleText
00049             anchors.top: systemTime.bottom
00050             anchors.topMargin: 10
00051             text: "Added Alarms :"
00052             color: "white"
00053             font.bold: true
00054         }
00055 
00056         // A time is run after every 2 sec, to update the time and date.
00057         Timer {
00058             id: timer
00059             interval: 2000; repeat: true
00060             running: true
00061             triggeredOnStart: true
00062 
00063             onTriggered: {
00064                 systemTime.text = "Time :" + alarmServer.getCurrentTime();
00065                 systemDate.text = "Date :" + alarmServer.getCurrentDate();
00066             }
00067         }
00068 
00069         // List view of all the alarms added.
00070         ListView {
00071             id: myView
00072             anchors.top: titleText.bottom
00073             anchors.topMargin: 10
00074             /*
00075             For landscape and portrait views.
00076             Portrait view:
00077             width: parent.width (i.e 360)
00078             height: 640-250 = 390 (if 360 X 640)
00079             Landscape view: width - 310, height : 240
00080             */
00081             width: parent.width > parent.height ? 310 : parent.width
00082             height: parent.width > parent.height ? 240 : parent.height-250
00083             ListModel { id: listModel }
00084             model: listModel
00085             delegate:
00086                 Rectangle{
00087                 width: 200
00088                 height: 50
00089                 color: "grey"
00090                 border.color:"black"
00091 
00092                 // List element is 'Id' of the alarm.
00093                 Text {
00094                     text: alarmId
00095                     anchors.centerIn: parent
00096                     color: "white"
00097                 }
00098 
00099                 MouseArea{
00100                     anchors.fill: parent
00101                     onClicked: {
00102                         alarmDetailsTxt.text = alarmServer.getAlarmDetails(alarmId);
00103                         alarmDetailsTxt.visible = true;
00104                     }
00105                }
00106             }
00107         }
00108 
00109 
00110         // Options to add fixed or floating alarm.
00111         Column{
00112             id: alarmOptions
00113 
00114             width: parent.width
00115             height: 170
00116             x:parent.width > parent.height ? parent.width-320 : 30
00117             y:parent.width > parent.height ? 100 : parent.height-170
00118             spacing: 5
00119 
00120             Button{ id: floatAlarm; width: 300; height: 50; text: "Add floating alarm"
00121                 onClicked: AlarmServer.buttonPressed(text)}
00122             Button{ id: fixedAlarm; width: 300; height: 50; text: "Add fixed alarm"
00123             onClicked: AlarmServer.buttonPressed(text)}
00124         }
00125 
00126         AlarmDetails{id: alarmDetailsTxt; width:parent.width; height:parent.height; visible: false; anchors.centerIn: main}
00127 
00128 
00129     }
00130 
00131     Component.onCompleted: pageStack.push(page)
00132 
00133     // Receive signals from Alarm Server
00134     Connections {
00135         target: alarmServer
00136         onAlarmAdded: {
00137             listModel.append({'alarmId': value})
00138         }
00139     }
00140 }

Generated by  doxygen 1.6.2