diff --git a/src/search/katesearchbar.h b/src/search/katesearchbar.h --- a/src/search/katesearchbar.h +++ b/src/search/katesearchbar.h @@ -146,6 +146,7 @@ void onPowerPatternContextMenuRequest(const QPoint &); void onPowerReplacmentContextMenuRequest(); void onPowerReplacmentContextMenuRequest(const QPoint &); + void onPowerFindOrReplaceCanceled(); private: // Helpers @@ -191,6 +192,7 @@ // Power search related Ui::PowerSearchBar *m_powerUi; + bool m_cancelSearchOrReplace = false; // attribute to highlight matches with KTextEditor::Attribute::Ptr highlightMatchAttribute; diff --git a/src/search/katesearchbar.cpp b/src/search/katesearchbar.cpp --- a/src/search/katesearchbar.cpp +++ b/src/search/katesearchbar.cpp @@ -801,6 +801,14 @@ // don't let selectionChanged signal mess around in this routine disconnect(m_view, SIGNAL(selectionChanged(KTextEditor::View*)), this, SLOT(updateSelectionOnly())); + // Offer Cancel button and disable not useful buttons + m_powerUi->searchCancelStacked->setCurrentIndex(m_powerUi->searchCancelStacked->indexOf(m_powerUi->cancelPage)); + m_powerUi->findNext->setEnabled(false); + m_powerUi->findPrev->setEnabled(false); + m_powerUi->replaceNext->setEnabled(false); + + m_cancelSearchOrReplace = false; // Ensure we are have GO! + const SearchOptions enabledOptions = searchOptions(SearchForward); const bool regexMode = enabledOptions.testFlag(Regex); @@ -824,7 +832,7 @@ workingRange.reset(m_view->doc()->newMovingRange(m_view->doc()->rangeOnLine(inputRange, line))); } - for (;;) { + do { match.searchText(*workingRange, searchPattern()); if (!match.isValid()) { break; @@ -873,7 +881,12 @@ if (!workingRange->toRange().isValid() || workingStart.atEndOfDocument()) { break; } - } + + if (matchCounter % 100 == 0) { + QCoreApplication::processEvents(QEventLoop::AllEvents); + } + + } while (!m_cancelSearchOrReplace); } while (block && ++line <= inputRange.end().line()); @@ -910,6 +923,12 @@ // restore connection connect(m_view, SIGNAL(selectionChanged(KTextEditor::View*)), this, SLOT(updateSelectionOnly())); + // Offer Find and Replace buttons and enable again useful buttons + m_powerUi->searchCancelStacked->setCurrentIndex(m_powerUi->searchCancelStacked->indexOf(m_powerUi->searchPage)); + m_powerUi->findNext->setEnabled(true); + m_powerUi->findPrev->setEnabled(true); + m_powerUi->replaceNext->setEnabled(true); + return matchCounter; } @@ -1393,6 +1412,7 @@ connect(m_powerUi->searchMode, SIGNAL(currentIndexChanged(int)), this, SLOT(onPowerModeChanged(int))); connect(m_powerUi->matchCase, SIGNAL(toggled(bool)), this, SLOT(onMatchCaseToggled(bool))); connect(m_powerUi->findAll, SIGNAL(clicked()), this, SLOT(findAll())); + connect(m_powerUi->cancel, &QPushButton::clicked, this, &KateSearchBar::onPowerFindOrReplaceCanceled); // Make [return] in pattern line edit trigger action connect(patternLineEdit, SIGNAL(returnPressed()), this, SLOT(onReturnPressed())); @@ -1648,6 +1668,11 @@ onPowerReplacmentContextMenuRequest(m_powerUi->replacement->mapFromGlobal(QCursor::pos())); } +void KateSearchBar::onPowerFindOrReplaceCanceled() +{ + m_cancelSearchOrReplace = true; +} + bool KateSearchBar::isPower() const { return m_powerUi != nullptr; diff --git a/src/search/searchbarpower.ui b/src/search/searchbarpower.ui --- a/src/search/searchbarpower.ui +++ b/src/search/searchbarpower.ui @@ -7,8 +7,8 @@ 0 0 - 565 - 107 + 1037 + 144 @@ -44,85 +44,10 @@ 0 - - - - - 9 - 0 - - - - Qt::StrongFocus - - - Text to search for - - - true - - - QComboBox::AdjustToMinimumContentsLengthWithIcon - - - - - - - - - Jump to next match - - - - - - - - true - - - - - - - Jump to previous match - - - - - - - - true - - - - - - - - - - 9 - 0 - - - - Text to replace with - - - true - - - QComboBox::AdjustToMinimumContentsLengthWithIcon - - - - F&ind: + Fin&d: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -158,53 +83,13 @@ - - - - - - Match case sensitive - - - - - - - - true - - - true - - - - - - - Search in the selection only - - - - - - - - true - - - true - - - - - 6 - 6 + 0 @@ -245,6 +130,40 @@ + + + + Match case sensitive + + + + .. + + + true + + + true + + + + + + + Search in the selection only + + + + .. + + + true + + + true + + + @@ -258,6 +177,34 @@ + + + + Jump to next match + + + + .. + + + true + + + + + + + Jump to previous match + + + + .. + + + true + + + @@ -269,61 +216,129 @@ - - - Replace all matches - - - Replace &All + + + 0 + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Replace all matches + + + Replace &All + + + + + + + &Find All + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Cancel + + + + + - + + + Switch to incremental search bar + - &Find All + + + + + + + true + + + true - - - - - - - - Switch to incremental search bar + + + + + 9 + 0 + - - + + Qt::StrongFocus - - - - + + Text to search for - + true - - true + + QComboBox::AdjustToMinimumContentsLengthWithIcon - - - - Qt::Vertical + + + + + 9 + 0 + + + + Text to replace with - - - 20 - 40 - + + true + + + QComboBox::AdjustToMinimumContentsLengthWithIcon - + @@ -333,7 +348,6 @@ pattern replacement searchMode - mutate