From ec3863f5c118f3127b0a52ea25e80de399eeedd5 Mon Sep 17 00:00:00 2001 From: Matt Vogt Date: Fri, 13 Jun 2014 09:45:17 +1000 Subject: [PATCH] [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. --- src/seasidecache.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/seasidecache.cpp b/src/seasidecache.cpp index b63c129..6011b2b 100644 --- a/src/seasidecache.cpp +++ b/src/seasidecache.cpp @@ -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(); + 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().label(); @@ -1157,11 +1163,6 @@ QString SeasideCache::generateDisplayLabelFromNonNameDetails(const QContact &con } } - QContactOrganization company = contact.detail(); - if (!company.name().isEmpty()) { - return company.name(); - } - foreach (const QContactPhoneNumber& phone, contact.details()) { if (!phone.number().isEmpty()) return phone.number();