]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QSpellcheckerDialog.C
get rid of QT3_SUPPORT and some cleanup
[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 <QListWidget>
17 #include <QPushButton>
18 #include <QCloseEvent>
19
20 namespace lyx {
21 namespace frontend {
22
23 QSpellcheckerDialog::QSpellcheckerDialog(QSpellchecker * form)
24         : form_(form)
25 {
26         setupUi(this);
27
28         connect(closePB, SIGNAL(clicked()),
29                 form, SLOT(slotClose()));
30
31         connect( replaceCO, SIGNAL( highlighted(const QString&) ),
32                 this, SLOT( replaceChanged(const QString &) ) );
33         connect( replacePB, SIGNAL( clicked() ),
34                 this, SLOT( replaceClicked() ) );
35         connect( ignorePB, SIGNAL( clicked() ),
36                 this, SLOT( ignoreClicked() ) );
37         connect( replacePB_3, SIGNAL( clicked() ),
38                 this, SLOT( acceptClicked() ) );
39         connect( addPB, SIGNAL( clicked() ),
40                 this, SLOT( addClicked() ) );
41         connect( suggestionsLW, SIGNAL( itemDoubleClicked(QListWidgetItem*) ),
42                 this, SLOT( replaceClicked() ) );
43         connect( suggestionsLW, SIGNAL( itemClicked(QListWidgetItem*) ),
44                 this, SLOT( suggestionChanged(QListWidgetItem*) ) );
45 }
46
47
48 void QSpellcheckerDialog::acceptClicked()
49 {
50         form_->accept();
51 }
52
53 void QSpellcheckerDialog::addClicked()
54 {
55         form_->add();
56 }
57
58 void QSpellcheckerDialog::replaceClicked()
59 {
60         form_->replace();
61 }
62
63 void QSpellcheckerDialog::ignoreClicked()
64 {
65         form_->ignore();
66 }
67
68 void QSpellcheckerDialog::suggestionChanged(QListWidgetItem * item)
69 {
70         if (replaceCO->count() != 0)
71                 replaceCO->setItemText(0, item->text());
72         else
73                 replaceCO->addItem(item->text());
74
75         replaceCO->setCurrentIndex(0);
76 }
77
78 void QSpellcheckerDialog::replaceChanged(const QString & str)
79 {
80         if (suggestionsLW->currentItem()->text() == str)
81                 return;
82
83         for (int i = 0; i < suggestionsLW->count(); ++i) {
84                 if (suggestionsLW->item(i)->text() == str) {
85                         suggestionsLW->setCurrentRow(i);
86                         break;
87                 }
88         }
89 }
90
91
92 void QSpellcheckerDialog::closeEvent(QCloseEvent * e)
93 {
94         form_->slotWMHide();
95         e->accept();
96 }
97
98
99 void QSpellcheckerDialog::reject()
100 {
101         form_->slotWMHide();
102         QDialog::reject();
103 }
104
105 } // namespace frontend
106 } // namespace lyx
107
108 #include "QSpellcheckerDialog_moc.cpp"