February 23, 2012

mkhpad mkhpad
Lab Rat
21 posts

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:

  1. import QtQuick 1.0
  2. import com.nokia.symbian 1.0
  3. import QtMobility.contacts 1.1
  4.  
  5.  
  6. Page {
  7.     id: mainPage
  8.  
  9.  
  10.      Text {
  11.          id: title
  12.          x: 130
  13.          y: 0
  14.          width: 101
  15.          height: 36
  16.          text: "Contacts"
  17.          font.family: "Times New Roman"
  18.          anchors.horizontalCenterOffset: 1
  19.          font.pointSize: 10
  20.          anchors.horizontalCenter: parent.horizontalCenter
  21.          anchors.top: parent.top
  22.          anchors.topMargin: 0
  23.          color: platformStyle.colorNormalLight
  24.  
  25.      }
  26.      ListView {
  27.          id: mainList
  28.          anchors.left: parent.left
  29.          anchors.leftMargin: 3
  30.          anchors.right: parent.right
  31.          anchors.rightMargin: 3
  32.          anchors.top: title.bottom
  33.          anchors.bottom: parent.bottom
  34.          anchors.topMargin: 3
  35.          cacheBuffer: 100
  36.          clip: true
  37.          highlightFollowsCurrentItem: true
  38.  
  39.          snapMode: ListView.SnapOneItem
  40.          model: contactModel.contacts
  41.          delegate: listDelegate
  42.  
  43.  
  44.          ContactModel {
  45.              id: contactModel
  46.             manager: "symbiansim" // "symbian" for other contact manager
  47.             autoUpdate :true
  48.              sortOrders:
  49.                  SortOrder {
  50.                      detail: ContactDetail.Name
  51.                      field: Name.LastName
  52.                      direction: Qt.AscendingOrder
  53.                  }
  54.          }
  55.  
  56.          Component {
  57.              id: listDelegate
  58.  
  59.              ListItem {
  60.                  id: contactItem
  61.                  subItemIndicator: true
  62.  
  63.                  ListItemText {
  64.                      id: nameItem
  65.                      mode: contactItem.mode
  66.                      role: "Title"
  67.                      text: displayLabel
  68.                  }
  69.  
  70.              }
  71.          }
  72.  
  73.          ScrollDecorator {
  74.              flickableItem: mainList
  75.          }
  76.  
  77.      }
  78. }

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:

  1. ListView {
  2.         id:  mainList
  3.         anchors.fill: parent
  4.         model: ContactModel {}
  5.         delegate: Text {
  6.             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?

 Signature 

Harish.M

1 reply

February 23, 2012

mkhpad mkhpad
Lab Rat
21 posts

[Solved]

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

 Signature 

Harish.M

 
  ‹‹ Access QML Model data in c++      Rotation/scaling problem with Package ››

You must log in to post a reply. Not a member yet? Register here!