]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QThesaurusDialog.C
build fixes, fixes to thesaurus and bibtex.
[features.git] / src / frontends / qt2 / QThesaurusDialog.C
1 /**
2  * \file QThesaurusDialog.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon <moz@compsoc.man.ac.uk>
7  */
8
9 #include <config.h>
10 #include <vector>
11
12 #include "LString.h" 
13  
14 #include "ControlThesaurus.h" 
15 #include "QThesaurusDialog.h"
16 #include "Dialogs.h"
17 #include "QThesaurus.h"
18
19 #include <qwidget.h>
20 #include <qpushbutton.h>
21 #include <qlistbox.h>
22 #include <qlineedit.h> 
23
24 QThesaurusDialog::QThesaurusDialog(QThesaurus * form)
25         : QThesaurusDialogBase(0, 0, false, 0),
26         form_(form)
27 {
28         connect(closePB, SIGNAL(clicked()),
29                 form, SLOT(slotClose()));
30 }
31
32  
33 void QThesaurusDialog::change_adaptor()
34 {
35         form_->changed();
36 }
37
38  
39 void QThesaurusDialog::closeEvent(QCloseEvent * e)
40 {
41         form_->slotWMHide();
42         e->accept();
43 }
44
45
46 void QThesaurusDialog::entryChanged()
47 {
48         updateLists();
49 }
50
51  
52 void QThesaurusDialog::replaceClicked()
53 {
54         form_->replace();
55 }
56
57  
58 void QThesaurusDialog::selectionChanged(const QString & str)
59 {
60         if (form_->readOnly())
61                 return;
62  
63         string const entry(str.latin1());
64         replaceED->setText(entry.c_str());
65         replacePB->setEnabled(true);
66         form_->changed();
67 }
68
69  
70 void QThesaurusDialog::selectionClicked(const QString & str)
71 {
72         selectionChanged(str);
73         entryED->setText(str);
74         updateLists();
75 }
76
77  
78 void QThesaurusDialog::updateLists()
79 {
80         ControlThesaurus & control(form_->controller());
81         string const entry(entryED->text().latin1());
82
83         std::vector<string> matches;
84
85         matches = control.getNouns(entry);
86         for (std::vector<string>::const_iterator cit = matches.begin();
87                 cit != matches.end(); ++cit)
88                 nounsLB->insertItem(cit->c_str());
89         matches = control.getVerbs(entry);
90         for (std::vector<string>::const_iterator cit = matches.begin();
91                 cit != matches.end(); ++cit)
92                 verbsLB->insertItem(cit->c_str());
93         matches = control.getAdjectives(entry);
94         for (std::vector<string>::const_iterator cit = matches.begin();
95                 cit != matches.end(); ++cit)
96                 adjectivesLB->insertItem(cit->c_str());
97         matches = control.getAdverbs(entry);
98         for (std::vector<string>::const_iterator cit = matches.begin();
99                 cit != matches.end(); ++cit)
100                 adverbsLB->insertItem(cit->c_str());
101         matches = control.getOthers(entry);
102         for (std::vector<string>::const_iterator cit = matches.begin();
103                 cit != matches.end(); ++cit)
104                 otherLB->insertItem(cit->c_str());
105 }