]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSearch.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiSearch.cpp
index c6225385656ce5391e6e08008f023ce61d41f864..a8f10e7c63cf59b1169b0c5b59911e2cb495c9d8 100644 (file)
 
 #include "GuiSearch.h"
 
+#include "qt_helpers.h"
+
 #include "FuncRequest.h"
 #include "lyxfind.h"
 
-#include "qt_helpers.h"
-
 #include <QLineEdit>
-#include <QCloseEvent>
-
-using std::string;
+#include <QShowEvent>
 
+using namespace std;
 
 namespace lyx {
 namespace frontend {
@@ -34,15 +33,14 @@ static void uniqueInsert(QComboBox * box, QString const & text)
                if (box->itemText(i) == text)
                        return;
 
-       box->addItem(text);
+       box->insertItem(0, text);
 }
 
 
-GuiSearch::GuiSearch(LyXView & lv)
-       : GuiDialog(lv, "findreplace")
+GuiSearch::GuiSearch(GuiView & lv)
+       : GuiDialog(lv, "findreplace", qt_("Find and Replace"))
 {
        setupUi(this);
-       setViewTitle(_("Find and Replace"));
 
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
        connect(findPB, SIGNAL(clicked()), this, SLOT(findClicked()));
@@ -64,17 +62,11 @@ GuiSearch::GuiSearch(LyXView & lv)
 }
 
 
-void GuiSearch::showView()
-{
-       findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
-       GuiDialog::showView();
-}
-
-
-void GuiSearch::closeEvent(QCloseEvent * e)
+void GuiSearch::showEvent(QShowEvent * e)
 {
-       slotClose();
-       GuiDialog::closeEvent(e);
+       findPB->setFocus();
+       findCO->lineEdit()->selectAll();
+       GuiDialog::showEvent(e);
 }
 
 
@@ -98,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();
 }
 
 
@@ -137,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"