#include <config.h>
-#include "GuiSearch.h"
-
-#include "FuncRequest.h"
#include "lyxfind.h"
-
#include "qt_helpers.h"
+#include "FuncRequest.h"
+#include "BufferView.h"
+#include "Buffer.h"
+#include "Cursor.h"
+#include "GuiSearch.h"
+#include "GuiView.h"
-#include <QLineEdit>
-#include <QCloseEvent>
+#include "support/gettext.h"
+#include "frontends/alert.h"
-using std::string;
+#include <QLineEdit>
+#include <QShowEvent>
+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")
+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()));
}
-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);
}
replaceallPB->setEnabled(false);
} else {
findPB->setEnabled(true);
- replacePB->setEnabled(!controller().isBufferReadonly());
- replaceallPB->setEnabled(!controller().isBufferReadonly());
+ replacePB->setEnabled(!isBufferReadonly());
+ replaceallPB->setEnabled(!isBufferReadonly());
}
}
find(needle, caseCB->isChecked(), wordsCB->isChecked(),
!backwardsCB->isChecked());
uniqueInsert(findCO, findCO->currentText());
- findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
+ findCO->lineEdit()->selectAll();
}
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));
}
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"