examples/QtQuick/qmlnotifyfriends/qml/qmlnotifyfriends/ContactsPage.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.contacts 1.1
00043 
00044 
00045 Page {
00046     tools: contactsTools
00047 
00048     property alias myContacts: myContactModel
00049     property string selectedContact: ""
00050     property int selectedContactId: 0
00051 
00052     Component {
00053         id: heading
00054 
00055         PageHeading {
00056             id: headingText
00057             width: parent.width
00058             text: qsTr("Notify friends")
00059         }
00060     }
00061 
00062     // ContactModel element, intialise it with 'symbiansim' manager.
00063     ContactModel{
00064         id: myContactModel
00065         manager: "symbiansim"
00066         autoUpdate: true
00067     }
00068 
00069     // List view of contacts.
00070     ListView{
00071         id: myContactList
00072         header: heading
00073         anchors.fill: parent
00074         model: myContactModel
00075         delegate:
00076             Rectangle{
00077             width: parent.width
00078             height: 75
00079             color: "black"
00080             border.color: "grey"
00081             //opacity: 0
00082             Column{
00083                 anchors.top: parent.top
00084                 anchors.topMargin: 5
00085                 anchors.left: parent.left
00086                 anchors.leftMargin: 5
00087                 width: parent.width
00088                 height: parent.height
00089                 Text{
00090                     color: "white"
00091                     text: {(contact.name.firstName + contact.name.lastName == "")
00092                           ? contact.displayLabel : contact.name.firstName +
00093                             contact.name.lastName }
00094 
00095                     font.pointSize: 9
00096                     font.bold: true
00097                 }
00098 
00099                 Text{
00100                     color: "white"
00101                     text: contact.phoneNumber.number
00102                     font.pointSize: 7
00103                 }
00104 
00105             }
00106             MouseArea{
00107                 anchors.fill: parent
00108                 onPressAndHold: {
00109                     parent.color = "grey"
00110                     contextMenu.open()
00111                     selectedContact = contact.phoneNumber.number
00112                     selectedContactId = index
00113                 }
00114 
00115                 onPositionChanged: parent.color = "black"
00116                 onReleased: parent.color = "black"
00117             }
00118         }
00119 
00120 
00121         spacing: 5
00122         clip: true
00123         highlightMoveDuration: 500
00124 
00125 
00126         ScrollDecorator {
00127             flickableItem: parent
00128         }
00129 
00130     }
00131 
00132 
00133     ToolBarLayout {
00134         id: contactsTools
00135         ToolButton {
00136             flat: true
00137             iconSource: "toolbar_back.svg"
00138             onClicked: Qt.quit()
00139         }
00140         ToolButton {
00141             flat: true
00142             iconSource: "toolbar_options.svg"
00143             onClicked:{
00144                 viewMenu.open();
00145             }
00146         }
00147     }
00148 
00149 
00150     /*
00151       Menu used to add contacts, change the settings from SIM memory to phone and vice-versa
00152     */
00153     Menu{
00154         id: viewMenu
00155 
00156         content:
00157             Column{
00158             width: viewMenu.width
00159 
00160             MenuItem{
00161                 text: qsTr("Add Contact")
00162                 onClicked:{
00163                     pageStack.push(addContactPage);
00164                     viewMenu.close();
00165                 }
00166             }
00167 
00168             MenuItem{
00169                 text: qsTr("Settings")
00170                 onClicked:{
00171                     settingsDialog.open();
00172                     //pageStack.push(settingsPage);
00173                     viewMenu.close();
00174                 }
00175             }
00176         }
00177     }
00178 
00179     // ContextMenu is used to add and delete contacts.
00180     ContextMenu{
00181         id: contextMenu
00182 
00183         content:
00184             Column{
00185             width: contextMenu.width
00186 
00187             MenuItem{
00188                 text: qsTr("Add Contact")
00189                 onClicked:{
00190                     pageStack.push(addContactPage);
00191                     contextMenu.close();
00192                 }
00193             }
00194 
00195             MenuItem{
00196                 text: qsTr("Delete Contact")
00197                 onClicked:{
00198                     myContactModel.removeContact(myContactModel.contacts[selectedContactId].contactId)
00199                     contextMenu.close();
00200                 }
00201             }
00202 
00203             MenuItem{
00204                 text: qsTr("Add Notification Alarm")
00205                 onClicked:{
00206                     pageStack.push(addAlarmPage);
00207                     contextMenu.close();
00208                 }
00209             }
00210         }
00211     }
00212 
00213     // Settings dialog is used to change the contacts manager.
00214     SettingsDialog{ id: settingsDialog; width: 360; height: 250 }
00215 
00216     // Connections for signals emitted by SettingsDialog.
00217     Connections{
00218         target: settingsDialog
00219         onAccepted:{
00220             if(settingsDialog.phoneMemory == true)
00221                 myContacts.manager = "symbian"
00222             else if(settingsDialog.simMemory == true)
00223                 myContacts.manager = "symbiansim"
00224         }
00225     }
00226 }

Generated by  doxygen 1.6.2