]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QSpellcheckerDialog.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / QSpellcheckerDialog.C
1 /**
2  * \file QSpellcheckerDialog.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
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 "QSpellcheckerDialog.h"
18 #include "QSpellchecker.h"
19 #include "gettext.h"
20
21 #include <qpushbutton.h>
22 #include <qlineedit.h>
23 #include <qlistbox.h>
24 #include <qcombobox.h>
25
26
27 QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form)
28         : QSpellcheckerDialogBase(0, 0, false, 0),
29         form_(form)
30 {
31         connect(closePB, SIGNAL(clicked()),
32                 this, SLOT(stop()));
33 }
34
35
36 void QSpellcheckerDialog::stop()
37 {
38         form_->stop();
39 }
40
41
42 void QSpellcheckerDialog::acceptClicked()
43 {
44         form_->accept();
45 }
46
47
48 void QSpellcheckerDialog::spellcheckClicked()
49 {
50         form_->spellcheck();
51 }
52
53
54 void QSpellcheckerDialog::addClicked()
55 {
56         form_->add();
57 }
58
59
60 void QSpellcheckerDialog::replaceClicked()
61 {
62         form_->replace();
63 }
64
65
66 void QSpellcheckerDialog::ignoreClicked()
67 {
68         form_->ignore();
69 }
70
71
72 void QSpellcheckerDialog::suggestionChanged(QString const & str)
73 {
74         if (replaceCO->count() != 0)
75                 replaceCO->changeItem(str, 0);
76         else
77                 replaceCO->insertItem(str);
78
79         replaceCO->setCurrentItem(0);
80 }
81
82
83 void QSpellcheckerDialog::replaceChanged(QString const & str)
84 {
85         if (suggestionsLB->currentText() == str)
86                 return;
87
88         unsigned int i = 0;
89         for (; i < suggestionsLB->count(); ++i) {
90                 if (suggestionsLB->text(i) == str)
91                         break;
92         }
93
94         if (i != suggestionsLB->count())
95                 suggestionsLB->setCurrentItem(i);
96 }
97
98
99 void QSpellcheckerDialog::closeEvent(QCloseEvent * e)
100 {
101         form_->stop();
102         form_->slotWMHide();
103         e->accept();
104 }
105
106
107 void QSpellcheckerDialog::reject()
108 {
109         form_->slotWMHide();
110         QSpellcheckerDialogBase::reject();
111 }