Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
[libcontacts] Prefer organization name to contact details in display …
…label

If a contact has no name details, but has an organization detail
including the name field, then it probably represents that organization
directly.  Prefer to use this detail as the display label in
preference to the contactable details of the contact.
  • Loading branch information
matthewvogt committed Jun 12, 2014
1 parent e442c84 commit ec3863f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/seasidecache.cpp
Expand Up @@ -1138,6 +1138,12 @@ QString SeasideCache::generateDisplayLabelFromNonNameDetails(const QContact &con
}
}

// If this contact has organization details but no name, it probably represents that organization directly
QContactOrganization company = contact.detail<QContactOrganization>();
if (!company.name().isEmpty()) {
return company.name();
}

// If none of the detail fields provides a label, fallback to the backend's label string, in
// preference to using any of the addressing details directly
const QString displayLabel = contact.detail<QContactDisplayLabel>().label();
Expand All @@ -1157,11 +1163,6 @@ QString SeasideCache::generateDisplayLabelFromNonNameDetails(const QContact &con
}
}

QContactOrganization company = contact.detail<QContactOrganization>();
if (!company.name().isEmpty()) {
return company.name();
}

foreach (const QContactPhoneNumber& phone, contact.details<QContactPhoneNumber>()) {
if (!phone.number().isEmpty())
return phone.number();
Expand Down

0 comments on commit ec3863f

Please sign in to comment.