examples/QtQuick/qmlnetworkinfo/qml/qmlnetworkinfo/main.qml

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation
00006 **
00007 **
00008 ** $QT_BEGIN_LICENSE:BSD$
00009 ** You may use this file under the terms of the BSD license as follows:
00010 **
00011 ** "Redistribution and use in source and binary forms, with or without
00012 ** modification, are permitted provided that the following conditions are
00013 ** met:
00014 **   * Redistributions of source code must retain the above copyright
00015 **     notice, this list of conditions and the following disclaimer.
00016 **   * Redistributions in binary form must reproduce the above copyright
00017 **     notice, this list of conditions and the following disclaimer in
00018 **     the documentation and/or other materials provided with the
00019 **     distribution.
00020 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00021 **     the names of its contributors may be used to endorse or promote
00022 **     products derived from this software without specific prior written
00023 **     permission.
00024 **
00025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00036 ** $QT_END_LICENSE$
00037 **
00038 ****************************************************************************/
00039 
00040 import QtQuick 1.0
00041 import com.nokia.symbian 1.0
00042 import QtMobility.systeminfo 1.1
00043 
00044 ApplicationWindow {
00045     id: window
00046 
00047     function setStateIfFound(target, name) {
00048         for (var i = 0; i < target.states.length; i++) {
00049             var curState = target.states[i];
00050             if(curState.name == name) {
00051                 target.state = name
00052                 break
00053             }
00054         }
00055     }
00056 
00057     ToolBarLayout {
00058         id: commonTools
00059         ToolButton {
00060             flat: true
00061             iconSource: "toolbar_back.svg"
00062             onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
00063         }
00064         ToolButton {
00065             flat: true
00066             iconSource: "toolbar_options.svg"
00067         }
00068     }
00069 
00070     Page {
00071         id: page
00072         //anchors.fill: parent
00073         tools: commonTools
00074 
00075         Component.onCompleted: {
00076             if(screen.currentOrientation == Screen.Portrait) {
00077                 setStateIfFound(page, "PortraitState")
00078             } else if(screen.currentOrientation == Screen.Landscape) {
00079                 setStateIfFound(page, "LandscapeState")
00080             }
00081         }
00082 
00083         PageHeading{
00084             id: heading
00085             anchors.top: parent.top
00086             width: parent.width
00087             text: qsTr("Network Information")
00088         }
00089 
00090         // Network Info element.
00091         NetworkInfo{
00092             id:myNetworkInfo
00093         }
00094 
00095         // Displays the details of the network information.
00096         TextArea{
00097             id: displayInfo
00098             anchors.top: heading.bottom
00099             anchors.topMargin: 10
00100             font.pointSize: 8
00101             anchors.left: parent.left
00102             anchors.leftMargin: 10
00103             width: parent.width
00104             readOnly: true
00105             text: {
00106                 "Current MCC : " + myNetworkInfo.currentMobileCountryCode + "\n" +
00107                  "Cell ID : " + myNetworkInfo.cellId + "\n" +
00108                  "Current MNC : " + myNetworkInfo.currentMobileNetworkCode + "\n" +
00109                  "Current Mode : " + myNetworkInfo.currentMode + "\n" +
00110                  "Network name : " + myNetworkInfo.networkName + "\n" +
00111                  "Home MCC : " + myNetworkInfo.homeMobileCountryCode + "\n" +
00112                  "Home MNC : " + myNetworkInfo.homeMobileNetworkCode + "\n" +
00113                  "Location Area Code : " + myNetworkInfo.locationAreaCode + "\n" +
00114                  "Network Status : " + myNetworkInfo.networkStatus + "\n" +
00115                  "Network Signal Strength : " + myNetworkInfo.networkSignalStrength
00116             }
00117         }
00118 
00119         Text{
00120             id: smsStatus
00121             width: parent.width
00122             anchors.top: displayInfo.bottom
00123             anchors.topMargin: 10
00124             anchors.leftMargin: 10
00125             text: "Sms delivery status..."
00126             color: "white"
00127         }
00128 
00129         // Settings window, which is used to enter the sender list numbers.
00130         SettingsPage{ id: settingsPage }
00131 
00132         // List of options, to send an Sms, setting the senders list of numbers.
00133         Column{
00134             id: optionsList
00135             anchors.bottom: parent.bottom
00136             anchors.bottomMargin: 20
00137             spacing: 10
00138             anchors.left: parent.left
00139             anchors.leftMargin: 20
00140             anchors.rightMargin: 20
00141             anchors.right: parent.right
00142 
00143             Button{
00144                 id: sendSmS
00145                 width: parent.width
00146                 text: "Send SMS"
00147                 onClicked:{
00148                     smsStatus.text = "Calling send message";
00149                     mymessaging.sendMessage( displayInfo.text, settingsPage.num1, settingsPage.num2
00150                                             , settingsPage.num3);
00151                 }
00152             }
00153 
00154             Button{
00155                 id: settings
00156                 width: parent.width
00157                 text: "Settings"
00158                 onClicked:{
00159                     pageStack.push(settingsPage);
00160                 }
00161             }
00162         }
00163 
00164         // Display the state change message for the message sent, when signal is emitted.
00165         Connections{
00166             target: mymessaging
00167             onMsgStatusReceived:{
00168                 smsStatus.text = response;
00169             }
00170         }
00171 
00172         Connections {
00173             target: screen
00174             onCurrentOrientationChanged: {
00175               if(screen.currentOrientation == Screen.Portrait) {
00176                 page.state = 'PortraitState'
00177               }
00178               if(screen.currentOrientation == Screen.Landscape) {
00179                 page.state = 'LandscapeState'
00180               }
00181             }
00182         }
00183 
00184         states: [
00185             State {
00186                 name: "PortraitState"
00187 
00188                 AnchorChanges {
00189                     target: optionsList
00190                     anchors.left: parent.left
00191                 }
00192 
00193                 AnchorChanges {
00194                     target: smsStatus
00195                     anchors.top: displayInfo.bottom
00196                     anchors.left: parent.left
00197                 }
00198             },
00199             State {
00200                 name: "LandscapeState"
00201 
00202                 AnchorChanges {
00203                     target: optionsList
00204                     anchors.left: displayInfo.right
00205                 }
00206 
00207                 AnchorChanges {
00208                     target: smsStatus
00209                     anchors.top: heading.bottom
00210                     anchors.left: displayInfo.right
00211                 }
00212 
00213                 PropertyChanges {
00214                     target: displayInfo
00215                     width: parent.width/2
00216                 }
00217             }
00218         ]
00219     }
00220     Component.onCompleted: pageStack.push(page)
00221 }
00222 

Generated by  doxygen 1.6.2