[KAddressbook] Improve the contacts list
Open, Needs TriagePublic

Description

During a discussion at Akademy we got a few ideas how to make KAddressbook slightly prettier - one of them was to improve the looks of the main contact list by improving the list delegates.

Right now each contact row looks like this

[picture] Firstname Lastname

Our idea is to go for a more modern, two-row look:

[ pic ] Firstname Lastname
[ pic ] email@address.cz, phone number

With the name being more prominent (bigger, maybe bold), the email address and phone number less so.

The picture could be rounded, instead of rectangular, maybe generating an icon with initials (like DV for Dan Vratil) when no photo is available in the contact.

This requires only implementing a new delegate for the listview, no knowledge of Akonadi or even contacts is needed.

dvratil created this task.Aug 16 2018, 7:39 PM

Daniel, I want to prepare a solution for this task, but I can't find a way to get an email address in added delegate inside paint event when the email address column is hidden. I tried to get it from the model but it only contains the columns that are visible in the GUI. Can you help me with this?

dvratil added a comment.EditedTue, Mar 31, 11:58 AM

Hi! Sure :) The underlying data model is Akonadi::ContactsTreeModel which is subclass of Akonadi::EntityTreeModel. Thus, if you have a QModelIndex, you can use the data() function to retrieve data for the Akonadi::EntityTreeModel::ItemRole, which gives you the Akonadi::Item which holds the contact itself: KContacts::Addressee

const auto item = index.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
if (!item.hasPayload<KContacts::Addressee>()) {
    // error handling
    return;
}
const auto contact = item.payload<KContacts::Addressee>();

Now you have the contact itself and you can access any data that are stored in there.