]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QThesaurusDialog.C
clear the thesaurus list boxes !!
[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         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         nounsLB->clear();
84         verbsLB->clear();
85         adjectivesLB->clear();
86         adverbsLB->clear();
87         otherLB->clear();
88  
89         std::vector<string> matches;
90
91         matches = control.getNouns(entry);
92         for (std::vector<string>::const_iterator cit = matches.begin();
93                 cit != matches.end(); ++cit)
94                 nounsLB->insertItem(cit->c_str());
95         matches = control.getVerbs(entry);
96         for (std::vector<string>::const_iterator cit = matches.begin();
97                 cit != matches.end(); ++cit)
98                 verbsLB->insertItem(cit->c_str());
99         matches = control.getAdjectives(entry);
100         for (std::vector<string>::const_iterator cit = matches.begin();
101                 cit != matches.end(); ++cit)
102                 adjectivesLB->insertItem(cit->c_str());
103         matches = control.getAdverbs(entry);
104         for (std::vector<string>::const_iterator cit = matches.begin();
105                 cit != matches.end(); ++cit)
106                 adverbsLB->insertItem(cit->c_str());
107         matches = control.getOthers(entry);
108         for (std::vector<string>::const_iterator cit = matches.begin();
109                 cit != matches.end(); ++cit)
110                 otherLB->insertItem(cit->c_str());
111 }