Skip to content
Snippets Groups Projects
Commit 4605c011 authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by Nicolas Jager
Browse files

Person: implement Ring::Role::Number role


It returns the bestId() of the lastUsedContactMethod().
This way views will not get an empty QVariant when asking for the
number role from a Person item.

This also makes sense as what we want to show most of the time and
most of the time a Person will only have one ContactMethod anyways.

Change-Id: I0edea8c4fe3f6848a523c4f88d3115cf13b20938
Reviewed-by: default avatarNicolas Jäger <nicolas.jager@savoirfairelinux.com>
parent bc5b6a62
No related branches found
No related tags found
No related merge requests found
...@@ -596,6 +596,11 @@ QVariant Person::roleData(int role) const ...@@ -596,6 +596,11 @@ QVariant Person::roleData(int role) const
case Qt::EditRole: case Qt::EditRole:
case static_cast<int>(Ring::Role::Name): case static_cast<int>(Ring::Role::Name):
return QVariant(formattedName()); return QVariant(formattedName());
case static_cast<int>(Ring::Role::Number):
{
auto cm = lastUsedContactMethod();
return cm ? cm->bestId() : QString();
}
case Qt::DecorationRole: case Qt::DecorationRole:
return GlobalInstances::pixmapManipulator().decorationRole(this); return GlobalInstances::pixmapManipulator().decorationRole(this);
case static_cast<int>(Person::Role::Organization): case static_cast<int>(Person::Role::Organization):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment