# HG changeset patch # User Andre Heinecke # Date 1469026672 -7200 # Node ID aaaf8cdbc85c79018d8cd9ff01d8df19385721db # Parent dcfb8e9d5ee9d4d9607d4f1d9fb11aed5d72c932 Make percent string formatting more flexible It now also responds to .94 or something like that and is prepared for multiple numbers after the dot. diff -r dcfb8e9d5ee9 -r aaaf8cdbc85c src/constants.h --- a/src/constants.h Wed Jul 20 16:56:54 2016 +0200 +++ b/src/constants.h Wed Jul 20 16:57:52 2016 +0200 @@ -63,7 +63,7 @@ /** * @brief The pattern used to match a multiple choice answer. */ -#define CHOICE_PATTERN "\"(.*)\",(?\\d+)?,(?\\d+\\.?\\d+)?" +#define CHOICE_PATTERN "\"(.*)\",(?\\d+)?,(?\\d{0,3}\\.{0,1}\\d*)?" /** * @brief The pattern used to match an unfilled choice answer. */ diff -r dcfb8e9d5ee9 -r aaaf8cdbc85c src/converter.cpp --- a/src/converter.cpp Wed Jul 20 16:56:54 2016 +0200 +++ b/src/converter.cpp Wed Jul 20 16:57:52 2016 +0200 @@ -242,8 +242,8 @@ xlsx.write(row, 2, percent == 0 ? QVariant() : percent); const QString numStr = choiceMatch.captured("num"); const QString numVotesString = QString("%1% | %2 Number of votes"). - arg(percentStr.isNull() ? QStringLiteral("0") : percentStr). - arg(numStr.isNull() ? QStringLiteral("0") : numStr); + arg(percentStr.isEmpty() ? QStringLiteral("0") : percentStr). + arg(numStr.isEmpty() ? QStringLiteral("0") : numStr); html << mChoiceVotesStyle.arg(numVotesString.toHtmlEscaped()); xlsx.write(row, 3, numVotesString, mChoiceVotesFmt); xlsx.setRowHeight(row, CHOICE_ROW_HEIGHT);