From b5b90ce17a2563f04320f3aae9cd18b9b4d67847 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 12 May 2014 15:56:48 +1000 Subject: [PATCH] [libcontacts] Check whether spacing should be used between name parts --- src/seasidecache.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/seasidecache.cpp b/src/seasidecache.cpp index 65249da..7d2cddb 100644 --- a/src/seasidecache.cpp +++ b/src/seasidecache.cpp @@ -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) { @@ -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); }