Commit 9d6657a2 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

UI: display bestID when formattedName is empty

This commit use bestID of last used contactMethod associated with
contact if formattedName is empty. It prevents SmartList and Contacts
from displaying placeholder text.

Change-Id: Ieb22697cb22c150af26d3de7caee49a9f92bc04a
Tuleap: #1585
Reviewed-by: default avatarAlexandre Lision <alexandre.lision@savoirfairelinux.com>
parent abf4e273
......@@ -167,6 +167,7 @@ NSInteger const CALL_BUTTON_TAG = 400;
NSTableCellView *result;
NSString* displayNameString = qIdx.data(Qt::DisplayRole).toString().toNSString();
if(!qIdx.parent().isValid()) {
result = [outlineView makeViewWithIdentifier:@"LetterCell" owner:outlineView];
[result setWantsLayer:YES];
......@@ -176,6 +177,18 @@ NSInteger const CALL_BUTTON_TAG = 400;
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
if(displayNameString.length == 0 && p) {
QVector<ContactMethod*> contactMethods = p->phoneNumbers();
if(contactMethods.count() > 0) {
ContactMethod* method = contactMethods[0];
for(int i = 0; i < contactMethods.count(); i++) {
if (contactMethods[i]->lastUsed() > method->lastUsed()) {
method = contactMethods[i];
}
}
displayNameString = method->getBestId().toNSString();
}
}
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(qIdx.data(Qt::DecorationRole)))];
[((ContextualTableCellView*) result) setContextualsControls:[NSMutableArray arrayWithObject:[result viewWithTag:CALL_BUTTON_TAG]]];
......@@ -188,7 +201,7 @@ NSInteger const CALL_BUTTON_TAG = 400;
}
NSTextField* displayName = [result viewWithTag:DISPLAYNAME_TAG];
[displayName setStringValue:qIdx.data(Qt::DisplayRole).toString().toNSString()];
[displayName setStringValue:displayNameString];
return result;
}
......
......@@ -261,7 +261,20 @@ NSInteger const CANCEL_BUTTON_TAG = 600;
}
NSTextField* displayName = [result viewWithTag:DISPLAYNAME_TAG];
[displayName setStringValue:qIdx.data((int)Ring::Role::Name).toString().toNSString()];
NSString* displayNameString = qIdx.data((int)Ring::Role::Name).toString().toNSString();
if(displayNameString.length == 0) {
QVector<ContactMethod*> contactMethods = RecentModel::instance().getContactMethods(qIdx);
if(contactMethods.count() > 0) {
ContactMethod* method = contactMethods[0];
for(int i = 0; i < contactMethods.count(); i++) {
if (contactMethods[i]->lastUsed() > method->lastUsed()) {
method = contactMethods[i];
}
}
displayNameString = method->getBestId().toNSString();
}
}
[displayName setStringValue:displayNameString];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(qIdx.data(Qt::DecorationRole)))];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment