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, 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
00279 if ( mDlg->folder() && mDlg->folder()->isSystemFolder() ) {
00280 QString imapPath;
00281 if ( mDlg->folder()->folderType() == KMFolderTypeImap )
00282 imapPath = static_cast<KMFolderImap*>( mDlg->folder()->storage() )->imapPath();
00283 if ( mDlg->folder()->folderType() == KMFolderTypeCachedImap )
00284 imapPath = static_cast<KMFolderCachedImap*>( mDlg->folder()->storage() )->imapPath();
00285 if ( imapPath == "/INBOX/" )
00286 mNameEdit->setEnabled( false );
00287 }
00288 label->setBuddy( mNameEdit );
00289 hl->addWidget( mNameEdit );
00290 connect( mNameEdit, SIGNAL( textChanged( const QString & ) ),
00291 this, SLOT( slotFolderNameChanged( const QString & ) ) );
00292
00293
00294
00295 QVBoxLayout *ivl = new QVBoxLayout( topLayout );
00296 ivl->setSpacing( KDialog::spacingHint() );
00297
00298 QHBoxLayout *ihl = new QHBoxLayout( ivl );
00299 mIconsCheckBox = new QCheckBox( i18n("Use custom &icons"), this );
00300 mIconsCheckBox->setChecked( false );
00301 ihl->addWidget( mIconsCheckBox );
00302 ihl->addStretch( 2 );
00303
00304 mNormalIconLabel = new QLabel( i18n("&Normal:"), this );
00305 mNormalIconLabel->setEnabled( false );
00306 ihl->addWidget( mNormalIconLabel );
00307
00308 mNormalIconButton = new KIconButton( this );
00309 mNormalIconLabel->setBuddy( mNormalIconButton );
00310 mNormalIconButton->setIconType( KIcon::NoGroup , KIcon::Any, true );
00311 mNormalIconButton->setIconSize( 16 );
00312 mNormalIconButton->setStrictIconSize( true );
00313 mNormalIconButton->setFixedSize( 28, 28 );
00314
00315 mNormalIconButton->setIcon( "folder" );
00316 mNormalIconButton->setEnabled( false );
00317 ihl->addWidget( mNormalIconButton );
00318
00319 mUnreadIconLabel = new QLabel( i18n("&Unread:"), this );
00320 mUnreadIconLabel->setEnabled( false );
00321 ihl->addWidget( mUnreadIconLabel );
00322
00323 mUnreadIconButton = new KIconButton( this );
00324 mUnreadIconLabel->setBuddy( mUnreadIconButton );
00325 mUnreadIconButton->setIconType( KIcon::NoGroup, KIcon::Any, true );
00326 mUnreadIconButton->setIconSize( 16 );
00327 mUnreadIconButton->setStrictIconSize( true );
00328 mUnreadIconButton->setFixedSize( 28, 28 );
00329
00330 mUnreadIconButton->setIcon( "folder_open" );
00331 mUnreadIconButton->setEnabled( false );
00332 ihl->addWidget( mUnreadIconButton );
00333 ihl->addStretch( 1 );
00334
00335 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00336 mNormalIconButton, SLOT(setEnabled(bool)) );
00337 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00338 mUnreadIconButton, SLOT(setEnabled(bool)) );
00339 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00340 mNormalIconLabel, SLOT(setEnabled(bool)) );
00341 connect( mIconsCheckBox, SIGNAL(toggled(bool)),
00342 mUnreadIconLabel, SLOT(setEnabled(bool)) );
00343
00344 connect( mNormalIconButton, SIGNAL(iconChanged(QString)),
00345 this, SLOT(slotChangeIcon(QString)) );
00346
00347
00348 addLine( this, topLayout);
00349 }
00350
00351
00352
00353 QHBoxLayout *hbl = new QHBoxLayout( topLayout );
00354 hbl->setSpacing( KDialog::spacingHint() );
00355 mNotifyOnNewMailCheckBox =
00356 new QCheckBox( i18n("Act on new/unread mail in this folder" ), this );
00357 QWhatsThis::add( mNotifyOnNewMailCheckBox,
00358 i18n( "<qt><p>If this option is enabled then you will be notified about "
00359 "new/unread mail in this folder. Moreover, going to the "
00360 "next/previous folder with unread messages will stop at this "
00361 "folder.</p>"
00362 "<p>Uncheck this option if you do not want to be notified about "
00363 "new/unread mail in this folder and if you want this folder to "
00364 "be skipped when going to the next/previous folder with unread "
00365 "messages. This is useful for ignoring any new/unread mail in "
00366 "your trash and spam folder.</p></qt>" ) );
00367 hbl->addWidget( mNotifyOnNewMailCheckBox );
00368
00369 if ( mDlg->folder()->folderType() == KMFolderTypeImap ) {
00370
00371
00372 QHBoxLayout *nml = new QHBoxLayout( topLayout );
00373 nml->setSpacing( KDialog::spacingHint() );
00374 mNewMailCheckBox = new QCheckBox( i18n("Include this folder in mail checks"), this );
00375
00376 mNewMailCheckBox->setChecked(true);
00377 nml->addWidget( mNewMailCheckBox );
00378 nml->addStretch( 1 );
00379 }
00380
00381
00382 hbl = new QHBoxLayout( topLayout );
00383 hbl->setSpacing( KDialog::spacingHint() );
00384 mKeepRepliesInSameFolderCheckBox =
00385 new QCheckBox( i18n("Keep replies in this folder" ), this );
00386 QWhatsThis::add( mKeepRepliesInSameFolderCheckBox,
00387 i18n( "Check this option if you want replies you write "
00388 "to mails in this folder to be put in this same folder "
00389 "after sending, instead of in the configured sent-mail folder." ) );
00390 hbl->addWidget( mKeepRepliesInSameFolderCheckBox );
00391 hbl->addStretch( 1 );
00392
00393 addLine( this, topLayout );
00394
00395
00396 QGridLayout *gl = new QGridLayout( topLayout, 3, 2, KDialog::spacingHint() );
00397 gl->setColStretch( 1, 100 );
00398 int row = -1;
00399
00400
00401 ++row;
00402 QString tip = i18n("Show Sender/Receiver Column in List of Messages");
00403
00404 QLabel *sender_label = new QLabel( i18n("Sho&w column:" ), this );
00405 gl->addWidget( sender_label, row, 0 );
00406 mShowSenderReceiverComboBox = new QComboBox( this );
00407 QToolTip::add( mShowSenderReceiverComboBox, tip );
00408 sender_label->setBuddy(mShowSenderReceiverComboBox);
00409 gl->addWidget( mShowSenderReceiverComboBox, row, 1 );
00410 mShowSenderReceiverComboBox->insertItem(i18n("Default"), 0);
00411 mShowSenderReceiverComboBox->insertItem(i18n("Sender"), 1);
00412 mShowSenderReceiverComboBox->insertItem(i18n("Receiver"), 2);
00413
00414 QString whoField;
00415 if (mDlg->folder()) whoField = mDlg->folder()->userWhoField();
00416 if (whoField.isEmpty()) mShowSenderReceiverComboBox->setCurrentItem(0);
00417 else if (whoField == "From") mShowSenderReceiverComboBox->setCurrentItem(1);
00418 else if (whoField == "To") mShowSenderReceiverComboBox->setCurrentItem(2);
00419
00420
00421
00422 ++row;
00423 label = new QLabel( i18n("&Sender identity:"), this );
00424 gl->addWidget( label, row, 0 );
00425 mIdentityComboBox = new KPIM::IdentityCombo( kmkernel->identityManager(), this );
00426 label->setBuddy( mIdentityComboBox );
00427 gl->addWidget( mIdentityComboBox, row, 1 );
00428 QWhatsThis::add( mIdentityComboBox,
00429 i18n( "Select the sender identity to be used when writing new mail "
00430 "or replying to mail in this folder. This means that if you are in "
00431 "one of your work folders, you can make KMail use the corresponding "
00432 "sender email address, signature and signing or encryption keys "
00433 "automatically. Identities can be set up in the main configuration "
00434 "dialog. (Settings -> Configure KMail)") );
00435
00436
00437
00438 if ( !mIsLocalSystemFolder && kmkernel->iCalIface().isEnabled() ) {
00439
00440
00441 ++row;
00442 label = new QLabel( i18n("&Folder contents:"), this );
00443 gl->addWidget( label, row, 0 );
00444 mContentsComboBox = new QComboBox( this );
00445 label->setBuddy( mContentsComboBox );
00446 gl->addWidget( mContentsComboBox, row, 1 );
00447
00448 mContentsComboBox->insertItem( i18n( "Mail" ) );
00449 mContentsComboBox->insertItem( i18n( "Calendar" ) );
00450 mContentsComboBox->insertItem( i18n( "Contacts" ) );
00451 mContentsComboBox->insertItem( i18n( "Notes" ) );
00452 mContentsComboBox->insertItem( i18n( "Tasks" ) );
00453 mContentsComboBox->insertItem( i18n( "Journal" ) );
00454 if ( mDlg->folder() )
00455 mContentsComboBox->setCurrentItem( mDlg->folder()->storage()->contentsType() );
00456 connect ( mContentsComboBox, SIGNAL ( activated( int ) ),
00457 this, SLOT( slotFolderContentsSelectionChanged( int ) ) );
00458 if ( mDlg->folder()->isReadOnly() )
00459 mContentsComboBox->setEnabled( false );
00460 } else {
00461 mContentsComboBox = 0;
00462 }
00463
00464 mIncidencesForComboBox = 0;
00465 mAlarmsBlockedCheckBox = 0;
00466
00467
00468
00469
00470 if ( ( GlobalSettings::self()->theIMAPResourceStorageFormat() ==
00471 GlobalSettings::EnumTheIMAPResourceStorageFormat::XML ) &&
00472 mContentsComboBox ) {
00473 ++row;
00474
00475 QLabel* label = new QLabel( i18n( "Generate free/&busy and activate alarms for:" ), this );
00476 gl->addWidget( label, row, 0 );
00477 mIncidencesForComboBox = new QComboBox( this );
00478 label->setBuddy( mIncidencesForComboBox );
00479 gl->addWidget( mIncidencesForComboBox, row, 1 );
00480
00481 const QString whatsThisForMyOwnFolders =
00482 i18n( "This setting defines which users sharing "
00483 "this folder should get \"busy\" periods in their freebusy lists "
00484 "and should see the alarms for the events or tasks in this folder. "
00485 "The setting applies to Calendar and Task folders only "
00486 "(for tasks, this setting is only used for alarms).\n\n"
00487 "Example use cases: if the boss shares a folder with his secretary, "
00488 "only the boss should be marked as busy for his meetings, so he should "
00489 "select \"Admins\", since the secretary has no admin rights on the folder.\n"
00490 "On the other hand if a working group shares a Calendar for "
00491 "group meetings, all readers of the folders should be marked "
00492 "as busy for meetings.\n"
00493 "A company-wide folder with optional events in it would use \"Nobody\" "
00494 "since it is not known who will go to those events." );
00495
00496 QWhatsThis::add( mIncidencesForComboBox, whatsThisForMyOwnFolders );
00497 mIncidencesForComboBox->insertItem( i18n( "Nobody" ) );
00498 mIncidencesForComboBox->insertItem( i18n( "Admins of This Folder" ) );
00499 mIncidencesForComboBox->insertItem( i18n( "All Readers of This Folder" ) );
00500 ++row;
00501 const QString whatsThisForReadOnlyFolders =
00502 i18n( "This setting allows you to disable alarms for folders shared by "
00503 "others. ");
00504 mAlarmsBlockedCheckBox = new QCheckBox( this );
00505 gl->addWidget( mAlarmsBlockedCheckBox, row, 0 );
00506 label = new QLabel( i18n( "Block free/&busy and alarms locally" ), this );
00507 gl->addWidget( label, row, 1 );
00508 label->setBuddy( mAlarmsBlockedCheckBox );
00509 QWhatsThis::add( mAlarmsBlockedCheckBox, whatsThisForReadOnlyFolders );
00510
00511 if ( mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeCalendar
00512 && mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeTask ) {
00513 mIncidencesForComboBox->setEnabled( false );
00514 mAlarmsBlockedCheckBox->setEnabled( false );
00515 }
00516 }
00517 topLayout->addStretch( 100 );
00518
00519 initializeWithValuesFromFolder( mDlg->folder() );
00520 }
00521
00522 void FolderDiaGeneralTab::load()
00523 {
00524
00525 }
00526
00527 void FolderDiaGeneralTab::initializeWithValuesFromFolder( KMFolder* folder ) {
00528 if ( !folder )
00529 return;
00530
00531 if ( !mIsLocalSystemFolder ) {
00532
00533 mIconsCheckBox->setChecked( folder->useCustomIcons() );
00534 mNormalIconLabel->setEnabled( folder->useCustomIcons() );
00535 mNormalIconButton->setEnabled( folder->useCustomIcons() );
00536 mUnreadIconLabel->setEnabled( folder->useCustomIcons() );
00537 mUnreadIconButton->setEnabled( folder->useCustomIcons() );
00538 QString iconPath = folder->normalIconPath();
00539 if ( !iconPath.isEmpty() )
00540 mNormalIconButton->setIcon( iconPath );
00541 iconPath = folder->unreadIconPath();
00542 if ( !iconPath.isEmpty() )
00543 mUnreadIconButton->setIcon( iconPath );
00544 }
00545
00546
00547 mIdentityComboBox->setCurrentIdentity( folder->identity() );
00548
00549 mNotifyOnNewMailCheckBox->setChecked( !folder->ignoreNewMail() );
00550
00551 const bool keepInFolder = !folder->isReadOnly() && folder->putRepliesInSameFolder();
00552 mKeepRepliesInSameFolderCheckBox->setChecked( keepInFolder );
00553 mKeepRepliesInSameFolderCheckBox->setDisabled( folder->isReadOnly() );
00554
00555 if (folder->folderType() == KMFolderTypeImap)
00556 {
00557 KMFolderImap* imapFolder = static_cast<KMFolderImap*>(folder->storage());
00558 bool checked = imapFolder->includeInMailCheck();
00559 mNewMailCheckBox->setChecked(checked);
00560 }
00561
00562 if ( mIncidencesForComboBox ) {
00563 KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( folder->storage() );
00564 mIncidencesForComboBox->setCurrentItem( dimap->incidencesFor() );
00565 mIncidencesForComboBox->setDisabled( mDlg->folder()->isReadOnly() );
00566 }
00567 if ( mAlarmsBlockedCheckBox ) {
00568 KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( folder->storage() );
00569 mAlarmsBlockedCheckBox->setChecked( dimap->alarmsBlocked() );
00570 }
00571 }
00572
00573
00574 void FolderDiaGeneralTab::slotFolderNameChanged( const QString& str )
00575 {
00576 mDlg->enableButtonOK( !str.isEmpty() );
00577 }
00578
00579
00580 void FolderDiaGeneralTab::slotFolderContentsSelectionChanged( int )
00581 {
00582 KMail::FolderContentsType type =
00583 static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
00584 if( type != KMail::ContentsTypeMail && GlobalSettings::self()->hideGroupwareFolders() ) {
00585 QString message = i18n("You have configured this folder to contain groupware information "
00586 "and the general configuration option to hide groupware folders is "
00587 "set. That means that this folder will disappear once the configuration "
00588 "dialog is closed. If you want to remove the folder again, you will need "
00589 "to temporarily disable hiding of groupware folders to be able to see it.");
00590 KMessageBox::information( this, message );
00591 }
00592 const bool enable = type == KMail::ContentsTypeCalendar ||
00593 type == KMail::ContentsTypeTask;
00594 if ( mIncidencesForComboBox )
00595 mIncidencesForComboBox->setEnabled( enable );
00596 if ( mAlarmsBlockedCheckBox )
00597 mAlarmsBlockedCheckBox->setEnabled( enable );
00598 }
00599
00600
00601 bool FolderDiaGeneralTab::save()
00602 {
00603 KMFolder* folder = mDlg->folder();
00604 folder->setIdentity( mIdentityComboBox->currentIdentity() );
00605
00606 if (mShowSenderReceiverComboBox->currentItem() == 1)
00607 folder->setUserWhoField("From");
00608 else if (mShowSenderReceiverComboBox->currentItem() == 2)
00609 folder->setUserWhoField("To");
00610 else
00611 folder->setUserWhoField("");
00612
00613 folder->setIgnoreNewMail( !mNotifyOnNewMailCheckBox->isChecked() );
00614 folder->setPutRepliesInSameFolder( mKeepRepliesInSameFolderCheckBox->isChecked() );
00615
00616 QString fldName, oldFldName;
00617 if ( !mIsLocalSystemFolder )
00618 {
00619 QString acctName;
00620 oldFldName = mDlg->folder()->name();
00621
00622 if (!mNameEdit->text().isEmpty())
00623 fldName = mNameEdit->text();
00624 else
00625 fldName = oldFldName;
00626
00627 if ( mDlg->parentFolder() &&
00628 mDlg->parentFolder()->folderType() != KMFolderTypeImap &&
00629 mDlg->parentFolder()->folderType() != KMFolderTypeCachedImap )
00630 fldName.remove('/');
00631 fldName.remove(QRegExp("^\\.*"));
00632 if (fldName.isEmpty()) fldName = i18n("unnamed");
00633
00634
00635
00636
00637 if ( folder->useCustomIcons() != mIconsCheckBox->isChecked() ) {
00638 folder->setUseCustomIcons( mIconsCheckBox->isChecked() );
00639
00640 if ( !folder->useCustomIcons() ) {
00641 folder->setIconPaths( "", "" );
00642 }
00643 }
00644 if ( folder->useCustomIcons() &&
00645 (( mNormalIconButton->icon() != folder->normalIconPath() ) &&
00646 ( !mNormalIconButton->icon().isEmpty())) ||
00647 (( mUnreadIconButton->icon() != folder->unreadIconPath() ) &&
00648 ( !mUnreadIconButton->icon().isEmpty())) ) {
00649 folder->setIconPaths( mNormalIconButton->icon(), mUnreadIconButton->icon() );
00650 }
00651
00652
00653 if ( mContentsComboBox ) {
00654 KMail::FolderContentsType type =
00655 static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
00656 folder->storage()->setContentsType( type );
00657 }
00658
00659 if ( folder->folderType() == KMFolderTypeCachedImap ) {
00660 KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( mDlg->folder()->storage() );
00661 if ( mIncidencesForComboBox ) {
00662 KMFolderCachedImap::IncidencesFor incfor = KMFolderCachedImap::IncForAdmins;
00663 incfor = static_cast<KMFolderCachedImap::IncidencesFor>( mIncidencesForComboBox->currentItem() );
00664 if ( dimap->incidencesFor() != incfor ) {
00665 dimap->setIncidencesFor( incfor );
00666 dimap->writeConfig();
00667 }
00668 }
00669 if ( mAlarmsBlockedCheckBox && mAlarmsBlockedCheckBox->isChecked() != dimap->alarmsBlocked() ) {
00670 dimap->setAlarmsBlocked( mAlarmsBlockedCheckBox->isChecked() );
00671 dimap->writeConfig();
00672 }
00673 }
00674
00675 if( folder->folderType() == KMFolderTypeImap )
00676 {
00677 KMFolderImap* imapFolder = static_cast<KMFolderImap*>( folder->storage() );
00678 imapFolder->setIncludeInMailCheck(
00679 mNewMailCheckBox->isChecked() );
00680 }
00681
00682
00683 folder->storage()->writeConfig();
00684
00685
00686
00687
00688
00689
00690 if ( !oldFldName.isEmpty() )
00691 {
00692 kmkernel->folderMgr()->renameFolder( folder, fldName );
00693 } else {
00694 kmkernel->folderMgr()->contentsChanged();
00695 }
00696 }
00697 return true;
00698 }
00699
00700 void FolderDiaGeneralTab::slotChangeIcon( QString icon )
00701 {
00702 mUnreadIconButton->setIcon( icon );
00703 }
00704
00705
00706 KMail::FolderDiaTemplatesTab::FolderDiaTemplatesTab( KMFolderDialog* dlg,
00707 QWidget* parent )
00708 : FolderDiaTab( parent, 0 ), mDlg( dlg )
00709 {
00710
00711 mIsLocalSystemFolder = mDlg->folder()->isSystemFolder() &&
00712 mDlg->folder()->folderType() != KMFolderTypeImap &&
00713 mDlg->folder()->folderType() != KMFolderTypeCachedImap;
00714
00715 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
00716
00717 mCustom = new QCheckBox( i18n("&Use custom message templates"), this );
00718 topLayout->addWidget( mCustom );
00719
00720 mWidget = new TemplatesConfiguration( this , "folder-templates" );
00721 mWidget->setEnabled( false );
00722 topLayout->addWidget( mWidget );
00723
00724 QHBoxLayout *btns = new QHBoxLayout( topLayout, KDialog::spacingHint() );
00725 mCopyGlobal = new KPushButton( i18n("&Copy global templates"), this );
00726 mCopyGlobal->setEnabled( false );
00727 btns->addWidget( mCopyGlobal );
00728
00729 connect( mCustom, SIGNAL(toggled(bool)),
00730 mWidget, SLOT(setEnabled(bool)) );
00731 connect( mCustom, SIGNAL(toggled(bool)),
00732 mCopyGlobal, SLOT(setEnabled(bool)) );
00733
00734 connect( mCopyGlobal, SIGNAL(clicked()),
00735 this, SLOT(slotCopyGlobal()) );
00736
00737 initializeWithValuesFromFolder( mDlg->folder() );
00738
00739 connect( mWidget, SIGNAL( changed() ),
00740 this, SLOT( slotEmitChanged( void ) ) );
00741 }
00742
00743 void FolderDiaTemplatesTab::load()
00744 {
00745
00746 }
00747
00748 void FolderDiaTemplatesTab::initializeWithValuesFromFolder( KMFolder* folder ) {
00749 if ( !folder )
00750 return;
00751
00752 mFolder = folder;
00753
00754 QString fid = folder->idString();
00755
00756 Templates t( fid );
00757
00758 mCustom->setChecked(t.useCustomTemplates());
00759
00760 mIdentity = folder->identity();
00761
00762 mWidget->loadFromFolder( fid, mIdentity );
00763 }
00764
00765
00766 bool FolderDiaTemplatesTab::save()
00767 {
00768 KMFolder* folder = mDlg->folder();
00769
00770 QString fid = folder->idString();
00771 Templates t(fid);
00772
00773 kdDebug() << "use custom templates for folder " << fid << ": " << mCustom->isChecked() << endl;
00774 t.setUseCustomTemplates(mCustom->isChecked());
00775 t.writeConfig();
00776
00777 mWidget->saveToFolder(fid);
00778
00779 return true;
00780 }
00781
00782
00783 void FolderDiaTemplatesTab::slotEmitChanged() {}
00784
00785 void FolderDiaTemplatesTab::slotCopyGlobal() {
00786 if ( mIdentity ) {
00787 mWidget->loadFromIdentity( mIdentity );
00788 }
00789 else {
00790 mWidget->loadFromGlobal();
00791 }
00792 }