00001
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 "folderdiaquotatab.h"
00047 #include "kmailicalifaceimpl.h"
00048 #include "globalsettings.h"
00049 #include "folderrequester.h"
00050
00051 #include <keditlistbox.h>
00052 #include <klineedit.h>
00053 #include <klocale.h>
00054 #include <knuminput.h>
00055 #include <kmessagebox.h>
00056 #include <kicondialog.h>
00057 #include <kconfig.h>
00058 #include <kdebug.h>
00059 #include <klistview.h>
00060 #include <kpushbutton.h>
00061
00062 #include <qcheckbox.h>
00063 #include <qlayout.h>
00064 #include <qgroupbox.h>
00065 #include <qregexp.h>
00066 #include <qlabel.h>
00067 #include <qvbox.h>
00068 #include <qtooltip.h>
00069 #include <qwhatsthis.h>
00070
00071 #include <assert.h>
00072 #include <qhbuttongroup.h>
00073 #include <qradiobutton.h>
00074 #include <qtextedit.h>
00075
00076 #include "templatesconfiguration.h"
00077 #include "templatesconfiguration_kfg.h"
00078
00079 #include "kmfolderdia.moc"
00080
00081 using namespace KMail;
00082
00083 static QString inCaseWeDecideToRenameTheTab( I18N_NOOP( "Permissions (ACL)" ) );
00084
00085
00086 KMFolderDialog::KMFolderDialog(KMFolder *aFolder, KMFolderDir *aFolderDir,
00087 KMFolderTree* aParent, const QString& aCap,
00088 const QString& aName):
00089 KDialogBase( KDialogBase::Tabbed,
00090 aCap, KDialogBase::Ok|KDialogBase::Cancel,
00091 KDialogBase::Ok, aParent, "KMFolderDialog", TRUE ),
00092 mFolder( aFolder ),
00093 mFolderDir( aFolderDir ),
00094 mParentFolder( 0 ),
00095 mIsNewFolder( aFolder == 0 ),
00096 mFolderTree( aParent )
00097 {
00098 kdDebug(5006)<<"KMFolderDialog::KMFolderDialog()" << endl;
00099
00100 QStringList folderNames;
00101 QValueList<QGuardedPtr<KMFolder> > folders;
00102
00103 aParent->createFolderList(&folderNames, &folders, true, true,
00104 true, false, true, false);
00105
00106 if( mFolderDir ) {
00107
00108 FolderList::ConstIterator it;
00109 int i = 1;
00110 for( it = folders.begin(); it != folders.end(); ++it, ++i ) {
00111 if( (*it)->child() == mFolderDir ) {
00112 mParentFolder = *it;
00113 break;
00114 }
00115 }
00116 }
00117
00118 FolderDiaTab* tab;
00119 QVBox* box;
00120
00121 box = addVBoxPage( i18n("General") );
00122 tab = new FolderDiaGeneralTab( this, aName, box );
00123 addTab( tab );
00124 box = addVBoxPage( i18n("Templates") );
00125 tab = new FolderDiaTemplatesTab( this, aName, box );
00126 addTab( tab );
00127
00128 KMFolder* refFolder = mFolder ? mFolder : mParentFolder;
00129 KMFolderType folderType = refFolder ? refFolder->folderType() : KMFolderTypeUnknown;
00130 bool noContent = mFolder ? mFolder->storage()->noContent() : false;
00131 if ( !noContent && refFolder && ( folderType == KMFolderTypeImap || folderType == KMFolderTypeCachedImap ) ) {
00132 if ( FolderDiaACLTab::supports( refFolder ) ) {
00133 box = addVBoxPage( i18n("Access Control") );
00134 tab = new FolderDiaACLTab( this, box );
00135 addTab( tab );
00136 }
00137 }
00138 if ( !noContent && refFolder && ( folderType == KMFolderTypeImap || folderType == KMFolderTypeCachedImap ) ) {
00139 if ( FolderDiaQuotaTab::supports( refFolder ) ) {
00140 box = addVBoxPage( i18n("Quota") );
00141 tab = new FolderDiaQuotaTab( this, box );
00142 addTab( tab );
00143 }
00144 }
00145
00146 for ( unsigned int i = 0 ; i < mTabs.count() ; ++i )
00147 mTabs[i]->load();
00148 }
00149
00150 void KMFolderDialog::addTab( FolderDiaTab* tab )
00151 {
00152 connect( tab, SIGNAL( readyForAccept() ),
00153 this, SLOT( slotReadyForAccept() ) );
00154 connect( tab, SIGNAL( cancelAccept() ),
00155 this, SLOT( slotCancelAccept() ) );
00156
00157
00158 mTabs.append( tab );
00159 }
00160
00161
00162 void KMFolderDialog::slotApply()
00163 {
00164 if ( mFolder.isNull() && !mIsNewFolder ) {
00165 KDialogBase::slotApply();
00166 return;
00167 }
00168 for ( unsigned int i = 0 ; i < mTabs.count() ; ++i )
00169 mTabs[i]->save();
00170 if ( !mFolder.isNull() && mIsNewFolder )
00171 mIsNewFolder = false;
00172 KDialogBase::slotApply();
00173 }
00174
00175
00176
00177
00178 void KMFolderDialog::slotOk()
00179 {
00180 if ( mFolder.isNull() && !mIsNewFolder ) {
00181 KDialogBase::slotOk();
00182 return;
00183 }
00184
00185 mDelayedSavingTabs = 0;
00186 for ( unsigned int i = 0 ; i < mTabs.count() ; ++i ) {
00187 FolderDiaTab::AcceptStatus s = mTabs[i]->accept();
00188 if ( s == FolderDiaTab::Canceled ) {
00189 slotCancelAccept();
00190 return;
00191 }
00192 else if ( s == FolderDiaTab::Delayed )
00193 ++mDelayedSavingTabs;
00194 }
00195
00196 if ( mDelayedSavingTabs )
00197 enableButtonOK( false );
00198 else
00199 KDialogBase::slotOk();
00200 }
00201
00202 void KMFolderDialog::slotReadyForAccept()
00203 {
00204 --mDelayedSavingTabs;
00205 if ( mDelayedSavingTabs == 0 )
00206 KDialogBase::slotOk();
00207 }
00208
00209 void KMFolderDialog::slotCancelAccept()
00210 {
00211 mDelayedSavingTabs = -1;
00212 enableButtonOK( true );
00213
00214 if ( !mFolder.isNull() )
00215 mIsNewFolder = false;
00216
00217
00218
00219
00220
00221
00222 }
00223
00224 void KMFolderDialog::slotChanged( bool )
00225 {
00226
00227
00228 }
00229
00230 void KMFolderDialog::setFolder( KMFolder* folder )
00231 {
00232 Q_ASSERT( mFolder.isNull() );
00233 mFolder = folder;
00234 }
00235
00236 static void addLine( QWidget *parent, QVBoxLayout* layout )
00237 {
00238 QFrame *line = new QFrame( parent, "line" );
00239 line->setGeometry( QRect( 80, 150, 250, 20 ) );
00240 line->setFrameShape( QFrame::HLine );
00241 line->setFrameShadow( QFrame::Sunken );
00242 line->setFrameShape( QFrame::HLine );
00243 layout->addWidget( line );
00244 }
00245
00246
00247 KMail::FolderDiaGeneralTab::FolderDiaGeneralTab( KMFolderDialog* dlg,
00248 const QString& aName,
00249 QWidget* parent, const char* name )
00250 : FolderDiaTab( parent, name ), mDlg( dlg )
00251 {
00252
00253
00254 mIsLocalSystemFolder = mDlg->folder()->isSystemFolder() &&
00255 mDlg->folder()->folderType() != KMFolderTypeImap &&
00256 mDlg->folder()->folderType() != KMFolderTypeCachedImap;
00257
00258 QLabel *label;
00259
00260 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
00261
00262
00263 if ( !mIsLocalSystemFolder ) {
00264
00265 QHBoxLayout *hl = new QHBoxLayout( topLayout );
00266 hl->setSpacing( KDialog::spacingHint() );
00267
00268 label = new QLabel( i18n("&Name:"), this );
00269 hl->addWidget( label );
00270
00271 mNameEdit = new KLineEdit( this );
00272 if( !mDlg->folder() )
00273 mNameEdit->setFocus();
00274 mNameEdit->setText( mDlg->folder() ? mDlg->folder()->label() : i18n("unnamed") );
00275 if (!aName.isEmpty())
00276 mNameEdit->setText(aName);
00277 mNameEdit->setMinimumSize(mNameEdit->sizeHint());
00278 label->setBuddy( mNameEdit );
00279 hl->addWidget( mNameEdit );
00280 connect( mNameEdit, SIGNAL( textChanged( const QString & ) ),
00281 this, SLOT( slotFolderNameChanged( const QString & ) ) );
00282
00283
00284
00285 QVBoxLayout *ivl = new QVBoxLayout( topLayout );
00286 ivl->setSpacing( KDialog::spacingHint() );
00287
00288 QHBoxLayout *ihl = new QHBoxLayout( ivl );
00289 mIconsCheckBox = new QCheckBox( i18n("Use custom &icons"), this );
00290 mIconsCheckBox->setChecked( false );
00291 ihl->addWidget( mIconsCheckBox );
00292 ihl->addStretch( 2 );
00293
00294 mNormalIconLabel = new QLabel( i18n("&Normal:"), this );
00295 mNormalIconLabel->setEnabled( false );
00296 ihl->addWidget( mNormalIconLabel );
00297
00298 mNormalIconButton = new KIconButton( this );
00299 mNormalIconLabel->setBuddy( mNormalIconButton );
00300 mNormalIconButton->setIconType( KIcon::NoGroup , KIcon::Any, true );
00301 mNormalIconButton->setIconSize( 16 );
00302 mNormalIconButton->setStrictIconSize( true );
00303 mNormalIconButton->setFixedSize( 28, 28 );
00304
00305 mNormalIconButton->setIcon( "folder" );
00306 mNormalIconButton->setEnabled( false );
00307 ihl->addWidget( mNormalIconButton );
00308
00309 mUnreadIconLabel = new QLabel( i18n("&Unread:"), this );
00310 mUnreadIconLabel->setEnabled( false );
00311 ihl->addWidget( mUnreadIconLabel );
00312
00313 mUnreadIconButton = new KIconButton( this );
00314 mUnreadIconLabel->setBuddy( mUnreadIconButton );
00315 mUnreadIconButton->setIconType( KIcon::NoGroup, KIcon::Any, true );
00316 mUnreadIconButton->setIconSize( 16 );
00317 mUnreadIconButton->setStrictIconSize( true );
00318 mUnreadIconButton->setFixedSize( 28, 28 );
00319
00320 mUnreadIconButton->setIcon( "folder_open" );
00321 mUnreadIconButton->setEnabled( false );
00322 ihl->addWidget( mUnreadIconButton );
00323 ihl->addStretch( 1 );
00324
00325 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00326 mNormalIconButton, SLOT(setEnabled(bool)) );
00327 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00328 mUnreadIconButton, SLOT(setEnabled(bool)) );
00329 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00330 mNormalIconLabel, SLOT(setEnabled(bool)) );
00331 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00332 mUnreadIconLabel, SLOT(setEnabled(bool)) );
00333
00334 connect( mNormalIconButton, SIGNAL(iconChanged(QString)),
00335 this, SLOT(slotChangeIcon(QString)) );
00336
00337
00338 addLine( this, topLayout);
00339 }
00340
00341
00342
00343 QHBoxLayout *hbl = new QHBoxLayout( topLayout );
00344 hbl->setSpacing( KDialog::spacingHint() );
00345 mNotifyOnNewMailCheckBox =
00346 new QCheckBox( i18n("Act on new/unread mail in this folder" ), this );
00347 QWhatsThis::add( mNotifyOnNewMailCheckBox,
00348 i18n( "<qt><p>If this option is enabled then you will be notified about "
00349 "new/unread mail in this folder. Moreover, going to the "
00350 "next/previous folder with unread messages will stop at this "
00351 "folder.</p>"
00352 "<p>Uncheck this option if you do not want to be notified about "
00353 "new/unread mail in this folder and if you want this folder to "
00354 "be skipped when going to the next/previous folder with unread "
00355 "messages. This is useful for ignoring any new/unread mail in "
00356 "your trash and spam folder.</p></qt>" ) );
00357 hbl->addWidget( mNotifyOnNewMailCheckBox );
00358
00359 if ( mDlg->folder()->folderType() == KMFolderTypeImap ) {
00360
00361
00362 QHBoxLayout *nml = new QHBoxLayout( topLayout );
00363 nml->setSpacing( KDialog::spacingHint() );
00364 mNewMailCheckBox = new QCheckBox( i18n("Include this folder in mail checks"), this );
00365
00366 mNewMailCheckBox->setChecked(true);
00367 nml->addWidget( mNewMailCheckBox );
00368 nml->addStretch( 1 );
00369 }
00370
00371
00372 hbl = new QHBoxLayout( topLayout );
00373 hbl->setSpacing( KDialog::spacingHint() );
00374 mKeepRepliesInSameFolderCheckBox =
00375 new QCheckBox( i18n("Keep replies in this folder" ), this );
00376 QWhatsThis::add( mKeepRepliesInSameFolderCheckBox,
00377 i18n( "Check this option if you want replies you write "
00378 "to mails in this folder to be put in this same folder "
00379 "after sending, instead of in the configured sent-mail folder." ) );
00380 hbl->addWidget( mKeepRepliesInSameFolderCheckBox );
00381 hbl->addStretch( 1 );
00382
00383 addLine( this, topLayout );
00384
00385
00386 QGridLayout *gl = new QGridLayout( topLayout, 3, 2, KDialog::spacingHint() );
00387 gl->setColStretch( 1, 100 );
00388 int row = -1;
00389
00390
00391 ++row;
00392 QString tip = i18n("Show Sender/Receiver Column in List of Messages");
00393
00394 QLabel *sender_label = new QLabel( i18n("Sho&w column:" ), this );
00395 gl->addWidget( sender_label, row, 0 );
00396 mShowSenderReceiverComboBox = new QComboBox( this );
00397 QToolTip::add( mShowSenderReceiverComboBox, tip );
00398 sender_label->setBuddy(mShowSenderReceiverComboBox);
00399 gl->addWidget( mShowSenderReceiverComboBox, row, 1 );
00400 mShowSenderReceiverComboBox->insertItem(i18n("Default"), 0);
00401 mShowSenderReceiverComboBox->insertItem(i18n("Sender"), 1);
00402 mShowSenderReceiverComboBox->insertItem(i18n("Receiver"), 2);
00403
00404 QString whoField;
00405 if (mDlg->folder()) whoField = mDlg->folder()->userWhoField();
00406 if (whoField.isEmpty()) mShowSenderReceiverComboBox->setCurrentItem(0);
00407 else if (whoField == "From") mShowSenderReceiverComboBox->setCurrentItem(1);
00408 else if (whoField == "To") mShowSenderReceiverComboBox->setCurrentItem(2);
00409
00410
00411
00412 ++row;
00413 label = new QLabel( i18n("&Sender identity:"), this );
00414 gl->addWidget( label, row, 0 );
00415 mIdentityComboBox = new KPIM::IdentityCombo( kmkernel->identityManager(), this );
00416 label->setBuddy( mIdentityComboBox );
00417 gl->addWidget( mIdentityComboBox, row, 1 );
00418 QWhatsThis::add( mIdentityComboBox,
00419 i18n( "Select the sender identity to be used when writing new mail "
00420 "or replying to mail in this folder. This means that if you are in "
00421 "one of your work folders, you can make KMail use the corresponding "
00422 "sender email address, signature and signing or encryption keys "
00423 "automatically. Identities can be set up in the main configuration "
00424 "dialog. (Settings -> Configure KMail)") );
00425
00426
00427
00428 if ( !mIsLocalSystemFolder && kmkernel->iCalIface().isEnabled() ) {
00429
00430
00431 ++row;
00432 label = new QLabel( i18n("&Folder contents:"), this );
00433 gl->addWidget( label, row, 0 );
00434 mContentsComboBox = new QComboBox( this );
00435 label->setBuddy( mContentsComboBox );
00436 gl->addWidget( mContentsComboBox, row, 1 );
00437
00438 mContentsComboBox->insertItem( i18n( "Mail" ) );
00439 mContentsComboBox->insertItem( i18n( "Calendar" ) );
00440 mContentsComboBox->insertItem( i18n( "Contacts" ) );
00441 mContentsComboBox->insertItem( i18n( "Notes" ) );
00442 mContentsComboBox->insertItem( i18n( "Tasks" ) );
00443 mContentsComboBox->insertItem( i18n( "Journal" ) );
00444 if ( mDlg->folder() )
00445 mContentsComboBox->setCurrentItem( mDlg->folder()->storage()->contentsType() );
00446 connect ( mContentsComboBox, SIGNAL ( activated( int ) ),
00447 this, SLOT( slotFolderContentsSelectionChanged( int ) ) );
00448 } else {
00449 mContentsComboBox = 0;
00450 }
00451
00452
00453
00454
00455 if ( ( GlobalSettings::self()->theIMAPResourceStorageFormat() ==
00456 GlobalSettings::EnumTheIMAPResourceStorageFormat::XML ) &&
00457 mContentsComboBox ) {
00458 ++row;
00459 QLabel* label = new QLabel( i18n( "Generate free/&busy and activate alarms for:" ), this );
00460 gl->addWidget( label, row, 0 );
00461 mIncidencesForComboBox = new QComboBox( this );
00462 label->setBuddy( mIncidencesForComboBox );
00463 gl->addWidget( mIncidencesForComboBox, row, 1 );
00464
00465 QWhatsThis::add( mIncidencesForComboBox,
00466 i18n( "This setting defines which users sharing "
00467 "this folder should get \"busy\" periods in their freebusy lists "
00468 "and should see the alarms for the events or tasks in this folder. "
00469 "The setting applies to Calendar and Task folders only "
00470 "(for tasks, this setting is only used for alarms).\n\n"
00471 "Example use cases: if the boss shares a folder with his secretary, "
00472 "only the boss should be marked as busy for his meetings, so he should "
00473 "select \"Admins\", since the secretary has no admin rights on the folder.\n"
00474 "On the other hand if a working group shares a Calendar for "
00475 "group meetings, all readers of the folders should be marked "
00476 "as busy for meetings.\n"
00477 "A company-wide folder with optional events in it would use \"Nobody\" "
00478 "since it is not known who will go to those events." ) );
00479
00480 mIncidencesForComboBox->insertItem( i18n( "Nobody" ) );
00481 mIncidencesForComboBox->insertItem( i18n( "Admins of This Folder" ) );
00482 mIncidencesForComboBox->insertItem( i18n( "All Readers of This Folder" ) );
00483
00484 if ( mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeCalendar
00485 && mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeTask ) {
00486 mIncidencesForComboBox->setEnabled( false );
00487 }
00488 } else {
00489 mIncidencesForComboBox = 0;
00490 }
00491
00492 topLayout->addStretch( 100 );
00493
00494 initializeWithValuesFromFolder( mDlg->folder() );
00495 }
00496
00497 void FolderDiaGeneralTab::load()
00498 {
00499
00500 }
00501
00502 void FolderDiaGeneralTab::initializeWithValuesFromFolder( KMFolder* folder ) {
00503 if ( !folder )
00504 return;
00505
00506 if ( !mIsLocalSystemFolder ) {
00507
00508 mIconsCheckBox->setChecked( folder->useCustomIcons() );
00509 mNormalIconLabel->setEnabled( folder->useCustomIcons() );
00510 mNormalIconButton->setEnabled( folder->useCustomIcons() );
00511 mUnreadIconLabel->setEnabled( folder->useCustomIcons() );
00512 mUnreadIconButton->setEnabled( folder->useCustomIcons() );
00513 QString iconPath = folder->normalIconPath();
00514 if ( !iconPath.isEmpty() )
00515 mNormalIconButton->setIcon( iconPath );
00516 iconPath = folder->unreadIconPath();
00517 if ( !iconPath.isEmpty() )
00518 mUnreadIconButton->setIcon( iconPath );
00519 }
00520
00521
00522 mIdentityComboBox->setCurrentIdentity( folder->identity() );
00523
00524 mNotifyOnNewMailCheckBox->setChecked( !folder->ignoreNewMail() );
00525
00526 const bool keepInFolder = !folder->isReadOnly() && folder->putRepliesInSameFolder();
00527 mKeepRepliesInSameFolderCheckBox->setChecked( keepInFolder );
00528 mKeepRepliesInSameFolderCheckBox->setDisabled( folder->isReadOnly() );
00529
00530 if (folder->folderType() == KMFolderTypeImap)
00531 {
00532 KMFolderImap* imapFolder = static_cast<KMFolderImap*>(folder->storage());
00533 bool checked = imapFolder->includeInMailCheck();
00534 mNewMailCheckBox->setChecked(checked);
00535 }
00536
00537 if ( mIncidencesForComboBox ) {
00538 KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( folder->storage() );
00539 mIncidencesForComboBox->setCurrentItem( dimap->incidencesFor() );
00540 }
00541 }
00542
00543
00544 void FolderDiaGeneralTab::slotFolderNameChanged( const QString& str )
00545 {
00546 mDlg->enableButtonOK( !str.isEmpty() );
00547 }
00548
00549
00550 void FolderDiaGeneralTab::slotFolderContentsSelectionChanged( int )
00551 {
00552 KMail::FolderContentsType type =
00553 static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
00554 if( type != KMail::ContentsTypeMail && GlobalSettings::self()->hideGroupwareFolders() ) {
00555 QString message = i18n("You have configured this folder to contain groupware information "
00556 "and the general configuration option to hide groupware folders is "
00557 "set. That means that this folder will disappear once the configuration "
00558 "dialog is closed. If you want to remove the folder again, you will need "
00559 "to temporarily disable hiding of groupware folders to be able to see it.");
00560 KMessageBox::information( this, message );
00561 }
00562
00563 if ( mIncidencesForComboBox )
00564 mIncidencesForComboBox->setEnabled( type == KMail::ContentsTypeCalendar ||
00565 type == KMail::ContentsTypeTask );
00566 }
00567
00568
00569 bool FolderDiaGeneralTab::save()
00570 {
00571 KMFolder* folder = mDlg->folder();
00572 folder->setIdentity( mIdentityComboBox->currentIdentity() );
00573
00574 if (mShowSenderReceiverComboBox->currentItem() == 1)
00575 folder->setUserWhoField("From");
00576 else if (mShowSenderReceiverComboBox->currentItem() == 2)
00577 folder->setUserWhoField("To");
00578 else
00579 folder->setUserWhoField("");
00580
00581 folder->setIgnoreNewMail( !mNotifyOnNewMailCheckBox->isChecked() );
00582 folder->setPutRepliesInSameFolder( mKeepRepliesInSameFolderCheckBox->isChecked() );
00583
00584 QString fldName, oldFldName;
00585 if ( !mIsLocalSystemFolder )
00586 {
00587 QString acctName;
00588 oldFldName = mDlg->folder()->name();
00589
00590 if (!mNameEdit->text().isEmpty())
00591 fldName = mNameEdit->text();
00592 else
00593 fldName = oldFldName;
00594
00595 if ( mDlg->parentFolder() &&
00596 mDlg->parentFolder()->folderType() != KMFolderTypeImap &&
00597 mDlg->parentFolder()->folderType() != KMFolderTypeCachedImap )
00598 fldName.remove('/');
00599 fldName.remove(QRegExp("^\\.*"));
00600 if (fldName.isEmpty()) fldName = i18n("unnamed");
00601
00602
00603
00604
00605 if ( folder->useCustomIcons() != mIconsCheckBox->isChecked() ) {
00606 folder->setUseCustomIcons( mIconsCheckBox->isChecked() );
00607
00608 if ( !folder->useCustomIcons() ) {
00609 folder->setIconPaths( "", "" );
00610 }
00611 }
00612 if ( folder->useCustomIcons() &&
00613 (( mNormalIconButton->icon() != folder->normalIconPath() ) &&
00614 ( !mNormalIconButton->icon().isEmpty())) ||
00615 (( mUnreadIconButton->icon() != folder->unreadIconPath() ) &&
00616 ( !mUnreadIconButton->icon().isEmpty())) ) {
00617 folder->setIconPaths( mNormalIconButton->icon(), mUnreadIconButton->icon() );
00618 }
00619
00620
00621 if ( mContentsComboBox ) {
00622 KMail::FolderContentsType type =
00623 static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
00624 folder->storage()->setContentsType( type );
00625 }
00626
00627 if ( mIncidencesForComboBox && folder->folderType() == KMFolderTypeCachedImap ) {
00628 KMFolderCachedImap::IncidencesFor incfor =
00629 static_cast<KMFolderCachedImap::IncidencesFor>( mIncidencesForComboBox->currentItem() );
00630 KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( mDlg->folder()->storage() );
00631 if ( dimap->incidencesFor() != incfor ) {
00632 dimap->setIncidencesFor( incfor );
00633 dimap->writeConfig();
00634 }
00635 }
00636
00637 if( folder->folderType() == KMFolderTypeImap )
00638 {
00639 KMFolderImap* imapFolder = static_cast<KMFolderImap*>( folder->storage() );
00640 imapFolder->setIncludeInMailCheck(
00641 mNewMailCheckBox->isChecked() );
00642 }
00643
00644
00645 folder->storage()->writeConfig();
00646
00647
00648
00649
00650
00651
00652 if ( !oldFldName.isEmpty() )
00653 {
00654 kmkernel->folderMgr()->renameFolder( folder, fldName );
00655 } else {
00656 kmkernel->folderMgr()->contentsChanged();
00657 }
00658 }
00659 return true;
00660 }
00661
00662 void FolderDiaGeneralTab::slotChangeIcon( QString icon )
00663 {
00664 mUnreadIconButton->setIcon( icon );
00665 }
00666
00667
00668 KMail::FolderDiaTemplatesTab::FolderDiaTemplatesTab( KMFolderDialog* dlg,
00669 const QString& aName,
00670 QWidget* parent, const char* name )
00671 : FolderDiaTab( parent, name ), mDlg( dlg )
00672 {
00673
00674 mIsLocalSystemFolder = mDlg->folder()->isSystemFolder() &&
00675 mDlg->folder()->folderType() != KMFolderTypeImap &&
00676 mDlg->folder()->folderType() != KMFolderTypeCachedImap;
00677
00678 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
00679
00680 mCustom = new QCheckBox( i18n("&Use custom message templates"), this );
00681 topLayout->addWidget( mCustom );
00682
00683 mWidget = new TemplatesConfiguration( this , "folder-templates" );
00684 mWidget->setEnabled( false );
00685 topLayout->addWidget( mWidget );
00686
00687 QHBoxLayout *btns = new QHBoxLayout( topLayout, KDialog::spacingHint() );
00688 mCopyGlobal = new KPushButton( i18n("&Copy global templates"), this );
00689 mCopyGlobal->setEnabled( false );
00690 btns->addWidget( mCopyGlobal );
00691
00692 connect( mCustom, SIGNAL(toggled(bool)),
00693 mWidget, SLOT(setEnabled(bool)) );
00694 connect( mCustom, SIGNAL(toggled(bool)),
00695 mCopyGlobal, SLOT(setEnabled(bool)) );
00696
00697 connect( mCopyGlobal, SIGNAL(clicked()),
00698 this, SLOT(slotCopyGlobal()) );
00699
00700 initializeWithValuesFromFolder( mDlg->folder() );
00701
00702 connect( mWidget, SIGNAL( changed() ),
00703 this, SLOT( slotEmitChanged( void ) ) );
00704 }
00705
00706 void FolderDiaTemplatesTab::load()
00707 {
00708
00709 }
00710
00711 void FolderDiaTemplatesTab::initializeWithValuesFromFolder( KMFolder* folder ) {
00712 if ( !folder )
00713 return;
00714
00715 mFolder = folder;
00716
00717 QString fid = folder->idString();
00718
00719 Templates t( fid );
00720
00721 mCustom->setChecked(t.useCustomTemplates());
00722
00723 mIdentity = folder->identity();
00724
00725 mWidget->loadFromFolder( fid, mIdentity );
00726 }
00727
00728
00729 bool FolderDiaTemplatesTab::save()
00730 {
00731 KMFolder* folder = mDlg->folder();
00732
00733 QString fid = folder->idString();
00734 Templates t(fid);
00735
00736 kdDebug() << "use custom templates for folder " << fid << ": " << mCustom->isChecked() << endl;
00737 t.setUseCustomTemplates(mCustom->isChecked());
00738 t.writeConfig();
00739
00740 mWidget->saveToFolder(fid);
00741
00742 return true;
00743 }
00744
00745
00746 void FolderDiaTemplatesTab::slotEmitChanged() {}
00747
00748 void FolderDiaTemplatesTab::slotCopyGlobal() {
00749 if ( mIdentity ) {
00750 mWidget->loadFromIdentity( mIdentity );
00751 }
00752 else {
00753 mWidget->loadFromGlobal();
00754 }
00755 }