comparison src/converter.cpp @ 56:5410f9f279ea

Redefine question pattern to be more robust We now assume that a question begins after two empty lines.
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 09 Aug 2016 09:59:16 +0200
parents aaaf8cdbc85c
children 4d65e654abf7
comparison
equal deleted inserted replaced
55:aaaf8cdbc85c 56:5410f9f279ea
178 178
179 QRegularExpression questionEx(QUESTION_PATTERN); 179 QRegularExpression questionEx(QUESTION_PATTERN);
180 QRegularExpression choiceEx(CHOICE_PATTERN); 180 QRegularExpression choiceEx(CHOICE_PATTERN);
181 QRegularExpression choiceAltEx(CHOICE_UNFILLED_PATTERN); 181 QRegularExpression choiceAltEx(CHOICE_UNFILLED_PATTERN);
182 QRegularExpression freetxtEx(FREETXT_PATTERN); 182 QRegularExpression freetxtEx(FREETXT_PATTERN);
183 QRegularExpression firstQuestionEx(FIRST_QUESTION_PATTERN);
183 184
184 input.replace("\r\n", "\n"); 185 input.replace("\r\n", "\n");
185 input.replace("\n\r", "\n"); 186 input.replace("\n\r", "\n");
186 input.replace("#NAME?\n", ""); 187 input.replace("#NAME?\n", "");
187 188
188 QRegularExpressionMatch match = questionEx.match(input); 189 QRegularExpressionMatch match = firstQuestionEx.match(input);
189 bool foundSomething = false; 190 bool foundSomething = false;
190 int cursor = match.capturedEnd(); 191 int cursor = match.capturedEnd();
191 while (match.hasMatch() && cursor != -1) { 192 while (match.hasMatch() && cursor != -1) {
192 /* We've matched a question pattern. With the answer 193 /* We've matched a question pattern. With the answer
193 line */ 194 line */
225 } 226 }
226 xlsx.write(row, 1, choiceName, mChoiceTextFmt); 227 xlsx.write(row, 1, choiceName, mChoiceTextFmt);
227 html << mChoiceTextStyle.arg(choiceName.toHtmlEscaped()); 228 html << mChoiceTextStyle.arg(choiceName.toHtmlEscaped());
228 qDebug() << "Captured for choice: " << choiceMatch.captured(0); 229 qDebug() << "Captured for choice: " << choiceMatch.captured(0);
229 bool ok; 230 bool ok;
230 const QString percentStr = choiceMatch.captured("percent"); 231 QString percentStr = choiceMatch.captured("percent");
231 double percent; 232 double percent;
232 if (percentStr.isNull()) { 233 if (percentStr.isNull()) {
233 percent = 0; 234 percent = 0;
234 ok = true; 235 ok = true;
235 } else { 236 } else {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)