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 | #include <QDir> | 14 | #include <QDir> |
| 15 | #include <QLineEdit> | 15 | #include <QLineEdit> |
| 16 | #include <QPlainTextEdit> | 16 | #include <QPlainTextEdit> |
| 17 | #include <QTextCursor> | ||
| 17 | #include <QPushButton> | 18 | #include <QPushButton> |
| 18 | #include <QSyntaxHighlighter> | 19 | #include <QSyntaxHighlighter> |
| 19 | 20 | ||
| @@ -25,6 +26,7 @@ const int INITIAL_HEIGHT = 480; · 5 unmodified lines | |||
| 25 | const int MINIMAL_WIDTH = 570; | 26 | const int MINIMAL_WIDTH = 570; |
| 26 | const int SEARCH_BUTTON_LEFT = 25; | 27 | const int SEARCH_BUTTON_LEFT = 25; |
| 27 | const int SEARCH_BUTTON_WIDTH = 20; | 28 | const int SEARCH_BUTTON_WIDTH = 20; |
| 29 | const int SEARCH_NEXT_BUTTON_WIDTH = 50; | ||
| 28 | const int SEARCH_TEXT_WIDTH = 240; | 30 | const int SEARCH_TEXT_WIDTH = 240; |
| 29 | const QColor HIGHLIGHT_COLOR = QColor("#3366CC"); | 31 | const QColor HIGHLIGHT_COLOR = QColor("#3366CC"); |
| 30 | 32 | ||
| @@ -75,9 +77,16 @@ void BaseLogDialog::initControls() { · 44 unmodified lines | |||
| 75 | // disable blue outline in Mac | 77 | // disable blue outline in Mac |
| 76 | _searchTextBox->setAttribute(Qt::WA_MacShowFocusRect, false); | 78 | _searchTextBox->setAttribute(Qt::WA_MacShowFocusRect, false); |
| 77 | _searchTextBox->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_TEXT_WIDTH, ELEMENT_HEIGHT); | 79 | _searchTextBox->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_TEXT_WIDTH, ELEMENT_HEIGHT); |
| 78 | _leftPad += SEARCH_TEXT_WIDTH + CHECKBOX_MARGIN; | 80 | _leftPad += SEARCH_TEXT_WIDTH; |
| 79 | _searchTextBox->show(); | 81 | _searchTextBox->show(); |
| 80 | connect(_searchTextBox, SIGNAL(textChanged(QString)), SLOT(handleSearchTextChanged(QString))); | 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 | _logTextBox = new QPlainTextEdit(this); | 91 | _logTextBox = new QPlainTextEdit(this); |
| 83 | _logTextBox->setReadOnly(true); | 92 | _logTextBox->setReadOnly(true); |
| @@ -105,11 +114,28 @@ void BaseLogDialog::handleSearchButton() { · 21 unmodified lines | |||
| 105 | } | 114 | } |
| 106 | 115 | ||
| 107 | void BaseLogDialog::handleSearchTextChanged(QString searchText) { | 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 | _searchTerm = searchText; | 126 | _searchTerm = searchText; |
| 109 | _highlighter->keyword = searchText; | 127 | _highlighter->keyword = searchText; |
| 110 | _highlighter->rehighlight(); | 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 | void BaseLogDialog::showLogData() { | 139 | void BaseLogDialog::showLogData() { |
| 114 | _logTextBox->clear(); | 140 | _logTextBox->clear(); |
| 115 | _logTextBox->appendPlainText(getCurrentLog()); | 141 | _logTextBox->appendPlainText(getCurrentLog()); |