I tried to create a list view that shows only the mobile phone numbers of my contacts. So i declared a detail filter that allows only contacts with mobile numbers. This works fine.

But in the component of the list view i can not differ between mobile and other phone numbers, so always the first number of the contact is shown.

How can I show only mobile numbers? I have no idea how this can be done in QML.

Qt Code:
  1. ListView {
  2. id: mainList
  3. anchors.fill: parent
  4. clip: true
  5. //highlightFollowsCurrentItem: true
  6. //snapMode: ListView.SnapOneItem
  7. model: contactModel.contacts
  8. delegate: listDelegate
  9.  
  10. ContactModel {
  11. id: contactModel
  12.  
  13. filter: DetailFilter {
  14. detail: ContactDetail.PhoneNumber
  15. field: PhoneNumber.PhoneNumber
  16. value: PhoneNumber.Mobile
  17. }
  18.  
  19. sortOrders: [
  20. SortOrder {
  21. detail: ContactDetail.Name
  22. field: Name.LastName
  23. direction: Qt.AscendingOrder
  24. },
  25. SortOrder {
  26. detail: ContactDetail.Name
  27. field: Name.FirstName
  28. direction: Qt.AscendingOrder
  29. }
  30. ]
  31. }
  32.  
  33. Component {
  34. id: listDelegate
  35. ListItem {
  36. id: listItem
  37. Column {
  38. anchors.fill: listItem.paddingItem
  39. ListItemText {
  40. id: nameItem
  41. mode: listItem.mode
  42. role: "Title"
  43. text: displayLabel
  44. }
  45. ListItemText {
  46. id: numberItem
  47. mode: listItem.mode
  48. role: "SubTitle"
  49. text: phoneNumber.number
  50. }
  51. }
  52. onClicked: sipgateApi.recieverNumber = numberItem.text
  53. }
  54. }
  55.  
  56. ScrollDecorator {
  57. flickableItem: mainList
  58. }
  59. }
To copy to clipboard, switch view to plain text mode