diff --git a/charsetsDlg.cpp b/charsetsDlg.cpp index d5a4f1547..a34306968 100644 --- a/charsetsDlg.cpp +++ b/charsetsDlg.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ int i; QBoxLayout *mainl=new QVBoxLayout(this); QBoxLayout *buttonsl=new QHBoxLayout(); QBoxLayout *optl=new QHBoxLayout(); - KCharsets *charsets=kapp->getCharsets(); + KCharsets *charsets=KGlobal::charsets(); QLabel *l=new QLabel(i18n("Message charset"),this,"l1"); @@ -43,10 +43,9 @@ int i; messageCharset=new QComboBox(this,"c1"); mainl->addWidget(messageCharset); - QStrList lst=charsets->registered(); + QStringList lst=charsets->availableCharsetNames(); messageCharset->insertItem( "default" ); - for(const char *chset=lst.first();chset;chset=lst.next()) - messageCharset->insertItem( chset ); + messageCharset->insertStringList( lst ); int n=messageCharset->count(); for(i=0;itext(i),message)){ @@ -61,10 +60,9 @@ int i; composerCharset=new QComboBox(this,"c2"); mainl->addWidget(composerCharset); - QStrList lst1=charsets->displayable(); + QStringList lst1=charsets->availableCharsetNames(); composerCharset->insertItem( "default" ); - for(const char *chset=lst1.first();chset;chset=lst1.next()) - composerCharset->insertItem( chset ); + composerCharset->insertStringList( lst ); n=composerCharset->count(); for(i=0;itext(i),composer)){ diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index d321c1ff4..22f943fcd 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -224,7 +224,7 @@ void KMComposeWin::readConfig(void) mQuoteUnknownCharacters = config->readNumEntry("quote-unknown",0); str = config->readEntry("default-charset", ""); - if (str.isNull() || str=="default" || !KCharset(str).ok()) + if (str.isNull() || str=="default" || !KGlobal::charsets()->isAvailable(str)) mDefaultCharset="default"; else mDefaultCharset=str; @@ -232,7 +232,7 @@ void KMComposeWin::readConfig(void) debug("Default charset: %s", (const char*)mDefaultCharset); str = config->readEntry("composer-charset", ""); - if (str.isNull() || str=="default" || !KCharset(str).isDisplayable()) + if (str.isNull() || str=="default" || !KGlobal::charsets()->isAvailable(str)) mDefComposeCharset="default"; else mDefComposeCharset=str; @@ -746,16 +746,17 @@ void KMComposeWin::setMsg(KMMessage* newMsg, bool mayAutoSign) if (mCharset==""){ mComposeCharset=mDefComposeCharset; if (mComposeCharset=="default" - && KCharset(mDefaultCharset).isDisplayable()) + && KGlobal::charsets()->isAvailable(mDefaultCharset)) mComposeCharset=mDefaultCharset; } - else if (KCharset(mCharset).isDisplayable()) mComposeCharset=mCharset; + else if (KGlobal::charsets()->isAvailable(mCharset)) + mComposeCharset=mCharset; else mComposeCharset=mDefComposeCharset; cout<<"Compose charset: "<setText(convertToLocal(bodyPart.bodyDecoded())); -#else - mEditor->setText(QString(bodyPart.bodyDecoded())); + + // FIXME: We might need a QTextCodec here #endif + mEditor->setText(QString(bodyPart.bodyDecoded())); mEditor->insertLine("\n", -1); for(i=1; iisAvailable(mDefaultCharset)) mComposeCharset=mDefaultCharset; } - else if (KCharset(mCharset).isDisplayable()) mComposeCharset=mCharset; + else if (KGlobal::charsets()->isAvailable(mCharset)) + mComposeCharset=mCharset; else mComposeCharset=mDefComposeCharset; cout<<"Compose charset: "<setText(convertToLocal(mMsg->bodyDecoded())); + // FIXME: QTextCodec needed? + mEditor->setText(QString(mMsg->bodyDecoded())); } #else else mEditor->setText(QString(mMsg->bodyDecoded())); @@ -844,34 +847,28 @@ bool KMComposeWin::applyChanges(void) mMsg->setTypeStr("text"); mMsg->setSubtypeStr("plain"); mMsg->setCteStr("quoted-printable"); -#if defined CHARSETS - str=convertToSend(pgpProcessedMsg()); + str = pgpProcessedMsg(); if (str.isNull()) return FALSE; +#if defined CHARSETS + convertToSend(str); cout<<"Setting charset to: "<setCharset(mCharset); +#endif mMsg->setBodyEncoded(str); -#else - str = pgpProcessedMsg(); - if (str.isNull()) return FALSE; - mMsg->setBodyEncoded(str); -#endif } else { mMsg->setTypeStr("text"); mMsg->setSubtypeStr("plain"); mMsg->setCteStr("8bit"); -#if defined CHARSETS - str=convertToSend(pgpProcessedMsg()); + str = pgpProcessedMsg(); if (str.isNull()) return FALSE; +#if defined CHARSETS + convertToSend(str); cout<<"Setting charset to: "<setCharset(mCharset); +#endif mMsg->setBody(str); -#else - str = pgpProcessedMsg(); - if (str.isNull()) return FALSE; - mMsg->setBody(str); -#endif } } else @@ -892,7 +889,7 @@ bool KMComposeWin::applyChanges(void) str = pgpProcessedMsg(); if (str.isNull()) return FALSE; #if defined CHARSETS - str=convertToSend(str); + convertToSend(str); cout<<"Setting charset to: "<setCharset(mCharset); #endif @@ -1710,8 +1707,6 @@ void KMComposeWin::slotSetCharsets(const char *message,const char *composer, #if defined CHARSETS mCharset=message; m7BitAscii=ascii; - if (composer!=mComposeCharset && quote) - transcodeMessageTo(composer); mComposeCharset=composer; mQuoteUnknownCharacters=quote; if (def) @@ -1742,85 +1737,33 @@ bool KMComposeWin::is8Bit(const QString str) return FALSE; } - -//----------------------------------------------------------------------------- -QString KMComposeWin::convertToLocal(const QString str) -{ - if (m7BitAscii && !is8Bit(str)) return str.copy(); - KCharset destCharset; - KCharset srcCharset; - if (mCharset=="") - { - if (mDefaultCharset=="default") mCharset=klocale->charset(); - else mCharset=mDefaultCharset; - } - srcCharset=mCharset; - if (mComposeCharset=="default") destCharset=klocale->charset(); - else destCharset=mComposeCharset; - if (srcCharset==destCharset) return str.copy(); - int flags=mQuoteUnknownCharacters?KCharsetConverter::OUTPUT_AMP_SEQUENCES:0; - KCharsetConverter conv(srcCharset,destCharset,flags); - KCharsetConversionResult result=conv.convert(str); - return result.copy(); -} - //----------------------------------------------------------------------------- -QString KMComposeWin::convertToSend(const QString str) +void KMComposeWin::convertToSend(const QString str) { cout<<"Converting to send...\n"; if (m7BitAscii && !is8Bit(str)) { mCharset="us-ascii"; - return str.copy(); + return; } if (mCharset=="") { if (mDefaultCharset=="default") - mCharset=klocale->charset(); + mCharset=KGlobal::charsets()->charsetForLocale(); else mCharset=mDefaultCharset; } cout<<"mCharset: "<charset(); - else srcCharset=mComposeCharset; - cout<<"srcCharset: "<text(); - KCharset srcCharset; - KCharset destCharset(charset); - if (mComposeCharset=="default") srcCharset=klocale->charset(); - else srcCharset=mComposeCharset; - cout<<"srcCharset: "<setText(result.copy()); -} - - //----------------------------------------------------------------------------- void KMComposeWin::setEditCharset() { QFont fnt=mSavedEditorFont; - KCharset kcharset; - if (mComposeCharset=="default") kcharset=klocale->charset(); - else if (mComposeCharset!="") kcharset=mComposeCharset; - cout<<"Setting font to: "<setFont(kcharset.setQFont(fnt)); + if (mComposeCharset=="default") + mComposeCharset=KGlobal::charsets()->charsetForLocale(); + cout<<"Setting font to: "<setQFont(fnt, mComposeCharset); + mEditor->setFont(fnt); } #endif //CHARSETS diff --git a/kmcomposewin.h b/kmcomposewin.h index 4ca06c5b1..056aadee0 100644 --- a/kmcomposewin.h +++ b/kmcomposewin.h @@ -287,15 +287,8 @@ private: virtual const QString pgpProcessedMsg(void); #if defined CHARSETS - /** Convert message text for editing. - Converts message to mComposeCharset charset (if neccessary).*/ - QString convertToLocal(const QString str); - - /** Converts message text for sending. */ - QString convertToSend(const QString str); - /** Converts message text for sending. */ - void transcodeMessageTo(const QString newCharset); + void convertToSend(const QString str); /** Test if string has any 8-bit characters */ bool is8Bit(const QString str);