X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiSearch.cpp;h=a8f10e7c63cf59b1169b0c5b59911e2cb495c9d8;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=1d42dd852f8be9e0b4b9adfb9f1e58dfa9eea17e;hpb=f5eb303b4bf73b72938bf87a0ab4514eedc322f3;p=lyx.git diff --git a/src/frontends/qt4/GuiSearch.cpp b/src/frontends/qt4/GuiSearch.cpp index 1d42dd852f..a8f10e7c63 100644 --- a/src/frontends/qt4/GuiSearch.cpp +++ b/src/frontends/qt4/GuiSearch.cpp @@ -14,43 +14,39 @@ #include "GuiSearch.h" +#include "qt_helpers.h" + #include "FuncRequest.h" #include "lyxfind.h" -#include "qt_helpers.h" - #include -#include - -using std::string; +#include +using namespace std; namespace lyx { namespace frontend { static void uniqueInsert(QComboBox * box, QString const & text) { - for (int i = 0; i < box->count(); ++i) { + for (int i = box->count(); --i >= 0; ) if (box->itemText(i) == text) return; - } - box->addItem(text); + box->insertItem(0, text); } -GuiSearch::GuiSearch(LyXView & lv) - : GuiDialog(lv, "findreplace"), Controller(this) +GuiSearch::GuiSearch(GuiView & lv) + : GuiDialog(lv, "findreplace", qt_("Find and Replace")) { setupUi(this); - setController(this, false); - setViewTitle(_("Find and Replace")); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(findPB, SIGNAL(clicked()), this, SLOT(findClicked())); connect(replacePB, SIGNAL(clicked()), this, SLOT(replaceClicked())); connect(replaceallPB, SIGNAL(clicked()), this, SLOT(replaceallClicked())); - connect(findCO, SIGNAL(editTextChanged(const QString &)), + connect(findCO, SIGNAL(editTextChanged(QString)), this, SLOT(findChanged())); setFocusProxy(findCO); @@ -66,17 +62,11 @@ GuiSearch::GuiSearch(LyXView & lv) } -void GuiSearch::showView() +void GuiSearch::showEvent(QShowEvent * e) { - findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length()); - GuiDialog::showView(); -} - - -void GuiSearch::closeEvent(QCloseEvent * e) -{ - slotClose(); - GuiDialog::closeEvent(e); + findPB->setFocus(); + findCO->lineEdit()->selectAll(); + GuiDialog::showEvent(e); } @@ -88,8 +78,8 @@ void GuiSearch::findChanged() replaceallPB->setEnabled(false); } else { findPB->setEnabled(true); - replacePB->setEnabled(!controller().isBufferReadonly()); - replaceallPB->setEnabled(!controller().isBufferReadonly()); + replacePB->setEnabled(!isBufferReadonly()); + replaceallPB->setEnabled(!isBufferReadonly()); } } @@ -100,7 +90,7 @@ void GuiSearch::findClicked() find(needle, caseCB->isChecked(), wordsCB->isChecked(), !backwardsCB->isChecked()); uniqueInsert(findCO, findCO->currentText()); - findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length()); + findCO->lineEdit()->selectAll(); } @@ -128,8 +118,8 @@ void GuiSearch::replaceallClicked() void GuiSearch::find(docstring const & search, bool casesensitive, bool matchword, bool forward) { - docstring const data = find2string(search, casesensitive, - matchword, forward); + docstring const data = + find2string(search, casesensitive, matchword, forward); dispatch(FuncRequest(LFUN_WORD_FIND, data)); } @@ -139,16 +129,16 @@ void GuiSearch::replace(docstring const & search, docstring const & replace, bool forward, bool all) { docstring const data = - replace2string(search, replace, casesensitive, + replace2string(replace, search, casesensitive, matchword, all, forward); dispatch(FuncRequest(LFUN_WORD_REPLACE, data)); } -Dialog * createGuiSearch(LyXView & lv) { return new GuiSearch(lv); } +Dialog * createGuiSearch(GuiView & lv) { return new GuiSearch(lv); } } // namespace frontend } // namespace lyx -#include "GuiSearch_moc.cpp" +#include "moc_GuiSearch.cpp"