]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSearchDialog.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / QSearchDialog.C
1 /**
2  * \file QSearchDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Edwin Leuven
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlSearch.h"
18 #include "QSearchDialog.h"
19 #include "QSearch.h"
20 #include "debug.h"
21
22 #include <qpushbutton.h>
23 #include <qcombobox.h>
24 #include <qcheckbox.h>
25 #include <qlineedit.h>
26 #include <qlabel.h>
27
28
29 QSearchDialog::QSearchDialog(QSearch * form)
30         : QSearchDialogBase(0, 0, false, 0),
31         form_(form)
32 {
33         connect(closePB, SIGNAL(clicked()),
34                 form_, SLOT(slotClose()));
35 }
36
37
38 void QSearchDialog::show()
39 {
40         QSearchDialogBase::show();
41         findCO->setFocus();
42         findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
43 }
44
45
46 void QSearchDialog::closeEvent(QCloseEvent * e)
47 {
48         form_->slotWMHide();
49         e->accept();
50 }
51
52
53 void QSearchDialog::findChanged()
54 {
55         if (findCO->currentText().isEmpty()) {
56                 findPB->setEnabled(false);
57                 replacePB->setEnabled(false);
58                 replaceallPB->setEnabled(false);
59         } else {
60                 findPB->setEnabled(true);
61                 replacePB->setEnabled(!form_->readOnly());
62                 replaceallPB->setEnabled(!form_->readOnly());
63         }
64 }
65
66
67 void QSearchDialog::findClicked()
68 {
69         string const find(findCO->currentText().latin1());
70         form_->find(find,
71                 caseCB->isChecked(),
72                 wordsCB->isChecked(),
73                 backwardsCB->isChecked());
74         findCO->insertItem(findCO->currentText());
75 }
76
77
78 void QSearchDialog::replaceClicked()
79 {
80         string const find(findCO->currentText().latin1());
81         string const replace(replaceCO->currentText().latin1());
82         form_->replace(find, replace,
83                 caseCB->isChecked(),
84                 wordsCB->isChecked(),
85                 false);
86         replaceCO->insertItem(replaceCO->currentText());
87 }
88
89
90 void QSearchDialog::replaceallClicked()
91 {
92         form_->replace(findCO->currentText().latin1(),
93                 replaceCO->currentText().latin1(),
94                 caseCB->isChecked(),
95                 wordsCB->isChecked(),
96                 true);
97 }