2 * \file QSearchDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "QSearchDialog.h"
15 #include "qt_helpers.h"
17 #include "controllers/ControlSearch.h"
19 #include <qcheckbox.h>
20 #include <qcombobox.h>
21 #include <qlineedit.h>
22 #include <qpushbutton.h>
31 void uniqueInsert(QComboBox * box, QString const & text)
33 for (int i = 0; i < box->count(); ++i) {
34 if (box->text(i) == text)
38 box->insertItem(text);
44 QSearchDialog::QSearchDialog(QSearch * form)
45 : QSearchDialogBase(0, 0, false, 0),
48 connect(closePB, SIGNAL(clicked()),
49 form_, SLOT(slotClose()));
53 void QSearchDialog::show()
55 QSearchDialogBase::show();
57 findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
61 void QSearchDialog::closeEvent(QCloseEvent * e)
68 void QSearchDialog::findChanged()
70 if (findCO->currentText().isEmpty()) {
71 findPB->setEnabled(false);
72 replacePB->setEnabled(false);
73 replaceallPB->setEnabled(false);
75 findPB->setEnabled(true);
76 replacePB->setEnabled(!form_->readOnly());
77 replaceallPB->setEnabled(!form_->readOnly());
82 void QSearchDialog::findClicked()
84 string const find(fromqstr(findCO->currentText()));
88 backwardsCB->isChecked());
89 uniqueInsert(findCO, findCO->currentText());
93 void QSearchDialog::replaceClicked()
95 string const find(fromqstr(findCO->currentText()));
96 string const replace(fromqstr(replaceCO->currentText()));
97 form_->replace(find, replace,
100 backwardsCB->isChecked(), false);
101 uniqueInsert(findCO, findCO->currentText());
102 uniqueInsert(replaceCO, replaceCO->currentText());
106 void QSearchDialog::replaceallClicked()
108 form_->replace(fromqstr(findCO->currentText()),
109 fromqstr(replaceCO->currentText()),
111 wordsCB->isChecked(),
113 uniqueInsert(findCO, findCO->currentText());
114 uniqueInsert(replaceCO, replaceCO->currentText());
117 } // namespace frontend