]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QSearchDialog.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / QSearchDialog.C
index 682ec23fdc67cc8a9640e91ee817c7856c1b5dcf..cbf882877dde0423bc9bb9761c281b18d197c594 100644 (file)
@@ -1,64 +1,97 @@
 /**
  * \file QSearchDialog.C
- * Copyright 2001 The LyX Team.
- * See the file COPYING.
+ * 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>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlSearch.h"
 #include "QSearchDialog.h"
+#include "QSearch.h"
+#include "debug.h"
 
 #include <qpushbutton.h>
 #include <qcombobox.h>
 #include <qcheckbox.h>
+#include <qlineedit.h>
 #include <qlabel.h>
 
-QSearchDialog::QSearchDialog(QSearch * form, QWidget * parent,  const char * name, bool modal, WFlags fl)
-       : QSearchDialogBase(parent, name, modal, fl),
+
+QSearchDialog::QSearchDialog(QSearch * form)
+       : QSearchDialogBase(0, 0, false, 0),
        form_(form)
 {
-       setCaption(name);
+       connect(closePB, SIGNAL(clicked()),
+               form_, SLOT(slotClose()));
 }
 
-QSearchDialog::~QSearchDialog()
+
+void QSearchDialog::show()
 {
+       QSearchDialogBase::show();
+       findCO->setFocus();
+       findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
 }
 
 
 void QSearchDialog::closeEvent(QCloseEvent * e)
 {
-       form_->close();
+       form_->slotWMHide();
        e->accept();
 }
 
 
-void QSearchDialog::setReadOnly(bool readonly)
+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()
 {
-       replace->setEnabled(!readonly);
-       replaceLabel->setEnabled(!readonly);
-       replacePB->setEnabled(!readonly);
-       replaceAllPB->setEnabled(!readonly);
+       string const find(findCO->currentText().latin1());
+       form_->find(find,
+               caseCB->isChecked(),
+               wordsCB->isChecked(),
+               backwardsCB->isChecked());
+       findCO->insertItem(findCO->currentText());
 }
 
 
-void QSearchDialog::Find()
+void QSearchDialog::replaceClicked()
 {
-       form_->find(tostr(find->currentText()).c_str(),
-                        caseSensitive->isChecked(),
-                        matchWord->isChecked(),
-                        !searchBack->isChecked());
+       string const find(findCO->currentText().latin1());
+       string const replace(replaceCO->currentText().latin1());
+       form_->replace(find, replace,
+               caseCB->isChecked(),
+               wordsCB->isChecked(),
+               false);
+       replaceCO->insertItem(replaceCO->currentText());
 }
 
 
-void QSearchDialog::Replace(bool replaceall)
+void QSearchDialog::replaceallClicked()
 {
-       form_->replace(tostr(find->currentText()).c_str(),
-                 tostr(replace->currentText()).c_str(),
-                 caseSensitive->isChecked(),
-                 matchWord->isChecked(),
-                 !searchBack->isChecked(),
-                 replaceall);
+       form_->replace(findCO->currentText().latin1(),
+               replaceCO->currentText().latin1(),
+               caseCB->isChecked(),
+               wordsCB->isChecked(),
+               true);
 }