22 #include <tqstringlist.h>
23 #include <tqpushbutton.h>
27 #include <tdeapplication.h>
29 #include <tdelistbox.h>
30 #include <kcombobox.h>
31 #include <tdelistview.h>
32 #include <klineedit.h>
33 #include <kpushbutton.h>
34 #include <kprogress.h>
35 #include <kbuttonbox.h>
39 #include "tdespelldlg.h"
40 #include "tdespellui.h"
43 #define NONSORTINGCOLUMN 2
45 class KSpellDlg::KSpellDlgPrivate {
51 KSpellDlg::KSpellDlg( TQWidget * parent,
const char * name,
bool _progressbar,
bool _modal )
53 parent,
name, _modal, i18n(
"Check Spelling"), Help|Cancel|User1,
54 Cancel, true, i18n(
"&Finished")
58 Q_UNUSED( _progressbar );
59 d =
new KSpellDlgPrivate;
60 d->ui =
new KSpellUI(
this );
61 setMainWidget( d->ui );
63 connect( d->ui->m_replaceBtn, TQ_SIGNAL(clicked()),
65 connect(
this, TQ_SIGNAL(ready(
bool)),
66 d->ui->m_replaceBtn, TQ_SLOT(setEnabled(
bool)) );
68 connect( d->ui->m_replaceAllBtn, TQ_SIGNAL(clicked()),
this, TQ_SLOT(replaceAll()));
69 connect(
this, TQ_SIGNAL(ready(
bool)), d->ui->m_replaceAllBtn, TQ_SLOT(setEnabled(
bool)));
71 connect( d->ui->m_skipBtn, TQ_SIGNAL(clicked()),
this, TQ_SLOT(ignore()));
72 connect(
this, TQ_SIGNAL(ready(
bool)), d->ui->m_skipBtn, TQ_SLOT(setEnabled(
bool)));
74 connect( d->ui->m_skipAllBtn, TQ_SIGNAL(clicked()),
this, TQ_SLOT(ignoreAll()));
75 connect(
this, TQ_SIGNAL(ready(
bool)), d->ui->m_skipAllBtn, TQ_SLOT(setEnabled(
bool)));
77 connect( d->ui->m_addBtn, TQ_SIGNAL(clicked()),
this, TQ_SLOT(add()));
78 connect(
this, TQ_SIGNAL(ready(
bool)), d->ui->m_addBtn, TQ_SLOT(setEnabled(
bool)));
80 connect( d->ui->m_suggestBtn, TQ_SIGNAL(clicked()),
this, TQ_SLOT(suggest()));
81 connect(
this, TQ_SIGNAL(ready(
bool)), d->ui->m_suggestBtn, TQ_SLOT(setEnabled(
bool)) );
82 d->ui->m_suggestBtn->hide();
84 connect(
this, TQ_SIGNAL(user1Clicked()),
this, TQ_SLOT(stop()));
86 connect( d->ui->m_replacement, TQ_SIGNAL(textChanged(
const TQString &)),
87 TQ_SLOT(textChanged(
const TQString &)) );
89 connect( d->ui->m_replacement, TQ_SIGNAL(returnPressed()), TQ_SLOT(
replace()) );
90 connect( d->ui->m_suggestions, TQ_SIGNAL(selectionChanged(TQListViewItem*)),
91 TQ_SLOT(slotSelectionChanged(TQListViewItem*)) );
93 connect( d->ui->m_suggestions, TQ_SIGNAL( doubleClicked ( TQListViewItem *,
const TQPoint &,
int ) ),
96 d->spellConfig->fillDicts( d->ui->m_language );
97 connect( d->ui->m_language, TQ_SIGNAL(activated(
int)),
98 d->spellConfig, TQ_SLOT(sSetDictionary(
int)) );
99 connect( d->spellConfig, TQ_SIGNAL(configChanged()),
100 TQ_SLOT(slotConfigChanged()) );
102 setHelp(
"spelldlg",
"tdespell" );
103 setMinimumSize( sizeHint() );
107 KSpellDlg::~KSpellDlg()
109 delete d->spellConfig;
114 KSpellDlg::init(
const TQString & _word, TQStringList * _sugg )
119 d->ui->m_suggestions->clear();
120 d->ui->m_suggestions->setSorting( NONSORTINGCOLUMN );
121 for ( TQStringList::Iterator it = _sugg->begin(); it != _sugg->end(); ++it ) {
122 TQListViewItem *item =
new TQListViewItem( d->ui->m_suggestions,
123 d->ui->m_suggestions->lastItem() );
124 item->setText( 0, *it );
126 kdDebug(750) <<
"KSpellDlg::init [" << word <<
"]" <<
endl;
130 d->ui->m_unknownWord->setText( _word );
132 if ( sugg->count() == 0 ) {
133 d->ui->m_replacement->setText( _word );
134 d->ui->m_replaceBtn->setEnabled(
false );
135 d->ui->m_replaceAllBtn->setEnabled(
false );
136 d->ui->m_suggestBtn->setEnabled(
false );
138 d->ui->m_replacement->setText( (*sugg)[0] );
139 d->ui->m_replaceBtn->setEnabled(
true );
140 d->ui->m_replaceAllBtn->setEnabled(
true );
141 d->ui->m_suggestBtn->setEnabled(
false );
142 d->ui->m_suggestions->setSelected( d->ui->m_suggestions->firstChild(),
true );
147 KSpellDlg::init(
const TQString& _word, TQStringList* _sugg,
148 const TQString& context )
153 d->ui->m_suggestions->clear();
154 d->ui->m_suggestions->setSorting( NONSORTINGCOLUMN );
155 for ( TQStringList::Iterator it = _sugg->begin(); it != _sugg->end(); ++it ) {
156 TQListViewItem *item =
new TQListViewItem( d->ui->m_suggestions,
157 d->ui->m_suggestions->lastItem() );
158 item->setText( 0, *it );
161 kdDebug(750) <<
"KSpellDlg::init [" << word <<
"]" <<
endl;
165 d->ui->m_unknownWord->setText( _word );
166 d->ui->m_contextLabel->setText( context );
168 if ( sugg->count() == 0 ) {
169 d->ui->m_replacement->setText( _word );
170 d->ui->m_replaceBtn->setEnabled(
false );
171 d->ui->m_replaceAllBtn->setEnabled(
false );
172 d->ui->m_suggestBtn->setEnabled(
false );
174 d->ui->m_replacement->setText( (*sugg)[0] );
175 d->ui->m_replaceBtn->setEnabled(
true );
176 d->ui->m_replaceAllBtn->setEnabled(
true );
177 d->ui->m_suggestBtn->setEnabled(
false );
178 d->ui->m_suggestions->setSelected( d->ui->m_suggestions->firstChild(),
true );
183 KSpellDlg::slotProgress(
unsigned int p )
188 progbar->setValue( (
int) p );
192 KSpellDlg::textChanged(
const TQString & )
194 d->ui->m_replaceBtn->setEnabled(
true );
195 d->ui->m_replaceAllBtn->setEnabled(
true );
196 d->ui->m_suggestBtn->setEnabled(
true );
200 KSpellDlg::slotSelectionChanged( TQListViewItem* item )
203 d->ui->m_replacement->setText( item->text( 0 ) );
211 KSpellDlg::closeEvent( TQCloseEvent * )
217 KSpellDlg::done(
int result )
219 emit command( result );
229 KSpellDlg::ignoreAll()
232 done( KS_IGNOREALL );
253 newword = d->ui->m_replacement->text();
265 KSpellDlg::replaceAll()
267 newword = d->ui->m_replacement->text();
268 done( KS_REPLACEALL );
274 newword = d->ui->m_replacement->text();
279 KSpellDlg::slotConfigChanged()
281 d->spellConfig->writeGlobalSettings();
285 #include "tdespelldlg.moc"
A dialog base class with standard buttons and predefined layouts.
A configuration class/dialog for KSpell.
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
TQString name(StdAccel id)
const TDEShortcut & replace()