• 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 
45 class KSpellDlg::KSpellDlgPrivate {
46 public:
47  KSpellUI* ui;
48  KSpellConfig* spellConfig;
49 };
50 
51 KSpellDlg::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, TQT_SIGNAL(clicked()),
64  this, TQT_SLOT(replace()));
65  connect( this, TQT_SIGNAL(ready(bool)),
66  d->ui->m_replaceBtn, TQT_SLOT(setEnabled(bool)) );
67 
68  connect( d->ui->m_replaceAllBtn, TQT_SIGNAL(clicked()), this, TQT_SLOT(replaceAll()));
69  connect(this, TQT_SIGNAL(ready(bool)), d->ui->m_replaceAllBtn, TQT_SLOT(setEnabled(bool)));
70 
71  connect( d->ui->m_skipBtn, TQT_SIGNAL(clicked()), this, TQT_SLOT(ignore()));
72  connect( this, TQT_SIGNAL(ready(bool)), d->ui->m_skipBtn, TQT_SLOT(setEnabled(bool)));
73 
74  connect( d->ui->m_skipAllBtn, TQT_SIGNAL(clicked()), this, TQT_SLOT(ignoreAll()));
75  connect( this, TQT_SIGNAL(ready(bool)), d->ui->m_skipAllBtn, TQT_SLOT(setEnabled(bool)));
76 
77  connect( d->ui->m_addBtn, TQT_SIGNAL(clicked()), this, TQT_SLOT(add()));
78  connect( this, TQT_SIGNAL(ready(bool)), d->ui->m_addBtn, TQT_SLOT(setEnabled(bool)));
79 
80  connect( d->ui->m_suggestBtn, TQT_SIGNAL(clicked()), this, TQT_SLOT(suggest()));
81  connect( this, TQT_SIGNAL(ready(bool)), d->ui->m_suggestBtn, TQT_SLOT(setEnabled(bool)) );
82  d->ui->m_suggestBtn->hide();
83 
84  connect(this, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(stop()));
85 
86  connect( d->ui->m_replacement, TQT_SIGNAL(textChanged(const TQString &)),
87  TQT_SLOT(textChanged(const TQString &)) );
88 
89  connect( d->ui->m_replacement, TQT_SIGNAL(returnPressed()), TQT_SLOT(replace()) );
90  connect( d->ui->m_suggestions, TQT_SIGNAL(selectionChanged(TQListViewItem*)),
91  TQT_SLOT(slotSelectionChanged(TQListViewItem*)) );
92 
93  connect( d->ui->m_suggestions, TQT_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int ) ),
94  TQT_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, TQT_SIGNAL(activated(int)),
98  d->spellConfig, TQT_SLOT(sSetDictionary(int)) );
99  connect( d->spellConfig, TQT_SIGNAL(configChanged()),
100  TQT_SLOT(slotConfigChanged()) );
101 
102  setHelp( "spelldlg", "tdespell" );
103  setMinimumSize( sizeHint() );
104  emit ready( false );
105 }
106 
107 KSpellDlg::~KSpellDlg()
108 {
109  delete d->spellConfig;
110  delete d;
111 }
112 
113 void
114 KSpellDlg::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 
146 void
147 KSpellDlg::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 
182 void
183 KSpellDlg::slotProgress( unsigned int p )
184 {
185  if (!progressbar)
186  return;
187 
188  progbar->setValue( (int) p );
189 }
190 
191 void
192 KSpellDlg::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 
199 void
200 KSpellDlg::slotSelectionChanged( TQListViewItem* item )
201 {
202  if ( item )
203  d->ui->m_replacement->setText( item->text( 0 ) );
204 }
205 
206 /*
207  exit functions
208  */
209 
210 void
211 KSpellDlg::closeEvent( TQCloseEvent * )
212 {
213  cancel();
214 }
215 
216 void
217 KSpellDlg::done( int result )
218 {
219  emit command( result );
220 }
221 void
222 KSpellDlg::ignore()
223 {
224  newword = word;
225  done( KS_IGNORE );
226 }
227 
228 void
229 KSpellDlg::ignoreAll()
230 {
231  newword = word;
232  done( KS_IGNOREALL );
233 }
234 
235 void
236 KSpellDlg::add()
237 {
238  newword = word;
239  done( KS_ADD );
240 }
241 
242 
243 void
244 KSpellDlg::cancel()
245 {
246  newword = word;
247  done( KS_CANCEL );
248 }
249 
250 void
251 KSpellDlg::replace()
252 {
253  newword = d->ui->m_replacement->text();
254  done( KS_REPLACE );
255 }
256 
257 void
258 KSpellDlg::stop()
259 {
260  newword = word;
261  done( KS_STOP );
262 }
263 
264 void
265 KSpellDlg::replaceAll()
266 {
267  newword = d->ui->m_replacement->text();
268  done( KS_REPLACEALL );
269 }
270 
271 void
272 KSpellDlg::suggest()
273 {
274  newword = d->ui->m_replacement->text();
275  done( KS_SUGGEST );
276 }
277 
278 void
279 KSpellDlg::slotConfigChanged()
280 {
281  d->spellConfig->writeGlobalSettings();
282  done( KS_CONFIG );
283 }
284 
285 #include "tdespelldlg.moc"
kdDebug
kdbgstream kdDebug(int area=0)
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:191
tdelocale.h
KSpell::ignore
virtual bool ignore(const TQString &word)
Tells ISpell/ASpell to ignore this word for the life of this KSpell instance.
Definition: tdespell.cpp:410
TDEStdAccel::replace
const TDEShortcut & replace()
KSpellConfig
A configuration class/dialog for KSpell.
Definition: ksconfig.h:87
KSpell::ready
void ready(KSpell *)
Emitted after KSpell has verified that ISpell/ASpell is running and working properly.
endl
kndbgstream & endl(kndbgstream &s)

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.8.8
This website is maintained by Timothy Pearson.