comparison src/textabbrev.cpp @ 464:6fc4fafc5e6b

Further minor abbrev fix
author Chris Cannam
date Mon, 04 Jul 2011 13:48:04 +0100
parents 3d7070aa959e
children 533519ebc0cb
comparison
equal deleted inserted replaced
463:3d7070aa959e 464:6fc4fafc5e6b
115 115
116 int truncateTo = tl; 116 int truncateTo = tl;
117 117
118 while (tw > maxWidth && truncateTo > 1) { 118 while (tw > maxWidth && truncateTo > 1) {
119 119
120 if (tw > maxWidth + acw * 10) { 120 if (tw > maxWidth + acw * (ellipsis.length() + 5)) {
121 float ratio = float(maxWidth) / float(tw); 121 float ratio = float(maxWidth) / float(tw);
122 truncateTo = int(truncateTo * ratio * 1.2) + 10; 122 truncateTo = int(truncateTo * ratio * 1.2) + 10;
123 if (truncateTo >= tl) truncateTo = tl - 1; 123 if (truncateTo >= tl) truncateTo = tl - 1;
124 } else { 124 } else {
125 truncateTo--; 125 truncateTo--;
137 tl = text.length() - ellipsis.length(); 137 tl = text.length() - ellipsis.length();
138 } 138 }
139 139
140 // std::cerr << "done, final tw = " << tw << std::endl; 140 // std::cerr << "done, final tw = " << tw << std::endl;
141 141
142 maxWidth = tw; 142 maxWidth = std::max(maxWidth, tw);
143 return text; 143 return text;
144 144
145 } else { 145 } else {
146 146
147 QStringList words = text.split(' ', QString::SkipEmptyParts); 147 QStringList words = text.split(' ', QString::SkipEmptyParts);