How to import the contacts details from the phone memory and sim memory ?



  • Hi all,
    I am trying to import the contacts from the phone and sim memory using QML.I had almost achieved it but i am in need of some help.

    This is my coding:
    main.qml:
    @
    import QtQuick 1.0
    import com.nokia.symbian 1.0
    import QtMobility.contacts 1.1

    Page {
    id: mainPage

     Text {
         id: title
         x: 130
         y: 0
         width: 101
         height: 36
         text: "Contacts"
         font.family: "Times New Roman"
         anchors.horizontalCenterOffset: 1
         font.pointSize: 10
         anchors.horizontalCenter: parent.horizontalCenter
         anchors.top: parent.top
         anchors.topMargin: 0
         color: platformStyle.colorNormalLight
    
     }
     ListView {
         id: mainList
         anchors.left: parent.left
         anchors.leftMargin: 3
         anchors.right: parent.right
         anchors.rightMargin: 3
         anchors.top: title.bottom
         anchors.bottom: parent.bottom
         anchors.topMargin: 3
         cacheBuffer: 100
         clip: true
         highlightFollowsCurrentItem: true
    
         snapMode: ListView.SnapOneItem
         model: contactModel.contacts
         delegate: listDelegate
    
    
         ContactModel {
             id: contactModel
            manager: "symbiansim" // "symbian" for other contact manager
            autoUpdate :true
             sortOrders:
                 SortOrder {
                     detail: ContactDetail.Name
                     field: Name.LastName
                     direction: Qt.AscendingOrder
                 }
         }
    
         Component {
             id: listDelegate
    
             ListItem {
                 id: contactItem
                 subItemIndicator: true
    
                 ListItemText {
                     id: nameItem
                     mode: contactItem.mode
                     role: "Title"
                     text: displayLabel
                 }
    
             }
         }
    
         ScrollDecorator {
             flickableItem: mainList
         }
    
     }
    

    }
    @

    From my code i am able to get the contacts from the phone as well as sim memory in a list view and i am able to scroll the list too.

    But what is the problem is:when i select any one of the contacts from the list it doesnt display the details as name,mobile number,e-mail.....it remains as such when i select those items

    Can anyone help me with this?
    I also tried to do something like this:
    @
    ListView {
    id: mainList
    anchors.fill: parent
    model: ContactModel {}
    delegate: Text {
    text: "Name: " + model.contact.name.firstName + " " + model.contact.name.lastName + " Number: " + model.contact.phoneNumber.number
    @
    but i dont know how to add this or this one is right anyone help me out?



  • [Solved]

    I finished it on my own with the second code i had suggested


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.