| 716 | } |
| 717 | |
| 718 | void TabDiagnostics::SearchFind(bool prev) { |
| 719 | this->ResetTextCursor(); |
| 720 | |
| 721 | QTextDocument::FindFlags flags = prev ? QTextDocument::FindBackward : QTextDocument::FindFlags(0); |
| 722 | |
| 723 | if (this->search_case) { |
| 724 | flags |= QTextDocument::FindCaseSensitively; |
| 725 | } |
| 726 | if (this->search_whole) { |
| 727 | flags |= QTextDocument::FindWholeWords; |
| 728 | } |
| 729 | |
| 730 | bool found = false; |
| 731 | if (this->search_regex) { |
| 732 | found = this->ui->diagnostic_status_text->find(QRegularExpression(this->ui->diagnostic_search_edit->text()), flags); |
| 733 | } else { |
| 734 | found = this->ui->diagnostic_status_text->find(this->ui->diagnostic_search_edit->text(), flags); |
| 735 | } |
| 736 | |
| 737 | QTextCursor cursor = this->ui->diagnostic_status_text->textCursor(); |
| 738 | |
| 739 | if (found) { |
| 740 | QTextCharFormat format; |
| 741 | format.setFontWeight(QFont::Bold); |
| 742 | cursor.mergeCharFormat(format); |
| 743 | |
| 744 | this->ui->diagnostic_status_text->ensureCursorVisible(); |
| 745 | } else { |
| 746 | if (!prev && !cursor.atStart()) { |
| 747 | this->ui->diagnostic_status_text->moveCursor(QTextCursor::Start); |
| 748 | this->SearchFind(prev); |
| 749 | return; |
| 750 | } |
| 751 | |
| 752 | if (prev && !cursor.atEnd()) { |
| 753 | this->ui->diagnostic_status_text->moveCursor(QTextCursor::End); |
| 754 | this->SearchFind(prev); |
| 755 | return; |
| 756 | } |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | void TabDiagnostics::on_search_case_activated() { this->ui->diagnostic_search_case->setChecked(!this->search_case); } |
| 761 |
no test coverage detected