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