Showing the changes to interface/src/ui/BaseLogDialog.cpp (1 of 2 files). Show all
Unified · Split
| @@ -14,6 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <QDir> |
| 15 | 15 | #include <QLineEdit> |
| 16 | 16 | #include <QPlainTextEdit> |
| 17 | +#include <QTextCursor> | |
| 17 | 18 | #include <QPushButton> |
| 18 | 19 | #include <QSyntaxHighlighter> |
| 19 | 20 | |
| @@ -25,6 +26,7 @@ const int INITIAL_HEIGHT = 480; · 5 unmodified lines | ||
| 25 | 26 | const int MINIMAL_WIDTH = 570; |
| 26 | 27 | const int SEARCH_BUTTON_LEFT = 25; |
| 27 | 28 | const int SEARCH_BUTTON_WIDTH = 20; |
| 29 | +const int SEARCH_NEXT_BUTTON_WIDTH = 50; | |
| 28 | 30 | const int SEARCH_TEXT_WIDTH = 240; |
| 29 | 31 | const QColor HIGHLIGHT_COLOR = QColor("#3366CC"); |
| 30 | 32 | |
| @@ -75,9 +77,16 @@ void BaseLogDialog::initControls() { · 44 unmodified lines | ||
| 75 | 77 | // disable blue outline in Mac |
| 76 | 78 | _searchTextBox->setAttribute(Qt::WA_MacShowFocusRect, false); |
| 77 | 79 | _searchTextBox->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_TEXT_WIDTH, ELEMENT_HEIGHT); |
| 78 | − _leftPad += SEARCH_TEXT_WIDTH + CHECKBOX_MARGIN; | |
| 80 | + _leftPad += SEARCH_TEXT_WIDTH; | |
| 79 | 81 | _searchTextBox->show(); |
| 80 | 82 | connect(_searchTextBox, SIGNAL(textChanged(QString)), SLOT(handleSearchTextChanged(QString))); |
| 83 | + | |
| 84 | + _searchNextButton = new QPushButton(this); | |
| 85 | + _searchNextButton->setObjectName("searchNextButton"); | |
| 86 | + _searchNextButton->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_NEXT_BUTTON_WIDTH, ELEMENT_HEIGHT); | |
| 87 | + _leftPad += SEARCH_NEXT_BUTTON_WIDTH + CHECKBOX_MARGIN; | |
| 88 | + _searchNextButton->show(); | |
| 89 | + connect(_searchNextButton, SIGNAL(clicked()), SLOT(toggleSearchNext())); | |
| 81 | 90 | |
| 82 | 91 | _logTextBox = new QPlainTextEdit(this); |
| 83 | 92 | _logTextBox->setReadOnly(true); |
| @@ -105,11 +114,28 @@ void BaseLogDialog::handleSearchButton() { · 21 unmodified lines | ||
| 105 | 114 | } |
| 106 | 115 | |
| 107 | 116 | void BaseLogDialog::handleSearchTextChanged(QString searchText) { |
| 117 | + QTextCursor searchCursor = _logTextBox->textCursor(); | |
| 118 | + searchCursor.setPosition(0, QTextCursor::MoveAnchor); | |
| 119 | + _logTextBox->setTextCursor(searchCursor); | |
| 120 | + bool foundTerm = _logTextBox->find(searchText); | |
| 121 | + | |
| 122 | + if (!foundTerm) { | |
| 123 | + searchCursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); | |
| 124 | + } | |
| 125 | + | |
| 108 | 126 | _searchTerm = searchText; |
| 109 | 127 | _highlighter->keyword = searchText; |
| 110 | 128 | _highlighter->rehighlight(); |
| 111 | 129 | } |
| 112 | 130 | |
| 131 | +void BaseLogDialog::toggleSearchNext() { | |
| 132 | + QTextCursor searchCursor = _logTextBox->textCursor(); | |
| 133 | + if (searchCursor.hasSelection()) { | |
| 134 | + QString selectedTerm = searchCursor.selectedText(); | |
| 135 | + _logTextBox->find(selectedTerm); | |
| 136 | + } | |
| 137 | +} | |
| 138 | + | |
| 113 | 139 | void BaseLogDialog::showLogData() { |
| 114 | 140 | _logTextBox->clear(); |
| 115 | 141 | _logTextBox->appendPlainText(getCurrentLog()); |