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