• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
tdespelldlg.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 1997 David Sweet <dsweet@kde.org>
3 Copyright (C) 2000 Rik Hemsley <rik@kde.org>
4 Copyright (C) 2000-2001 Wolfram Diestel <wolfram@steloj.de>
5 Copyright (C) 2003 Zack Rusin <zack@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include <tqstringlist.h>
23#include <tqpushbutton.h>
24#include <tqlabel.h>
25#include <tqlayout.h>
26
27#include <tdeapplication.h>
28#include <tdelocale.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>
36#include <kdebug.h>
37
38#include "ksconfig.h"
39#include "tdespelldlg.h"
40#include "tdespellui.h"
41
42//to initially disable sorting in the suggestions listview
43#define NONSORTINGCOLUMN 2
44
45class KSpellDlg::KSpellDlgPrivate {
46public:
47 KSpellUI* ui;
48 KSpellConfig* spellConfig;
49};
50
51KSpellDlg::KSpellDlg( TQWidget * parent, const char * name, bool _progressbar, bool _modal )
52 : KDialogBase(
53 parent, name, _modal, i18n("Check Spelling"), Help|Cancel|User1,
54 Cancel, true, i18n("&Finished")
55 ),
56 progressbar( false )
57{
58 Q_UNUSED( _progressbar );
59 d = new KSpellDlgPrivate;
60 d->ui = new KSpellUI( this );
61 setMainWidget( d->ui );
62
63 connect( d->ui->m_replaceBtn, TQ_SIGNAL(clicked()),
64 this, TQ_SLOT(replace()));
65 connect( this, TQ_SIGNAL(ready(bool)),
66 d->ui->m_replaceBtn, TQ_SLOT(setEnabled(bool)) );
67
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)));
70
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)));
73
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)));
76
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)));
79
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();
83
84 connect(this, TQ_SIGNAL(user1Clicked()), this, TQ_SLOT(stop()));
85
86 connect( d->ui->m_replacement, TQ_SIGNAL(textChanged(const TQString &)),
87 TQ_SLOT(textChanged(const TQString &)) );
88
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*)) );
92
93 connect( d->ui->m_suggestions, TQ_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ),
94 TQ_SLOT( replace() ) );
95 d->spellConfig = new KSpellConfig( 0, 0 ,0, false );
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()) );
101
102 setHelp( "spelldlg", "tdespell" );
103 setMinimumSize( sizeHint() );
104 emit ready( false );
105}
106
107KSpellDlg::~KSpellDlg()
108{
109 delete d->spellConfig;
110 delete d;
111}
112
113void
114KSpellDlg::init( const TQString & _word, TQStringList * _sugg )
115{
116 sugg = _sugg;
117 word = _word;
118
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 );
125 }
126 kdDebug(750) << "KSpellDlg::init [" << word << "]" << endl;
127
128 emit ready( true );
129
130 d->ui->m_unknownWord->setText( _word );
131
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 );
137 } else {
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 );
143 }
144}
145
146void
147KSpellDlg::init( const TQString& _word, TQStringList* _sugg,
148 const TQString& context )
149{
150 sugg = _sugg;
151 word = _word;
152
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 );
159 }
160
161 kdDebug(750) << "KSpellDlg::init [" << word << "]" << endl;
162
163 emit ready( true );
164
165 d->ui->m_unknownWord->setText( _word );
166 d->ui->m_contextLabel->setText( context );
167
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 );
173 } else {
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 );
179 }
180}
181
182void
183KSpellDlg::slotProgress( unsigned int p )
184{
185 if (!progressbar)
186 return;
187
188 progbar->setValue( (int) p );
189}
190
191void
192KSpellDlg::textChanged( const TQString & )
193{
194 d->ui->m_replaceBtn->setEnabled( true );
195 d->ui->m_replaceAllBtn->setEnabled( true );
196 d->ui->m_suggestBtn->setEnabled( true );
197}
198
199void
200KSpellDlg::slotSelectionChanged( TQListViewItem* item )
201{
202 if ( item )
203 d->ui->m_replacement->setText( item->text( 0 ) );
204}
205
206/*
207 exit functions
208 */
209
210void
211KSpellDlg::closeEvent( TQCloseEvent * )
212{
213 cancel();
214}
215
216void
217KSpellDlg::done( int result )
218{
219 emit command( result );
220}
221void
222KSpellDlg::ignore()
223{
224 newword = word;
225 done( KS_IGNORE );
226}
227
228void
229KSpellDlg::ignoreAll()
230{
231 newword = word;
232 done( KS_IGNOREALL );
233}
234
235void
236KSpellDlg::add()
237{
238 newword = word;
239 done( KS_ADD );
240}
241
242
243void
244KSpellDlg::cancel()
245{
246 newword = word;
247 done( KS_CANCEL );
248}
249
250void
251KSpellDlg::replace()
252{
253 newword = d->ui->m_replacement->text();
254 done( KS_REPLACE );
255}
256
257void
258KSpellDlg::stop()
259{
260 newword = word;
261 done( KS_STOP );
262}
263
264void
265KSpellDlg::replaceAll()
266{
267 newword = d->ui->m_replacement->text();
268 done( KS_REPLACEALL );
269}
270
271void
272KSpellDlg::suggest()
273{
274 newword = d->ui->m_replacement->text();
275 done( KS_SUGGEST );
276}
277
278void
279KSpellDlg::slotConfigChanged()
280{
281 d->spellConfig->writeGlobalSettings();
282 done( KS_CONFIG );
283}
284
285#include "tdespelldlg.moc"
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:192
KSpellConfig
A configuration class/dialog for KSpell.
Definition: ksconfig.h:88
endl
kndbgstream & endl(kndbgstream &s)
kdDebug
kdbgstream kdDebug(int area=0)
TDEStdAccel::name
TQString name(StdAccel id)
TDEStdAccel::replace
const TDEShortcut & replace()
tdelocale.h

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.4
This website is maintained by Timothy Pearson.