We have moved to a new Sailfish OS Forum. Please start new discussions there.
0

How to search programmatically for people?

asked 2019-02-17 01:14:54 +0200

jsommer gravatar image

updated 2019-02-17 08:51:49 +0200

I want to search for people, weherein the search input string matches with the prefix of the first or last name. I'm using the Nemo QML plugin for contaxts. In the QML type definitions of this plugin I found the following method for the PeopleModel:

Method {
    name: "search"
    Parameter { name: "pattern"; type: "string" }
}

I assumed, that I can use a regular expression:

import org.nemomobile.contacts 1.0
...
PeopleModel {
    id: contacts
    ...
}
...
var regex = new RegExp("(^|\\s)" + searchInput + "*", i)
contacts.search(regex)

Unfortunately, this doesn't work. Has someone any idea or advice?

By the way: Does someone know the status of QtPIM respectively QtContacts? They are announced as the officially supported platform API.

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-02-17 18:41:27 +0200

jsommer gravatar image

I played around with the API and it seems, that the parameter has to be a plain text without regular expression or wildcards. The name pattern of the parameter was causing my assumption.

Now I have the problem, that the id of a Person is undefined:

var contact = contacts.get(i)
var contactId = contact.id

I assume I have to load the QML Type Person somehow?

edit flag offensive delete publish link more

Comments

I foind the problem. I have to use another method to retrieve the contact:

var contact = contacts.personByRow(i)
var contactId = contact.id
jsommer ( 2019-02-24 18:57:54 +0200 )edit
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2019-02-17 01:14:54 +0200

Seen: 279 times

Last updated: Feb 17 '19