comparison src/converter.cpp @ 63:4d65e654abf7

Converter: Handle empty percent strings again
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 26 Aug 2016 12:24:32 +0200
parents 5410f9f279ea
children defd29b9f25a
comparison
equal deleted inserted replaced
62:797435c1bbeb 63:4d65e654abf7
228 html << mChoiceTextStyle.arg(choiceName.toHtmlEscaped()); 228 html << mChoiceTextStyle.arg(choiceName.toHtmlEscaped());
229 qDebug() << "Captured for choice: " << choiceMatch.captured(0); 229 qDebug() << "Captured for choice: " << choiceMatch.captured(0);
230 bool ok; 230 bool ok;
231 QString percentStr = choiceMatch.captured("percent"); 231 QString percentStr = choiceMatch.captured("percent");
232 double percent; 232 double percent;
233 if (percentStr.isNull()) { 233 if (percentStr.isEmpty()) {
234 percent = 0; 234 percent = 0;
235 ok = true; 235 ok = true;
236 } else { 236 } else {
237 percent = percentStr.toDouble(&ok); 237 percent = percentStr.toDouble(&ok);
238 } 238 }
239 if (!ok) { 239 if (!ok) {
240 mErrors << "Unparsable number in string: " + choiceMatch.captured(); 240 mErrors << "Unparsable number in string: " + choiceMatch.captured();
241 percent = 0;
242 percentStr = QString();
243 /* PercentStr was not a number. */
241 } 244 }
242 makeBar(html, percent, doc); 245 makeBar(html, percent, doc);
243 xlsx.write(row, 2, percent == 0 ? QVariant() : percent); 246 xlsx.write(row, 2, percent == 0 ? QVariant() : percent);
244 const QString numStr = choiceMatch.captured("num"); 247 const QString numStr = choiceMatch.captured("num");
245 const QString numVotesString = QString("%1% | %2 Number of votes"). 248 const QString numVotesString = QString("%1% | %2 Number of votes").
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)