Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
None
-
5.1.0
-
None
-
SailfishOS Alpha SDK (latest version available), running on the Emulator
Host is OSX
qt5-qtdeclarative-pim-contacts-5.1.0+git4-1.3.12.i486
-
ef85e412310fd155508031021c57eedfa5622e83
Description
Hi All
I am experimenting with QtContacts 5.0 on SailfishOS using QML
.
However things go pear-shaped when I try and filter the contacts:
I get the error:
file:///usr/share/ContactsDemo/qml/pages/FirstPage.qml:62: Unable to assign int to
[unknown property type]
This refers to the detail: ContactDetail.Name of the Filter, even though it was able to
use an identical property to sort.
Having delved into the source of QDeclarativeContactSortOrder and
QDeclarativeContactDetailFilter, I see that the first declares detail to be of type int,
but the second declares detail to be QDeclarativeContactDetail::DetailType
class QDeclarativeContactSortOrder :public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_PROPERTY(int detail READ detail WRITE setDetail NOTIFY sortOrderChanged)
class QDeclarativeContactDetailFilter : public QDeclarativeContactFilter, public
QQmlParserStatus
{
Q_OBJECT
Q_PROPERTY(QDeclarativeContactDetail::DetailType detail READ detail WRITE setDetail
NOTIFY valueChanged())
However I have got no further in figuring out what I am doing wrong / what is going wrong.
Something very similar to the code below works on Harmattan./Qt 4.7.4 /Qt Mobility Contacts: On Harmattan Filtering works for Name.firstName and Name.lastName, but not for DisplayLabel.Label (see https://bugreports.qt-project.org/browse/QTBUG-35259). In fact I was trying to reproduce the DisplayLabel filter problem on Qt5.0 when I found that I cannot filter at all....
Any ideas?
Thanks
Chris
//Start FirstPage.qml
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtContacts 5.0
Page {
id: page
ContactModel {
id: contactsModel
manager: "memory"
Component.onCompleted:
sortOrders: [
SortOrder
]
filter: detailFilter1
}
DetailFilter
ListView {
id: contactList
anchors.fill: parent
model: contactsModel
delegate:contactDelegate
clip: true
onCountChanged:
}
Component {
id: contactDelegate
PhoneContactsDelegate {
}
}
function insertContact(firstName, lastName, phoneNumber) {
// read in values from the input fields
var displaylabel = firstName.trim() + " " + lastName.trim()
var values = [firstName,
lastName,
displaylabel,
phoneNumber]
var newContact = Qt.createQmlObject("import QtContacts 5.0; Contact{ }", page)
setDetailValues(newContact, values)
newContact.save()
contactsModel.saveContact(newContact)
}
function setDetailValues(c, values)
}
//End FirstPage.qml
//Start PhoneContactsDelegate.qml
import QtQuick 2.0
Item {
id: backGroundRect
width: parent.width
height: 80
Text {
id: nameText
anchors
font.pointSize: 30
font.weight: Font.DemiBold
text: model.contact.displayLabel.label.trim();
}
Text {
id: numberText
anchors
font.pointSize: 20
font.weight: Font.Light
text: model.contact.phoneNumber.number // + ", " + model.contact.contactId
}
}
//End PhoneContactsDelegate.qml