[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: Two more problems with HEAD
From:       "Aaron J. Seigo" <aseigo () mountlinux ! com>
Date:       2001-09-02 6:38:02
[Download RAW message or body]

hi..

> Actually I wonder how that ever worked correctely, since the destructive
> close is not the last command in KMComposeWin::doSend(), but even moving it
> at the end doesn't help. However replacing it with "hide(); delete this;"
> doesn't crash for some strange reason.
> Any ideas?

could it perhaps be because all the widgets in kmcomposewin are created on 
the stack? i took a look and was suprised to see all the widgets initialized 
in the ctor initialization list, but after looking at the header file i 
realized that they are indeed actual objects and not pointers...

Qt really doesn't like it when you put a widget on the stack, because it 
later tries to delete it from its parent widget's dtor and ... well .. of 
course that doesn't work well.. this would also explain the useless 
backtraces you were getting =) i'm actually surprised it worked at all?

please test the attatched patch.. it compiles, but i haven't got my Qt3 
install up and working properly yet for testing.

-- 
Aaron Seigo
["kmcomposewin.diff" (text/x-diff)]

Index: kmcomposewin.h
===================================================================
RCS file: /home/projects/kdecvs/cvsroot/kdenetwork/kmail/kmcomposewin.h,v
retrieving revision 1.123
diff -u -3 -d -p -r1.123 kmcomposewin.h
--- kmcomposewin.h	2001/08/30 11:55:12	1.123
+++ kmcomposewin.h	2001/09/03 18:23:04
@@ -427,14 +427,14 @@ protected:
   /**
    * Header fields.
    */
-    QString subject(void) const { return mEdtSubject.text(); }
-    QString to(void) const { return mEdtTo.text(); }
+    QString subject(void) const { return mEdtSubject->text(); }
+    QString to(void) const { return mEdtTo->text(); }
     QString cc(void) const
-   { return (mEdtCc.isHidden()) ? QString() : mEdtCc.text(); }
+   { return (mEdtCc->isHidden()) ? QString() : mEdtCc->text(); }
     QString bcc(void) const
-   { return (mEdtBcc.isHidden()) ? QString() : mEdtBcc.text(); }
-    QString from(void) const { return mEdtFrom.text(); }
-    QString replyTo(void) const { return mEdtReplyTo.text(); }
+   { return (mEdtBcc->isHidden()) ? QString() : mEdtBcc->text(); }
+    QString from(void) const { return mEdtFrom->text(); }
+    QString replyTo(void) const { return mEdtReplyTo->text(); }
 
   /**
    * Ask for confirmation if the message was changed before close.
@@ -484,13 +484,13 @@ private:
   QCString defaultCharset(void) const;
 
 protected:
-  QWidget   mMainWidget;
-  QComboBox mIdentity, mTransport;
-  KMLineEdit mEdtFrom, mEdtReplyTo, mEdtTo, mEdtCc, mEdtBcc, mEdtSubject;
-  QLabel    mLblIdentity, mLblTransport;
-  QLabel    mLblFrom, mLblReplyTo, mLblTo, mLblCc, mLblBcc, mLblSubject;
-  QCheckBox mBtnIdentity, mBtnTransport;
-  QPushButton mBtnTo, mBtnCc, mBtnBcc, mBtnFrom, mBtnReplyTo;
+  QWidget   *mMainWidget;
+  QComboBox *mIdentity, *mTransport;
+  KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc, *mEdtSubject;
+  QLabel    *mLblIdentity, *mLblTransport;
+  QLabel    *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
+  QCheckBox *mBtnIdentity, *mBtnTransport;
+  QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnFrom, *mBtnReplyTo;
   bool mSpellCheckInProgress;
   bool mDone;
 
Index: kmcomposewin.cpp
===================================================================
RCS file: /home/projects/kdecvs/cvsroot/kdenetwork/kmail/kmcomposewin.cpp,v
retrieving revision 1.381
diff -u -3 -d -p -r1.381 kmcomposewin.cpp
--- kmcomposewin.cpp	2001/09/01 13:15:03	1.381
+++ kmcomposewin.cpp	2001/09/03 18:23:04
@@ -64,7 +64,7 @@
 #include <qtabdialog.h>
 #include <qlabel.h>
 #include <qlayout.h>
-#include <qptrlist.h>
+#include <qlist.h>
 #include <qpainter.h>
 #include <qpixmap.h>
 #include <qregexp.h>
@@ -87,24 +87,33 @@
 
 //-----------------------------------------------------------------------------
 KMComposeWin::KMComposeWin(KMMessage *aMsg, QString id )
-  : KMTopLevelWidget (), MailComposerIface(),
-  mMainWidget(this),
-  mIdentity(&mMainWidget), mTransport(true, &mMainWidget),
-  mEdtFrom(this,false,&mMainWidget), mEdtReplyTo(this,false,&mMainWidget),
-  mEdtTo(this,true,&mMainWidget),  mEdtCc(this,true,&mMainWidget),
-  mEdtBcc(this,true,&mMainWidget),
-  mEdtSubject(this,false,&mMainWidget, "subjectLine"),
-  mLblIdentity(&mMainWidget), mLblTransport(&mMainWidget),
-  mLblFrom(&mMainWidget), mLblReplyTo(&mMainWidget), mLblTo(&mMainWidget),
-  mLblCc(&mMainWidget), mLblBcc(&mMainWidget), mLblSubject(&mMainWidget),
-  mBtnIdentity(i18n("Sticky"),&mMainWidget),
-  mBtnTransport(i18n("Sticky"),&mMainWidget),
-  mBtnTo("...",&mMainWidget), mBtnCc("...",&mMainWidget),
-  mBtnBcc("...",&mMainWidget),  mBtnFrom("...",&mMainWidget),
-  mBtnReplyTo("...",&mMainWidget),
-  mId( id )
-
+  : KMTopLevelWidget (), MailComposerIface(), mId( id )
 {
+  mMainWidget = new QWidget(this);
+  
+  mIdentity = new QComboBox(mMainWidget);
+  mTransport = new QComboBox(true, mMainWidget);
+  mEdtFrom = new KMLineEdit(this,false,mMainWidget);
+  mEdtReplyTo = new KMLineEdit(this,false,mMainWidget);
+  mEdtTo = new KMLineEdit(this,true,mMainWidget);
+  mEdtCc = new KMLineEdit(this,true,mMainWidget);
+  mEdtBcc = new KMLineEdit(this,true,mMainWidget);
+  mEdtSubject = new KMLineEdit(this,false,mMainWidget, "subjectLine");
+  mLblIdentity = new QLabel(mMainWidget); 
+  mLblTransport = new QLabel(mMainWidget);
+  mLblFrom = new QLabel(mMainWidget);
+  mLblReplyTo = new QLabel(mMainWidget);
+  mLblTo = new QLabel(mMainWidget);
+  mLblCc = new QLabel(mMainWidget);
+  mLblBcc = new QLabel(mMainWidget);
+  mLblSubject = new QLabel(mMainWidget);
+  mBtnIdentity = new QCheckBox(i18n("Sticky"),mMainWidget);
+  mBtnTransport = new QCheckBox(i18n("Sticky"),mMainWidget);
+  mBtnTo = new QPushButton("...",mMainWidget); 
+  mBtnCc = new QPushButton("...",mMainWidget);
+  mBtnBcc = new QPushButton("...",mMainWidget);
+  mBtnFrom = new QPushButton("...",mMainWidget);
+  mBtnReplyTo = new QPushButton("...",mMainWidget);
   //setWFlags( WType_TopLevel | WStyle_Dialog );
   mDone = false;
   mGrid = NULL;
@@ -113,27 +122,27 @@ KMComposeWin::KMComposeWin(KMMessage *aM
   mAtmTempList.setAutoDelete(TRUE);
   mAutoDeleteMsg = FALSE;
   mFolder = NULL;
-  mEditor = new KMEdit(&mMainWidget, this);
+  mEditor = new KMEdit(mMainWidget, this);
   disableBreaking = false;
   QString tip = i18n("Select email address(es)");
-  QToolTip::add( &mBtnTo, tip );
-  QToolTip::add( &mBtnCc, tip );
-  QToolTip::add( &mBtnReplyTo, tip );
+  QToolTip::add( mBtnTo, tip );
+  QToolTip::add( mBtnCc, tip );
+  QToolTip::add( mBtnReplyTo, tip );
 
   mSpellCheckInProgress=FALSE;
 
   setCaption( i18n("Composer") );
   setMinimumSize(200,200);
 
-  mBtnIdentity.setFocusPolicy(QWidget::NoFocus);
-  mBtnTransport.setFocusPolicy(QWidget::NoFocus);
-  mBtnTo.setFocusPolicy(QWidget::NoFocus);
-  mBtnCc.setFocusPolicy(QWidget::NoFocus);
-  mBtnBcc.setFocusPolicy(QWidget::NoFocus);
-  mBtnFrom.setFocusPolicy(QWidget::NoFocus);
-  mBtnReplyTo.setFocusPolicy(QWidget::NoFocus);
+  mBtnIdentity->setFocusPolicy(QWidget::NoFocus);
+  mBtnTransport->setFocusPolicy(QWidget::NoFocus);
+  mBtnTo->setFocusPolicy(QWidget::NoFocus);
+  mBtnCc->setFocusPolicy(QWidget::NoFocus);
+  mBtnBcc->setFocusPolicy(QWidget::NoFocus);
+  mBtnFrom->setFocusPolicy(QWidget::NoFocus);
+  mBtnReplyTo->setFocusPolicy(QWidget::NoFocus);
 
-  mAtmListBox = new QListView(&mMainWidget, "mAtmListBox");
+  mAtmListBox = new QListView(mMainWidget, "mAtmListBox");
   mAtmListBox->setFocusPolicy(QWidget::NoFocus);
   mAtmListBox->addColumn(i18n("Name"), 200);
   mAtmListBox->addColumn(i18n("Size"), 80);
@@ -151,28 +160,28 @@ KMComposeWin::KMComposeWin(KMMessage *aM
   toolbarAction->setChecked(!toolBar()->isHidden());
   statusbarAction->setChecked(!statusBar()->isHidden());
 
-  connect(&mEdtSubject,SIGNAL(textChanged(const QString&)),
+  connect(mEdtSubject,SIGNAL(textChanged(const QString&)),
 	  SLOT(slotUpdWinTitle(const QString&)));
-  connect(&mBtnTo,SIGNAL(clicked()),SLOT(slotAddrBookTo()));
-  connect(&mBtnCc,SIGNAL(clicked()),SLOT(slotAddrBookCc()));
-  connect(&mBtnBcc,SIGNAL(clicked()),SLOT(slotAddrBookBcc()));
-  connect(&mBtnReplyTo,SIGNAL(clicked()),SLOT(slotAddrBookReplyTo()));
-  connect(&mBtnFrom,SIGNAL(clicked()),SLOT(slotAddrBookFrom()));
-  connect(&mIdentity,SIGNAL(activated(int)),SLOT(slotIdentityActivated(int)));
+  connect(mBtnTo,SIGNAL(clicked()),SLOT(slotAddrBookTo()));
+  connect(mBtnCc,SIGNAL(clicked()),SLOT(slotAddrBookCc()));
+  connect(mBtnBcc,SIGNAL(clicked()),SLOT(slotAddrBookBcc()));
+  connect(mBtnReplyTo,SIGNAL(clicked()),SLOT(slotAddrBookReplyTo()));
+  connect(mBtnFrom,SIGNAL(clicked()),SLOT(slotAddrBookFrom()));
+  connect(mIdentity,SIGNAL(activated(int)),SLOT(slotIdentityActivated(int)));
 
-  connect(&mEdtTo,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+  connect(mEdtTo,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
           SLOT(slotCompletionModeChanged(KGlobalSettings::Completion)));
-  connect(&mEdtCc,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+  connect(mEdtCc,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
           SLOT(slotCompletionModeChanged(KGlobalSettings::Completion)));
-  connect(&mEdtBcc,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+  connect(mEdtBcc,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
           SLOT(slotCompletionModeChanged(KGlobalSettings::Completion)));
-  connect(&mEdtReplyTo,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+  connect(mEdtReplyTo,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
           SLOT(slotCompletionModeChanged(KGlobalSettings::Completion)));
-  connect(&mEdtFrom,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
+  connect(mEdtFrom,SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
           SLOT(slotCompletionModeChanged(KGlobalSettings::Completion)));
 
-  mMainWidget.resize(480,510);
-  setCentralWidget(&mMainWidget);
+  mMainWidget->resize(480,510);
+  setCentralWidget(mMainWidget);
   rethinkFields();
 
   if (useExtEditor) {
@@ -187,7 +196,7 @@ KMComposeWin::KMComposeWin(KMMessage *aM
   if (aMsg)
     setMsg(aMsg);
 
-  mEdtTo.setFocus();
+  mEdtTo->setFocus();
   mDone = true;
 }
 
@@ -330,13 +339,13 @@ void KMComposeWin::readColorConfig(void)
   mPalette.setActive(cgrp);
   mPalette.setInactive(cgrp);
 
-  mEdtTo.setPalette(mPalette);
-  mEdtFrom.setPalette(mPalette);
-  mEdtCc.setPalette(mPalette);
-  mEdtSubject.setPalette(mPalette);
-  mEdtReplyTo.setPalette(mPalette);
-  mEdtBcc.setPalette(mPalette);
-  mTransport.setPalette(mPalette);
+  mEdtTo->setPalette(mPalette);
+  mEdtFrom->setPalette(mPalette);
+  mEdtCc->setPalette(mPalette);
+  mEdtSubject->setPalette(mPalette);
+  mEdtReplyTo->setPalette(mPalette);
+  mEdtBcc->setPalette(mPalette);
+  mTransport->setPalette(mPalette);
   mEditor->setPalette(mPalette);
 }
 
@@ -356,9 +365,9 @@ void KMComposeWin::readConfig(void)
   else
   {
     mDefCharset = str;
-/*    if ( !KGlobal::charsets()->isAvailable(   obsolete with QT3
+    if ( !KGlobal::charsets()->isAvailable(
       KGlobal::charsets()->charsetForEncoding(mDefCharset)) )
-        mDefCharset = "default"; */
+        mDefCharset = "default";
   }
 
   kdDebug(5006) << "Default charset: " << mDefCharset << endl;
@@ -368,10 +377,10 @@ void KMComposeWin::readConfig(void)
   mShowHeaders = config->readNumEntry("headers", HDR_STANDARD);
   mWordWrap = config->readNumEntry("word-wrap", 1);
   mLineBreak = config->readNumEntry("break-at", 78);
-  mBtnIdentity.setChecked(config->readBoolEntry("sticky-identity", false));
-  if (mBtnIdentity.isChecked())
+  mBtnIdentity->setChecked(config->readBoolEntry("sticky-identity", false));
+  if (mBtnIdentity->isChecked())
     mId = config->readEntry("previous-identity", mId );
-  mBtnTransport.setChecked(config->readBoolEntry("sticky-transport", false));
+  mBtnTransport->setChecked(config->readBoolEntry("sticky-transport", false));
   mTransportHistory = config->readListEntry("transport-history");
   maxTransportItems = config->readNumEntry("max-transport-items",10);
 
@@ -384,11 +393,11 @@ void KMComposeWin::readConfig(void)
 
   int mode = config->readNumEntry("Completion Mode",
                                   KGlobalSettings::completionMode() );
-  mEdtFrom.setCompletionMode( (KGlobalSettings::Completion) mode );
-  mEdtReplyTo.setCompletionMode( (KGlobalSettings::Completion) mode );
-  mEdtTo.setCompletionMode( (KGlobalSettings::Completion) mode );
-  mEdtCc.setCompletionMode( (KGlobalSettings::Completion) mode );
-  mEdtBcc.setCompletionMode( (KGlobalSettings::Completion) mode );
+  mEdtFrom->setCompletionMode( (KGlobalSettings::Completion) mode );
+  mEdtReplyTo->setCompletionMode( (KGlobalSettings::Completion) mode );
+  mEdtTo->setCompletionMode( (KGlobalSettings::Completion) mode );
+  mEdtCc->setCompletionMode( (KGlobalSettings::Completion) mode );
+  mEdtBcc->setCompletionMode( (KGlobalSettings::Completion) mode );
 
   readColorConfig();
 
@@ -441,22 +450,22 @@ void KMComposeWin::readConfig(void)
     resize(siz);
   }
 
-  mIdentity.clear();
-  mIdentity.insertStringList( KMIdentity::identities() );
-  for (int i=0; i < mIdentity.count(); ++i)
-    if (mIdentity.text(i) == mId) {
-      mIdentity.setCurrentItem(i);
+  mIdentity->clear();
+  mIdentity->insertStringList( KMIdentity::identities() );
+  for (int i=0; i < mIdentity->count(); ++i)
+    if (mIdentity->text(i) == mId) {
+      mIdentity->setCurrentItem(i);
       break;
     }
 
-  if (!mBtnTransport.isChecked() || mTransportHistory.isEmpty()) {
+  if (!mBtnTransport->isChecked() || mTransportHistory.isEmpty()) {
     QString curTransport = kernel->msgSender()->transportString();
     mTransportHistory.remove( curTransport );
     mTransportHistory.prepend( curTransport );
   }
   while (mTransportHistory.count() > (uint)maxTransportItems)
     mTransportHistory.remove( mTransportHistory.last());
-  mTransport.insertStringList( mTransportHistory );
+  mTransport->insertStringList( mTransportHistory );
 }
 
 
@@ -470,11 +479,11 @@ void KMComposeWin::writeConfig(void)
     KConfigGroupSaver saver(config, "Composer");
     config->writeEntry("signature", mAutoSign?"auto":"manual");
     config->writeEntry("headers", mShowHeaders);
-    config->writeEntry("sticky-transport", mBtnTransport.isChecked());
-    config->writeEntry("sticky-identity", mBtnIdentity.isChecked());
-    config->writeEntry("previous-identity", mIdentity.currentText() );
-    mTransportHistory.remove(mTransport.currentText());
-    mTransportHistory.prepend(mTransport.currentText());
+    config->writeEntry("sticky-transport", mBtnTransport->isChecked());
+    config->writeEntry("sticky-identity", mBtnIdentity->isChecked());
+    config->writeEntry("previous-identity", mIdentity->currentText() );
+    mTransportHistory.remove(mTransport->currentText());
+    mTransportHistory.prepend(mTransport->currentText());
     config->writeEntry("transport-history", mTransportHistory );
   }
 
@@ -594,7 +603,7 @@ void KMComposeWin::rethinkFields(bool fr
   numRows = mNumHeaders + 2;
 
   if (mGrid) delete mGrid;
-  mGrid = new QGridLayout(&mMainWidget, numRows, 3, 4, 4);
+  mGrid = new QGridLayout(mMainWidget, numRows, 3, 4, 4);
   mGrid->setColStretch(0, 1);
   mGrid->setColStretch(1, 100);
   mGrid->setColStretch(2, 1);
@@ -607,28 +616,28 @@ void KMComposeWin::rethinkFields(bool fr
 
   if (!fromSlot) identityAction->setChecked(abs(mShowHeaders)&HDR_IDENTITY);
   rethinkHeaderLine(showHeaders,HDR_IDENTITY, row, i18n("&Identity:"),
-		    &mLblIdentity, &mIdentity, &mBtnIdentity);
+		    mLblIdentity, mIdentity, mBtnIdentity);
   if (!fromSlot) transportAction->setChecked(abs(mShowHeaders)&HDR_TRANSPORT);
   rethinkHeaderLine(showHeaders,HDR_TRANSPORT, row, i18n("Mai&l Transport:"),
-		    &mLblTransport, &mTransport, &mBtnTransport);
+		    mLblTransport, mTransport, mBtnTransport);
   if (!fromSlot) fromAction->setChecked(abs(mShowHeaders)&HDR_FROM);
   rethinkHeaderLine(showHeaders,HDR_FROM, row, i18n("Fro&m:"),
-		    &mLblFrom, &mEdtFrom, &mBtnFrom);
+		    mLblFrom, mEdtFrom, mBtnFrom);
   if (!fromSlot) replyToAction->setChecked(abs(mShowHeaders)&HDR_REPLY_TO);
   rethinkHeaderLine(showHeaders,HDR_REPLY_TO,row,i18n("&Reply to:"),
-		    &mLblReplyTo, &mEdtReplyTo, &mBtnReplyTo);
+		    mLblReplyTo, mEdtReplyTo, mBtnReplyTo);
   if (!fromSlot) toAction->setChecked(abs(mShowHeaders)&HDR_TO);
   rethinkHeaderLine(showHeaders,HDR_TO, row, i18n("&To:"),
-		    &mLblTo, &mEdtTo, &mBtnTo);
+		    mLblTo, mEdtTo, mBtnTo);
   if (!fromSlot) ccAction->setChecked(abs(mShowHeaders)&HDR_CC);
   rethinkHeaderLine(showHeaders,HDR_CC, row, i18n("&Cc:"),
-		    &mLblCc, &mEdtCc, &mBtnCc);
+		    mLblCc, mEdtCc, mBtnCc);
   if (!fromSlot) bccAction->setChecked(abs(mShowHeaders)&HDR_BCC);
   rethinkHeaderLine(showHeaders,HDR_BCC, row, i18n("&Bcc:"),
-		    &mLblBcc, &mEdtBcc, &mBtnBcc);
+		    mLblBcc, mEdtBcc, mBtnBcc);
   if (!fromSlot) subjectAction->setChecked(abs(mShowHeaders)&HDR_SUBJECT);
   rethinkHeaderLine(showHeaders,HDR_SUBJECT, row, i18n("S&ubject:"),
-		    &mLblSubject, &mEdtSubject);
+		    mLblSubject, mEdtSubject);
   assert(row<=mNumHeaders);
 
   mGrid->addMultiCellWidget(mEditor, row, mNumHeaders, 0, 2);
@@ -1012,25 +1021,25 @@ void KMComposeWin::setMsg(KMMessage* new
     }
   mMsg = newMsg;
 
-  mEdtTo.setText(mMsg->to());
-  mEdtFrom.setText(mMsg->from());
-  mEdtCc.setText(mMsg->cc());
-  mEdtSubject.setText(mMsg->subject());
-  mEdtReplyTo.setText(mMsg->replyTo());
-  mEdtBcc.setText(mMsg->bcc());
+  mEdtTo->setText(mMsg->to());
+  mEdtFrom->setText(mMsg->from());
+  mEdtCc->setText(mMsg->cc());
+  mEdtSubject->setText(mMsg->subject());
+  mEdtReplyTo->setText(mMsg->replyTo());
+  mEdtBcc->setText(mMsg->bcc());
 
-  if (!mBtnIdentity.isChecked() && !newMsg->headerField("X-KMail-Identity").isEmpty())
+  if (!mBtnIdentity->isChecked() && !newMsg->headerField("X-KMail-Identity").isEmpty())
     mId = newMsg->headerField("X-KMail-Identity");
 
-  for (int i=0; i < mIdentity.count(); ++i)
-    if (mIdentity.text(i) == mId) {
-      mIdentity.setCurrentItem(i);
-      if (mBtnIdentity.isChecked()) slotIdentityActivated(i);
+  for (int i=0; i < mIdentity->count(); ++i)
+    if (mIdentity->text(i) == mId) {
+      mIdentity->setCurrentItem(i);
+      if (mBtnIdentity->isChecked()) slotIdentityActivated(i);
       break;
     }
 
   // get PGP user id for the currently selected identity
-  KMIdentity ident(mIdentity.currentText());
+  KMIdentity ident(mIdentity->currentText());
   ident.readConfig();
   QString pgpUserId = ident.pgpIdentity();
 
@@ -1048,8 +1057,8 @@ void KMComposeWin::setMsg(KMMessage* new
   }
 
   QString transport = newMsg->headerField("X-KMail-Transport");
-  if (!mBtnTransport.isChecked() && !transport.isEmpty())
-    mTransport.insertItem( transport, 0 );
+  if (!mBtnTransport->isChecked() && !transport.isEmpty())
+    mTransport->insertItem( transport, 0 );
 
   num = mMsg->numBodyParts();
 
@@ -1156,9 +1165,9 @@ bool KMComposeWin::applyChanges(void)
   mMsg->setReplyTo(replyTo());
   mMsg->setBcc(bcc());
 
-  if (mIdentity.currentText() == i18n("Default"))
+  if (mIdentity->currentText() == i18n("Default"))
     mMsg->removeHeaderField("X-KMail-Identity");
-  else mMsg->setHeaderField("X-KMail-Identity", mIdentity.currentText());
+  else mMsg->setHeaderField("X-KMail-Identity", mIdentity->currentText());
 
   if (!replyTo().isEmpty()) replyAddr = replyTo();
   else replyAddr = from();
@@ -1237,14 +1246,14 @@ bool KMComposeWin::applyChanges(void)
       mMsg->addBodyPart(msgPart);
   }
   if (!mAutoDeleteMsg) mEditor->setModified(FALSE);
-  mEdtFrom.setEdited(FALSE);
-  mEdtReplyTo.setEdited(FALSE);
-  mEdtTo.setEdited(FALSE);
-  mEdtCc.setEdited(FALSE);
-  mEdtBcc.setEdited(FALSE);
-  mEdtSubject.setEdited(FALSE);
-  if (mTransport.lineEdit())
-    mTransport.lineEdit()->setEdited(FALSE);
+  mEdtFrom->setEdited(FALSE);
+  mEdtReplyTo->setEdited(FALSE);
+  mEdtTo->setEdited(FALSE);
+  mEdtCc->setEdited(FALSE);
+  mEdtBcc->setEdited(FALSE);
+  mEdtSubject->setEdited(FALSE);
+  if (mTransport->lineEdit())
+    mTransport->lineEdit()->setEdited(FALSE);
 
   // remove fields that contain no data (e.g. an empty Cc: or Bcc:)
   mMsg->cleanupHeader();
@@ -1257,10 +1266,10 @@ bool KMComposeWin::queryClose ()
 {
   int rc;
 
-  if(mEditor->isModified() || mEdtFrom.edited() || mEdtReplyTo.edited() ||
-     mEdtTo.edited() || mEdtCc.edited() || mEdtBcc.edited() ||
-     mEdtSubject.edited() ||
-     (mTransport.lineEdit() && mTransport.lineEdit()->edited()))
+  if(mEditor->isModified() || mEdtFrom->edited() || mEdtReplyTo->edited() ||
+     mEdtTo->edited() || mEdtCc->edited() || mEdtBcc->edited() ||
+     mEdtSubject->edited() ||
+     (mTransport->lineEdit() && mTransport->lineEdit()->edited()))
   {
     rc = KMessageBox::warningYesNoCancel(this,
            i18n("Do you want to discard the message or save it for later?"),
@@ -1571,35 +1580,35 @@ void KMComposeWin::slotAddrBook()
 //-----------------------------------------------------------------------------
 void KMComposeWin::slotAddrBookFrom()
 {
-  addrBookSelInto(&mEdtFrom);
+  addrBookSelInto(mEdtFrom);
 }
 
 
 //-----------------------------------------------------------------------------
 void KMComposeWin::slotAddrBookReplyTo()
 {
-  addrBookSelInto(&mEdtReplyTo);
+  addrBookSelInto(mEdtReplyTo);
 }
 
 
 //-----------------------------------------------------------------------------
 void KMComposeWin::slotAddrBookTo()
 {
-  addrBookSelInto(&mEdtTo);
+  addrBookSelInto(mEdtTo);
 }
 
 
 //-----------------------------------------------------------------------------
 void KMComposeWin::slotAddrBookCc()
 {
-  addrBookSelInto(&mEdtCc);
+  addrBookSelInto(mEdtCc);
 }
 
 
 //-----------------------------------------------------------------------------
 void KMComposeWin::slotAddrBookBcc()
 {
-  addrBookSelInto(&mEdtBcc);
+  addrBookSelInto(mEdtBcc);
 }
 
 
@@ -2110,9 +2119,9 @@ void KMComposeWin::doSend(int aSendNow, 
   // rectify the problem by editing their outgoing preferences and
   // resending.
   // Hence this following conditional
-  if ((mTransport.currentText() != kernel->msgSender()->transportString()) ||
+  if ((mTransport->currentText() != kernel->msgSender()->transportString()) ||
       (!hf.isEmpty() && (hf != kernel->msgSender()->transportString())))
-    mMsg->setHeaderField("X-KMail-Transport", mTransport.currentText());
+    mMsg->setHeaderField("X-KMail-Transport", mTransport->currentText());
 
   disableBreaking = saveInDrafts;
   if (saveInDrafts)
@@ -2141,10 +2150,10 @@ void KMComposeWin::doSend(int aSendNow, 
   // with minimal code changes.  If you want to add more warning boxes
   // (say if the From: field is empty), then you will need to modify this.
   if (!editSubject) {
-    if (mEdtTo.text().stripWhiteSpace().isEmpty())
-      mEdtTo.setFocus();
+    if (mEdtTo->text().stripWhiteSpace().isEmpty())
+      mEdtTo->setFocus();
     else
-      mEdtSubject.setFocus();
+      mEdtSubject->setFocus();
   }
 
   busy = false;
@@ -2170,7 +2179,7 @@ void KMComposeWin::slotSaveDraft()
 void KMComposeWin::slotSendNow()
 {
   if (mConfirmSend) {
-    switch(KMessageBox::warningYesNoCancel(&mMainWidget,
+    switch(KMessageBox::warningYesNoCancel(mMainWidget,
                                     i18n("About to send email..."),
                                     i18n("Send Confirmation"),
                                     i18n("Send &Now"),
@@ -2294,8 +2303,19 @@ void KMComposeWin::slotSpellcheckDone()
 //-----------------------------------------------------------------------------
 void KMComposeWin::setEditCharset()
 {
+  QFont fnt=mSavedEditorFont;
   if (mCharset == "default" || mCharset.isEmpty())
     mCharset = defaultCharset();
+  QString cset = mCharset;
+  if (mUnicodeFont) cset = "iso10646-1";
+  fnt.setCharSet(KGlobal::charsets()->charsetForEncoding(cset));
+  mEditor->setFont(fnt);
+  mEdtFrom->setFont(fnt);
+  mEdtReplyTo->setFont(fnt);
+  mEdtTo->setFont(fnt);
+  mEdtCc->setFont(fnt);
+  mEdtBcc->setFont(fnt);
+  mEdtSubject->setFont(fnt);
 }
 
 //-----------------------------------------------------------------------------
@@ -2306,7 +2326,7 @@ QCString KMComposeWin::defaultCharset(vo
   // however KGlobal::locale->charset() has a fallback value of iso-8859-1,
   // we try to be smarter
   QCString aStr = QTextCodec::codecForLocale()->name();
-/*  if ((retval == "iso-8859-1") && (aStr != "ISO 8859-1"))
+  if ((retval == "iso-8859-1") && (aStr != "ISO 8859-1"))
   {
     // read locale if it really gives iso-8859-1
     KConfig *globalConfig = KGlobal::instance()->config();
@@ -2328,7 +2348,7 @@ QCString KMComposeWin::defaultCharset(vo
     }
     //we should be pretty safe: still if sth goes wrong we return iso-8859-1
   }
-  else */ if (retval == "jisx0208.1983-0") retval = "iso-2022-jp";
+  else if (retval == "jisx0208.1983-0") retval = "iso-2022-jp";
   else if (retval == "ksc5601.1987-0") retval = "euc-kr";
   return retval;
 }
@@ -2357,18 +2377,18 @@ void KMComposeWin::focusNextPrevEdit(con
 //-----------------------------------------------------------------------------
 void KMComposeWin::slotIdentityActivated(int)
 {
-  QString identStr = mIdentity.currentText();
+  QString identStr = mIdentity->currentText();
   if (!KMIdentity::identities().contains(identStr))
     return;
   KMIdentity ident(identStr);
   ident.readConfig();
 
   if(!ident.fullEmailAddr().isNull())
-    mEdtFrom.setText(ident.fullEmailAddr());
+    mEdtFrom->setText(ident.fullEmailAddr());
   if(!ident.replyToAddr().isNull())
-    mEdtReplyTo.setText(ident.replyToAddr());
+    mEdtReplyTo->setText(ident.replyToAddr());
   else
-    mEdtReplyTo.setText("");
+    mEdtReplyTo->setText("");
   if (ident.organization().isEmpty())
     mMsg->removeHeaderField("Organization");
   else
@@ -2377,7 +2397,7 @@ void KMComposeWin::slotIdentityActivated
   QString edtText = mEditor->text();
   int pos = edtText.findRev( "\n-- \n" + mOldSigText);
 
-  if (!mBtnTransport.isChecked()) {
+  if (!mBtnTransport->isChecked()) {
     if (ident.transport().isEmpty())
       mMsg->removeHeaderField("X-KMail-Transport");
     else
@@ -2386,17 +2406,17 @@ void KMComposeWin::slotIdentityActivated
     if (transp.isEmpty()) transp = kernel->msgSender()->transportString();
     bool found = false;
     int i;
-    for (i = 0; i < mTransport.count(); i++) {
-      if (mTransport.text(i) == transp) {
+    for (i = 0; i < mTransport->count(); i++) {
+      if (mTransport->text(i) == transp) {
         found = true;
-        mTransport.setCurrentItem(i);
+        mTransport->setCurrentItem(i);
         break;
       }
     }
     if (found == false) {
-      if (i == mTransport.maxCount()) mTransport.setMaxCount(i + 1);
-      mTransport.insertItem(transp,i);
-      mTransport.setCurrentItem(i);
+      if (i == mTransport->maxCount()) mTransport->setMaxCount(i + 1);
+      mTransport->insertItem(transp,i);
+      mTransport->setCurrentItem(i);
     }
   }
 
@@ -2498,11 +2518,11 @@ void KMComposeWin::slotCompletionModeCha
     config->sync(); // maybe not?
 
     // sync all the lineedits to the same completion mode
-    mEdtFrom.setCompletionMode( mode );
-    mEdtReplyTo.setCompletionMode( mode );
-    mEdtTo.setCompletionMode( mode );
-    mEdtCc.setCompletionMode( mode );
-    mEdtBcc.setCompletionMode( mode );
+    mEdtFrom->setCompletionMode( mode );
+    mEdtReplyTo->setCompletionMode( mode );
+    mEdtTo->setCompletionMode( mode );
+    mEdtCc->setCompletionMode( mode );
+    mEdtBcc->setCompletionMode( mode );
 }
 
 //=============================================================================
@@ -2830,10 +2850,9 @@ QString KMEdit::brokenText() const
 {
     QString temp;
 
-    int num_lines = numLines();
-    for (int i = 0; i < num_lines; ++i) {
-      temp += textLine(i);
-      if (i + 1 < num_lines)
+    for (int i = 0; i < numLines(); ++i) {
+      temp += *getString(i);
+      if (i + 1 < numLines())
 	temp += '\n';
     }
 

_______________________________________________
Kmail Developers mailing list
Kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic