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.
14 #include "ControlSearch.h"
15 #include "QSearchDialog.h"
17 #include "qt_helpers.h"
19 #include <qpushbutton.h>
20 #include <qcombobox.h>
21 #include <qcheckbox.h>
22 #include <qlineedit.h>
28 void uniqueInsert(QComboBox * box, QString const & text)
30 for (int i = 0; i < box->count(); ++i) {
31 if (box->text(i) == text)
35 box->insertItem(text);
41 QSearchDialog::QSearchDialog(QSearch * form)
42 : QSearchDialogBase(0, 0, false, 0),
45 connect(closePB, SIGNAL(clicked()),
46 form_, SLOT(slotClose()));
50 void QSearchDialog::show()
52 QSearchDialogBase::show();
54 findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
58 void QSearchDialog::closeEvent(QCloseEvent * e)
65 void QSearchDialog::findChanged()
67 if (findCO->currentText().isEmpty()) {
68 findPB->setEnabled(false);
69 replacePB->setEnabled(false);
70 replaceallPB->setEnabled(false);
72 findPB->setEnabled(true);
73 replacePB->setEnabled(!form_->readOnly());
74 replaceallPB->setEnabled(!form_->readOnly());
79 void QSearchDialog::findClicked()
81 string const find(fromqstr(findCO->currentText()));
85 backwardsCB->isChecked());
86 uniqueInsert(findCO, findCO->currentText());
90 void QSearchDialog::replaceClicked()
92 string const find(fromqstr(findCO->currentText()));
93 string const replace(fromqstr(replaceCO->currentText()));
94 form_->replace(find, replace,
97 backwardsCB->isChecked(), false);
98 uniqueInsert(findCO, findCO->currentText());
99 uniqueInsert(replaceCO, replaceCO->currentText());
103 void QSearchDialog::replaceallClicked()
105 form_->replace(fromqstr(findCO->currentText()),
106 fromqstr(replaceCO->currentText()),
108 wordsCB->isChecked(),
110 uniqueInsert(findCO, findCO->currentText());
111 uniqueInsert(replaceCO, replaceCO->currentText());