]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QSpellcheckerDialog.C
This new citation dialog follows a new design similar to lyx-1.3:
[lyx.git] / src / frontends / qt4 / 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 #include "QSpellcheckerDialog.h"
14 #include "QSpellchecker.h"
15
16 #include <Q3ListBox>
17 #include <QPushButton>
18 //Added by qt3to4:
19 #include <QCloseEvent>
20
21 namespace lyx {
22 namespace frontend {
23
24 QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form)
25         : form_(form)
26 {
27         setupUi(this);
28
29         connect(closePB, SIGNAL(clicked()),
30                 form, SLOT(slotClose()));
31     
32     connect( replaceCO, SIGNAL( highlighted(const QString&) ), this, SLOT( replaceChanged(const QString &) ) );
33     connect( replacePB, SIGNAL( clicked() ), this, SLOT( replaceClicked() ) );
34     connect( ignorePB, SIGNAL( clicked() ), this, SLOT( ignoreClicked() ) );
35     connect( replacePB_3, SIGNAL( clicked() ), this, SLOT( acceptClicked() ) );
36     connect( addPB, SIGNAL( clicked() ), this, SLOT( addClicked() ) );
37     connect( suggestionsLB, SIGNAL( doubleClicked(QListBoxItem*) ), this, SLOT( replaceClicked() ) );
38     connect( suggestionsLB, SIGNAL( highlighted(const QString&) ), this, SLOT( suggestionChanged(const QString &) ) );
39 }
40
41
42 void QSpellcheckerDialog::acceptClicked()
43 {
44         form_->accept();
45 }
46
47 void QSpellcheckerDialog::addClicked()
48 {
49         form_->add();
50 }
51
52 void QSpellcheckerDialog::replaceClicked()
53 {
54         form_->replace();
55 }
56
57 void QSpellcheckerDialog::ignoreClicked()
58 {
59         form_->ignore();
60 }
61
62 void QSpellcheckerDialog::suggestionChanged(const QString & str)
63 {
64         if (replaceCO->count() != 0)
65                 replaceCO->changeItem(str, 0);
66         else
67                 replaceCO->insertItem(str);
68
69         replaceCO->setCurrentItem(0);
70 }
71
72 void QSpellcheckerDialog::replaceChanged(const QString & str)
73 {
74         if (suggestionsLB->currentText() == str)
75                 return;
76
77         unsigned int i = 0;
78         for (; i < suggestionsLB->count(); ++i) {
79                 if (suggestionsLB->text(i) == str)
80                         break;
81         }
82
83         if (i != suggestionsLB->count())
84                 suggestionsLB->setCurrentItem(i);
85 }
86
87
88 void QSpellcheckerDialog::closeEvent(QCloseEvent * e)
89 {
90         form_->slotWMHide();
91         e->accept();
92 }
93
94
95 void QSpellcheckerDialog::reject()
96 {
97         form_->slotWMHide();
98         QDialog::reject();
99 }
100
101 } // namespace frontend
102 } // namespace lyx