]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSearchDialog.C
Lots and lots of little trivial bits.
[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 QSearchDialog::QSearchDialog(QSearch * form)
29         : QSearchDialogBase(0, 0, false, 0),
30         form_(form)
31 {
32         connect(closePB, SIGNAL(clicked()),
33                 form_, SLOT(slotClose()));
34 }
35
36
37 void QSearchDialog::show()
38 {
39         QSearchDialogBase::show();
40         findCO->setFocus();
41         findCO->lineEdit()->setSelection(0, findCO->lineEdit()->text().length());
42 }
43
44  
45 void QSearchDialog::closeEvent(QCloseEvent * e)
46 {
47         form_->slotWMHide();
48         e->accept();
49 }
50
51
52 void QSearchDialog::findChanged()
53 {
54         if (findCO->currentText().isEmpty()) {
55                 findPB->setEnabled(false);
56                 replacePB->setEnabled(false);
57                 replaceallPB->setEnabled(false);
58         } else {
59                 findPB->setEnabled(true);
60                 replacePB->setEnabled(!form_->readOnly());
61                 replaceallPB->setEnabled(!form_->readOnly());
62         }
63 }
64
65
66 void QSearchDialog::findClicked()
67 {
68         string const find(findCO->currentText().latin1());
69         form_->find(find,
70                 caseCB->isChecked(),
71                 wordsCB->isChecked(),
72                 backwardsCB->isChecked());
73         findCO->insertItem(findCO->currentText());
74 }
75
76
77 void QSearchDialog::replaceClicked()
78 {
79         string const find(findCO->currentText().latin1());
80         string const replace(replaceCO->currentText().latin1());
81         form_->replace(find, replace,
82                 caseCB->isChecked(),
83                 wordsCB->isChecked(),
84                 false);
85         replaceCO->insertItem(replaceCO->currentText());
86 }
87
88
89 void QSearchDialog::replaceallClicked()
90 {
91         form_->replace(findCO->currentText().latin1(),
92                 replaceCO->currentText().latin1(),
93                 caseCB->isChecked(),
94                 wordsCB->isChecked(),
95                 true);
96 }