lyx_mirror/src/frontends/qt4/QSearchDialog.C
Abdelrazak Younes 995da7bafc Qt4 compilation speedup patch by Bo Peng and me.
* configure.ac: removed frontends/qt4/moc compilation.
* frontends/qt4/: moc files (*_moc.cpp) are now included at the end of relevant source file (*.C)
* SConscript: adapted to "moc included in .C file" change.
* frontends/qt4/Makefile.am:  adapted to "moc included in .C file" change.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13860 a592a061-630c-0410-9148-cb99ea01b6c8
2006-05-18 08:51:12 +00:00

128 lines
2.7 KiB
C

/**
* \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>
using std::string;
namespace lyx {
namespace frontend {
namespace {
void uniqueInsert(QComboBox * box, QString const & text)
{
for (int i = 0; i < box->count(); ++i) {
if (box->text(i) == text)
return;
}
box->insertItem(text);
}
};
QSearchDialog::QSearchDialog(QSearch * form)
: form_(form)
{
setupUi(this);
connect(closePB, SIGNAL(clicked()),
form_, SLOT(slotClose()));
connect( findPB, SIGNAL( clicked() ), this, SLOT( findClicked() ) );
connect( replacePB, SIGNAL( clicked() ), this, SLOT( replaceClicked() ) );
connect( replaceallPB, SIGNAL( clicked() ), this, SLOT( replaceallClicked() ) );
connect( findCO, SIGNAL( textChanged(const QString&) ), this, SLOT( findChanged() ) );
}
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()
{
string const find(fromqstr(findCO->currentText()));
form_->find(find,
caseCB->isChecked(),
wordsCB->isChecked(),
backwardsCB->isChecked());
uniqueInsert(findCO, findCO->currentText());
}
void QSearchDialog::replaceClicked()
{
string const find(fromqstr(findCO->currentText()));
string const replace(fromqstr(replaceCO->currentText()));
form_->replace(find, replace,
caseCB->isChecked(),
wordsCB->isChecked(),
backwardsCB->isChecked(), false);
uniqueInsert(findCO, findCO->currentText());
uniqueInsert(replaceCO, replaceCO->currentText());
}
void QSearchDialog::replaceallClicked()
{
form_->replace(fromqstr(findCO->currentText()),
fromqstr(replaceCO->currentText()),
caseCB->isChecked(),
wordsCB->isChecked(),
false, true);
uniqueInsert(findCO, findCO->currentText());
uniqueInsert(replaceCO, replaceCO->currentText());
}
} // namespace frontend
} // namespace lyx
#include "QSearchDialog_moc.cpp"