| 355 | } |
| 356 | |
| 357 | QString InputEdit::toConvertedText() const |
| 358 | { |
| 359 | QTextCursor cursor = textCursor(); |
| 360 | cursor.movePosition(QTextCursor::Start); |
| 361 | |
| 362 | QString text; |
| 363 | while (!cursor.atEnd()) { |
| 364 | auto format = cursor.charFormat(); |
| 365 | auto currentText = cursor.selectedText(); |
| 366 | text.append(cursor.selectedText()); |
| 367 | |
| 368 | if (format.type() == QTextFormat::InvalidFormat && (currentText == QString(QChar::ObjectReplacementCharacter))) { |
| 369 | auto innerText = format.property(QTextFormat::UserProperty).toString(); |
| 370 | if (innerText.mid(1) == selectedCodeTag) { |
| 371 | text.append("\n```\n" + innerText + "\n" + selectedCode + "\n```\n"); |
| 372 | } else if (!innerText.isEmpty()) { |
| 373 | text.append('`' + innerText + '`'); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | cursor.clearSelection(); |
| 378 | cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); |
| 379 | } |
| 380 | |
| 381 | text.append(cursor.selectedText()); |
| 382 | return text.remove(QChar::ObjectReplacementCharacter); |
| 383 | } |
| 384 | |
| 385 | void InputEdit::appendTag(const QString &text) |
| 386 | { |
no test coverage detected