--Boundary-03=_KDwk/6WBB0fAhd1 Content-Type: multipart/mixed; boundary="Boundary-01=_JDwk/tk3Eyg2C5C" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_JDwk/tk3Eyg2C5C Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, the patches do the following. ksconfig.diff: KSpellConfig::fillDicts( QComboBox *box ) fills a combo box with the=20 available dictionaries. But it doesn't set the currently used=20 dictionary as current item of the combo box. This patch fixes this bug.=20 It's a bug because there is no other way to set the correct current=20 item because the user of KSpellConfig only knows about the human=20 readable dictionary names but not about the internal dictionary names.=20 Without this fix fillDicts is completely useless. ksyntaxhighlighter.diff: Currently KDictSpellingHighlighter (the class that's for example used in=20 KMail for as-you-type spell checking) has a static cache for already=20 checked words and uses the global KSpellConfig. In order to be able to=20 compose two messages in different languages at the same time in KMail=20 it's necessary to add support for a custom KSpellConfig to=20 KDictSpellingHighlighter. Furthermore the static cache is useless for=20 multiple languages. Therefore this patch makes KDictSpellingHighlighter=20 use a non-static cache in case a custom KSpellConfig is provided. With those two patches in kdelibs it was quite easy to add a language=20 selection box to KMail's composer (which is a must for multilingual=20 users). Regards, Ingo P.S.: If the signature on this message is broken then it's most likely=20 mailmans fault. --Boundary-01=_JDwk/tk3Eyg2C5C Content-Type: text/x-diff; charset="us-ascii"; name="ksyntaxhighlighter.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ksyntaxhighlighter.diff" Index: ksyntaxhighlighter.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdeui/ksyntaxhighlighter.h,v retrieving revision 1.6 diff -u -3 -p -r1.6 ksyntaxhighlighter.h =2D-- ksyntaxhighlighter.h 18 Oct 2003 19:22:42 -0000 1.6 +++ ksyntaxhighlighter.h 19 Oct 2003 20:36:59 -0000 @@ -32,6 +32,7 @@ class QAccel; class QTimer; class KSpell; +class KSpellConfig; =20 class KSyntaxHighlighter : public QSyntaxHighlighter { @@ -95,7 +96,8 @@ public: const QColor& QuoteColor0 =3D black, const QColor& QuoteColor1 =3D QColor( 0x00, 0x80, 0x00 ), const QColor& QuoteColor2 =3D QColor( 0x00, 0x70, 0x00 ), =2D const QColor& QuoteColor3 =3D QColor( 0x00, 0x60, 0x00 ) ); + const QColor& QuoteColor3 =3D QColor( 0x00, 0x60, 0x00 ), + KSpellConfig *spellConfig =3D 0 ); ~KDictSpellingHighlighter(); =20 virtual bool isMisspelled( const QString &word ); @@ -138,6 +140,7 @@ protected slots: void slotDictionaryChanged(); void slotSpellReady( KSpell *spell ); void slotAutoDetection(); + void slotLocalSpellConfigChanged(); =20 private: class KDictSpellingHighlighterPrivate; Index: ksyntaxhighlighter.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdeui/ksyntaxhighlighter.cpp,v retrieving revision 1.12 diff -u -3 -p -r1.12 ksyntaxhighlighter.cpp =2D-- ksyntaxhighlighter.cpp 18 Oct 2003 19:22:42 -0000 1.12 +++ ksyntaxhighlighter.cpp 19 Oct 2003 20:36:59 -0000 @@ -67,10 +67,14 @@ class KDictSpellingHighlighter::KDictSpe { public: KDictSpellingHighlighterPrivate() : + mDict( 0 ), spell( 0 ), + mSpellConfig( 0 ), + rehighlightRequest( 0 ), wordCount( 0 ), errorCount( 0 ), =2D autoReady( false ) {} + autoReady( false ), + globalConfig( true ) {} =20 ~KDictSpellingHighlighterPrivate() { delete rehighlightRequest; @@ -84,14 +88,17 @@ public: return statDict; } =20 + QDict* mDict; QDict autoDict; QDict autoIgnoreDict; static QObject *sDictionaryMonitor; KSpell *spell; + KSpellConfig *mSpellConfig; QTimer *rehighlightRequest; QString spellKey; int wordCount, errorCount; bool active, automatic, autoReady; + bool globalConfig; private: static QDict* statDict; =20 @@ -257,12 +264,15 @@ KDictSpellingHighlighter::KDictSpellingH const QColor& depth0, const QColor& depth1, const QColor& depth2, =2D const QColor& depth3 ) + const QColor& depth3, + KSpellConfig *spellCon= fig ) : KSpellingHighlighter( textEdit, spellColor, colorQuoting, depth0, depth1, depth2, depth3 ) { d =3D new KDictSpellingHighlighterPrivate(); =20 + d->mSpellConfig =3D spellConfig; + d->globalConfig =3D ( spellConfig =3D=3D 0 ); d->automatic =3D autoEnable; d->active =3D spellCheckingActive; =20 @@ -273,10 +283,17 @@ KDictSpellingHighlighter::KDictSpellingH connect( d->rehighlightRequest, SIGNAL( timeout() ), this, SLOT( slotRehighlight() )); =20 =2D d->spellKey =3D spellKey(); + if ( d->globalConfig ) { + d->spellKey =3D spellKey(); =20 =2D if ( !d->sDictionaryMonitor ) =2D d->sDictionaryMonitor =3D new QObject(); + if ( !d->sDictionaryMonitor ) + d->sDictionaryMonitor =3D new QObject(); + } + else { + d->mDict =3D new QDict(50021); + connect( d->mSpellConfig, SIGNAL( configChanged() ), + this, SLOT( slotLocalSpellConfigChanged() ) ); + } =20 slotDictionaryChanged(); startTimer( 2 * 1000 ); @@ -286,13 +303,17 @@ KDictSpellingHighlighter::~KDictSpelling { delete d->spell; d->spell =3D 0; + delete d->mDict; + d->mDict =3D 0; delete d; } =20 void KDictSpellingHighlighter::slotSpellReady( KSpell *spell ) { =2D connect( d->sDictionaryMonitor, SIGNAL( destroyed()), =2D this, SLOT( slotDictionaryChanged() )); + if ( d->globalConfig ) { + connect( d->sDictionaryMonitor, SIGNAL( destroyed()), + this, SLOT( slotDictionaryChanged() )); + } if ( spell !=3D d->spell ) { delete d->spell; @@ -318,7 +341,8 @@ bool KDictSpellingHighlighter::isMisspel d->autoIgnoreDict.replace( word, Ignore ); =20 // "dict" is used as a cache to store the results of KSpell =2D if ( !d->sDict()->isEmpty() && (*d->sDict())[word] =3D=3D NotOkay ) { + QDict* dict =3D ( d->globalConfig ? d->sDict() : d->mDict ); + if ( !dict->isEmpty() && (*dict)[word] =3D=3D NotOkay ) { if ( d->autoReady && ( d->autoDict[word] !=3D NotOkay )) { if ( !d->autoIgnoreDict[word] ) { ++d->errorCount; @@ -329,7 +353,7 @@ bool KDictSpellingHighlighter::isMisspel } return d->active; } =2D if ( !d->sDict()->isEmpty() && (*d->sDict())[word] =3D=3D Okay ) { + if ( !dict->isEmpty() && (*dict)[word] =3D=3D Okay ) { if ( d->autoReady && !d->autoDict[word] ) { d->autoDict.replace( word, Okay ); if ( !d->autoIgnoreDict[word] ) @@ -339,7 +363,7 @@ bool KDictSpellingHighlighter::isMisspel } =20 // there is no 'spelt correctly' signal so default to Okay =2D d->sDict()->replace( word, Okay ); + dict->replace( word, Okay ); =20 // yes I tried checkWord, the docs lie and it didn't give useful signa= ls :-( if ( d->spell ) @@ -362,7 +386,10 @@ void KDictSpellingHighlighter::slotMissp { Q_UNUSED( suggestions ); // kdDebug() << suggestions.join( " " ).latin1() << endl; =2D d->sDict()->replace( originalWord, NotOkay ); + if ( d->globalConfig ) + d->sDict()->replace( originalWord, NotOkay ); + else + d->mDict->replace( originalWord, NotOkay ); =20 //Emit this baby so that apps that want to have suggestions in a popup= over //the misspelled word can catch them. @@ -418,7 +447,14 @@ void KDictSpellingHighlighter::slotDicti d->autoDict.clear(); =20 d->spell =3D new KSpell( 0, i18n( "Incremental Spellcheck" ), this, =2D SLOT( slotSpellReady( KSpell * ) )); + SLOT( slotSpellReady( KSpell * ) ), d->mSpellConfig ); +} + +void KDictSpellingHighlighter::slotLocalSpellConfigChanged() +{ + // the spell config has been changed, so we have to restart from scrat= ch + d->mDict->clear(); + slotDictionaryChanged(); } =20 QString KDictSpellingHighlighter::spellKey() @@ -477,11 +514,13 @@ bool KDictSpellingHighlighter::eventFilt { // ### this is a joke, isn't it? Reparsing KGlobal::config() upon every f= ocus-in-event??? if (o =3D=3D textEdit() && (e->type() =3D=3D QEvent::FocusIn)) { =2D QString skey =3D spellKey(); =2D if ( d->spell && d->spellKey !=3D skey ) { =2D d->spellKey =3D skey; =2D KDictSpellingHighlighter::dictionaryChanged(); =2D } + if ( d->globalConfig ) { + QString skey =3D spellKey(); + if ( d->spell && d->spellKey !=3D skey ) { + d->spellKey =3D skey; + KDictSpellingHighlighter::dictionaryChanged(); + } + } } =20 if (o =3D=3D textEdit() && (e->type() =3D=3D QEvent::KeyPress)) { --Boundary-01=_JDwk/tk3Eyg2C5C Content-Type: text/x-diff; charset="us-ascii"; name="ksconfig.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ksconfig.diff" Index: ksconfig.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdelibs/kdeui/ksconfig.cpp,v retrieving revision 1.80 diff -u -3 -p -r1.80 ksconfig.cpp =2D-- ksconfig.cpp 30 Sep 2003 01:37:33 -0000 1.80 +++ ksconfig.cpp 19 Oct 2003 20:55:39 -0000 @@ -671,6 +671,14 @@ KSpellConfig::fillDicts( QComboBox* box=20 } } } + int whichelement =3D -1; + for ( unsigned int i =3D 0; i < langfnames.count(); ++i ) { + if ( langfnames[i] =3D=3D qsdict ) + whichelement =3D i; + } + if ( whichelement >=3D 0 ) { + box->setCurrentItem( whichelement ); + } } } =20 --Boundary-01=_JDwk/tk3Eyg2C5C-- --Boundary-03=_KDwk/6WBB0fAhd1 Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQA/kwDKGnR+RTDgudgRAoeSAKDQ5W91J1jwNCLyLm0/VEaIVaUscQCfetWq 0HHIDZYKsU+4SnZepB+24kY= =saX9 -----END PGP SIGNATURE----- --Boundary-03=_KDwk/6WBB0fAhd1--