]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSearchDialog.C
fill combo boxes in search dialog
[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 <qlabel.h>
19
20 QSearchDialog::QSearchDialog(QSearch * form)
21         : QSearchDialogBase(0, 0, false, 0),
22         form_(form)
23 {
24         connect(closePB, SIGNAL(clicked()),
25                 form_, SLOT(slotClose()));
26         findCO->setDuplicatesEnabled(false); 
27         findCO->setInsertionPolicy(QComboBox::AtTop); 
28         replaceCO->setDuplicatesEnabled(false); 
29         replaceCO->setInsertionPolicy(QComboBox::AtTop); 
30 }
31
32
33 void QSearchDialog::closeEvent(QCloseEvent * e)
34 {
35         form_->slotWMHide();
36         e->accept();
37 }
38
39
40 void QSearchDialog::findChanged()
41 {
42         if (findCO->currentText().isEmpty()) {
43                 findPB->setEnabled(false);
44                 replacePB->setEnabled(false);
45                 replaceallPB->setEnabled(false);
46         } else {
47                 findPB->setEnabled(true);
48                 replacePB->setEnabled(!form_->readOnly());
49                 replaceallPB->setEnabled(!form_->readOnly());
50         }
51 }
52
53
54 void QSearchDialog::findClicked()
55 {
56         string const find(findCO->currentText().latin1());
57         form_->find(find,
58                 caseCB->isChecked(),
59                 wordsCB->isChecked(),
60                 backwardsCB->isChecked());
61         findCO->insertItem(findCO->currentText());
62 }
63
64
65 void QSearchDialog::replaceClicked()
66 {
67         string const find(findCO->currentText().latin1());
68         string const replace(replaceCO->currentText().latin1());
69         form_->replace(find, replace,
70                 caseCB->isChecked(),
71                 wordsCB->isChecked(),
72                 false);
73         replaceCO->insertItem(replaceCO->currentText());
74 }
75
76
77 void QSearchDialog::replaceallClicked()
78 {
79         form_->replace(findCO->currentText().latin1(),
80                 replaceCO->currentText().latin1(),
81                 caseCB->isChecked(),
82                 wordsCB->isChecked(),
83                 true);
84 }