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
Merge pull request #80 from nemomobile/configure-name-spacing
[libcontacts] Check whether spacing should be used between name parts
  • Loading branch information
blammit committed May 16, 2014
2 parents 00ec0ba + b5b90ce commit af9a67c
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 af9a67c

Please sign in to comment.