• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • collectionpage
collectiongeneralpage.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  Copyright (c) 2009-2013 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "collectiongeneralpage.h"
19 
20 #include "collectionannotationsattribute.h"
21 #include "newmailnotifierattribute.h"
22 #include "foldercollection.h"
23 #include "kernel/mailkernel.h"
24 #include "util/mailutil.h"
25 
26 #include "pimcommon/util/pimutil.h"
27 #include <Akonadi/AgentManager>
28 #include <Akonadi/AttributeFactory>
29 #include <Akonadi/Collection>
30 #include <Akonadi/CollectionModifyJob>
31 #include <Akonadi/EntityDisplayAttribute>
32 
33 #include <KPIMIdentities/IdentityCombo>
34 
35 #include <KColorScheme>
36 #include <KComboBox>
37 #include <KDialog>
38 #include <KLineEdit>
39 #include <KLocale>
40 #include <KMessageBox>
41 
42 #include <QCheckBox>
43 #include <QHBoxLayout>
44 #include <QLabel>
45 #include <QVBoxLayout>
46 
47 // TODO Where should these be?
48 #define KOLAB_FOLDERTYPE "/vendor/kolab/folder-type"
49 #define KOLAB_INCIDENCESFOR "/vendor/kolab/incidences-for"
50 #define KOLAB_SHAREDSEEN "/vendor/cmu/cyrus-imapd/sharedseen"
51 
52 using namespace Akonadi;
53 using namespace MailCommon;
54 
55 CollectionGeneralPage::CollectionGeneralPage( QWidget *parent )
56  : CollectionPropertiesPage( parent ), mNameEdit( 0 ), mFolderCollection( 0 )
57 {
58  setObjectName( QLatin1String( "MailCommon::CollectionGeneralPage" ) );
59  setPageTitle( i18nc( "@title:tab General settings for a folder.", "General" ) );
60 }
61 
62 CollectionGeneralPage::~CollectionGeneralPage()
63 {
64 }
65 
66 static void addLine( QWidget *parent, QVBoxLayout *layout )
67 {
68  QFrame *line = new QFrame( parent );
69  line->setGeometry( QRect( 80, 150, 250, 20 ) );
70  line->setFrameShape( QFrame::HLine );
71  line->setFrameShadow( QFrame::Sunken );
72  line->setFrameShape( QFrame::HLine );
73  layout->addWidget( line );
74 }
75 
76 static QString incidencesForToString( CollectionGeneralPage::IncidencesFor type )
77 {
78  switch ( type ) {
79  case CollectionGeneralPage::IncForNobody:
80  return QLatin1String("nobody");
81  case CollectionGeneralPage::IncForAdmins:
82  return QLatin1String("admins");
83  case CollectionGeneralPage::IncForReaders:
84  return QLatin1String("readers");
85  }
86 
87  return QString(); // can't happen
88 }
89 
90 static CollectionGeneralPage::IncidencesFor incidencesForFromString( const QString &string )
91 {
92  if ( string == QLatin1String("nobody") ) {
93  return CollectionGeneralPage::IncForNobody;
94  }
95  else if ( string == QLatin1String("admins") ) {
96  return CollectionGeneralPage::IncForAdmins;
97  }
98  else if ( string == QLatin1String("readers") ) {
99  return CollectionGeneralPage::IncForReaders;
100  }
101 
102  return CollectionGeneralPage::IncForAdmins; // by default
103 }
104 
105 static QString folderContentDescription( CollectionGeneralPage::FolderContentsType type )
106 {
107  switch ( type ) {
108  case CollectionGeneralPage::ContentsTypeMail:
109  return ( i18nc( "type of folder content", "Mail" ) );
110  case CollectionGeneralPage::ContentsTypeCalendar:
111  return ( i18nc( "type of folder content", "Calendar" ) );
112  case CollectionGeneralPage::ContentsTypeContact:
113  return ( i18nc( "type of folder content", "Contacts" ) );
114  case CollectionGeneralPage::ContentsTypeNote:
115  return ( i18nc( "type of folder content", "Notes" ) );
116  case CollectionGeneralPage::ContentsTypeTask:
117  return ( i18nc( "type of folder content", "Tasks" ) );
118  case CollectionGeneralPage::ContentsTypeJournal:
119  return ( i18nc( "type of folder content", "Journal" ) );
120  case CollectionGeneralPage::ContentsTypeConfiguration:
121  return ( i18nc( "type of folder content", "Configuration" ) );
122  case CollectionGeneralPage::ContentsTypeFreebusy:
123  return ( i18nc( "type of folder content", "Freebusy" ) );
124  case CollectionGeneralPage::ContentsTypeFile:
125  return ( i18nc( "type of folder content", "Files" ) );
126  default:
127  return ( i18nc( "type of folder content", "Unknown" ) );
128  }
129 }
130 
131 static CollectionGeneralPage::FolderContentsType contentsTypeFromString( const QString &type )
132 {
133  if ( type == i18nc( "type of folder content", "Mail" ) ) {
134  return CollectionGeneralPage::ContentsTypeMail;
135  }
136  if ( type == i18nc( "type of folder content", "Calendar" ) ) {
137  return CollectionGeneralPage::ContentsTypeCalendar;
138  }
139  if ( type == i18nc( "type of folder content", "Contacts" ) ) {
140  return CollectionGeneralPage::ContentsTypeContact;
141  }
142  if ( type == i18nc( "type of folder content", "Notes" ) ) {
143  return CollectionGeneralPage::ContentsTypeNote;
144  }
145  if ( type == i18nc( "type of folder content", "Tasks" ) ) {
146  return CollectionGeneralPage::ContentsTypeTask;
147  }
148  if ( type == i18nc( "type of folder content", "Journal" ) ) {
149  return CollectionGeneralPage::ContentsTypeJournal;
150  }
151  if ( type == i18nc( "type of folder content", "Configuration" ) ) {
152  return CollectionGeneralPage::ContentsTypeConfiguration;
153  }
154  if ( type == i18nc( "type of folder content", "Freebusy" ) ) {
155  return CollectionGeneralPage::ContentsTypeFreebusy;
156  }
157  if ( type == i18nc( "type of folder content", "Files" ) ) {
158  return CollectionGeneralPage::ContentsTypeFile;
159  }
160 
161  return CollectionGeneralPage::ContentsTypeMail; //safety return value
162 }
163 
164 static QString typeNameFromKolabType( const QByteArray &type )
165 {
166  if ( type == "task" || type == "task.default" ) {
167  return i18nc( "type of folder content", "Tasks" );
168  }
169  if ( type == "event" || type == "event.default" ) {
170  return i18nc( "type of folder content", "Calendar" );
171  }
172  if ( type == "contact" || type == "contact.default" ) {
173  return i18nc( "type of folder content", "Contacts" );
174  }
175  if ( type == "note" || type == "note.default" ) {
176  return i18nc( "type of folder content", "Notes" );
177  }
178  if ( type == "journal" || type == "journal.default" ) {
179  return i18nc( "type of folder content", "Journal" );
180  }
181  if ( type == "configuration" || type == "configuration.default" ) {
182  return i18nc( "type of folder content", "Configuration" );
183  }
184  if ( type == "freebusy" || type == "freebusy.default" ) {
185  return i18nc( "type of folder content", "Freebusy" );
186  }
187  if ( type == "file" || type == "file.default" ) {
188  return i18nc( "type of folder content", "Files" );
189  }
190 
191  return i18nc( "type of folder content", "Mail" );
192 }
193 
194 static QByteArray kolabNameFromType( CollectionGeneralPage::FolderContentsType type )
195 {
196  switch ( type ) {
197  case CollectionGeneralPage::ContentsTypeCalendar:
198  return "event";
199  case CollectionGeneralPage::ContentsTypeContact:
200  return "contact";
201  case CollectionGeneralPage::ContentsTypeNote:
202  return "note";
203  case CollectionGeneralPage::ContentsTypeTask:
204  return "task";
205  case CollectionGeneralPage::ContentsTypeJournal:
206  return "journal";
207  case CollectionGeneralPage::ContentsTypeConfiguration:
208  return "configuration";
209  case CollectionGeneralPage::ContentsTypeFreebusy:
210  return "freebusy";
211  case CollectionGeneralPage::ContentsTypeFile:
212  return "file";
213  default:
214  return QByteArray();
215  }
216 }
217 
218 static CollectionGeneralPage::FolderContentsType typeFromKolabName( const QByteArray &name )
219 {
220  if ( name == "task" || name == "task.default" ) {
221  return CollectionGeneralPage::ContentsTypeTask;
222  }
223  if ( name == "event" || name == "event.default" ) {
224  return CollectionGeneralPage::ContentsTypeCalendar;
225  }
226  if ( name == "contact" || name == "contact.default" ) {
227  return CollectionGeneralPage::ContentsTypeContact;
228  }
229  if ( name == "note" || name == "note.default" ) {
230  return CollectionGeneralPage::ContentsTypeNote;
231  }
232  if ( name == "journal" || name == "journal.default" ) {
233  return CollectionGeneralPage::ContentsTypeJournal;
234  }
235  if ( name == "configuration" || name == "configuration.default" ) {
236  return CollectionGeneralPage::ContentsTypeConfiguration;
237  }
238  if ( name == "freebusy" || name == "freebusy.default" ) {
239  return CollectionGeneralPage::ContentsTypeFreebusy;
240  }
241  if ( name == "file" || name == "file.default" ) {
242  return CollectionGeneralPage::ContentsTypeFile;
243  }
244 
245  return CollectionGeneralPage::ContentsTypeMail;
246 }
247 
248 void CollectionGeneralPage::init( const Akonadi::Collection &collection )
249 {
250  mIsLocalSystemFolder = CommonKernel->isSystemFolderCollection( collection ) ||
251  Kernel::folderIsInbox( collection, true );
252 
253  mIsResourceFolder = ( collection.parentCollection() == Akonadi::Collection::root() );
254  QLabel *label;
255 
256  QVBoxLayout *topLayout = new QVBoxLayout( this );
257  topLayout->setSpacing( KDialog::spacingHint() );
258  topLayout->setMargin( 0 );
259 
260  // Musn't be able to edit details for a non-resource, system folder.
261  if ( ( !mIsLocalSystemFolder || mIsResourceFolder ) &&
262  !mFolderCollection->isReadOnly() ) {
263 
264  QHBoxLayout *hl = new QHBoxLayout();
265  topLayout->addItem( hl );
266  hl->setSpacing( KDialog::spacingHint() );
267  hl->setMargin( KDialog::marginHint() );
268  label = new QLabel( i18nc( "@label:textbox Name of the folder.", "&Name:" ), this );
269  hl->addWidget( label );
270 
271  mNameEdit = new KLineEdit( this );
272  connect( mNameEdit, SIGNAL(textChanged(QString)), SLOT(slotNameChanged(QString)) );
273  label->setBuddy( mNameEdit );
274  hl->addWidget( mNameEdit );
275  }
276 
277  // should new mail in this folder be ignored?
278  QHBoxLayout *hbl = new QHBoxLayout();
279  topLayout->addItem( hbl );
280  hbl->setSpacing( KDialog::spacingHint() );
281  hbl->setMargin( KDialog::marginHint() );
282  mNotifyOnNewMailCheckBox =
283  new QCheckBox( i18n( "Act on new/unread mail in this folder" ), this );
284  mNotifyOnNewMailCheckBox->setWhatsThis(
285  i18n( "<qt><p>If this option is enabled then you will be notified about "
286  "new/unread mail in this folder. Moreover, going to the "
287  "next/previous folder with unread messages will stop at this "
288  "folder.</p>"
289  "<p>Uncheck this option if you do not want to be notified about "
290  "new/unread mail in this folder and if you want this folder to "
291  "be skipped when going to the next/previous folder with unread "
292  "messages. This is useful for ignoring any new/unread mail in "
293  "your trash and spam folder.</p></qt>" ) );
294  hbl->addWidget( mNotifyOnNewMailCheckBox );
295  // should replies to mails in this folder be kept in this same folder?
296  hbl = new QHBoxLayout();
297  topLayout->addItem( hbl );
298  hbl->setSpacing( KDialog::spacingHint() );
299  hbl->setMargin( KDialog::marginHint() );
300  mKeepRepliesInSameFolderCheckBox =
301  new QCheckBox( i18n( "Keep replies in this folder" ), this );
302  mKeepRepliesInSameFolderCheckBox->setWhatsThis(
303  i18n( "Check this option if you want replies you write "
304  "to mails in this folder to be put in this same folder "
305  "after sending, instead of in the configured sent-mail folder." ) );
306  hbl->addWidget( mKeepRepliesInSameFolderCheckBox );
307  hbl->addStretch( 1 );
308  // should this folder be shown in the folder selection dialog?
309  hbl = new QHBoxLayout();
310  topLayout->addItem( hbl );
311  hbl->setSpacing( KDialog::spacingHint() );
312  hbl->setMargin( KDialog::marginHint() );
313  mHideInSelectionDialogCheckBox =
314  new QCheckBox( i18n( "Hide this folder in the folder selection dialog" ), this );
315  mHideInSelectionDialogCheckBox->setWhatsThis(
316  i18nc( "@info:whatsthis",
317  "Check this option if you do not want this folder "
318  "to be shown in folder selection dialogs, such as the <interface>"
319  "Jump to Folder</interface> dialog." ) );
320  hbl->addWidget( mHideInSelectionDialogCheckBox );
321  hbl->addStretch( 1 );
322 
323  addLine( this, topLayout );
324  // use grid layout for the following combobox settings
325  QGridLayout *gl = new QGridLayout();
326  gl->setMargin( KDialog::marginHint() );
327  topLayout->addItem( gl );
328  gl->setSpacing( KDialog::spacingHint() );
329  gl->setColumnStretch( 1, 100 ); // make the second column use all available space
330  int row = -1;
331 
332  // sender identity
333  ++row;
334  mUseDefaultIdentityCheckBox = new QCheckBox( i18n( "Use &default identity" ), this );
335  gl->addWidget( mUseDefaultIdentityCheckBox );
336  connect( mUseDefaultIdentityCheckBox, SIGNAL(stateChanged(int)),
337  this, SLOT(slotIdentityCheckboxChanged()) );
338  ++row;
339  label = new QLabel( i18n( "&Sender identity:" ), this );
340  gl->addWidget( label, row, 0 );
341  mIdentityComboBox = new KPIMIdentities::IdentityCombo( KernelIf->identityManager(), this );
342  label->setBuddy( mIdentityComboBox );
343  gl->addWidget( mIdentityComboBox, row, 1 );
344  mIdentityComboBox->setWhatsThis(
345  i18n( "Select the sender identity to be used when writing new mail "
346  "or replying to mail in this folder. This means that if you are in "
347  "one of your work folders, you can make KMail use the corresponding "
348  "sender email address, signature and signing or encryption keys "
349  "automatically. Identities can be set up in the main configuration "
350  "dialog. (Settings -> Configure KMail)" ) );
351 
352  CollectionGeneralPage::FolderContentsType contentsType = CollectionGeneralPage::ContentsTypeMail;
353 
354  const CollectionAnnotationsAttribute *annotationAttribute =
355  collection.attribute<CollectionAnnotationsAttribute>();
356 
357  const QMap<QByteArray, QByteArray> annotations =
358  ( annotationAttribute ?
359  annotationAttribute->annotations() :
360  QMap<QByteArray, QByteArray>() );
361 
362  const bool sharedSeen = ( annotations.value( KOLAB_SHAREDSEEN ) == "true" );
363 
364  const IncidencesFor incidencesFor =
365  incidencesForFromString( QLatin1String(annotations.value( KOLAB_INCIDENCESFOR )) );
366 
367  const FolderContentsType folderType = typeFromKolabName( annotations.value( KOLAB_FOLDERTYPE ) );
368 
369  // Only do make this settable, if the IMAP resource is enabled
370  // and it's not the personal folders (those must not be changed)
371  if ( collection.resource().contains( IMAP_RESOURCE_IDENTIFIER ) ) {
372  ++row;
373  label = new QLabel( i18n( "&Folder contents:" ), this );
374  gl->addWidget( label, row, 0 );
375  mContentsComboBox = new KComboBox( this );
376  label->setBuddy( mContentsComboBox );
377  gl->addWidget( mContentsComboBox, row, 1 );
378  mContentsComboBox->addItem( folderContentDescription( ContentsTypeMail ) );
379  mContentsComboBox->addItem( folderContentDescription( ContentsTypeCalendar ) );
380  mContentsComboBox->addItem( folderContentDescription( ContentsTypeContact ) );
381  mContentsComboBox->addItem( folderContentDescription( ContentsTypeNote ) );
382  mContentsComboBox->addItem( folderContentDescription( ContentsTypeTask ) );
383  mContentsComboBox->addItem( folderContentDescription( ContentsTypeJournal ) );
384  mContentsComboBox->addItem( folderContentDescription( ContentsTypeConfiguration ) );
385  mContentsComboBox->addItem( folderContentDescription( ContentsTypeFreebusy ) );
386  mContentsComboBox->addItem( folderContentDescription( ContentsTypeFile ) );
387 
388  mContentsComboBox->setCurrentIndex( contentsType );
389 
390  connect( mContentsComboBox, SIGNAL(activated(int)),
391  this, SLOT(slotFolderContentsSelectionChanged(int)) );
392 
393  if ( mFolderCollection->isReadOnly() || mIsResourceFolder ) {
394  mContentsComboBox->setEnabled( false );
395  }
396 
397  } else {
398  mContentsComboBox = 0;
399  }
400 
401  // Kolab incidences-for annotation.
402  // Show incidences-for combobox if the contents type can be changed (new folder),
403  // or if it's set to calendar or task (existing folder)
404  if ( folderType == ContentsTypeCalendar || folderType == ContentsTypeTask ) {
405  ++row;
406  QLabel *label = new QLabel( i18n( "Generate free/&busy and activate alarms for:" ), this );
407  gl->addWidget( label, row, 0 );
408  mIncidencesForComboBox = new KComboBox( this );
409  label->setBuddy( mIncidencesForComboBox );
410  gl->addWidget( mIncidencesForComboBox, row, 1 );
411 
412  mIncidencesForComboBox->addItem( i18n( "Nobody" ) );
413  mIncidencesForComboBox->addItem( i18n( "Admins of This Folder" ) );
414  mIncidencesForComboBox->addItem( i18n( "All Readers of This Folder" ) );
415  const QString whatsThisForMyOwnFolders =
416  i18n( "This setting defines which users sharing "
417  "this folder should get \"busy\" periods in their freebusy lists "
418  "and should see the alarms for the events or tasks in this folder. "
419  "The setting applies to Calendar and Task folders only "
420  "(for tasks, this setting is only used for alarms).\n\n"
421  "Example use cases: if the boss shares a folder with his secretary, "
422  "only the boss should be marked as busy for his meetings, so he should "
423  "select \"Admins\", since the secretary has no admin rights on the folder.\n"
424  "On the other hand if a working group shares a Calendar for "
425  "group meetings, all readers of the folders should be marked "
426  "as busy for meetings.\n"
427  "A company-wide folder with optional events in it would use \"Nobody\" "
428  "since it is not known who will go to those events." );
429 
430  mIncidencesForComboBox->setWhatsThis( whatsThisForMyOwnFolders );
431  mIncidencesForComboBox->setCurrentIndex( incidencesFor );
432  } else {
433  mIncidencesForComboBox = 0;
434  }
435 
436  if ( collection.resource().contains( IMAP_RESOURCE_IDENTIFIER ) ) {
437  mSharedSeenFlagsCheckBox = new QCheckBox( this );
438  mSharedSeenFlagsCheckBox->setText( i18n( "Share unread state with all users" ) );
439  mSharedSeenFlagsCheckBox->setChecked( sharedSeen );
440  ++row;
441  gl->addWidget( mSharedSeenFlagsCheckBox, row, 0, 1, 1 );
442  mSharedSeenFlagsCheckBox->setWhatsThis(
443  i18n( "If enabled, the unread state of messages in this folder will be "
444  "the same for all users having access to this folder. If disabled "
445  "(the default), every user with access to this folder has their "
446  "own unread state." ) );
447  } else {
448  mSharedSeenFlagsCheckBox = 0;
449  }
450 
451  topLayout->addStretch( 100 ); // eat all superfluous space
452 }
453 
454 void CollectionGeneralPage::load( const Akonadi::Collection &collection )
455 {
456  mFolderCollection = FolderCollection::forCollection( collection );
457  init( collection );
458 
459  if ( mNameEdit ) {
460  const QString displayName = collection.displayName();
461 
462  if ( !mIsLocalSystemFolder || mIsResourceFolder ) {
463  mNameEdit->setText( displayName );
464  }
465  }
466 
467  // folder identity
468  mIdentityComboBox->setCurrentIdentity( mFolderCollection->identity() );
469  mUseDefaultIdentityCheckBox->setChecked( mFolderCollection->useDefaultIdentity() );
470 
471  // ignore new mail
472  mNotifyOnNewMailCheckBox->setChecked( !Util::ignoreNewMailInFolder(collection) );
473 
474  const bool keepInFolder = ( mFolderCollection->canCreateMessages() &&
475  mFolderCollection->putRepliesInSameFolder() );
476 
477  mKeepRepliesInSameFolderCheckBox->setChecked( keepInFolder );
478  mKeepRepliesInSameFolderCheckBox->setEnabled( mFolderCollection->canCreateMessages() );
479  mHideInSelectionDialogCheckBox->setChecked( mFolderCollection->hideInSelectionDialog() );
480 
481  if ( mContentsComboBox ) {
482  const CollectionAnnotationsAttribute *annotationsAttribute =
483  collection.attribute<CollectionAnnotationsAttribute>();
484 
485  if ( annotationsAttribute ) {
486  const QMap<QByteArray, QByteArray> annotations = annotationsAttribute->annotations();
487  if ( annotations.contains( KOLAB_FOLDERTYPE ) ) {
488  mContentsComboBox->setCurrentItem(
489  typeNameFromKolabType( annotations[ KOLAB_FOLDERTYPE ] ) );
490  }
491  }
492  }
493 }
494 
495 void CollectionGeneralPage::save( Collection &collection )
496 {
497  if ( mNameEdit ) {
498  if ( !mIsLocalSystemFolder ) {
499  const QString nameFolder(mNameEdit->text().trimmed());
500  bool canRenameFolder = !(nameFolder.startsWith( QLatin1Char('.') ) ||
501  nameFolder.endsWith( QLatin1Char('.') ) ||
502  nameFolder.contains( QLatin1Char( '/' ) ) ||
503  nameFolder.isEmpty());
504 
505  if ( mIsResourceFolder && collection.resource().contains( IMAP_RESOURCE_IDENTIFIER ) ) {
506  collection.setName( nameFolder );
507  Akonadi::AgentInstance instance =
508  Akonadi::AgentManager::self()->instance( collection.resource() );
509  instance.setName( nameFolder );
510  } else if (canRenameFolder) {
511  if ( collection.hasAttribute<Akonadi::EntityDisplayAttribute>() &&
512  !collection.attribute<Akonadi::EntityDisplayAttribute>()->displayName().isEmpty() ) {
513  collection.attribute<Akonadi::EntityDisplayAttribute>()->setDisplayName(
514  nameFolder );
515  } else if ( !nameFolder.isEmpty() ) {
516  collection.setName( nameFolder );
517  }
518  }
519  }
520  }
521 
522  if (!mNotifyOnNewMailCheckBox->isChecked()) {
523  MailCommon::NewMailNotifierAttribute *newMailNotifierAttr = collection.attribute<MailCommon::NewMailNotifierAttribute>( Akonadi::Entity::AddIfMissing );
524  newMailNotifierAttr->setIgnoreNewMail(true);
525  } else {
526  collection.removeAttribute<MailCommon::NewMailNotifierAttribute>();
527  }
528 
529  CollectionAnnotationsAttribute *annotationsAttribute =
530  collection.attribute<CollectionAnnotationsAttribute>( Entity::AddIfMissing );
531 
532  QMap<QByteArray, QByteArray> annotations = annotationsAttribute->annotations();
533  if ( mSharedSeenFlagsCheckBox && mSharedSeenFlagsCheckBox->isEnabled() ) {
534  annotations[ KOLAB_SHAREDSEEN ] = mSharedSeenFlagsCheckBox->isChecked() ? "true" : "false";
535  }
536 
537  if ( mIncidencesForComboBox && mIncidencesForComboBox->isEnabled() ) {
538  annotations[ KOLAB_INCIDENCESFOR ] =
539  incidencesForToString(
540  static_cast<IncidencesFor>( mIncidencesForComboBox->currentIndex() ) ).toLatin1();
541  }
542 
543  if ( mContentsComboBox ) {
544  const CollectionGeneralPage::FolderContentsType type =
545  contentsTypeFromString( mContentsComboBox->currentText() );
546 
547  const QByteArray kolabName = kolabNameFromType( type ) ;
548  if ( !kolabName.isEmpty() ) {
549  QString iconName;
550  switch( type ) {
551  case ContentsTypeCalendar:
552  iconName= QString::fromLatin1( "view-calendar" );
553  break;
554  case ContentsTypeContact:
555  iconName= QString::fromLatin1( "view-pim-contacts" );
556  break;
557  case ContentsTypeNote:
558  iconName = QString::fromLatin1( "view-pim-notes" );
559  break;
560  case ContentsTypeTask:
561  iconName = QString::fromLatin1( "view-pim-tasks" );
562  break;
563  case ContentsTypeJournal:
564  iconName = QString::fromLatin1( "view-pim-journal" );
565  break;
566  case ContentsTypeConfiguration:
567  iconName = QString::fromLatin1( "configure" );
568  break;
569  case ContentsTypeFreebusy:
570  iconName = QString::fromLatin1( "view-calendar-agenda" );
571  break;
572  case ContentsTypeFile:
573  iconName = QString::fromLatin1( "document-open" );
574  break;
575  case ContentsTypeMail:
576  default:
577  break;
578  }
579 
580  Akonadi::EntityDisplayAttribute *attribute =
581  collection.attribute<Akonadi::EntityDisplayAttribute>( Akonadi::Entity::AddIfMissing );
582  attribute->setIconName( iconName );
583  new Akonadi::CollectionModifyJob( collection );
584  annotations[ KOLAB_FOLDERTYPE ] = kolabName;
585  }
586  }
587  if ( annotations.isEmpty() ) {
588  collection.removeAttribute<CollectionAnnotationsAttribute>();
589  } else {
590  annotationsAttribute->setAnnotations( annotations );
591  }
592 
593  if ( mFolderCollection ) {
594  mFolderCollection->setIdentity( mIdentityComboBox->currentIdentity() );
595  mFolderCollection->setUseDefaultIdentity( mUseDefaultIdentityCheckBox->isChecked() );
596 
597  mFolderCollection->setPutRepliesInSameFolder( mKeepRepliesInSameFolderCheckBox->isChecked() );
598  mFolderCollection->setHideInSelectionDialog( mHideInSelectionDialogCheckBox->isChecked() );
599  mFolderCollection->writeConfig();
600  }
601 }
602 
603 void CollectionGeneralPage::slotIdentityCheckboxChanged()
604 {
605  mIdentityComboBox->setEnabled( !mUseDefaultIdentityCheckBox->isChecked() );
606 }
607 
608 void CollectionGeneralPage::slotFolderContentsSelectionChanged( int )
609 {
610  const CollectionGeneralPage::FolderContentsType type =
611  contentsTypeFromString( mContentsComboBox->currentText() );
612 
613  if ( type != CollectionGeneralPage::ContentsTypeMail ) {
614  const QString message =
615  i18n( "You have configured this folder to contain groupware information. "
616  "That means that this folder will disappear once the configuration "
617  "dialog is closed." );
618 
619  KMessageBox::information( this, message );
620  }
621 
622  const bool enable = ( type == CollectionGeneralPage::ContentsTypeCalendar ||
623  type == CollectionGeneralPage::ContentsTypeTask );
624 
625  if ( mIncidencesForComboBox ) {
626  mIncidencesForComboBox->setEnabled( enable );
627  }
628 }
629 
630 void CollectionGeneralPage::slotNameChanged( const QString &name )
631 {
632 #ifndef QT_NO_STYLE_STYLESHEET
633  QString styleSheet;
634  if ( name.startsWith( QLatin1Char('.') ) ||
635  name.endsWith( QLatin1Char('.') ) ||
636  name.contains( QLatin1Char( '/' ) ) ||
637  name.isEmpty() ) {
638  if (mColorName.isEmpty()) {
639  const KColorScheme::BackgroundRole bgColorScheme( KColorScheme::NegativeBackground );
640  KStatefulBrush bgBrush( KColorScheme::View, bgColorScheme );
641  mColorName = bgBrush.brush( this ).color().name();
642  }
643  styleSheet = QString::fromLatin1( "QLineEdit{ background-color:%1 }" ).
644  arg( mColorName );
645  }
646  setStyleSheet(styleSheet);
647 #endif
648 }
649 
650 #include "collectiongeneralpage.moc"
MailCommon::Util::ignoreNewMailInFolder
MAILCOMMON_EXPORT bool ignoreNewMailInFolder(const Akonadi::Collection &collection)
Definition: mailutil.cpp:571
MailCommon::CollectionGeneralPage::ContentsTypeMail
Definition: collectiongeneralpage.h:52
contentsTypeFromString
static CollectionGeneralPage::FolderContentsType contentsTypeFromString(const QString &type)
Definition: collectiongeneralpage.cpp:131
foldercollection.h
KernelIf
#define KernelIf
Definition: mailkernel.h:186
MailCommon::CollectionGeneralPage::ContentsTypeCalendar
Definition: collectiongeneralpage.h:53
QWidget
MailCommon::CollectionGeneralPage::ContentsTypeJournal
Definition: collectiongeneralpage.h:57
MailCommon::Kernel::folderIsInbox
static bool folderIsInbox(const Akonadi::Collection &, bool withoutPop3InboxSetting=false)
Definition: mailkernel.cpp:335
KOLAB_INCIDENCESFOR
#define KOLAB_INCIDENCESFOR
Definition: collectiongeneralpage.cpp:49
MailCommon::CollectionGeneralPage::~CollectionGeneralPage
~CollectionGeneralPage()
Definition: collectiongeneralpage.cpp:62
MailCommon::CollectionGeneralPage::ContentsTypeFile
Definition: collectiongeneralpage.h:60
incidencesForToString
static QString incidencesForToString(CollectionGeneralPage::IncidencesFor type)
Definition: collectiongeneralpage.cpp:76
addLine
static void addLine(QWidget *parent, QVBoxLayout *layout)
Definition: collectiongeneralpage.cpp:66
MailCommon::CollectionGeneralPage::load
void load(const Akonadi::Collection &collection)
Definition: collectiongeneralpage.cpp:454
MailCommon::CollectionGeneralPage::ContentsTypeNote
Definition: collectiongeneralpage.h:55
newmailnotifierattribute.h
MailCommon::CollectionGeneralPage::ContentsTypeContact
Definition: collectiongeneralpage.h:54
MailCommon::CollectionGeneralPage::IncForNobody
Definition: collectiongeneralpage.h:65
collectiongeneralpage.h
KOLAB_FOLDERTYPE
#define KOLAB_FOLDERTYPE
Definition: collectiongeneralpage.cpp:48
collectionannotationsattribute.h
MailCommon::CollectionGeneralPage::FolderContentsType
FolderContentsType
Definition: collectiongeneralpage.h:51
folderContentDescription
static QString folderContentDescription(CollectionGeneralPage::FolderContentsType type)
Definition: collectiongeneralpage.cpp:105
incidencesForFromString
static CollectionGeneralPage::IncidencesFor incidencesForFromString(const QString &string)
Definition: collectiongeneralpage.cpp:90
MailCommon::CollectionAnnotationsAttribute
Definition: collectionannotationsattribute.h:29
MailCommon::CollectionGeneralPage::IncForReaders
Definition: collectiongeneralpage.h:67
CommonKernel
#define CommonKernel
Definition: mailkernel.h:189
MailCommon::CollectionAnnotationsAttribute::setAnnotations
void setAnnotations(const QMap< QByteArray, QByteArray > &annotations)
Definition: collectionannotationsattribute.cpp:36
MailCommon::FolderCollection::forCollection
static QSharedPointer< FolderCollection > forCollection(const Akonadi::Collection &coll, bool writeConfig=true)
Definition: foldercollection.cpp:46
MailCommon::CollectionGeneralPage::save
void save(Akonadi::Collection &collection)
Definition: collectiongeneralpage.cpp:495
MailCommon::NewMailNotifierAttribute
Definition: newmailnotifierattribute.h:27
mailkernel.h
typeFromKolabName
static CollectionGeneralPage::FolderContentsType typeFromKolabName(const QByteArray &name)
Definition: collectiongeneralpage.cpp:218
MailCommon::CollectionGeneralPage::ContentsTypeFreebusy
Definition: collectiongeneralpage.h:59
typeNameFromKolabType
static QString typeNameFromKolabType(const QByteArray &type)
Definition: collectiongeneralpage.cpp:164
MailCommon::CollectionGeneralPage::IncidencesFor
IncidencesFor
Definition: collectiongeneralpage.h:64
displayName
const char * displayName
Definition: daterulewidgethandler.cpp:35
MailCommon::NewMailNotifierAttribute::setIgnoreNewMail
void setIgnoreNewMail(bool b)
Definition: newmailnotifierattribute.cpp:79
MailCommon::CollectionGeneralPage::init
void init(const Akonadi::Collection &)
Definition: collectiongeneralpage.cpp:248
MailCommon::CollectionGeneralPage::IncForAdmins
Definition: collectiongeneralpage.h:66
mailutil.h
MailCommon::CollectionAnnotationsAttribute::annotations
QMap< QByteArray, QByteArray > annotations() const
Definition: collectionannotationsattribute.cpp:42
KOLAB_SHAREDSEEN
#define KOLAB_SHAREDSEEN
Definition: collectiongeneralpage.cpp:50
MailCommon::CollectionGeneralPage::ContentsTypeConfiguration
Definition: collectiongeneralpage.h:58
MailCommon::CollectionGeneralPage::ContentsTypeTask
Definition: collectiongeneralpage.h:56
kolabNameFromType
static QByteArray kolabNameFromType(CollectionGeneralPage::FolderContentsType type)
Definition: collectiongeneralpage.cpp:194
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:14 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal