File r890882.diff of Package kdepim4

Subject: kmail: update detected encoding on inserting file in composer
From: wstephenson@suse.de
Bug: kde#88781
Patch-upstream: 890882
--- kmail/kmcomposewin.cpp	(revision 890881)
+++ kmail/kmcomposewin.cpp	(revision 890882)
@@ -2337,23 +2337,6 @@ void KMComposeWin::slotAttachFileResult(
         mEditor->textCursor().insertText( QString::fromLocal8Bit( loadData.data.data() ) );
     }
 
-    // If the user has set a custom encoding, check if that encoding can still encode
-    // the whole text. If not, change the encoding back to automatic.
-    if ( !mAutoCharset ) {
-      const QTextCodec *currentCodec = KMMsgBase::codecForName( mCharset );
-      if ( currentCodec ) {
-        QString editorText = mEditor->toPlainText();
-        QByteArray encodedText = currentCodec->fromUnicode( editorText );
-        if ( currentCodec->toUnicode( encodedText ) != editorText ) {
-          kDebug() << "Current encoding" << mCharset << "can't encode content, changing to auto.";
-          mEncodingAction->setCurrentItem( 0 );
-          slotSetCharset();
-        }
-      }
-      else
-        kWarning() << "No codec found for current encoding. How can this happen!?";
-    }
-
     mMapAtmLoadData.erase( it );
     if ( attachURLfound ) {
       emit attachmentAdded( attachUrl, true );
@@ -2480,15 +2463,17 @@ void KMComposeWin::slotAttachFileResult(
 void KMComposeWin::slotInsertFile()
 {
   QString encodingStr;
-  KUrl u = mEditor->insertFile(KMMsgBase::supportedEncodings(false),encodingStr );
-  if( u.isEmpty()) return;
+  KUrl u = mEditor->insertFile( KMMsgBase::supportedEncodings( false ),
+                                encodingStr );
+  if ( u.isEmpty() )
+    return;
 
   mRecentAction->addUrl(u);
   // Prevent race condition updating list when multiple composers are open
   {
     KConfig *config = KMKernel::config();
     KConfigGroup group( config, "Composer" );
-    QString encoding = KMMsgBase::encodingForName(encodingStr).toLatin1();
+    QString encoding = KMMsgBase::encodingForName( encodingStr ).toLatin1();
     QStringList urls = group.readEntry( "recent-urls", QStringList() );
     QStringList encodings = group.readEntry( "recent-encodings", QStringList() );
     // Prevent config file from growing without bound
--- libkdepim/kmeditor.cpp	(revision 890881)
+++ libkdepim/kmeditor.cpp	(revision 890882)
@@ -28,6 +28,7 @@
 #include <kpimidentities/signature.h>
 
 #include <kdeversion.h>
+#include <kabstractfilewidget.h>
 #include <KCharsets>
 #include <KComboBox>
 #include <KCursor>
@@ -500,23 +501,27 @@ KUrl KMeditor::insertFile( const QString
   fdlg.setOperationMode( KFileDialog::Opening );
   fdlg.okButton()->setText( i18n( "&Insert" ) );
   fdlg.setCaption( i18n( "Insert File" ) );
+
+  KComboBox *encodingCombo = 0;
   if ( !encodingLst.isEmpty() )
   {
-    KComboBox *combo = new KComboBox( this );
-    combo->addItems( encodingLst );
-    fdlg.toolBar()->addWidget( combo );
-    for ( int i = 0; i < combo->count(); i++ )
+    encodingCombo = new KComboBox( this );
+    encodingCombo->addItems( encodingLst );
+    // FIXME: after lifted string freeze: add back "Encoding" string
+    fdlg.fileWidget()->setCustomWidget( /*i18n( "Encoding:" )*/QString(), encodingCombo );
+    for ( int i = 0; i < encodingCombo->count(); i++ )
       if ( KGlobal::charsets()->codecForName( KGlobal::charsets()->
-                                       encodingForName( combo->itemText( i ) ) )
+                                       encodingForName( encodingCombo->itemText( i ) ) )
            == QTextCodec::codecForLocale() )
-        combo->setCurrentIndex(i);
-    encodingStr = combo->currentText();
+        encodingCombo->setCurrentIndex(i);
   }
   if ( !fdlg.exec() )
     return KUrl();
-
-  KUrl u = fdlg.selectedUrl();
-  return u;
+  else {
+    if ( encodingCombo )
+      encodingStr = encodingCombo->currentText();
+    return fdlg.selectedUrl();
+  }
 }
 
 void KMeditor::enableWordWrap( int wrapColumn )
Index: kmail/kmcomposewin.cpp
===================================================================
Index: libkdepim/kmeditor.cpp
===================================================================
openSUSE Build Service is sponsored by