History

Toggle next for search on Log

kunalgosar committed 9 years ago

Commit c01d0b31 parent 3e520912 files · +29 −1Browse files

Showing the changes to interface/src/ui/BaseLogDialog.cpp (1 of 2 files). Show all

Unified · Split

interface/src/ui/BaseLogDialog.cpp+27−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <QDir>
1515 #include <QLineEdit>
1616 #include <QPlainTextEdit>
17+#include <QTextCursor>
1718 #include <QPushButton>
1819 #include <QSyntaxHighlighter>
1920
@@ -25,6 +26,7 @@ const int INITIAL_HEIGHT = 480; · 5 unmodified lines
2526 const int MINIMAL_WIDTH = 570;
2627 const int SEARCH_BUTTON_LEFT = 25;
2728 const int SEARCH_BUTTON_WIDTH = 20;
29+const int SEARCH_NEXT_BUTTON_WIDTH = 50;
2830 const int SEARCH_TEXT_WIDTH = 240;
2931 const QColor HIGHLIGHT_COLOR = QColor("#3366CC");
3032
@@ -75,9 +77,16 @@ void BaseLogDialog::initControls() { · 44 unmodified lines
7577 // disable blue outline in Mac
7678 _searchTextBox->setAttribute(Qt::WA_MacShowFocusRect, false);
7779 _searchTextBox->setGeometry(_leftPad, ELEMENT_MARGIN, SEARCH_TEXT_WIDTH, ELEMENT_HEIGHT);
78− _leftPad += SEARCH_TEXT_WIDTH + CHECKBOX_MARGIN;
80+ _leftPad += SEARCH_TEXT_WIDTH;
7981 _searchTextBox->show();
8082 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()));
8190
8291 _logTextBox = new QPlainTextEdit(this);
8392 _logTextBox->setReadOnly(true);
@@ -105,11 +114,28 @@ void BaseLogDialog::handleSearchButton() { · 21 unmodified lines
105114 }
106115
107116 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+
108126 _searchTerm = searchText;
109127 _highlighter->keyword = searchText;
110128 _highlighter->rehighlight();
111129 }
112130
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+
113139 void BaseLogDialog::showLogData() {
114140 _logTextBox->clear();
115141 _logTextBox->appendPlainText(getCurrentLog());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t