Skip to content

Commit

Permalink
Fix variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Jan 5, 2022
1 parent c489e79 commit 4d42add
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
25 changes: 12 additions & 13 deletions qplaintexteditsearchwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ QPlainTextEditSearchWidget::QPlainTextEditSearchWidget(QPlainTextEdit *parent)
connect(ui->replaceAllButton, &QPushButton::clicked, this,
&QPlainTextEditSearchWidget::doReplaceAll);

connect(&debounceTimer_, &QTimer::timeout,
connect(&_debounceTimer, &QTimer::timeout,
this, &QPlainTextEditSearchWidget::performSearch);

installEventFilter(this);
Expand Down Expand Up @@ -114,18 +114,18 @@ bool QPlainTextEditSearchWidget::eventFilter(QObject *obj, QEvent *event) {
if (keyEvent->key() == Qt::Key_Escape) {
deactivate();
return true;
} else if (!debounceTimer_.isActive() &&
} else if (!_debounceTimer.isActive() &&
(keyEvent->modifiers().testFlag(Qt::ShiftModifier) &&
(keyEvent->key() == Qt::Key_Return)) ||
(keyEvent->key() == Qt::Key_Up)) {
doSearchUp();
return true;
} else if (!debounceTimer_.isActive() &&
} else if (!_debounceTimer.isActive() &&
((keyEvent->key() == Qt::Key_Return) ||
(keyEvent->key() == Qt::Key_Down))) {
doSearchDown();
return true;
} else if (!debounceTimer_.isActive() && keyEvent->key() == Qt::Key_F3) {
} else if (!_debounceTimer.isActive() && keyEvent->key() == Qt::Key_F3) {
doSearch(!keyEvent->modifiers().testFlag(Qt::ShiftModifier));
return true;
}
Expand All @@ -144,11 +144,10 @@ bool QPlainTextEditSearchWidget::eventFilter(QObject *obj, QEvent *event) {

void QPlainTextEditSearchWidget::searchLineEditTextChanged(
const QString &arg1) {
_searchTerm = arg1;

searchTerm_ = arg1;

if (debounceTimer_.interval() != 0 && !searchTerm_.isEmpty()) {
debounceTimer_.start();
if (_debounceTimer.interval() != 0 && !_searchTerm.isEmpty()) {
_debounceTimer.start();
ui->searchDownButton->setEnabled(false);
ui->searchUpButton->setEnabled(false);
} else {
Expand All @@ -163,10 +162,10 @@ void QPlainTextEditSearchWidget::performSearch()
if (searchMode == RegularExpressionMode) {
// Prevent stuck application when the user enters just start or end markers
static const QRegularExpression regExp(R"(^[\^\$]+$)");
if (regExp.match(searchTerm_).hasMatch()) {
if (regExp.match(_searchTerm).hasMatch()) {
clearSearchExtraSelections();

if (debounceTimer_.isActive()) {
if (_debounceTimer.isActive()) {
stopDebounce();
}
return;
Expand Down Expand Up @@ -209,7 +208,7 @@ void QPlainTextEditSearchWidget::setSearchExtraSelections() const {

void QPlainTextEditSearchWidget::stopDebounce()
{
debounceTimer_.stop();
_debounceTimer.stop();
ui->searchDownButton->setEnabled(true);
ui->searchUpButton->setEnabled(true);
}
Expand Down Expand Up @@ -272,7 +271,7 @@ void QPlainTextEditSearchWidget::doReplaceAll() {
bool QPlainTextEditSearchWidget::doSearch(bool searchDown,
bool allowRestartAtTop,
bool updateUI) {
if (debounceTimer_.isActive()) {
if (_debounceTimer.isActive()) {
stopDebounce();
}

Expand Down Expand Up @@ -432,7 +431,7 @@ void QPlainTextEditSearchWidget::setSearchMode(SearchMode searchMode) {

void QPlainTextEditSearchWidget::setDebounceDelay(uint debounceDelay)
{
debounceTimer_.setInterval(static_cast<int>(debounceDelay));
_debounceTimer.setInterval(static_cast<int>(debounceDelay));
}

void QPlainTextEditSearchWidget::activate(bool focus) {
Expand Down
4 changes: 2 additions & 2 deletions qplaintexteditsearchwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class QPlainTextEditSearchWidget : public QWidget {
int _currentSearchResult;
QList<QTextEdit::ExtraSelection> _searchExtraSelections;
QColor selectionColor;
QTimer debounceTimer_;
QString searchTerm_;
QTimer _debounceTimer;
QString _searchTerm;
void setSearchExtraSelections() const;
void stopDebounce();

Expand Down

0 comments on commit 4d42add

Please sign in to comment.