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