kmail

kmfolderdia.cpp

00001 // -*- mode: C++; c-file-style: "gnu" -*-
00033 #include <config.h>
00034 
00035 #include "kmfolderdia.h"
00036 #include "kmacctfolder.h"
00037 #include "kmfoldermgr.h"
00038 #include <libkpimidentities/identitycombo.h>
00039 #include "kmfolderimap.h"
00040 #include "kmfoldercachedimap.h"
00041 #include "kmfolder.h"
00042 #include "kmheaders.h"
00043 #include "kmcommands.h"
00044 #include "kmfoldertree.h"
00045 #include "folderdiaacltab.h"
00046 #include "kmailicalifaceimpl.h"
00047 #include "globalsettings.h"
00048 #include "folderrequester.h"
00049 
00050 #include <keditlistbox.h>
00051 #include <klineedit.h>
00052 #include <klocale.h>
00053 #include <knuminput.h>
00054 #include <kmessagebox.h>
00055 #include <kicondialog.h>
00056 #include <kconfig.h>
00057 #include <kdebug.h>
00058 #include <klistview.h>
00059 
00060 #include <qcheckbox.h>
00061 #include <qlayout.h>
00062 #include <qgroupbox.h>
00063 #include <qregexp.h>
00064 #include <qlabel.h>
00065 #include <qvbox.h>
00066 #include <qtooltip.h>
00067 #include <qwhatsthis.h>
00068 
00069 #include <assert.h>
00070 #include <qhbuttongroup.h>
00071 #include <qradiobutton.h>
00072 
00073 #include "kmfolderdia.moc"
00074 
00075 using namespace KMail;
00076 
00077 static QString inCaseWeDecideToRenameTheTab( I18N_NOOP( "Permissions (ACL)" ) );
00078 
00079 //-----------------------------------------------------------------------------
00080 KMFolderDialog::KMFolderDialog(KMFolder *aFolder, KMFolderDir *aFolderDir,
00081                    KMFolderTree* aParent, const QString& aCap,
00082                    const QString& aName):
00083   KDialogBase( KDialogBase::Tabbed,
00084                aCap, KDialogBase::Ok|KDialogBase::Cancel,
00085                KDialogBase::Ok, aParent, "KMFolderDialog", TRUE ),
00086   mFolder( aFolder ),
00087   mFolderDir( aFolderDir ),
00088   mParentFolder( 0 ),
00089   mIsNewFolder( aFolder == 0 ),
00090   mFolderTree( aParent )
00091 {
00092   kdDebug(5006)<<"KMFolderDialog::KMFolderDialog()" << endl;
00093 
00094   QStringList folderNames;
00095   QValueList<QGuardedPtr<KMFolder> > folders;
00096   // get all folders but search and folders that can not have children
00097   aParent->createFolderList(&folderNames, &folders, true, true,
00098                             true, false, true, false);
00099 
00100   if( mFolderDir ) {
00101     // search the parent folder of the folder
00102     FolderList::ConstIterator it;
00103     int i = 1;
00104     for( it = folders.begin(); it != folders.end(); ++it, ++i ) {
00105       if( (*it)->child() == mFolderDir ) {
00106         mParentFolder = *it;
00107         break;
00108       }
00109     }
00110   }
00111 
00112   FolderDiaTab* tab;
00113   QVBox* box;
00114 
00115   box = addVBoxPage( i18n("General") );
00116   tab = new FolderDiaGeneralTab( this, aName, box );
00117   addTab( tab );
00118 
00119   KMFolder* refFolder = mFolder ? mFolder : mParentFolder;
00120   KMFolderType folderType = refFolder ? refFolder->folderType() : KMFolderTypeUnknown;
00121   bool noContent = mFolder ? mFolder->storage()->noContent() : false;
00122   if ( !noContent && refFolder && ( folderType == KMFolderTypeImap || folderType == KMFolderTypeCachedImap ) ) {
00123     if ( FolderDiaACLTab::supports( refFolder ) ) {
00124       box = addVBoxPage( i18n("Access Control") );
00125       tab = new FolderDiaACLTab( this, box );
00126       addTab( tab );
00127     }
00128   }
00129 
00130   for ( unsigned int i = 0 ; i < mTabs.count() ; ++i )
00131     mTabs[i]->load();
00132 }
00133 
00134 void KMFolderDialog::addTab( FolderDiaTab* tab )
00135 {
00136   connect( tab, SIGNAL( readyForAccept() ),
00137            this, SLOT( slotReadyForAccept() ) );
00138   connect( tab, SIGNAL( cancelAccept() ),
00139            this, SLOT( slotCancelAccept() ) );
00140   //connect( tab, SIGNAL(changed( bool )),
00141   //         this, SLOT(slotChanged( bool )) );
00142   mTabs.append( tab );
00143 }
00144 
00145 // Not used yet (no button), but ready to be used :)
00146 void KMFolderDialog::slotApply()
00147 {
00148   if ( mFolder.isNull() && !mIsNewFolder ) { // deleted meanwhile?
00149     KDialogBase::slotApply();
00150     return;
00151   }
00152   for ( unsigned int i = 0 ; i < mTabs.count() ; ++i )
00153     mTabs[i]->save();
00154   if ( !mFolder.isNull() && mIsNewFolder ) // we just created it
00155     mIsNewFolder = false; // so it's not new anymore :)
00156   KDialogBase::slotApply();
00157 }
00158 
00159 // Called when pressing Ok
00160 // We want to apply the changes first (which is async), before closing the dialog,
00161 // in case of errors during the upload.
00162 void KMFolderDialog::slotOk()
00163 {
00164   if ( mFolder.isNull() && !mIsNewFolder ) { // deleted meanwhile?
00165     KDialogBase::slotOk();
00166     return;
00167   }
00168 
00169   mDelayedSavingTabs = 0; // number of tabs which need delayed saving
00170   for ( unsigned int i = 0 ; i < mTabs.count() ; ++i ) {
00171     FolderDiaTab::AcceptStatus s = mTabs[i]->accept();
00172     if ( s == FolderDiaTab::Canceled ) {
00173       slotCancelAccept();
00174       return;
00175     }
00176     else if ( s == FolderDiaTab::Delayed )
00177       ++mDelayedSavingTabs;
00178   }
00179 
00180   if ( mDelayedSavingTabs )
00181     enableButtonOK( false );
00182   else
00183     KDialogBase::slotOk();
00184 }
00185 
00186 void KMFolderDialog::slotReadyForAccept()
00187 {
00188   --mDelayedSavingTabs;
00189   if ( mDelayedSavingTabs == 0 )
00190     KDialogBase::slotOk();
00191 }
00192 
00193 void KMFolderDialog::slotCancelAccept()
00194 {
00195   mDelayedSavingTabs = -1;
00196   enableButtonOK( true );
00197   // Don't try to create it twice
00198   if ( !mFolder.isNull() )
00199     mIsNewFolder = false;
00200 
00201   // Other tabs might call slotReadyForAccept. -1 ensures that it won't close the dialog,
00202   // but the OK button being enabled means that people might succeed in running
00203   // the same job from save more than once.
00204   // Solution: mAcceptCanceled = true instead of -1.
00205   // Bah for now we only have one tab which can delay saving -> later.
00206 }
00207 
00208 void KMFolderDialog::slotChanged( bool )
00209 {
00210   // TODO, support for 'changed', and Apply button.
00211   // sample code for here: KCMultiDialog calls bool changed() on every KCModuleProxy...
00212 }
00213 
00214 void KMFolderDialog::setFolder( KMFolder* folder )
00215 {
00216   Q_ASSERT( mFolder.isNull() );
00217   mFolder = folder;
00218 }
00219 
00220 static void addLine( QWidget *parent, QVBoxLayout* layout )
00221 {
00222    QFrame *line = new QFrame( parent, "line" );
00223    line->setGeometry( QRect( 80, 150, 250, 20 ) );
00224    line->setFrameShape( QFrame::HLine );
00225    line->setFrameShadow( QFrame::Sunken );
00226    line->setFrameShape( QFrame::HLine );
00227    layout->addWidget( line );
00228 }
00229 
00230 //----------------------------------------------------------------------------
00231 KMail::FolderDiaGeneralTab::FolderDiaGeneralTab( KMFolderDialog* dlg,
00232                                                  const QString& aName,
00233                                                  QWidget* parent, const char* name )
00234   : FolderDiaTab( parent, name ), mDlg( dlg )
00235 {
00236 
00237 
00238   mIsLocalSystemFolder = mDlg->folder()->isSystemFolder() &&
00239        mDlg->folder()->folderType() != KMFolderTypeImap &&
00240        mDlg->folder()->folderType() != KMFolderTypeCachedImap;
00241 
00242   QLabel *label;
00243 
00244   QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
00245 
00246   // Musn't be able to edit details for a system folder.
00247   if ( !mIsLocalSystemFolder ) {
00248 
00249     QHBoxLayout *hl = new QHBoxLayout( topLayout );
00250     hl->setSpacing( KDialog::spacingHint() );
00251 
00252     label = new QLabel( i18n("&Name:"), this );
00253     hl->addWidget( label );
00254 
00255     mNameEdit = new KLineEdit( this );
00256     if( !mDlg->folder() )
00257             mNameEdit->setFocus();
00258     mNameEdit->setText( mDlg->folder() ? mDlg->folder()->label() : i18n("unnamed") );
00259     if (!aName.isEmpty())
00260             mNameEdit->setText(aName);
00261     mNameEdit->setMinimumSize(mNameEdit->sizeHint());
00262     label->setBuddy( mNameEdit );
00263     hl->addWidget( mNameEdit );
00264     connect( mNameEdit, SIGNAL( textChanged( const QString & ) ),
00265                     this, SLOT( slotFolderNameChanged( const QString & ) ) );
00266 
00267 
00268     //start icons group
00269     QVBoxLayout *ivl = new QVBoxLayout( topLayout );
00270     ivl->setSpacing( KDialog::spacingHint() );
00271 
00272     QHBoxLayout *ihl = new QHBoxLayout( ivl );
00273     mIconsCheckBox = new QCheckBox( i18n("Use custom &icons"), this );
00274     mIconsCheckBox->setChecked( false );
00275     ihl->addWidget( mIconsCheckBox );
00276     ihl->addStretch( 2 );
00277 
00278     mNormalIconLabel = new QLabel( i18n("&Normal:"), this );
00279     mNormalIconLabel->setEnabled( false );
00280     ihl->addWidget( mNormalIconLabel );
00281 
00282     mNormalIconButton = new KIconButton( this );
00283     mNormalIconLabel->setBuddy( mNormalIconButton );
00284     mNormalIconButton->setIconType( KIcon::NoGroup , KIcon::Any, true );
00285     mNormalIconButton->setIconSize( 16 );
00286     mNormalIconButton->setStrictIconSize( true );
00287     mNormalIconButton->setFixedSize( 28, 28 );
00288     // Can't use iconset here
00289     mNormalIconButton->setIcon( "folder" );
00290     mNormalIconButton->setEnabled( false );
00291     ihl->addWidget( mNormalIconButton );
00292 
00293     mUnreadIconLabel = new QLabel( i18n("&Unread:"), this );
00294     mUnreadIconLabel->setEnabled( false );
00295     ihl->addWidget( mUnreadIconLabel );
00296 
00297     mUnreadIconButton = new KIconButton( this );
00298     mUnreadIconLabel->setBuddy( mUnreadIconButton );
00299     mUnreadIconButton->setIconType( KIcon::NoGroup, KIcon::Any, true );
00300     mUnreadIconButton->setIconSize( 16 );
00301     mUnreadIconButton->setStrictIconSize( true );
00302     mUnreadIconButton->setFixedSize( 28, 28 );
00303     // Can't use iconset here
00304     mUnreadIconButton->setIcon( "folder_open" );
00305     mUnreadIconButton->setEnabled( false );
00306     ihl->addWidget( mUnreadIconButton );
00307     ihl->addStretch( 1 );
00308 
00309     connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00310                     mNormalIconButton, SLOT(setEnabled(bool)) );
00311     connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00312                     mUnreadIconButton, SLOT(setEnabled(bool)) );
00313     connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00314                     mNormalIconLabel, SLOT(setEnabled(bool)) );
00315     connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00316                     mUnreadIconLabel, SLOT(setEnabled(bool)) );
00317 
00318     connect( mNormalIconButton, SIGNAL(iconChanged(QString)),
00319                     this, SLOT(slotChangeIcon(QString)) );
00320 
00321     //end icons group
00322     addLine( this, topLayout);
00323   }
00324 
00325 
00326   // should new mail in this folder be ignored?
00327   QHBoxLayout *hbl = new QHBoxLayout( topLayout );
00328   hbl->setSpacing( KDialog::spacingHint() );
00329   mNotifyOnNewMailCheckBox =
00330     new QCheckBox( i18n("Act on new/unread mail in this folder" ), this );
00331   QWhatsThis::add( mNotifyOnNewMailCheckBox,
00332       i18n( "<qt><p>If this option is enabled then you will be notified about "
00333             "new/unread mail in this folder. Moreover, going to the "
00334             "next/previous folder with unread messages will stop at this "
00335             "folder.</p>"
00336             "<p>Uncheck this option if you do not want to be notified about "
00337             "new/unread mail in this folder and if you want this folder to "
00338             "be skipped when going to the next/previous folder with unread "
00339             "messages. This is useful for ignoring any new/unread mail in "
00340             "your trash and spam folder.</p></qt>" ) );
00341   hbl->addWidget( mNotifyOnNewMailCheckBox );
00342 
00343   if ( mDlg->folder()->folderType() == KMFolderTypeImap ) {
00344     // should this folder be included in new-mail-checks?
00345 
00346     QHBoxLayout *nml = new QHBoxLayout( topLayout );
00347     nml->setSpacing( KDialog::spacingHint() );
00348     mNewMailCheckBox = new QCheckBox( i18n("Include this folder in mail checks"), this );
00349     // default is on
00350     mNewMailCheckBox->setChecked(true);
00351     nml->addWidget( mNewMailCheckBox );
00352     nml->addStretch( 1 );
00353   }
00354 
00355   // should replies to mails in this folder be kept in this same folder?
00356   hbl = new QHBoxLayout( topLayout );
00357   hbl->setSpacing( KDialog::spacingHint() );
00358   mKeepRepliesInSameFolderCheckBox =
00359     new QCheckBox( i18n("Keep replies in this folder" ), this );
00360   QWhatsThis::add( mKeepRepliesInSameFolderCheckBox,
00361                    i18n( "Check this option if you want replies you write "
00362                          "to mails in this folder to be put in this same folder "
00363                          "after sending, instead of in the configured sent-mail folder." ) );
00364   hbl->addWidget( mKeepRepliesInSameFolderCheckBox );
00365   hbl->addStretch( 1 );
00366 
00367   addLine( this, topLayout );
00368 
00369   // use grid layout for the following combobox settings
00370   QGridLayout *gl = new QGridLayout( topLayout, 3, 2, KDialog::spacingHint() );
00371   gl->setColStretch( 1, 100 ); // make the second column use all available space
00372   int row = -1;
00373 
00374   // sender or receiver column?
00375   ++row;
00376   QString tip = i18n("Show Sender/Receiver Column in List of Messages");
00377 
00378   QLabel *sender_label = new QLabel( i18n("Sho&w column:" ), this );
00379   gl->addWidget( sender_label, row, 0 );
00380   mShowSenderReceiverComboBox = new QComboBox( this );
00381   QToolTip::add( mShowSenderReceiverComboBox, tip );
00382   sender_label->setBuddy(mShowSenderReceiverComboBox);
00383   gl->addWidget( mShowSenderReceiverComboBox, row, 1 );
00384   mShowSenderReceiverComboBox->insertItem(i18n("Default"), 0);
00385   mShowSenderReceiverComboBox->insertItem(i18n("Sender"), 1);
00386   mShowSenderReceiverComboBox->insertItem(i18n("Receiver"), 2);
00387 
00388   QString whoField;
00389   if (mDlg->folder()) whoField = mDlg->folder()->userWhoField();
00390   if (whoField.isEmpty()) mShowSenderReceiverComboBox->setCurrentItem(0);
00391   else if (whoField == "From") mShowSenderReceiverComboBox->setCurrentItem(1);
00392   else if (whoField == "To") mShowSenderReceiverComboBox->setCurrentItem(2);
00393 
00394 
00395   // sender identity
00396   ++row;
00397   label = new QLabel( i18n("&Sender identity:"), this );
00398   gl->addWidget( label, row, 0 );
00399   mIdentityComboBox = new KPIM::IdentityCombo( kmkernel->identityManager(), this );
00400   label->setBuddy( mIdentityComboBox );
00401   gl->addWidget( mIdentityComboBox, row, 1 );
00402   QWhatsThis::add( mIdentityComboBox,
00403       i18n( "Select the sender identity to be used when writing new mail "
00404         "or replying to mail in this folder. This means that if you are in "
00405         "one of your work folders, you can make KMail use the corresponding "
00406         "sender email address, signature and signing or encryption keys "
00407         "automatically. Identities can be set up in the main configuration "
00408         "dialog. (Settings -> Configure KMail)") );
00409 
00410 
00411   // folder contents
00412   if ( !mIsLocalSystemFolder && kmkernel->iCalIface().isEnabled() ) {
00413     // Only do make this settable, if the IMAP resource is enabled
00414     // and it's not the personal folders (those must not be changed)
00415     ++row;
00416     label = new QLabel( i18n("&Folder contents:"), this );
00417     gl->addWidget( label, row, 0 );
00418     mContentsComboBox = new QComboBox( this );
00419     label->setBuddy( mContentsComboBox );
00420     gl->addWidget( mContentsComboBox, row, 1 );
00421 
00422     mContentsComboBox->insertItem( i18n( "Mail" ) );
00423     mContentsComboBox->insertItem( i18n( "Calendar" ) );
00424     mContentsComboBox->insertItem( i18n( "Contacts" ) );
00425     mContentsComboBox->insertItem( i18n( "Notes" ) );
00426     mContentsComboBox->insertItem( i18n( "Tasks" ) );
00427     mContentsComboBox->insertItem( i18n( "Journal" ) );
00428     if ( mDlg->folder() )
00429       mContentsComboBox->setCurrentItem( mDlg->folder()->storage()->contentsType() );
00430     connect ( mContentsComboBox, SIGNAL ( activated( int ) ),
00431               this, SLOT( slotFolderContentsSelectionChanged( int ) ) );
00432   } else {
00433     mContentsComboBox = 0;
00434   }
00435 
00436   // Kolab incidences-for annotation.
00437   // Show incidences-for combobox if the contents type can be changed (new folder),
00438   // or if it's set to calendar or task (existing folder)
00439   if ( ( GlobalSettings::self()->theIMAPResourceStorageFormat() ==
00440          GlobalSettings::EnumTheIMAPResourceStorageFormat::XML ) &&
00441       mContentsComboBox ) {
00442     ++row;
00443     QLabel* label = new QLabel( i18n( "Generate free/&busy and activate alarms for:" ), this );
00444     gl->addWidget( label, row, 0 );
00445     mIncidencesForComboBox = new QComboBox( this );
00446     label->setBuddy( mIncidencesForComboBox );
00447     gl->addWidget( mIncidencesForComboBox, row, 1 );
00448 
00449     QWhatsThis::add( mIncidencesForComboBox,
00450                      i18n( "This setting defines which users sharing "
00451                            "this folder should get \"busy\" periods in their freebusy lists "
00452                            "and should see the alarms for the events or tasks in this folder. "
00453                            "The setting applies to Calendar and Task folders only "
00454                            "(for tasks, this setting is only used for alarms).\n\n"
00455                            "Example use cases: if the boss shares a folder with his secretary, "
00456                            "only the boss should be marked as busy for his meetings, so he should "
00457                            "select \"Admins\", since the secretary has no admin rights on the folder.\n"
00458                            "On the other hand if a working group shares a Calendar for "
00459                            "group meetings, all readers of the folders should be marked "
00460                            "as busy for meetings.\n"
00461                            "A company-wide folder with optional events in it would use \"Nobody\" "
00462                            "since it is not known who will go to those events." ) );
00463 
00464     mIncidencesForComboBox->insertItem( i18n( "Nobody" ) );
00465     mIncidencesForComboBox->insertItem( i18n( "Admins of This Folder" ) );
00466     mIncidencesForComboBox->insertItem( i18n( "All Readers of This Folder" ) );
00467 
00468     if ( mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeCalendar
00469       && mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeTask ) {
00470       mIncidencesForComboBox->setEnabled( false );
00471     }
00472   } else {
00473     mIncidencesForComboBox = 0;
00474   }
00475 
00476   topLayout->addStretch( 100 ); // eat all superfluous space
00477 
00478   initializeWithValuesFromFolder( mDlg->folder() );
00479 }
00480 
00481 void FolderDiaGeneralTab::load()
00482 {
00483   // Nothing here, all is done in the ctor
00484 }
00485 
00486 void FolderDiaGeneralTab::initializeWithValuesFromFolder( KMFolder* folder ) {
00487   if ( !folder )
00488     return;
00489 
00490   if ( !mIsLocalSystemFolder ) {
00491     // folder icons
00492     mIconsCheckBox->setChecked( folder->useCustomIcons() );
00493     mNormalIconLabel->setEnabled( folder->useCustomIcons() );
00494     mNormalIconButton->setEnabled( folder->useCustomIcons() );
00495     mUnreadIconLabel->setEnabled( folder->useCustomIcons() );
00496     mUnreadIconButton->setEnabled( folder->useCustomIcons() );
00497     QString iconPath = folder->normalIconPath();
00498     if ( !iconPath.isEmpty() )
00499       mNormalIconButton->setIcon( iconPath );
00500     iconPath = folder->unreadIconPath();
00501     if ( !iconPath.isEmpty() )
00502       mUnreadIconButton->setIcon( iconPath );
00503   }
00504 
00505   // folder identity
00506   mIdentityComboBox->setCurrentIdentity( folder->identity() );
00507   // ignore new mail
00508   mNotifyOnNewMailCheckBox->setChecked( !folder->ignoreNewMail() );
00509 
00510   const bool keepInFolder = !folder->isReadOnly() && folder->putRepliesInSameFolder();
00511   mKeepRepliesInSameFolderCheckBox->setChecked( keepInFolder );
00512   mKeepRepliesInSameFolderCheckBox->setDisabled( folder->isReadOnly() );
00513 
00514   if (folder->folderType() == KMFolderTypeImap)
00515   {
00516     KMFolderImap* imapFolder = static_cast<KMFolderImap*>(folder->storage());
00517     bool checked = imapFolder->includeInMailCheck();
00518     mNewMailCheckBox->setChecked(checked);
00519   }
00520 
00521   if ( mIncidencesForComboBox ) {
00522     KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( folder->storage() );
00523     mIncidencesForComboBox->setCurrentItem( dimap->incidencesFor() );
00524   }
00525 }
00526 
00527 //-----------------------------------------------------------------------------
00528 void FolderDiaGeneralTab::slotFolderNameChanged( const QString& str )
00529 {
00530   mDlg->enableButtonOK( !str.isEmpty() );
00531 }
00532 
00533 //-----------------------------------------------------------------------------
00534 void FolderDiaGeneralTab::slotFolderContentsSelectionChanged( int )
00535 {
00536   KMail::FolderContentsType type =
00537     static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
00538   if( type != KMail::ContentsTypeMail && GlobalSettings::self()->hideGroupwareFolders() ) {
00539     QString message = i18n("You have configured this folder to contain groupware information "
00540         "and the general configuration option to hide groupware folders is "
00541         "set. That means that this folder will disappear once the configuration "
00542         "dialog is closed. If you want to remove the folder again, you will need "
00543         "to temporarily disable hiding of groupware folders to be able to see it.");
00544     KMessageBox::information( this, message );
00545   }
00546 
00547   if ( mIncidencesForComboBox )
00548       mIncidencesForComboBox->setEnabled( type == KMail::ContentsTypeCalendar ||
00549                                           type == KMail::ContentsTypeTask );
00550 }
00551 
00552 //-----------------------------------------------------------------------------
00553 bool FolderDiaGeneralTab::save()
00554 {
00555   KMFolder* folder = mDlg->folder();
00556   folder->setIdentity( mIdentityComboBox->currentIdentity() );
00557   // set whoField
00558   if (mShowSenderReceiverComboBox->currentItem() == 1)
00559     folder->setUserWhoField("From");
00560   else if (mShowSenderReceiverComboBox->currentItem() == 2)
00561     folder->setUserWhoField("To");
00562   else
00563     folder->setUserWhoField("");
00564 
00565   folder->setIgnoreNewMail( !mNotifyOnNewMailCheckBox->isChecked() );
00566   folder->setPutRepliesInSameFolder( mKeepRepliesInSameFolderCheckBox->isChecked() );
00567 
00568   QString fldName, oldFldName;
00569   if ( !mIsLocalSystemFolder )
00570   {
00571     QString acctName;
00572     oldFldName = mDlg->folder()->name();
00573 
00574     if (!mNameEdit->text().isEmpty())
00575       fldName = mNameEdit->text();
00576     else
00577       fldName = oldFldName;
00578 
00579     if ( mDlg->parentFolder() &&
00580          mDlg->parentFolder()->folderType() != KMFolderTypeImap &&
00581          mDlg->parentFolder()->folderType() != KMFolderTypeCachedImap )
00582       fldName.remove('/');
00583     fldName.remove(QRegExp("^\\.*"));
00584     if (fldName.isEmpty()) fldName = i18n("unnamed");
00585 
00586 
00587     // Update the tree iff new icon paths are different and not empty or if
00588     // useCustomIcons changed.
00589     if ( folder->useCustomIcons() != mIconsCheckBox->isChecked() ) {
00590       folder->setUseCustomIcons( mIconsCheckBox->isChecked() );
00591       // Reset icons, useCustomIcons was turned off.
00592       if ( !folder->useCustomIcons() ) {
00593         folder->setIconPaths( "", "" );
00594       }
00595     }
00596     if ( folder->useCustomIcons() &&
00597         (( mNormalIconButton->icon() != folder->normalIconPath() ) &&
00598          ( !mNormalIconButton->icon().isEmpty())) ||
00599         (( mUnreadIconButton->icon() != folder->unreadIconPath() ) &&
00600          ( !mUnreadIconButton->icon().isEmpty())) ) {
00601       folder->setIconPaths( mNormalIconButton->icon(), mUnreadIconButton->icon() );
00602     }
00603 
00604     // Set type field
00605     if ( mContentsComboBox ) {
00606       KMail::FolderContentsType type =
00607         static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
00608       folder->storage()->setContentsType( type );
00609     }
00610 
00611     if ( mIncidencesForComboBox && folder->folderType() == KMFolderTypeCachedImap ) {
00612       KMFolderCachedImap::IncidencesFor incfor =
00613         static_cast<KMFolderCachedImap::IncidencesFor>( mIncidencesForComboBox->currentItem() );
00614       KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( mDlg->folder()->storage() );
00615       if ( dimap->incidencesFor() != incfor ) {
00616         dimap->setIncidencesFor( incfor );
00617         dimap->writeConfig();
00618       }
00619     }
00620 
00621     if( folder->folderType() == KMFolderTypeImap )
00622     {
00623       KMFolderImap* imapFolder = static_cast<KMFolderImap*>( folder->storage() );
00624       imapFolder->setIncludeInMailCheck(
00625           mNewMailCheckBox->isChecked() );
00626     }
00627     // make sure everything is on disk, connected slots will call readConfig()
00628     // when creating a new folder.
00629     folder->storage()->writeConfig();
00630     // Renamed an existing folder? We don't check for oldName == newName on
00631     // purpose here. The folder might be pending renaming on the next dimap
00632     // sync already, in which case the old name would still be around and
00633     // something like Calendar -> CalendarFoo -> Calendar inbetween syncs would
00634     // fail. Therefor let the folder sort it out itself, whether the rename is
00635     // a noop or not.
00636     if ( !oldFldName.isEmpty() )
00637     {
00638       kmkernel->folderMgr()->renameFolder( folder, fldName );
00639     } else {
00640       kmkernel->folderMgr()->contentsChanged();
00641     }
00642   }
00643   return true;
00644 }
00645 
00646 void FolderDiaGeneralTab::slotChangeIcon( QString icon ) // can't use a const-ref here, due to KIconButton's signal
00647 {
00648     mUnreadIconButton->setIcon( icon );
00649 }
KDE Home | KDE Accessibility Home | Description of Access Keys