2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* \file QSearchDialog.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Edwin Leuven
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "QSearchDialog.h"
|
|
|
|
#include "QSearch.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
|
|
|
#include "controllers/ControlSearch.h"
|
|
|
|
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
void uniqueInsert(QComboBox * box, QString const & text)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < box->count(); ++i) {
|
2006-08-17 08:58:35 +00:00
|
|
|
if (box->itemText(i) == text)
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-08-17 08:58:35 +00:00
|
|
|
box->addItem(text);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2006-12-30 10:30:02 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
QSearchDialog::QSearchDialog(QSearch * form)
|
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
2006-12-30 10:30:02 +00:00
|
|
|
connect(closePB, SIGNAL(clicked()),
|
|
|
|
form_, SLOT(slotClose()));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-12-30 10:30:02 +00:00
|
|
|
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&) ), this, SLOT( findChanged() ) );
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSearchDialog::show()
|
|
|
|
{
|
|
|
|
QDialog::show();
|
|
|
|
findCO->setFocus();
|
|
|
|
findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSearchDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSearchDialog::findChanged()
|
|
|
|
{
|
|
|
|
if (findCO->currentText().isEmpty()) {
|
|
|
|
findPB->setEnabled(false);
|
|
|
|
replacePB->setEnabled(false);
|
|
|
|
replaceallPB->setEnabled(false);
|
|
|
|
} else {
|
|
|
|
findPB->setEnabled(true);
|
|
|
|
replacePB->setEnabled(!form_->readOnly());
|
|
|
|
replaceallPB->setEnabled(!form_->readOnly());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSearchDialog::findClicked()
|
|
|
|
{
|
2006-12-10 11:52:46 +00:00
|
|
|
docstring const find(qstring_to_ucs4(findCO->currentText()));
|
2006-03-05 17:24:44 +00:00
|
|
|
form_->find(find,
|
|
|
|
caseCB->isChecked(),
|
|
|
|
wordsCB->isChecked(),
|
|
|
|
backwardsCB->isChecked());
|
|
|
|
uniqueInsert(findCO, findCO->currentText());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSearchDialog::replaceClicked()
|
|
|
|
{
|
2006-12-10 11:52:46 +00:00
|
|
|
docstring const find(qstring_to_ucs4(findCO->currentText()));
|
|
|
|
docstring const replace(qstring_to_ucs4(replaceCO->currentText()));
|
2006-03-05 17:24:44 +00:00
|
|
|
form_->replace(find, replace,
|
|
|
|
caseCB->isChecked(),
|
|
|
|
wordsCB->isChecked(),
|
|
|
|
backwardsCB->isChecked(), false);
|
|
|
|
uniqueInsert(findCO, findCO->currentText());
|
|
|
|
uniqueInsert(replaceCO, replaceCO->currentText());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QSearchDialog::replaceallClicked()
|
|
|
|
{
|
2006-12-10 11:52:46 +00:00
|
|
|
form_->replace(qstring_to_ucs4(findCO->currentText()),
|
|
|
|
qstring_to_ucs4(replaceCO->currentText()),
|
2006-03-05 17:24:44 +00:00
|
|
|
caseCB->isChecked(),
|
|
|
|
wordsCB->isChecked(),
|
|
|
|
false, true);
|
|
|
|
uniqueInsert(findCO, findCO->currentText());
|
|
|
|
uniqueInsert(replaceCO, replaceCO->currentText());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
|
|
|
#include "QSearchDialog_moc.cpp"
|