mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
GuiSearch: separate findClicked() slot from more general function
the latter one is also accessed by different paths than clicking
This commit is contained in:
parent
180fca2fcd
commit
ca160da07d
@ -106,7 +106,7 @@ void GuiSearchWidget::keyPressEvent(QKeyEvent * ev)
|
||||
|
||||
// catch Return and Shift-Return
|
||||
if (ev->key() == Qt::Key_Return || ev->key() == Qt::Key_Enter) {
|
||||
findClicked(ev->modifiers() == Qt::ShiftModifier);
|
||||
doFind(ev->modifiers() == Qt::ShiftModifier);
|
||||
return;
|
||||
}
|
||||
if (ev->key() == Qt::Key_Escape) {
|
||||
@ -119,12 +119,13 @@ void GuiSearchWidget::keyPressEvent(QKeyEvent * ev)
|
||||
KeyModifier mod = lyx::q_key_state(ev->modifiers());
|
||||
KeySequence keyseq(&theTopLevelKeymap(), &theTopLevelKeymap());
|
||||
FuncRequest fr = keyseq.addkey(sym, mod);
|
||||
if (fr == FuncRequest(LFUN_WORD_FIND_FORWARD) || fr == FuncRequest(LFUN_WORD_FIND)) {
|
||||
findClicked();
|
||||
if (fr == FuncRequest(LFUN_WORD_FIND_FORWARD)
|
||||
|| fr == FuncRequest(LFUN_WORD_FIND)) {
|
||||
doFind();
|
||||
return;
|
||||
}
|
||||
if (fr == FuncRequest(LFUN_WORD_FIND_BACKWARD)) {
|
||||
findClicked(true);
|
||||
doFind(true);
|
||||
return;
|
||||
}
|
||||
if (fr == FuncRequest(LFUN_DIALOG_TOGGLE, "findreplace")) {
|
||||
@ -193,41 +194,31 @@ void GuiSearchWidget::findChanged()
|
||||
replacePrevPB->setEnabled(replace);
|
||||
replaceallPB->setEnabled(replace);
|
||||
if (instantSearchCB->isChecked() && !emptytext)
|
||||
findClicked(false, true);
|
||||
doFind(false, true);
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::findClicked(bool const backwards, bool const instant)
|
||||
void GuiSearchWidget::findClicked()
|
||||
{
|
||||
docstring const needle = qstring_to_ucs4(findCO->currentText());
|
||||
find(needle, caseCB->isChecked(), wordsCB->isChecked(), !backwards,
|
||||
instant, wrapCB->isChecked(), selectionCB->isChecked());
|
||||
uniqueInsert(findCO, findCO->currentText());
|
||||
if (!instant)
|
||||
findCO->lineEdit()->selectAll();
|
||||
doFind();
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::findPrevClicked()
|
||||
{
|
||||
findClicked(true);
|
||||
doFind(true);
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::replaceClicked(bool const backwards)
|
||||
void GuiSearchWidget::replaceClicked()
|
||||
{
|
||||
docstring const needle = qstring_to_ucs4(findCO->currentText());
|
||||
docstring const repl = qstring_to_ucs4(replaceCO->currentText());
|
||||
replace(needle, repl, caseCB->isChecked(), wordsCB->isChecked(),
|
||||
!backwards, false, wrapCB->isChecked(), selectionCB->isChecked());
|
||||
uniqueInsert(findCO, findCO->currentText());
|
||||
uniqueInsert(replaceCO, replaceCO->currentText());
|
||||
doReplace();
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::replacePrevClicked()
|
||||
{
|
||||
replaceClicked(true);
|
||||
doReplace(true);
|
||||
}
|
||||
|
||||
|
||||
@ -242,9 +233,20 @@ void GuiSearchWidget::replaceallClicked()
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::doFind(bool const backwards, bool const instant)
|
||||
{
|
||||
docstring const needle = qstring_to_ucs4(findCO->currentText());
|
||||
find(needle, caseCB->isChecked(), wordsCB->isChecked(), !backwards,
|
||||
instant, wrapCB->isChecked(), selectionCB->isChecked());
|
||||
uniqueInsert(findCO, findCO->currentText());
|
||||
if (!instant)
|
||||
findCO->lineEdit()->selectAll();
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::find(docstring const & search, bool casesensitive,
|
||||
bool matchword, bool forward, bool instant,
|
||||
bool wrap, bool onlysel)
|
||||
bool matchword, bool forward, bool instant,
|
||||
bool wrap, bool onlysel)
|
||||
{
|
||||
docstring const sdata =
|
||||
find2string(search, casesensitive, matchword,
|
||||
@ -254,6 +256,17 @@ void GuiSearchWidget::find(docstring const & search, bool casesensitive,
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::doReplace(bool const backwards)
|
||||
{
|
||||
docstring const needle = qstring_to_ucs4(findCO->currentText());
|
||||
docstring const repl = qstring_to_ucs4(replaceCO->currentText());
|
||||
replace(needle, repl, caseCB->isChecked(), wordsCB->isChecked(),
|
||||
!backwards, false, wrapCB->isChecked(), selectionCB->isChecked());
|
||||
uniqueInsert(findCO, findCO->currentText());
|
||||
uniqueInsert(replaceCO, replaceCO->currentText());
|
||||
}
|
||||
|
||||
|
||||
void GuiSearchWidget::replace(docstring const & search, docstring const & replace,
|
||||
bool casesensitive, bool matchword,
|
||||
bool forward, bool all, bool wrap, bool onlysel)
|
||||
@ -261,6 +274,7 @@ void GuiSearchWidget::replace(docstring const & search, docstring const & replac
|
||||
docstring const sdata =
|
||||
replace2string(replace, search, casesensitive,
|
||||
matchword, all, forward, true, wrap, onlysel);
|
||||
|
||||
dispatch(FuncRequest(LFUN_WORD_REPLACE, sdata));
|
||||
}
|
||||
|
||||
|
@ -45,10 +45,9 @@ public:
|
||||
private Q_SLOTS:
|
||||
void findChanged();
|
||||
void findBufferChanged();
|
||||
void findClicked(bool const backwards = false,
|
||||
bool const instant = false);
|
||||
void findClicked();
|
||||
void findPrevClicked();
|
||||
void replaceClicked(bool const backwards = false);
|
||||
void replaceClicked();
|
||||
void replacePrevClicked();
|
||||
void replaceallClicked();
|
||||
void minimizeClicked(bool const toggle = true);
|
||||
@ -61,6 +60,11 @@ private:
|
||||
void keyPressEvent(QKeyEvent * e) override;
|
||||
///
|
||||
void showEvent(QShowEvent * e) override;
|
||||
///
|
||||
void doFind(bool const backwards = false,
|
||||
bool const instant = false);
|
||||
///
|
||||
void doReplace(bool const backwards = false);
|
||||
/// Searches occurrence of string
|
||||
void find(docstring const & search,
|
||||
bool casesensitive, bool matchword,
|
||||
|
Loading…
Reference in New Issue
Block a user