Justify row correctly after double space

The wordSpacing property of a QFont object applies only once when there are multiple spaces between words. Therefore Row::Element::countSeparators shall not count spaces, but groups of spaces.

Fixes bug #9808.
This commit is contained in:
Jean-Marc Lasgouttes 2015-10-28 13:58:11 +01:00
parent 1814739853
commit b5871decc0

View File

@ -41,7 +41,19 @@ int Row::Element::countSeparators() const
{
if (type != STRING)
return 0;
return count(str.begin(), str.end(), ' ');
// Consecutive spaces count as only one separator.
bool wasspace = false;
int nsep = 0;
for (size_t i = 0 ; i < str.size() ; ++i) {
if (str[i] == ' ') {
if (!wasspace) {
++nsep;
wasspace = true;
}
} else
wasspace = false;
}
return nsep;
}