MrBlueSky
1st June 2011, 15:17
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.
ListView {
id: mainList
anchors.fill: parent
clip: true
//highlightFollowsCurrentItem: true
//snapMode: ListView.SnapOneItem
model: contactModel.contacts
delegate: listDelegate
ContactModel {
id: contactModel
filter: DetailFilter {
detail: ContactDetail.PhoneNumber
field: PhoneNumber.PhoneNumber
value: PhoneNumber.Mobile
}
sortOrders: [
SortOrder {
detail: ContactDetail.Name
field: Name.LastName
direction: Qt.AscendingOrder
},
SortOrder {
detail: ContactDetail.Name
field: Name.FirstName
direction: Qt.AscendingOrder
}
]
}
Component {
id: listDelegate
ListItem {
id: listItem
Column {
anchors.fill: listItem.paddingItem
ListItemText {
id: nameItem
mode: listItem.mode
role: "Title"
text: displayLabel
}
ListItemText {
id: numberItem
mode: listItem.mode
role: "SubTitle"
text: phoneNumber.number
}
}
onClicked: sipgateApi.recieverNumber = numberItem.text
}
}
ScrollDecorator {
flickableItem: mainList
}
}
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.
ListView {
id: mainList
anchors.fill: parent
clip: true
//highlightFollowsCurrentItem: true
//snapMode: ListView.SnapOneItem
model: contactModel.contacts
delegate: listDelegate
ContactModel {
id: contactModel
filter: DetailFilter {
detail: ContactDetail.PhoneNumber
field: PhoneNumber.PhoneNumber
value: PhoneNumber.Mobile
}
sortOrders: [
SortOrder {
detail: ContactDetail.Name
field: Name.LastName
direction: Qt.AscendingOrder
},
SortOrder {
detail: ContactDetail.Name
field: Name.FirstName
direction: Qt.AscendingOrder
}
]
}
Component {
id: listDelegate
ListItem {
id: listItem
Column {
anchors.fill: listItem.paddingItem
ListItemText {
id: nameItem
mode: listItem.mode
role: "Title"
text: displayLabel
}
ListItemText {
id: numberItem
mode: listItem.mode
role: "SubTitle"
text: phoneNumber.number
}
}
onClicked: sipgateApi.recieverNumber = numberItem.text
}
}
ScrollDecorator {
flickableItem: mainList
}
}