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

Commit

Permalink
[libcontacts] Check whether spacing should be used between name parts
Browse files Browse the repository at this point in the history
  • Loading branch information
Bea Lam committed May 12, 2014
1 parent 00ec0ba commit b5b90ce
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/seasidecache.cpp
Expand Up @@ -1085,6 +1085,15 @@ bool SeasideCache::isPopulated(FilterType filterType)
return instancePtr->m_populated & (1 << filterType);
}

static bool needsSpaceBetweenNames(const QString &first, const QString &second)
{
if (first.isEmpty() || second.isEmpty()) {
return false;
}
return first[first.length()-1].script() != QChar::Script_Han
|| second[0].script() != QChar::Script_Han;
}

// small helper to avoid inconvenience
QString SeasideCache::generateDisplayLabel(const QContact &contact, DisplayLabelOrder order)
{
Expand All @@ -1106,8 +1115,9 @@ QString SeasideCache::generateDisplayLabel(const QContact &contact, DisplayLabel
displayLabel.append(nameStr1);

if (!nameStr2.isEmpty()) {
if (!displayLabel.isEmpty())
if (needsSpaceBetweenNames(nameStr1, nameStr2)) {
displayLabel.append(" ");
}
displayLabel.append(nameStr2);
}

Expand Down

0 comments on commit b5b90ce

Please sign in to comment.