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