]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QThesaurusDialog.C
Thesaurus dialog. Untested, as it won't build for me. I get undefined
[lyx.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         string const entry(str.latin1());
61         entryED->setText(entry.c_str());
62         updateLists();
63 }
64
65  
66 void QThesaurusDialog::updateLists()
67 {
68         ControlThesaurus & control(form_->controller());
69         string const entry(entryED->text().latin1());
70
71         std::vector<string> matches;
72
73         matches = control.getNouns(entry);
74         for (std::vector<string>::const_iterator cit = matches.begin();
75                 cit != matches.end(); ++cit)
76                 nounsLB->insertItem(cit->c_str());
77         matches = control.getVerbs(entry);
78         for (std::vector<string>::const_iterator cit = matches.begin();
79                 cit != matches.end(); ++cit)
80                 verbsLB->insertItem(cit->c_str());
81         matches = control.getAdjectives(entry);
82         for (std::vector<string>::const_iterator cit = matches.begin();
83                 cit != matches.end(); ++cit)
84                 adjectivesLB->insertItem(cit->c_str());
85         matches = control.getAdverbs(entry);
86         for (std::vector<string>::const_iterator cit = matches.begin();
87                 cit != matches.end(); ++cit)
88                 adverbsLB->insertItem(cit->c_str());
89         matches = control.getOthers(entry);
90         for (std::vector<string>::const_iterator cit = matches.begin();
91                 cit != matches.end(); ++cit)
92                 otherLB->insertItem(cit->c_str());
93 }