Osso_abook_contact_chooser_select_contacts() usage with Qt
-
I'm developing a Qt program for the N900. It needs to select more than one contact at a time. I want to present a list of contacts with some contacts pre-selected. I can't figure out how to show this in an OssoABookContactChooser. Can you help, please? Perhaps there is a better way than the one that I have chosen.
I started with the useful example at "How to user native Maemo5 contacts dialogs":http://wiki.forum.nokia.com/index.php/How_to_use_native_Maemo5_contacts_dialogs. I changed it to permit multiple selections. I use osso_abook_contact_chooser_select_contacts() to tell it which ones I want selected when I show the dialog. When I show the dialog, there are no contacts already selected.
Here is a fragment of the code that I am using:
@
// list of QString representations of contact UIDs
// This is already populated for me and I can prove that the
// strings in it represent valid contact UIDs.
QStringList *selectedContacts = ...;
GList g = 0;
GtkWidget contactChooser = osso_abook_contact_chooser_new_with_capabilities (NULL, qPrintable(windowTitle), caps, order);
osso_abook_contact_chooser_set_minimum_selection(OSSO_ABOOK_CONTACT_CHOOSER(contactChooser), lower_limit);
osso_abook_contact_chooser_set_maximum_selection(OSSO_ABOOK_CONTACT_CHOOSER(contactChooser), upper_limit);if (0 != selectedContacts) {
QString contact;
foreach (contact, *selectedContacts) {qDebug() << "Looking up " << contact; OssoABookContact *c = QOssoABookDialog::lookup(contact); if (0 != c) { qDebug() << "Found " << osso_abook_contact_get_uid(c) << " " << osso_abook_contact_get_display_name(c); g= g_list_prepend(g, c); } else qDebug() << "Did not find " << contact; } osso_abook_contact_chooser_select_contacts(OSSO_ABOOK_CONTACT_CHOOSER(contactChooser), g);
}
//Shows a modal dialog.
GList* contacts; // Do not free
if (gtk_dialog_run(GTK_DIALOG(contactChooser)) == GTK_RESPONSE_OK){
...
}
@ -
You should ask the question on Maemo's forums. They generally know a lot more than we do about the services.
-
I think you will have more luck with this question on the Maemo forum: While it is possible to mix Gtk and Qt widgets it is nothing most people here have much experience with.
If you can not get the information you need from QtMobility (which has a contacts API IIRC), then you are better of with pure Gtk code in my opinion: Your application will be Maemo specific anyway, so why bother with the added complexity of mixing Gtk and Qt?
-
As far as I can tell, QtMobility doesn't provide a way to select contacts in a finger-friendly way. It only provides a way to manipulate contacts.
I am writing my application using Qt 4.7 because that's what comes with QtCreator. This is my first foray into Qt programming and programming for the N900 phone.
If I want finger-friendly selection, I must either use the older Maemo functions or make my own out of raw Qt. I guess I could do the latter but I'd rather use the former for the time being because it should mean that I have to write much less code. Eventually, I will throw away the Maemo-specific things.
I thank the two of you, Tobias Hunger and Benjamin Poulain, for your advice. I am seeking an answer on the Maemo forum.
-
There is an end to this story. I wrote my own finger-friendly Qt implementation of Maemo5's native contact chooser. As far as I can tell, no Maemo5 developer ever used the native one in the way I want to use it. I'll go so far as to say that the native one is broken.
Writing my own was harder than I expected but not impossible. I had some help from some Trolls at Qt Developer Days in San Francisco. I'm grateful for their eager, friendly help. Thanks to Martin, Benedikte, and Pierre.