| 309 | } |
| 310 | |
| 311 | QString Logging::indentString(const QString &string, const QStringList &indentBrackets) |
| 312 | { |
| 313 | QString result; |
| 314 | QChar quote{'\0'}; |
| 315 | QChar last{'\0'}; |
| 316 | QChar current{'\0'}; |
| 317 | int indent = 0; |
| 318 | |
| 319 | for (int i = 0; i < string.length(); ++i) |
| 320 | { |
| 321 | current = string[i]; |
| 322 | |
| 323 | if (quote != QChar('\0')) |
| 324 | { |
| 325 | if (quote == current) |
| 326 | quote = '\0'; |
| 327 | } |
| 328 | else |
| 329 | { |
| 330 | switch (current.toLatin1()) |
| 331 | { |
| 332 | case '\'': |
| 333 | case '"': |
| 334 | quote = current; |
| 335 | break; |
| 336 | case ',': |
| 337 | result += "\n" + QString(indent, QChar(' ')); |
| 338 | break; |
| 339 | default: |
| 340 | if (isOpenBracket(indentBrackets, current)) |
| 341 | { |
| 342 | result += "\n" + QString(indent, QChar(' ')); |
| 343 | indent++; |
| 344 | } |
| 345 | else if (isCloseBracket(indentBrackets, current)) |
| 346 | { |
| 347 | indent--; |
| 348 | result += "\n" + QString(indent, QChar(' ')); |
| 349 | } |
| 350 | break; |
| 351 | } |
| 352 | } |
| 353 | if (isOpenBracket(indentBrackets, last)) |
| 354 | { |
| 355 | if (!isCloseBracket(indentBrackets, current)) |
| 356 | result += "\n" + QString(indent, QChar(' ')); |
| 357 | } |
| 358 | result += QString(current); |
| 359 | last = string[i]; |
| 360 | } |
| 361 | return result; |
| 362 | } |
| 363 |
nothing calls this directly
no test coverage detected