00001
00002
00003
00004
00005
00006 #include <config.h>
00007
00008 #include "kmedit.h"
00009 #include "kmlineeditspell.h"
00010
00011 #define REALLY_WANT_KMCOMPOSEWIN_H
00012 #include "kmcomposewin.h"
00013 #undef REALLY_WANT_KMCOMPOSEWIN_H
00014 #include "kmmsgdict.h"
00015 #include "kmfolder.h"
00016 #include "kmcommands.h"
00017
00018 #include <maillistdrag.h>
00019 using KPIM::MailListDrag;
00020
00021 #include <libkdepim/kfileio.h>
00022 #include <libemailfunctions/email.h>
00023
00024 #include <kcursor.h>
00025 #include <kprocess.h>
00026
00027 #include <kpopupmenu.h>
00028 #include <kdebug.h>
00029 #include <kmessagebox.h>
00030 #include <kurldrag.h>
00031
00032 #include <ktempfile.h>
00033 #include <klocale.h>
00034 #include <kapplication.h>
00035 #include <kdirwatch.h>
00036 #include <kiconloader.h>
00037
00038 #include "globalsettings.h"
00039 #include "replyphrases.h"
00040
00041 #include <kspell.h>
00042 #include <kspelldlg.h>
00043 #include <spellingfilter.h>
00044 #include <ksyntaxhighlighter.h>
00045
00046 #include <qregexp.h>
00047 #include <qbuffer.h>
00048 #include <qevent.h>
00049
00050 #include <sys/stat.h>
00051 #include <sys/types.h>
00052 #include <stdlib.h>
00053 #include <unistd.h>
00054 #include <errno.h>
00055 #include <fcntl.h>
00056 #include <assert.h>
00057
00058
00059 void KMEdit::contentsDragEnterEvent(QDragEnterEvent *e)
00060 {
00061 if (e->provides(MailListDrag::format()))
00062 e->accept(true);
00063 else if (e->provides("image/png"))
00064 e->accept();
00065 else
00066 return KEdit::contentsDragEnterEvent(e);
00067 }
00068
00069 void KMEdit::contentsDragMoveEvent(QDragMoveEvent *e)
00070 {
00071 if (e->provides(MailListDrag::format()))
00072 e->accept();
00073 else if (e->provides("image/png"))
00074 e->accept();
00075 else
00076 return KEdit::contentsDragMoveEvent(e);
00077 }
00078
00079 void KMEdit::keyPressEvent( QKeyEvent* e )
00080 {
00081 if( e->key() == Key_Return ) {
00082 int line, col;
00083 getCursorPosition( &line, &col );
00084 QString lineText = text( line );
00085
00086 lineText.truncate( lineText.length() - 1 );
00087
00088
00089 if( ( col > 0 ) && ( col < int( lineText.length() ) ) ) {
00090 bool isQuotedLine = false;
00091 uint bot = 0;
00092 while( bot < lineText.length() ) {
00093 if( ( lineText[bot] == '>' ) || ( lineText[bot] == '|' ) ) {
00094 isQuotedLine = true;
00095 ++bot;
00096 }
00097 else if( lineText[bot].isSpace() ) {
00098 ++bot;
00099 }
00100 else {
00101 break;
00102 }
00103 }
00104
00105 KEdit::keyPressEvent( e );
00106
00107
00108
00109
00110 if( isQuotedLine
00111 && ( bot != lineText.length() )
00112 && ( col >= int( bot ) ) ) {
00113
00114
00115
00116 getCursorPosition( &line, &col );
00117 QString newLine = text( line );
00118
00119
00120 unsigned int leadingWhiteSpaceCount = 0;
00121 while( ( leadingWhiteSpaceCount < newLine.length() )
00122 && newLine[leadingWhiteSpaceCount].isSpace() ) {
00123 ++leadingWhiteSpaceCount;
00124 }
00125 newLine = newLine.replace( 0, leadingWhiteSpaceCount,
00126 lineText.left( bot ) );
00127 removeParagraph( line );
00128 insertParagraph( newLine, line );
00129
00130
00131
00132 setCursorPosition( line, 0 );
00133 }
00134 }
00135 else
00136 KEdit::keyPressEvent( e );
00137 }
00138 else
00139 KEdit::keyPressEvent( e );
00140 }
00141
00142 void KMEdit::contentsDropEvent(QDropEvent *e)
00143 {
00144 if (e->provides(MailListDrag::format())) {
00145
00146 QByteArray serNums;
00147 MailListDrag::decode( e, serNums );
00148 QBuffer serNumBuffer(serNums);
00149 serNumBuffer.open(IO_ReadOnly);
00150 QDataStream serNumStream(&serNumBuffer);
00151 Q_UINT32 serNum;
00152 KMFolder *folder = 0;
00153 int idx;
00154 QPtrList<KMMsgBase> messageList;
00155 while (!serNumStream.atEnd()) {
00156 KMMsgBase *msgBase = 0;
00157 serNumStream >> serNum;
00158 KMMsgDict::instance()->getLocation(serNum, &folder, &idx);
00159 if (folder)
00160 msgBase = folder->getMsgBase(idx);
00161 if (msgBase)
00162 messageList.append( msgBase );
00163 }
00164 serNumBuffer.close();
00165 uint identity = folder ? folder->identity() : 0;
00166 KMCommand *command =
00167 new KMForwardAttachedCommand(mComposer, messageList,
00168 identity, mComposer);
00169 command->start();
00170 }
00171 else if( e->provides("image/png") ) {
00172 emit attachPNGImageData(e->encodedData("image/png"));
00173 }
00174 else if( KURLDrag::canDecode( e ) ) {
00175 KURL::List urlList;
00176 if( KURLDrag::decode( e, urlList ) ) {
00177 KPopupMenu p;
00178 p.insertItem( i18n("Add as Text"), 0 );
00179 p.insertItem( i18n("Add as Attachment"), 1 );
00180 int id = p.exec( mapToGlobal( e->pos() ) );
00181 switch ( id) {
00182 case 0:
00183 for ( KURL::List::Iterator it = urlList.begin();
00184 it != urlList.end(); ++it ) {
00185 insert( (*it).url() );
00186 }
00187 break;
00188 case 1:
00189 for ( KURL::List::Iterator it = urlList.begin();
00190 it != urlList.end(); ++it ) {
00191 mComposer->addAttach( *it );
00192 }
00193 break;
00194 }
00195 }
00196 else if ( QTextDrag::canDecode( e ) ) {
00197 QString s;
00198 if ( QTextDrag::decode( e, s ) )
00199 insert( s );
00200 }
00201 else
00202 kdDebug(5006) << "KMEdit::contentsDropEvent, unable to add dropped object" << endl;
00203 }
00204 else if( e->provides("text/x-textsnippet") ) {
00205 emit insertSnippet();
00206 }
00207 else {
00208 KEdit::contentsDropEvent(e);
00209 }
00210 }
00211
00212 KMEdit::KMEdit(QWidget *parent, KMComposeWin* composer,
00213 KSpellConfig* autoSpellConfig,
00214 const char *name)
00215 : KEdit( parent, name ),
00216 mComposer( composer ),
00217 mKSpell( 0 ),
00218 mSpellConfig( autoSpellConfig ),
00219 mSpellingFilter( 0 ),
00220 mExtEditorTempFile( 0 ),
00221 mExtEditorTempFileWatcher( 0 ),
00222 mExtEditorProcess( 0 ),
00223 mUseExtEditor( false ),
00224 mWasModifiedBeforeSpellCheck( false ),
00225 mSpellChecker( 0 ),
00226 mSpellLineEdit( false ),
00227 mPasteMode( QClipboard::Clipboard )
00228 {
00229 installEventFilter(this);
00230 KCursor::setAutoHideCursor( this, true, true );
00231 setOverwriteEnabled( true );
00232 }
00233
00234
00235 void KMEdit::initializeAutoSpellChecking()
00236 {
00237 if ( mSpellChecker )
00238 return;
00239 QColor defaultColor1( 0x00, 0x80, 0x00 );
00240 QColor defaultColor2( 0x00, 0x70, 0x00 );
00241 QColor defaultColor3( 0x00, 0x60, 0x00 );
00242 QColor defaultForeground( kapp->palette().active().text() );
00243
00244 QColor c = Qt::red;
00245 KConfigGroup readerConfig( KMKernel::config(), "Reader" );
00246 QColor col1;
00247 if ( !readerConfig.readBoolEntry( "defaultColors", true ) )
00248 col1 = readerConfig.readColorEntry( "ForegroundColor", &defaultForeground );
00249 else
00250 col1 = defaultForeground;
00251 QColor col2 = readerConfig.readColorEntry( "QuotedText3", &defaultColor3 );
00252 QColor col3 = readerConfig.readColorEntry( "QuotedText2", &defaultColor2 );
00253 QColor col4 = readerConfig.readColorEntry( "QuotedText1", &defaultColor1 );
00254 QColor misspelled = readerConfig.readColorEntry( "MisspelledColor", &c );
00255 mSpellChecker = new KDictSpellingHighlighter( this, true,
00256 false,
00257 misspelled,
00258 true,
00259 col1, col2, col3, col4,
00260 mSpellConfig );
00261
00262 connect( mSpellChecker, SIGNAL(newSuggestions(const QString&, const QStringList&, unsigned int)),
00263 this, SLOT(addSuggestion(const QString&, const QStringList&, unsigned int)) );
00264 }
00265
00266
00267 QPopupMenu *KMEdit::createPopupMenu( const QPoint& pos )
00268 {
00269 enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll };
00270
00271 QPopupMenu *menu = KEdit::createPopupMenu( pos );
00272 if ( !QApplication::clipboard()->image().isNull() ) {
00273 int id = menu->idAt(0);
00274 menu->setItemEnabled( id - IdPaste, true);
00275 }
00276
00277 return menu;
00278 }
00279
00280 void KMEdit::deleteAutoSpellChecking()
00281 {
00282 delete mSpellChecker;
00283 mSpellChecker =0;
00284 }
00285
00286 void KMEdit::addSuggestion(const QString& text, const QStringList& lst, unsigned int )
00287 {
00288 mReplacements[text] = lst;
00289 }
00290
00291 void KMEdit::setSpellCheckingActive(bool spellCheckingActive)
00292 {
00293 if ( mSpellChecker ) {
00294 mSpellChecker->setActive(spellCheckingActive);
00295 }
00296 }
00297
00298
00299 KMEdit::~KMEdit()
00300 {
00301 removeEventFilter(this);
00302
00303 delete mKSpell;
00304 delete mSpellChecker;
00305 mSpellChecker = 0;
00306
00307 }
00308
00309
00310
00311 QString KMEdit::brokenText()
00312 {
00313 QString temp, line;
00314
00315 int num_lines = numLines();
00316 for (int i = 0; i < num_lines; ++i)
00317 {
00318 int lastLine = 0;
00319 line = textLine(i);
00320 for (int j = 0; j < (int)line.length(); ++j)
00321 {
00322 if (lineOfChar(i, j) > lastLine)
00323 {
00324 lastLine = lineOfChar(i, j);
00325 temp += '\n';
00326 }
00327 temp += line[j];
00328 }
00329 if (i + 1 < num_lines) temp += '\n';
00330 }
00331
00332 return temp;
00333 }
00334
00335
00336 unsigned int KMEdit::lineBreakColumn() const
00337 {
00338 unsigned int lineBreakColumn = 0;
00339 unsigned int numlines = numLines();
00340 while ( numlines-- ) {
00341 lineBreakColumn = QMAX( lineBreakColumn, textLine( numlines ).length() );
00342 }
00343 return lineBreakColumn;
00344 }
00345
00346
00347 bool KMEdit::eventFilter(QObject*o, QEvent* e)
00348 {
00349 if (o == this)
00350 KCursor::autoHideEventFilter(o, e);
00351
00352 if (e->type() == QEvent::KeyPress)
00353 {
00354 QKeyEvent *k = (QKeyEvent*)e;
00355
00356 if (mUseExtEditor) {
00357 if (k->key() == Key_Up)
00358 {
00359 emit focusUp();
00360 return true;
00361 }
00362
00363
00364 if ( (k->key() == Key_Shift) || (k->key() == Key_Control) ||
00365 (k->key() == Key_Meta) || (k->key() == Key_Alt) )
00366 return true;
00367 if (mExtEditorTempFile) return true;
00368 QString sysLine = mExtEditor;
00369 mExtEditorTempFile = new KTempFile();
00370
00371 mExtEditorTempFile->setAutoDelete(true);
00372
00373 (*mExtEditorTempFile->textStream()) << text();
00374
00375 mExtEditorTempFile->close();
00376
00377 sysLine.replace( "%f", mExtEditorTempFile->name() );
00378 mExtEditorProcess = new KProcess();
00379 mExtEditorProcess->setUseShell( true );
00380 sysLine += " ";
00381 while (!sysLine.isEmpty())
00382 {
00383 *mExtEditorProcess << sysLine.left(sysLine.find(" ")).local8Bit();
00384 sysLine.remove(0, sysLine.find(" ") + 1);
00385 }
00386 connect(mExtEditorProcess, SIGNAL(processExited(KProcess*)),
00387 SLOT(slotExternalEditorDone(KProcess*)));
00388 if (!mExtEditorProcess->start())
00389 {
00390 KMessageBox::error( topLevelWidget(),
00391 i18n("Unable to start external editor.") );
00392 killExternalEditor();
00393 } else {
00394 mExtEditorTempFileWatcher = new KDirWatch( this, "mExtEditorTempFileWatcher" );
00395 connect( mExtEditorTempFileWatcher, SIGNAL(dirty(const QString&)),
00396 SLOT(slotExternalEditorTempFileChanged(const QString&)) );
00397 mExtEditorTempFileWatcher->addFile( mExtEditorTempFile->name() );
00398 }
00399 return true;
00400 } else {
00401
00402
00403 if (k->key() == Key_Up && k->state() != ShiftButton && currentLine() == 0
00404 && lineOfChar(0, currentColumn()) == 0)
00405 {
00406 deselect();
00407 emit focusUp();
00408 return true;
00409 }
00410
00411
00412 if (k->key() == Key_Backtab && k->state() == ShiftButton)
00413 {
00414 deselect();
00415 emit focusUp();
00416 return true;
00417 }
00418
00419 }
00420 } else if ( e->type() == QEvent::ContextMenu ) {
00421 QContextMenuEvent *event = (QContextMenuEvent*) e;
00422
00423 int para = 1, charPos, firstSpace, lastSpace;
00424
00425
00426 charPos = charAt( viewportToContents(event->pos()), ¶ );
00427 QString paraText = text( para );
00428
00429 if( !paraText.at(charPos).isSpace() )
00430 {
00431
00432 const QRegExp wordBoundary( "[\\s\\W]" );
00433 firstSpace = paraText.findRev( wordBoundary, charPos ) + 1;
00434 lastSpace = paraText.find( wordBoundary, charPos );
00435 if( lastSpace == -1 )
00436 lastSpace = paraText.length();
00437 QString word = paraText.mid( firstSpace, lastSpace - firstSpace );
00438
00439 if( !word.isEmpty() && mReplacements.contains( word ) )
00440 {
00441 KPopupMenu p;
00442 p.insertTitle( i18n("Suggestions") );
00443
00444
00445 QStringList reps = mReplacements[word];
00446 if( reps.count() > 0 )
00447 {
00448 int listPos = 0;
00449 for ( QStringList::Iterator it = reps.begin(); it != reps.end(); ++it ) {
00450 p.insertItem( *it, listPos );
00451 listPos++;
00452 }
00453 }
00454 else
00455 {
00456 p.insertItem( QString::fromLatin1("No Suggestions"), -2 );
00457 }
00458
00459
00460 int id = p.exec( mapToGlobal( event->pos() ) );
00461
00462 if( id > -1 )
00463 {
00464
00465 int parIdx = 1, txtIdx = 1;
00466 getCursorPosition(&parIdx, &txtIdx);
00467 setSelection(para, firstSpace, para, lastSpace);
00468 insert(mReplacements[word][id]);
00469
00470
00471 if ( para == parIdx && txtIdx >= lastSpace )
00472 txtIdx += mReplacements[word][id].length() - word.length();
00473 setCursorPosition(parIdx, txtIdx);
00474 }
00475
00476 return true;
00477 }
00478 }
00479 } else if ( e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut ) {
00480 QFocusEvent *fe = static_cast<QFocusEvent*>(e);
00481 if(! (fe->reason() == QFocusEvent::ActiveWindow || fe->reason() == QFocusEvent::Popup) )
00482 emit focusChanged( fe->gotFocus() );
00483 }
00484
00485 return KEdit::eventFilter(o, e);
00486 }
00487
00488
00489 int KMEdit::autoSpellChecking( bool on )
00490 {
00491 if ( textFormat() == Qt::RichText ) {
00492
00493 if ( on )
00494 KMessageBox::sorry(this, i18n("Automatic spellchecking is not possible on text with markup."));
00495 return -1;
00496 }
00497 if ( mSpellChecker ) {
00498
00499 mSpellChecker->setAutomatic( on );
00500 mSpellChecker->setActive( on );
00501 }
00502 return 1;
00503 }
00504
00505
00506 void KMEdit::slotExternalEditorTempFileChanged( const QString & fileName ) {
00507 if ( !mExtEditorTempFile )
00508 return;
00509 if ( fileName != mExtEditorTempFile->name() )
00510 return;
00511
00512 setAutoUpdate(false);
00513 clear();
00514
00515 insertLine(QString::fromLocal8Bit(KPIM::kFileToString( fileName, true, false )), -1);
00516 setAutoUpdate(true);
00517 repaint();
00518 }
00519
00520 void KMEdit::slotExternalEditorDone( KProcess * proc ) {
00521 assert(proc == mExtEditorProcess);
00522
00523 slotExternalEditorTempFileChanged( mExtEditorTempFile->name() );
00524 killExternalEditor();
00525 }
00526
00527 void KMEdit::killExternalEditor() {
00528 delete mExtEditorTempFileWatcher; mExtEditorTempFileWatcher = 0;
00529 delete mExtEditorTempFile; mExtEditorTempFile = 0;
00530 delete mExtEditorProcess; mExtEditorProcess = 0;
00531 }
00532
00533
00534 bool KMEdit::checkExternalEditorFinished() {
00535 if ( !mExtEditorProcess )
00536 return true;
00537 switch ( KMessageBox::warningYesNoCancel( topLevelWidget(),
00538 i18n("The external editor is still running.\n"
00539 "Abort the external editor or leave it open?"),
00540 i18n("External Editor"),
00541 i18n("Abort Editor"), i18n("Leave Editor Open") ) ) {
00542 case KMessageBox::Yes:
00543 killExternalEditor();
00544 return true;
00545 case KMessageBox::No:
00546 return true;
00547 default:
00548 return false;
00549 }
00550 }
00551
00552 void KMEdit::spellcheck()
00553 {
00554 if ( mKSpell )
00555 return;
00556 mWasModifiedBeforeSpellCheck = isModified();
00557 mSpellLineEdit = !mSpellLineEdit;
00558
00559
00560
00561
00562
00563
00564
00565 mKSpell = new KSpell(this, i18n("Spellcheck - KMail"), this,
00566 SLOT(slotSpellcheck2(KSpell*)));
00567
00568
00569 QStringList l = KSpellingHighlighter::personalWords();
00570 for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) {
00571 mKSpell->addPersonal( *it );
00572 }
00573 connect (mKSpell, SIGNAL( death()),
00574 this, SLOT (slotSpellDone()));
00575 connect (mKSpell, SIGNAL (misspelling (const QString &, const QStringList &, unsigned int)),
00576 this, SLOT (slotMisspelling (const QString &, const QStringList &, unsigned int)));
00577 connect (mKSpell, SIGNAL (corrected (const QString &, const QString &, unsigned int)),
00578 this, SLOT (slotCorrected (const QString &, const QString &, unsigned int)));
00579 connect (mKSpell, SIGNAL (done(const QString &)),
00580 this, SLOT (slotSpellResult (const QString&)));
00581 }
00582
00583 void KMEdit::cut()
00584 {
00585 KEdit::cut();
00586 if ( textFormat() != Qt::RichText && mSpellChecker )
00587 mSpellChecker->restartBackgroundSpellCheck();
00588 }
00589
00590 void KMEdit::clear()
00591 {
00592 KEdit::clear();
00593 if ( textFormat() != Qt::RichText && mSpellChecker )
00594 mSpellChecker->restartBackgroundSpellCheck();
00595 }
00596
00597 void KMEdit::del()
00598 {
00599 KEdit::del();
00600 if ( textFormat() != Qt::RichText && mSpellChecker )
00601 mSpellChecker->restartBackgroundSpellCheck();
00602 }
00603
00604 void KMEdit::paste()
00605 {
00606 mComposer->paste( mPasteMode );
00607 }
00608
00609
00610
00611
00612
00613
00614 void KMEdit::contentsMouseReleaseEvent( QMouseEvent * e )
00615 {
00616 if( e->button() != Qt::MidButton )
00617 return KEdit::contentsMouseReleaseEvent( e );
00618 mPasteMode = QClipboard::Selection;
00619 KEdit::contentsMouseReleaseEvent( e );
00620 mPasteMode = QClipboard::Clipboard;
00621 }
00622
00623 void KMEdit::slotMisspelling(const QString &text, const QStringList &lst, unsigned int pos)
00624 {
00625 kdDebug(5006)<<"void KMEdit::slotMisspelling(const QString &text, const QStringList &lst, unsigned int pos) : "<<text <<endl;
00626 if( mSpellLineEdit )
00627 mComposer->sujectLineWidget()->spellCheckerMisspelling( text, lst, pos);
00628 else
00629 misspelling(text, lst, pos);
00630 }
00631
00632 void KMEdit::slotCorrected (const QString &oldWord, const QString &newWord, unsigned int pos)
00633 {
00634 kdDebug(5006)<<"slotCorrected (const QString &oldWord, const QString &newWord, unsigned int pos) : "<<oldWord<<endl;
00635 if( mSpellLineEdit )
00636 mComposer->sujectLineWidget()->spellCheckerCorrected( oldWord, newWord, pos);
00637 else {
00638 unsigned int l = 0;
00639 unsigned int cnt = 0;
00640 bool _bold,_underline,_italic;
00641 QColor _color;
00642 QFont _font;
00643 posToRowCol (pos, l, cnt);
00644 setCursorPosition(l, cnt+1);
00645 _bold = bold();
00646 _underline = underline();
00647 _italic = italic();
00648 _color = color();
00649 _font = currentFont();
00650 corrected(oldWord, newWord, pos);
00651 setSelection (l, cnt, l, cnt+newWord.length());
00652 setBold(_bold);
00653 setItalic(_italic);
00654 setUnderline(_underline);
00655 setColor(_color);
00656 setCurrentFont(_font);
00657 }
00658
00659 }
00660
00661 void KMEdit::slotSpellcheck2(KSpell*)
00662 {
00663 if( !mSpellLineEdit)
00664 {
00665 spellcheck_start();
00666
00667 QString quotePrefix;
00668 if(mComposer && mComposer->msg())
00669 {
00670 int languageNr = GlobalSettings::self()->replyCurrentLanguage();
00671 ReplyPhrases replyPhrases( QString::number(languageNr) );
00672 replyPhrases.readConfig();
00673
00674 quotePrefix = mComposer->msg()->formatString(
00675 replyPhrases.indentPrefix() );
00676 }
00677
00678 kdDebug(5006) << "spelling: new SpellingFilter with prefix=\"" << quotePrefix << "\"" << endl;
00679 QTextEdit plaintext;
00680 plaintext.setText(text());
00681 plaintext.setTextFormat(Qt::PlainText);
00682 mSpellingFilter = new SpellingFilter(plaintext.text(), quotePrefix, SpellingFilter::FilterUrls,
00683 SpellingFilter::FilterEmailAddresses);
00684
00685 mKSpell->check(mSpellingFilter->filteredText());
00686 }
00687 else if( mComposer )
00688 mKSpell->check( mComposer->sujectLineWidget()->text());
00689 }
00690
00691 void KMEdit::slotSpellResult(const QString &s)
00692 {
00693 if( !mSpellLineEdit)
00694 spellcheck_stop();
00695
00696 int dlgResult = mKSpell->dlgResult();
00697 if ( dlgResult == KS_CANCEL )
00698 {
00699 if( mSpellLineEdit)
00700 {
00701
00702 mSpellLineEdit = false;
00703 QString tmpText( s );
00704 tmpText = tmpText.remove('\n');
00705
00706 if( tmpText != mComposer->sujectLineWidget()->text() )
00707 mComposer->sujectLineWidget()->setText( tmpText );
00708 }
00709 else
00710 {
00711 setModified(true);
00712 }
00713 }
00714 mKSpell->cleanUp();
00715 KDictSpellingHighlighter::dictionaryChanged();
00716
00717 emit spellcheck_done( dlgResult );
00718 }
00719
00720 void KMEdit::slotSpellDone()
00721 {
00722 kdDebug(5006)<<" void KMEdit::slotSpellDone()\n";
00723 KSpell::spellStatus status = mKSpell->status();
00724 delete mKSpell;
00725 mKSpell = 0;
00726
00727 kdDebug(5006) << "spelling: delete SpellingFilter" << endl;
00728 delete mSpellingFilter;
00729 mSpellingFilter = 0;
00730 mComposer->sujectLineWidget()->deselect();
00731 if (status == KSpell::Error)
00732 {
00733 KMessageBox::sorry( topLevelWidget(),
00734 i18n("ISpell/Aspell could not be started. Please "
00735 "make sure you have ISpell or Aspell properly "
00736 "configured and in your PATH.") );
00737 emit spellcheck_done( KS_CANCEL );
00738 }
00739 else if (status == KSpell::Crashed)
00740 {
00741 spellcheck_stop();
00742 KMessageBox::sorry( topLevelWidget(),
00743 i18n("ISpell/Aspell seems to have crashed.") );
00744 emit spellcheck_done( KS_CANCEL );
00745 }
00746 else
00747 {
00748 if( mSpellLineEdit )
00749 spellcheck();
00750 else if( !mComposer->subjectTextWasSpellChecked() && status == KSpell::FinishedNoMisspellingsEncountered )
00751 KMessageBox::information( topLevelWidget(),
00752 i18n("No misspellings encountered.") );
00753 }
00754 }
00755
00756 void KMEdit::setCursorPositionFromStart( unsigned int pos ) {
00757 unsigned int l = 0;
00758 unsigned int c = 0;
00759 posToRowCol( pos, l, c );
00760
00761
00762 setCursorPosition( l, c );
00763 ensureCursorVisible();
00764 }
00765
00766 #include "kmedit.moc"