kmail

kmfolderdia.cpp
1 
32 #include <config.h>
33 
34 #include "acljobs.h"
35 #include "kmfolderdia.h"
36 #include "kmacctfolder.h"
37 #include "kmfoldermgr.h"
38 #include <libkpimidentities/identitycombo.h>
39 #include "kmfolderimap.h"
40 #include "kmfoldercachedimap.h"
41 #include "kmfolder.h"
42 #include "kmheaders.h"
43 #include "kmcommands.h"
44 #include "kmfoldertree.h"
45 #include "folderdiaacltab.h"
46 #include "folderdiaquotatab.h"
47 #include "kmailicalifaceimpl.h"
48 #include "globalsettings.h"
49 #include "folderrequester.h"
50 
51 #include <keditlistbox.h>
52 #include <klineedit.h>
53 #include <tdelocale.h>
54 #include <knuminput.h>
55 #include <tdemessagebox.h>
56 #include <kicondialog.h>
57 #include <tdeconfig.h>
58 #include <kdebug.h>
59 #include <tdelistview.h>
60 #include <kpushbutton.h>
61 
62 #include <tqcheckbox.h>
63 #include <tqlayout.h>
64 #include <tqgroupbox.h>
65 #include <tqregexp.h>
66 #include <tqlabel.h>
67 #include <tqvbox.h>
68 #include <tqtooltip.h>
69 #include <tqwhatsthis.h>
70 
71 #include <assert.h>
72 #include <tqhbuttongroup.h>
73 #include <tqradiobutton.h>
74 #include <tqtextedit.h>
75 
76 #include "templatesconfiguration.h"
77 #include "templatesconfiguration_kfg.h"
78 
79 #include "kmfolderdia.moc"
80 
81 using namespace KMail;
82 
83 static TQString inCaseWeDecideToRenameTheTab( I18N_NOOP( "Permissions (ACL)" ) );
84 
85 //-----------------------------------------------------------------------------
86 KMFolderDialog::KMFolderDialog(KMFolder *aFolder, KMFolderDir *aFolderDir,
87  KMFolderTree* aParent, const TQString& aCap,
88  const TQString& aName):
89  KDialogBase( KDialogBase::Tabbed,
90  aCap, KDialogBase::Ok|KDialogBase::Cancel,
91  KDialogBase::Ok, aParent, "KMFolderDialog", TRUE ),
92  mFolder( aFolder ),
93  mFolderDir( aFolderDir ),
94  mParentFolder( 0 ),
95  mIsNewFolder( aFolder == 0 ),
96  mFolderTree( aParent )
97 {
98  kdDebug(5006)<<"KMFolderDialog::KMFolderDialog()" << endl;
99 
100  TQStringList folderNames;
101  TQValueList<TQGuardedPtr<KMFolder> > folders;
102  // get all folders but search and folders that can not have children
103  aParent->createFolderList(&folderNames, &folders, true, true,
104  true, false, true, false);
105 
106  if( mFolderDir ) {
107  // search the parent folder of the folder
108  FolderList::ConstIterator it;
109  int i = 1;
110  for( it = folders.begin(); it != folders.end(); ++it, ++i ) {
111  if( (*it)->child() == mFolderDir ) {
112  mParentFolder = *it;
113  break;
114  }
115  }
116  }
117 
118  FolderDiaTab* tab;
119  TQVBox* box;
120 
121  box = addVBoxPage( i18n("General") );
122  tab = new FolderDiaGeneralTab( this, aName, box );
123  addTab( tab );
124  box = addVBoxPage( i18n("Templates") );
125  tab = new FolderDiaTemplatesTab( this, box );
126  addTab( tab );
127 
128  KMFolder* refFolder = mFolder ? mFolder : mParentFolder;
129  KMFolderType folderType = refFolder ? refFolder->folderType() : KMFolderTypeUnknown;
130  bool noContent = mFolder ? mFolder->storage()->noContent() : false;
131  if ( !noContent && refFolder && ( folderType == KMFolderTypeImap || folderType == KMFolderTypeCachedImap ) ) {
132  if ( FolderDiaACLTab::supports( refFolder ) ) {
133  box = addVBoxPage( i18n("Access Control") );
134  tab = new FolderDiaACLTab( this, box );
135  addTab( tab );
136  }
137  }
138  if ( !noContent && refFolder && ( folderType == KMFolderTypeImap || folderType == KMFolderTypeCachedImap ) ) {
139  if ( FolderDiaQuotaTab::supports( refFolder ) ) {
140  box = addVBoxPage( i18n("Quota") );
141  tab = new FolderDiaQuotaTab( this, box );
142  addTab( tab );
143  }
144  }
145 
146  for ( unsigned int i = 0 ; i < mTabs.count() ; ++i )
147  mTabs[i]->load();
148 }
149 
150 void KMFolderDialog::addTab( FolderDiaTab* tab )
151 {
152  connect( tab, TQ_SIGNAL( readyForAccept() ),
153  this, TQ_SLOT( slotReadyForAccept() ) );
154  connect( tab, TQ_SIGNAL( cancelAccept() ),
155  this, TQ_SLOT( slotCancelAccept() ) );
156  //connect( tab, TQ_SIGNAL(changed( bool )),
157  // this, TQ_SLOT(slotChanged( bool )) );
158  mTabs.append( tab );
159 }
160 
161 // Not used yet (no button), but ready to be used :)
162 void KMFolderDialog::slotApply()
163 {
164  if ( mFolder.isNull() && !mIsNewFolder ) { // deleted meanwhile?
165  KDialogBase::slotApply();
166  return;
167  }
168  for ( unsigned int i = 0 ; i < mTabs.count() ; ++i )
169  mTabs[i]->save();
170  if ( !mFolder.isNull() && mIsNewFolder ) // we just created it
171  mIsNewFolder = false; // so it's not new anymore :)
172  KDialogBase::slotApply();
173 }
174 
175 // Called when pressing Ok
176 // We want to apply the changes first (which is async), before closing the dialog,
177 // in case of errors during the upload.
178 void KMFolderDialog::slotOk()
179 {
180  if ( mFolder.isNull() && !mIsNewFolder ) { // deleted meanwhile?
181  KDialogBase::slotOk();
182  return;
183  }
184 
185  mDelayedSavingTabs = 0; // number of tabs which need delayed saving
186  for ( unsigned int i = 0 ; i < mTabs.count() ; ++i ) {
187  FolderDiaTab::AccepStatus s = mTabs[i]->accept();
188  if ( s == FolderDiaTab::Canceled ) {
189  slotCancelAccept();
190  return;
191  }
192  else if ( s == FolderDiaTab::Delayed )
193  ++mDelayedSavingTabs;
194  }
195 
196  if ( mDelayedSavingTabs )
197  enableButtonOK( false );
198  else
199  KDialogBase::slotOk();
200 }
201 
202 void KMFolderDialog::slotReadyForAccept()
203 {
204  --mDelayedSavingTabs;
205  if ( mDelayedSavingTabs == 0 )
206  KDialogBase::slotOk();
207 }
208 
209 void KMFolderDialog::slotCancelAccept()
210 {
211  mDelayedSavingTabs = -1;
212  enableButtonOK( true );
213  // Don't try to create it twice
214  if ( !mFolder.isNull() )
215  mIsNewFolder = false;
216 
217  // Other tabs might call slotReadyForAccept. -1 ensures that it won't close the dialog,
218  // but the OK button being enabled means that people might succeed in running
219  // the same job from save more than once.
220  // Solution: mAcceptCanceled = true instead of -1.
221  // Bah for now we only have one tab which can delay saving -> later.
222 }
223 
224 void KMFolderDialog::slotChanged( bool )
225 {
226  // TODO, support for 'changed', and Apply button.
227  // sample code for here: KCMultiDialog calls bool changed() on every TDECModuleProxy...
228 }
229 
230 void KMFolderDialog::setFolder( KMFolder* folder )
231 {
232  Q_ASSERT( mFolder.isNull() );
233  mFolder = folder;
234 }
235 
236 static void addLine( TQWidget *parent, TQVBoxLayout* layout )
237 {
238  TQFrame *line = new TQFrame( parent, "line" );
239  line->setGeometry( TQRect( 80, 150, 250, 20 ) );
240  line->setFrameShape( TQFrame::HLine );
241  line->setFrameShadow( TQFrame::Sunken );
242  line->setFrameShape( TQFrame::HLine );
243  layout->addWidget( line );
244 }
245 
246 //----------------------------------------------------------------------------
247 KMail::FolderDiaGeneralTab::FolderDiaGeneralTab( KMFolderDialog* dlg,
248  const TQString& aName,
249  TQWidget* parent, const char* name )
250  : FolderDiaTab( parent, name ),
251  mSharedSeenFlagsCheckBox( 0 ),
252  mDlg( dlg )
253 {
254 
255  mIsLocalSystemFolder = mDlg->folder()->isSystemFolder();
256  mIsResourceFolder = kmkernel->iCalIface().isStandardResourceFolder( mDlg->folder() );
257 
258  TQLabel *label;
259 
260  TQVBoxLayout *topLayout = new TQVBoxLayout( this, 0, KDialog::spacingHint() );
261 
262  // Musn't be able to edit details for a non-resource, system folder.
263  if ( !mIsLocalSystemFolder || mIsResourceFolder ) {
264 
265  TQHBoxLayout *hl = new TQHBoxLayout( topLayout );
266  hl->setSpacing( KDialog::spacingHint() );
267 
268  label = new TQLabel( i18n("&Name:"), this );
269  hl->addWidget( label );
270 
271  // Determine if we are allowed to rename this folder. Only possible if the folder supports
272  // ACLs.
273  bool nameChangeAllowed = true;
274  if ( mDlg->folder() && mDlg->parentFolder() &&
275  mDlg->folder()->storage() && mDlg->parentFolder()->storage() &&
276  ( mDlg->folder()->folderType() == KMFolderTypeCachedImap ||
277  mDlg->folder()->folderType() == KMFolderTypeImap ) ) {
278  ImapAccountBase *account = 0;
279  KMFolderCachedImap *dimap = 0;
280  KMFolderImap *imap = 0;
281  if ( mDlg->folder()->folderType() == KMFolderTypeCachedImap ) {
282  dimap = static_cast<KMFolderCachedImap*>( mDlg->folder()->storage() );
283  account = dynamic_cast<ImapAccountBase*>( dimap->account() );
284  }
285  if ( mDlg->folder()->folderType() == KMFolderTypeImap ) {
286  imap = static_cast<KMFolderImap*>( mDlg->folder()->storage() );
287  account = dynamic_cast<ImapAccountBase*>( imap->account() );
288  }
289 
290  if ( account && account->hasACLSupport() ) {
291  int parentRights = -1;
292  int folderRights = -1;
293  bool parentRightsOk = false;
294  bool folderRightsOk = false;
295  if ( imap ) {
296  KMFolderImap * const parent = dynamic_cast<KMFolderImap*>( mDlg->parentFolder()->storage() );
297  folderRights = imap->userRights();
298  folderRightsOk = imap->userRightsState() == KMail::ACLJobs::Ok;
299  if ( parent ) {
300  parentRights = parent->userRights();
301  parentRightsOk = parent->userRightsState() == KMail::ACLJobs::Ok;
302  }
303  } else if ( dimap ) {
304  KMFolderCachedImap * const parent = dynamic_cast<KMFolderCachedImap*>( mDlg->parentFolder()->storage() );
305  folderRights = dimap->userRights();
306  folderRightsOk = dimap->userRightsState() == KMail::ACLJobs::Ok;
307  if ( parent ) {
308  parentRights = parent->userRights();
309  parentRightsOk = parent->userRightsState() == KMail::ACLJobs::Ok;
310  }
311  }
312 
313  // For renaming, we need support for deleting the mailbox and then re-creating it.
314  if ( parentRightsOk && folderRightsOk &&
315  ( !( parentRights & KMail::ACLJobs::Create ) || !( folderRights & KMail::ACLJobs::Delete ) ) ) {
316  nameChangeAllowed = false;
317  }
318  }
319  }
320 
321  mNameEdit = new KLineEdit( this );
322  if( !mDlg->folder() && nameChangeAllowed )
323  mNameEdit->setFocus();
324  mNameEdit->setEnabled( nameChangeAllowed );
325  if ( !nameChangeAllowed ) {
326  TQToolTip::add( mNameEdit, i18n( "Not enough permissions to rename this folder.\n"
327  "The parent folder doesn't have write support.\n"
328  "A sync is needed after changing the permissions." ) );
329  }
330  mNameEdit->setText( mDlg->folder() ? mDlg->folder()->label() : i18n("unnamed") );
331  if (!aName.isEmpty())
332  mNameEdit->setText(aName);
333  mNameEdit->setMinimumSize(mNameEdit->sizeHint());
334  // prevent renaming of IMAP inbox
335  if ( mDlg->folder() && mDlg->folder()->isSystemFolder() ) {
336  TQString imapPath;
337  if ( mDlg->folder()->folderType() == KMFolderTypeImap )
338  imapPath = static_cast<KMFolderImap*>( mDlg->folder()->storage() )->imapPath();
339  if ( mDlg->folder()->folderType() == KMFolderTypeCachedImap )
340  imapPath = static_cast<KMFolderCachedImap*>( mDlg->folder()->storage() )->imapPath();
341  if ( imapPath == "/INBOX/" )
342  mNameEdit->setEnabled( false );
343  }
344  label->setBuddy( mNameEdit );
345  hl->addWidget( mNameEdit );
346  connect( mNameEdit, TQ_SIGNAL( textChanged( const TQString & ) ),
347  this, TQ_SLOT( slotFolderNameChanged( const TQString & ) ) );
348 
349 
350  //start icons group
351  TQVBoxLayout *ivl = new TQVBoxLayout( topLayout );
352  ivl->setSpacing( KDialog::spacingHint() );
353 
354  TQHBoxLayout *ihl = new TQHBoxLayout( ivl );
355  mIconsCheckBox = new TQCheckBox( i18n("Use custom &icons"), this );
356  mIconsCheckBox->setChecked( false );
357  ihl->addWidget( mIconsCheckBox );
358  ihl->addStretch( 2 );
359 
360  mNormalIconLabel = new TQLabel( i18n("&Normal:"), this );
361  mNormalIconLabel->setEnabled( false );
362  ihl->addWidget( mNormalIconLabel );
363 
364  mNormalIconButton = new TDEIconButton( this );
365  mNormalIconLabel->setBuddy( mNormalIconButton );
366  mNormalIconButton->setIconType( TDEIcon::NoGroup , TDEIcon::Any, true );
367  mNormalIconButton->setIconSize( 16 );
368  mNormalIconButton->setStrictIconSize( true );
369  mNormalIconButton->setFixedSize( 28, 28 );
370  // Can't use iconset here
371  mNormalIconButton->setIcon( "folder" );
372  mNormalIconButton->setEnabled( false );
373  ihl->addWidget( mNormalIconButton );
374 
375  mUnreadIconLabel = new TQLabel( i18n("&Unread:"), this );
376  mUnreadIconLabel->setEnabled( false );
377  ihl->addWidget( mUnreadIconLabel );
378 
379  mUnreadIconButton = new TDEIconButton( this );
380  mUnreadIconLabel->setBuddy( mUnreadIconButton );
381  mUnreadIconButton->setIconType( TDEIcon::NoGroup, TDEIcon::Any, true );
382  mUnreadIconButton->setIconSize( 16 );
383  mUnreadIconButton->setStrictIconSize( true );
384  mUnreadIconButton->setFixedSize( 28, 28 );
385  // Can't use iconset here
386  mUnreadIconButton->setIcon( "folder_open" );
387  mUnreadIconButton->setEnabled( false );
388  ihl->addWidget( mUnreadIconButton );
389  ihl->addStretch( 1 );
390 
391  connect( mIconsCheckBox, TQ_SIGNAL(toggled(bool)),
392  mNormalIconButton, TQ_SLOT(setEnabled(bool)) );
393  connect( mIconsCheckBox, TQ_SIGNAL(toggled(bool)),
394  mUnreadIconButton, TQ_SLOT(setEnabled(bool)) );
395  connect( mIconsCheckBox, TQ_SIGNAL(toggled(bool)),
396  mNormalIconLabel, TQ_SLOT(setEnabled(bool)) );
397  connect( mIconsCheckBox, TQ_SIGNAL(toggled(bool)),
398  mUnreadIconLabel, TQ_SLOT(setEnabled(bool)) );
399 
400  connect( mNormalIconButton, TQ_SIGNAL(iconChanged(TQString)),
401  this, TQ_SLOT(slotChangeIcon(TQString)) );
402 
403  //end icons group
404  addLine( this, topLayout);
405  }
406 
407 
408  // should new mail in this folder be ignored?
409  TQHBoxLayout *hbl = new TQHBoxLayout( topLayout );
410  hbl->setSpacing( KDialog::spacingHint() );
411  mNotifyOnNewMailCheckBox =
412  new TQCheckBox( i18n("Act on new/unread mail in this folder" ), this );
413  TQWhatsThis::add( mNotifyOnNewMailCheckBox,
414  i18n( "<qt><p>If this option is enabled then you will be notified about "
415  "new/unread mail in this folder. Moreover, going to the "
416  "next/previous folder with unread messages will stop at this "
417  "folder.</p>"
418  "<p>Uncheck this option if you do not want to be notified about "
419  "new/unread mail in this folder and if you want this folder to "
420  "be skipped when going to the next/previous folder with unread "
421  "messages. This is useful for ignoring any new/unread mail in "
422  "your trash and spam folder.</p></qt>" ) );
423  hbl->addWidget( mNotifyOnNewMailCheckBox );
424 
425  if ( mDlg->folder()->folderType() == KMFolderTypeImap ) {
426  // should this folder be included in new-mail-checks?
427 
428  TQHBoxLayout *nml = new TQHBoxLayout( topLayout );
429  nml->setSpacing( KDialog::spacingHint() );
430  mNewMailCheckBox = new TQCheckBox( i18n("Include this folder in mail checks"), this );
431  // default is on
432  mNewMailCheckBox->setChecked(true);
433  nml->addWidget( mNewMailCheckBox );
434  nml->addStretch( 1 );
435  }
436 
437  // should replies to mails in this folder be kept in this same folder?
438  hbl = new TQHBoxLayout( topLayout );
439  hbl->setSpacing( KDialog::spacingHint() );
440  mKeepRepliesInSameFolderCheckBox =
441  new TQCheckBox( i18n("Keep replies in this folder" ), this );
442  TQWhatsThis::add( mKeepRepliesInSameFolderCheckBox,
443  i18n( "Check this option if you want replies you write "
444  "to mails in this folder to be put in this same folder "
445  "after sending, instead of in the configured sent-mail folder." ) );
446  hbl->addWidget( mKeepRepliesInSameFolderCheckBox );
447  hbl->addStretch( 1 );
448 
449  addLine( this, topLayout );
450 
451  // use grid layout for the following combobox settings
452  TQGridLayout *gl = new TQGridLayout( topLayout, 3, 2, KDialog::spacingHint() );
453  gl->setColStretch( 1, 100 ); // make the second column use all available space
454  int row = -1;
455 
456  // sender or receiver column?
457  ++row;
458  TQString tip = i18n("Show Sender/Receiver Column in List of Messages");
459 
460  TQLabel *sender_label = new TQLabel( i18n("Sho&w column:" ), this );
461  gl->addWidget( sender_label, row, 0 );
462  mShowSenderReceiverComboBox = new TQComboBox( this );
463  TQToolTip::add( mShowSenderReceiverComboBox, tip );
464  sender_label->setBuddy(mShowSenderReceiverComboBox);
465  gl->addWidget( mShowSenderReceiverComboBox, row, 1 );
466  mShowSenderReceiverComboBox->insertItem(i18n("Default"), 0);
467  mShowSenderReceiverComboBox->insertItem(i18n("Sender"), 1);
468  mShowSenderReceiverComboBox->insertItem(i18n("Receiver"), 2);
469 
470  TQString whoField;
471  if (mDlg->folder()) whoField = mDlg->folder()->userWhoField();
472  if (whoField.isEmpty()) mShowSenderReceiverComboBox->setCurrentItem(0);
473  else if (whoField == "From") mShowSenderReceiverComboBox->setCurrentItem(1);
474  else if (whoField == "To") mShowSenderReceiverComboBox->setCurrentItem(2);
475 
476 
477  // sender identity
478  ++row;
479  label = new TQLabel( i18n("&Sender identity:"), this );
480  gl->addWidget( label, row, 0 );
481  mIdentityComboBox = new KPIM::IdentityCombo( kmkernel->identityManager(), this );
482  label->setBuddy( mIdentityComboBox );
483  gl->addWidget( mIdentityComboBox, row, 1 );
484  TQWhatsThis::add( mIdentityComboBox,
485  i18n( "Select the sender identity to be used when writing new mail "
486  "or replying to mail in this folder. This means that if you are in "
487  "one of your work folders, you can make KMail use the corresponding "
488  "sender email address, signature and signing or encryption keys "
489  "automatically. Identities can be set up in the main configuration "
490  "dialog. (Settings -> Configure KMail)") );
491 
492  // folder contents
493  if ( ( !mIsLocalSystemFolder || mIsResourceFolder ) &&
494  kmkernel->iCalIface().isEnabled() &&
495  mDlg->folder() && mDlg->folder()->folderType() != KMFolderTypeImap ) {
496  // Only do make this settable, if the IMAP resource is enabled
497  // and it's not the personal folders (those must not be changed)
498  ++row;
499  label = new TQLabel( i18n("&Folder contents:"), this );
500  gl->addWidget( label, row, 0 );
501  mContentsComboBox = new TQComboBox( this );
502  label->setBuddy( mContentsComboBox );
503  gl->addWidget( mContentsComboBox, row, 1 );
504 
505  mContentsComboBox->insertItem( i18n( "Mail" ) );
506  mContentsComboBox->insertItem( i18n( "Calendar" ) );
507  mContentsComboBox->insertItem( i18n( "Contacts" ) );
508  mContentsComboBox->insertItem( i18n( "Notes" ) );
509  mContentsComboBox->insertItem( i18n( "Tasks" ) );
510  mContentsComboBox->insertItem( i18n( "Journal" ) );
511  if ( mDlg->folder() )
512  mContentsComboBox->setCurrentItem( mDlg->folder()->storage()->contentsType() );
513  connect ( mContentsComboBox, TQ_SIGNAL ( activated( int ) ),
514  this, TQ_SLOT( slotFolderContentsSelectionChanged( int ) ) );
515  if ( mDlg->folder()->isReadOnly() || mIsResourceFolder )
516  mContentsComboBox->setEnabled( false );
517  } else {
518  mContentsComboBox = 0;
519  }
520 
521  mIncidencesForComboBox = 0;
522  mAlarmsBlockedCheckBox = 0;
523 
524  // Kolab incidences-for annotation.
525  // Show incidences-for combobox if the contents type can be changed (new folder),
526  // or if it's set to calendar or task (existing folder)
527  if ( ( GlobalSettings::self()->theIMAPResourceStorageFormat() ==
528  GlobalSettings::EnumTheIMAPResourceStorageFormat::XML ) &&
529  mContentsComboBox ) {
530  ++row;
531 
532  TQLabel* label = new TQLabel( i18n( "Generate free/&busy and activate alarms for:" ), this );
533  gl->addWidget( label, row, 0 );
534  mIncidencesForComboBox = new TQComboBox( this );
535  label->setBuddy( mIncidencesForComboBox );
536  gl->addWidget( mIncidencesForComboBox, row, 1 );
537 
538  const TQString whatsThisForMyOwnFolders =
539  i18n( "This setting defines which users sharing "
540  "this folder should get \"busy\" periods in their freebusy lists "
541  "and should see the alarms for the events or tasks in this folder. "
542  "The setting applies to Calendar and Task folders only "
543  "(for tasks, this setting is only used for alarms).\n\n"
544  "Example use cases: if the boss shares a folder with their secretary, "
545  "only the boss should be marked as busy for their meetings, so they should "
546  "select \"Admins\", since the secretary has no admin rights on the folder.\n"
547  "On the other hand if a working group shares a Calendar for "
548  "group meetings, all readers of the folders should be marked "
549  "as busy for meetings.\n"
550  "A company-wide folder with optional events in it would use \"Nobody\" "
551  "since it is not known who will go to those events." );
552 
553  TQWhatsThis::add( mIncidencesForComboBox, whatsThisForMyOwnFolders );
554  mIncidencesForComboBox->insertItem( i18n( "Nobody" ) );
555  mIncidencesForComboBox->insertItem( i18n( "Admins of This Folder" ) );
556  mIncidencesForComboBox->insertItem( i18n( "All Readers of This Folder" ) );
557  ++row;
558  const TQString whatsThisForReadOnlyFolders =
559  i18n( "This setting allows you to disable alarms for folders shared by others. ");
560  mAlarmsBlockedCheckBox = new TQCheckBox( this );
561  mAlarmsBlockedCheckBox->setText( i18n( "Block alarms locally" ) );
562  gl->addMultiCellWidget( mAlarmsBlockedCheckBox, row, row, 0, 1);
563  TQWhatsThis::add( mAlarmsBlockedCheckBox, whatsThisForReadOnlyFolders );
564 
565  if ( mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeCalendar
566  && mDlg->folder()->storage()->contentsType() != KMail::ContentsTypeTask ) {
567  mIncidencesForComboBox->setEnabled( false );
568  mAlarmsBlockedCheckBox->setEnabled( false );
569  }
570  }
571 
572  if ( mDlg->folder()->folderType() == KMFolderTypeCachedImap ) {
573  kdDebug() << k_funcinfo << mDlg->folder()->folderType() << endl;
574  mSharedSeenFlagsCheckBox = new TQCheckBox( this );
575  mSharedSeenFlagsCheckBox->setText( i18n( "Share unread state with all users" ) );
576  ++row;
577  gl->addMultiCellWidget( mSharedSeenFlagsCheckBox, row, row, 0, 1 );
578  TQWhatsThis::add( mSharedSeenFlagsCheckBox, i18n( "If enabled, the unread state of messages in this folder will be the same "
579  "for all users having access to this folders. If disabled (the default), every user with access to this folder has her "
580  "own unread state." ) );
581  }
582  topLayout->addStretch( 100 ); // eat all superfluous space
583 
584  initializeWithValuesFromFolder( mDlg->folder() );
585 }
586 
587 void FolderDiaGeneralTab::load()
588 {
589  // Nothing here, all is done in the ctor
590 }
591 
592 void FolderDiaGeneralTab::initializeWithValuesFromFolder( KMFolder* folder ) {
593  if ( !folder )
594  return;
595 
596  if ( !mIsLocalSystemFolder ) {
597  // folder icons
598  mIconsCheckBox->setChecked( folder->useCustomIcons() );
599  mNormalIconLabel->setEnabled( folder->useCustomIcons() );
600  mNormalIconButton->setEnabled( folder->useCustomIcons() );
601  mUnreadIconLabel->setEnabled( folder->useCustomIcons() );
602  mUnreadIconButton->setEnabled( folder->useCustomIcons() );
603  TQString iconPath = folder->normalIconPath();
604  if ( !iconPath.isEmpty() )
605  mNormalIconButton->setIcon( iconPath );
606  iconPath = folder->unreadIconPath();
607  if ( !iconPath.isEmpty() )
608  mUnreadIconButton->setIcon( iconPath );
609  }
610 
611  // folder identity
612  mIdentityComboBox->setCurrentIdentity( folder->identity() );
613  // ignore new mail
614  mNotifyOnNewMailCheckBox->setChecked( !folder->ignoreNewMail() );
615 
616  const bool keepInFolder = !folder->isReadOnly() && folder->putRepliesInSameFolder();
617  mKeepRepliesInSameFolderCheckBox->setChecked( keepInFolder );
618  mKeepRepliesInSameFolderCheckBox->setDisabled( folder->isReadOnly() );
619 
620  if (folder->folderType() == KMFolderTypeImap)
621  {
622  KMFolderImap* imapFolder = static_cast<KMFolderImap*>(folder->storage());
623  bool checked = imapFolder->includeInMailCheck();
624  mNewMailCheckBox->setChecked(checked);
625  }
626 
627  if ( mIncidencesForComboBox ) {
628  KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( folder->storage() );
629  mIncidencesForComboBox->setCurrentItem( dimap->incidencesFor() );
630  mIncidencesForComboBox->setDisabled( mDlg->folder()->isReadOnly() );
631  }
632  if ( mAlarmsBlockedCheckBox ) {
633  KMFolderCachedImap* dimap = static_cast<KMFolderCachedImap *>( folder->storage() );
634  mAlarmsBlockedCheckBox->setChecked( dimap->alarmsBlocked() );
635  }
636  if ( mSharedSeenFlagsCheckBox ) {
637  KMFolderCachedImap *dimap = static_cast<KMFolderCachedImap*>( folder->storage() );
638  ImapAccountBase *account = dynamic_cast<ImapAccountBase*>( dimap->account() );
639  mSharedSeenFlagsCheckBox->setChecked( dimap->sharedSeenFlags() );
640  mSharedSeenFlagsCheckBox->setDisabled( folder->isReadOnly() );
641  if ( account && account->hasCapability( "x-kmail-sharedseen" ) )
642  mSharedSeenFlagsCheckBox->show();
643  else
644  mSharedSeenFlagsCheckBox->hide();
645  }
646 }
647 
648 //-----------------------------------------------------------------------------
649 void FolderDiaGeneralTab::slotFolderNameChanged( const TQString& str )
650 {
651  mDlg->enableButtonOK( !str.isEmpty() );
652 }
653 
654 //-----------------------------------------------------------------------------
655 void FolderDiaGeneralTab::slotFolderContentsSelectionChanged( int )
656 {
657  KMail::FolderContentsType type =
658  static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
659  if( type != KMail::ContentsTypeMail && GlobalSettings::self()->hideGroupwareFolders() ) {
660  TQString message = i18n("You have configured this folder to contain groupware information "
661  "and the general configuration option to hide groupware folders is "
662  "set. That means that this folder will disappear once the configuration "
663  "dialog is closed. If you want to remove the folder again, you will need "
664  "to temporarily disable hiding of groupware folders to be able to see it.");
665  KMessageBox::information( this, message );
666  }
667  const bool enable = type == KMail::ContentsTypeCalendar ||
668  type == KMail::ContentsTypeTask;
669  if ( mIncidencesForComboBox )
670  mIncidencesForComboBox->setEnabled( enable );
671  if ( mAlarmsBlockedCheckBox )
672  mAlarmsBlockedCheckBox->setEnabled( enable );
673 }
674 
675 //-----------------------------------------------------------------------------
677 {
678  KMFolder* folder = mDlg->folder();
679  folder->setIdentity( mIdentityComboBox->currentIdentity() );
680  // set whoField
681  if (mShowSenderReceiverComboBox->currentItem() == 1)
682  folder->setUserWhoField("From");
683  else if (mShowSenderReceiverComboBox->currentItem() == 2)
684  folder->setUserWhoField("To");
685  else
686  folder->setUserWhoField("");
687 
688  folder->setIgnoreNewMail( !mNotifyOnNewMailCheckBox->isChecked() );
689  folder->setPutRepliesInSameFolder( mKeepRepliesInSameFolderCheckBox->isChecked() );
690 
691  TQString fldName, oldFldName;
692  KMFolderCachedImap* dimap = 0;
693  if ( folder->folderType() == KMFolderTypeCachedImap )
694  dimap = static_cast<KMFolderCachedImap *>( mDlg->folder()->storage() );
695 
696  if ( !mIsLocalSystemFolder || mIsResourceFolder )
697  {
698  oldFldName = mDlg->folder()->name();
699  if (!mNameEdit->text().isEmpty())
700  fldName = mNameEdit->text();
701  else
702  fldName = oldFldName;
703 
704  if ( mDlg->parentFolder() &&
705  mDlg->parentFolder()->folderType() != KMFolderTypeImap &&
706  mDlg->parentFolder()->folderType() != KMFolderTypeCachedImap )
707  fldName.remove('/');
708  fldName.remove(TQRegExp("^\\.*"));
709  if (fldName.isEmpty()) fldName = i18n("unnamed");
710 
711 
712  // Update the tree iff new icon paths are different and not empty or if
713  // useCustomIcons changed.
714  if ( folder->useCustomIcons() != mIconsCheckBox->isChecked() ) {
715  folder->setUseCustomIcons( mIconsCheckBox->isChecked() );
716  // Reset icons, useCustomIcons was turned off.
717  if ( !folder->useCustomIcons() ) {
718  folder->setIconPaths( "", "" );
719  }
720  }
721  if ( folder->useCustomIcons() && (
722  (( mNormalIconButton->icon() != folder->normalIconPath() ) &&
723  ( !mNormalIconButton->icon().isEmpty())) ||
724  (( mUnreadIconButton->icon() != folder->unreadIconPath() ) &&
725  ( !mUnreadIconButton->icon().isEmpty())) ) ) {
726  folder->setIconPaths( mNormalIconButton->icon(), mUnreadIconButton->icon() );
727  }
728 
729  // Set type field
730  if ( mContentsComboBox ) {
731  KMail::FolderContentsType type =
732  static_cast<KMail::FolderContentsType>( mContentsComboBox->currentItem() );
733  folder->storage()->setContentsType( type );
734  }
735 
736  if ( dimap ) {
737  if ( mIncidencesForComboBox ) {
738  KMFolderCachedImap::IncidencesFor incfor = KMFolderCachedImap::IncForAdmins;
739  incfor = static_cast<KMFolderCachedImap::IncidencesFor>( mIncidencesForComboBox->currentItem() );
740  if ( dimap->incidencesFor() != incfor ) {
741  dimap->setIncidencesFor( incfor );
742  dimap->writeConfig();
743  }
744  }
745  if ( mAlarmsBlockedCheckBox && mAlarmsBlockedCheckBox->isChecked() != dimap->alarmsBlocked() ) {
746  dimap->setAlarmsBlocked( mAlarmsBlockedCheckBox->isChecked() );
747  dimap->writeConfig();
748  }
749  }
750 
751  if( folder->folderType() == KMFolderTypeImap )
752  {
753  KMFolderImap* imapFolder = static_cast<KMFolderImap*>( folder->storage() );
754  imapFolder->setIncludeInMailCheck(
755  mNewMailCheckBox->isChecked() );
756  }
757  }
758 
759  if ( dimap && mSharedSeenFlagsCheckBox &&
760  mSharedSeenFlagsCheckBox->isChecked() != dimap->sharedSeenFlags() ) {
761  dimap->setSharedSeenFlags( mSharedSeenFlagsCheckBox->isChecked() );
762  dimap->writeConfig();
763  }
764 
765  // make sure everything is on disk, connected slots will call readConfig()
766  // when creating a new folder.
767  folder->storage()->writeConfig();
768 
769  TQString msg;
770  if ( !folder->isValidName( fldName, msg ) ) {
771  KMessageBox::sorry( this, msg );
772  return false;
773  } else {
774  // Renamed an existing folder? We don't check for oldName == newName on
775  // purpose here. The folder might be pending renaming on the next dimap
776  // sync already, in which case the old name would still be around and
777  // something like Calendar -> CalendarFoo -> Calendar inbetween syncs would
778  // fail. Therefor let the folder sort it out itself, whether the rename is
779  // a noop or not.
780  if ( !oldFldName.isEmpty() )
781  {
782  kmkernel->folderMgr()->renameFolder( folder, fldName );
783  } else {
784  kmkernel->folderMgr()->contentsChanged();
785  }
786  }
787 
788  return true;
789 }
790 
791 void FolderDiaGeneralTab::slotChangeIcon( TQString icon ) // can't use a const-ref here, due to TDEIconButton's signal
792 {
793  mUnreadIconButton->setIcon( icon );
794 }
795 
796 //----------------------------------------------------------------------------
797 KMail::FolderDiaTemplatesTab::FolderDiaTemplatesTab( KMFolderDialog* dlg,
798  TQWidget* parent )
799  : FolderDiaTab( parent, 0 ), mDlg( dlg )
800 {
801 
802  mIsLocalSystemFolder = mDlg->folder()->isSystemFolder();
803 
804 
805  TQVBoxLayout *topLayout = new TQVBoxLayout( this, 0, KDialog::spacingHint() );
806 
807  mCustom = new TQCheckBox( i18n("&Use custom message templates"), this );
808  topLayout->addWidget( mCustom );
809 
810  mWidget = new TemplatesConfiguration( this , "folder-templates" );
811  mWidget->setEnabled( false );
812  topLayout->addWidget( mWidget );
813 
814  TQHBoxLayout *btns = new TQHBoxLayout( topLayout, KDialog::spacingHint() );
815  mCopyGlobal = new KPushButton( i18n("&Copy global templates"), this );
816  mCopyGlobal->setEnabled( false );
817  btns->addWidget( mCopyGlobal );
818 
819  connect( mCustom, TQ_SIGNAL(toggled(bool)),
820  mWidget, TQ_SLOT(setEnabled(bool)) );
821  connect( mCustom, TQ_SIGNAL(toggled(bool)),
822  mCopyGlobal, TQ_SLOT(setEnabled(bool)) );
823 
824  connect( mCopyGlobal, TQ_SIGNAL(clicked()),
825  this, TQ_SLOT(slotCopyGlobal()) );
826 
827  initializeWithValuesFromFolder( mDlg->folder() );
828 
829  connect( mWidget, TQ_SIGNAL( changed() ),
830  this, TQ_SLOT( slotEmitChanged( void ) ) );
831 }
832 
833 void FolderDiaTemplatesTab::load()
834 {
835 
836 }
837 
838 void FolderDiaTemplatesTab::initializeWithValuesFromFolder( KMFolder* folder ) {
839  if ( !folder )
840  return;
841 
842  mFolder = folder;
843 
844  TQString fid = folder->idString();
845 
846  Templates t( fid );
847 
848  mCustom->setChecked(t.useCustomTemplates());
849 
850  mIdentity = folder->identity();
851 
852  mWidget->loadFromFolder( fid, mIdentity );
853 }
854 
855 //-----------------------------------------------------------------------------
857 {
858  KMFolder* folder = mDlg->folder();
859 
860  TQString fid = folder->idString();
861  Templates t(fid);
862 
863  kdDebug() << "use custom templates for folder " << fid << ": " << mCustom->isChecked() << endl;
864  t.setUseCustomTemplates(mCustom->isChecked());
865  t.writeConfig();
866 
867  mWidget->saveToFolder(fid);
868 
869  return true;
870 }
871 
872 
873 void FolderDiaTemplatesTab::slotEmitChanged() {}
874 
875 void FolderDiaTemplatesTab::slotCopyGlobal() {
876  if ( mIdentity ) {
877  mWidget->loadFromIdentity( mIdentity );
878  }
879  else {
880  mWidget->loadFromGlobal();
881  }
882 }
bool putRepliesInSameFolder() const
Returns true if the replies to mails from this folder should be put in the same folder.
Definition: kmfolder.h:519
bool ignoreNewMail() const
Returns true if the user doesn't want to get notified about new mail in this folder.
Definition: kmfolder.h:526
void changed(bool)
Called when this module was changed [not really used yet].
bool isReadOnly() const
Is the folder read-only?
Definition: kmfolder.cpp:561
Dialog for handling the properties of a mail folder.
Definition: kmfolderdia.h:198
KMail list that manages the contents of one directory that may contain folders and/or other directori...
Definition: kmfolderdir.h:15
bool useCustomIcons() const
Icon related methods.
Definition: kmfolder.h:499
bool isValidName(const TQString &folderName, TQString &message)
Returns true if the name is valid for a child of this folder.
Definition: kmfolder.cpp:899
virtual void writeConfig()
Write the config file.
This is the base class for tabs in the folder dialog.
Definition: kmfolderdia.h:69
virtual void setContentsType(KMail::FolderContentsType type, bool quiet=false)
Set the type of contents held in this folder (mail, calendar, etc.)
"Quota" tab in the folder dialog Internal class, only used by KMFolderDialog
"General" tab in the folder dialog Internal class, only used by KMFolderDialog
Definition: kmfolderdia.h:111
virtual bool save()
Unlike ConfigModuleTab, we return a bool from save.
"Templates" tab in the folder dialog Internal class, only used by KMFolderDialog
Definition: kmfolderdia.h:163
TQString idString() const
Returns a string that can be used to identify this folder.
Definition: kmfolder.cpp:705
virtual bool save()
Unlike ConfigModuleTab, we return a bool from save.
"Access Control" tab in the folder dialog Internal class, only used by KMFolderDialog
KMFolderType folderType() const
Returns the type of this folder.
Definition: kmfolder.cpp:233
folderdiaquotatab.h
Definition: aboutdata.cpp:40
bool isSystemFolder() const
Returns true if the folder is a kmail system folder.
Definition: kmfolder.h:369
@ Ok
The user rights/ACL have been fetched from the server sucessfully.
Definition: acljobs.h:66
Mail folder.
Definition: kmfolder.h:68
virtual bool noContent() const
Returns, if the folder can't contain mails, but only subfolder.