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