• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.3 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
  • contact
  • editor
contacteditorwidget.cpp
1 /*
2  This file is part of Akonadi Contact.
3 
4  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #include "contacteditorwidget.h"
23 
24 #include "addresseditwidget.h"
25 #include "categorieseditwidget.h"
26 #include "contacteditorpageplugin.h"
27 #include "contactmetadata_p.h"
28 #include "customfieldseditwidget.h"
29 #include "dateeditwidget.h"
30 #include "displaynameeditwidget.h"
31 #include "emaileditwidget.h"
32 #include "freebusyeditwidget.h"
33 #include "geoeditwidget.h"
34 #include "imagewidget.h"
35 #include "imeditwidget.h"
36 #include "nameeditwidget.h"
37 #include "phoneeditwidget.h"
38 #include "soundeditwidget.h"
39 
40 #include <kconfig.h>
41 #include <kconfiggroup.h>
42 #include <klineedit.h>
43 #include <klocale.h>
44 #include <kstandarddirs.h>
45 #include <ktabwidget.h>
46 #include <ktextedit.h>
47 #include <kurlrequester.h>
48 
49 #include <Nepomuk/ResourceManager>
50 
51 #include <QtCore/QDirIterator>
52 #include <QtCore/QPluginLoader>
53 #include <QtGui/QGroupBox>
54 #include <QtGui/QLabel>
55 #include <QtGui/QLayout>
56 #include <QtGui/QCheckBox>
57 
58 class ContactEditorWidget::Private
59 {
60  public:
61  Private( ContactEditorWidget *parent )
62  : mParent( parent )
63  {
64  }
65 
66  void initGui();
67  void initGuiContactTab();
68  void initGuiLocationTab();
69  void initGuiBusinessTab();
70  void initGuiPersonalTab();
71  void initGuiNotesTab();
72  void initGuiCustomFieldsTab();
73 
74  void loadCustomPages();
75 
76  QString loadCustom( const KABC::Addressee &contact, const QString &key ) const;
77  void storeCustom( KABC::Addressee &contact, const QString &key, const QString &value ) const;
78 
79  ContactEditorWidget *mParent;
80  KTabWidget *mTabWidget;
81 
82  // widgets from name group
83  NameEditWidget *mNameWidget;
84  ImageWidget *mPhotoWidget;
85  DisplayNameEditWidget *mDisplayNameWidget;
86  KLineEdit *mNickNameWidget;
87  SoundEditWidget *mPronunciationWidget;
88 
89  // widgets from Internet group
90  EmailEditWidget *mEmailWidget;
91  KLineEdit *mHomepageWidget;
92  KLineEdit *mBlogWidget;
93  IMEditWidget *mIMWidget;
94 
95  // widgets from phones group
96  PhoneEditWidget *mPhonesWidget;
97 
98  CategoriesEditWidget *mCategoriesWidget;
99 
100  KComboBox* mMailPreferFormatting;
101  QCheckBox *mAllowRemoteContent;
102 
103 
104  // widgets from addresses group
105  AddressEditWidget *mAddressesWidget;
106 
107  // widgets from coordinates group
108  GeoEditWidget *mCoordinatesWidget;
109 
110  // widgets from general group
111  ImageWidget *mLogoWidget;
112  KLineEdit *mOrganizationWidget;
113  KLineEdit *mProfessionWidget;
114  KLineEdit *mTitleWidget;
115  KLineEdit *mDepartmentWidget;
116  KLineEdit *mOfficeWidget;
117  KLineEdit *mManagerWidget;
118  KLineEdit *mAssistantWidget;
119 
120  // widgets from groupware group
121  FreeBusyEditWidget *mFreeBusyWidget;
122 
123  // widgets from notes group
124  KTextEdit *mNotesWidget;
125 
126  // widgets from dates group
127  DateEditWidget *mBirthdateWidget;
128  DateEditWidget *mAnniversaryWidget;
129 
130  // widgets from family group
131  KLineEdit *mPartnerWidget;
132 
133  // widgets from custom fields group
134  CustomFieldsEditWidget *mCustomFieldsWidget;
135 
136  // custom editor pages
137  QList<Akonadi::ContactEditorPagePlugin*> mCustomPages;
138 };
139 
140 void ContactEditorWidget::Private::initGui()
141 {
142  QVBoxLayout *layout = new QVBoxLayout( mParent );
143  layout->setMargin( 0 );
144 
145  mTabWidget = new KTabWidget( mParent );
146  layout->addWidget( mTabWidget );
147 
148  initGuiContactTab();
149  initGuiLocationTab();
150  initGuiBusinessTab();
151  initGuiPersonalTab();
152  initGuiNotesTab();
153  initGuiCustomFieldsTab();
154 
155  loadCustomPages();
156 }
157 
158 void ContactEditorWidget::Private::initGuiContactTab()
159 {
160  QWidget *widget = new QWidget;
161  QGridLayout *layout = new QGridLayout( widget );
162 
163  mTabWidget->addTab( widget, i18nc( "@title:tab", "Contact" ) );
164 
165  QGroupBox *nameGroupBox = new QGroupBox( i18nc( "@title:group Name related properties of a contact", "Name" ) );
166  QGroupBox *internetGroupBox = new QGroupBox( i18nc( "@title:group", "Internet" ) );
167  QGroupBox *phonesGroupBox = new QGroupBox( i18nc( "@title:group", "Phones" ) );
168 
169  layout->addWidget( nameGroupBox, 0, 0 );
170  layout->addWidget( internetGroupBox, 0, 1 );
171  layout->addWidget( phonesGroupBox, 1, 0, 4, 1 );
172 
173  QGridLayout *nameLayout = new QGridLayout( nameGroupBox );
174  QGridLayout *internetLayout = new QGridLayout( internetGroupBox );
175  QGridLayout *phonesLayout = new QGridLayout( phonesGroupBox );
176 
177  QLabel *label = 0;
178 
179  // setup name group box
180  label = new QLabel( i18nc( "@label The name of a contact", "Name:" ) );
181  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
182  nameLayout->addWidget( label, 0, 0 );
183 
184  mNameWidget = new NameEditWidget;
185  label->setBuddy( mNameWidget );
186  nameLayout->addWidget( mNameWidget, 0, 1 );
187 
188  mPhotoWidget = new ImageWidget( ImageWidget::Photo );
189  mPhotoWidget->setMinimumSize( QSize( 100, 140 ) );
190  nameLayout->addWidget( mPhotoWidget, 0, 2, 4, 1 );
191 
192  label = new QLabel( i18nc( "@label The display name of a contact", "Display:" ) );
193  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
194  nameLayout->addWidget( label, 1, 0 );
195 
196  mDisplayNameWidget = new DisplayNameEditWidget;
197  label->setBuddy( mDisplayNameWidget );
198  nameLayout->addWidget( mDisplayNameWidget, 1, 1 );
199 
200  label = new QLabel( i18nc( "@label The nickname of a contact", "Nickname:" ) );
201  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
202  nameLayout->addWidget( label, 2, 0 );
203 
204  mNickNameWidget = new KLineEdit;
205  label->setBuddy( mNickNameWidget );
206  nameLayout->addWidget( mNickNameWidget, 2, 1 );
207 
208  label = new QLabel( i18nc( "@label The pronunciation of a contact's name", "Pronunciation:" ) );
209  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
210  nameLayout->addWidget( label, 3, 0 );
211 
212  mPronunciationWidget = new SoundEditWidget;
213  label->setBuddy( mPronunciationWidget );
214  nameLayout->addWidget( mPronunciationWidget, 3, 1 );
215 
216  nameLayout->setRowStretch( 4, 1 );
217 
218  // setup Internet group box
219  label = new QLabel( i18nc( "@label The email address of a contact", "Email:" ) );
220  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
221  internetLayout->addWidget( label, 0, 0 );
222 
223  mEmailWidget = new EmailEditWidget;
224  label->setBuddy( mEmailWidget );
225  internetLayout->addWidget( mEmailWidget, 0, 1 );
226 
227  label = new QLabel( i18nc( "@label The homepage URL of a contact", "Homepage:" ) );
228  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
229  internetLayout->addWidget( label, 1, 0 );
230 
231  mHomepageWidget = new KLineEdit;
232  label->setBuddy( mHomepageWidget );
233  internetLayout->addWidget( mHomepageWidget, 1, 1 );
234 
235  label = new QLabel( i18nc( "@label The blog URL of a contact", "Blog:" ) );
236  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
237  internetLayout->addWidget( label, 2, 0 );
238 
239  mBlogWidget = new KLineEdit;
240  label->setBuddy( mBlogWidget );
241  internetLayout->addWidget( mBlogWidget, 2, 1 );
242 
243  label = new QLabel( i18nc( "@label The instant messaging address of a contact", "Messaging:" ) );
244  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
245  internetLayout->addWidget( label, 3, 0 );
246 
247  mIMWidget = new IMEditWidget;
248  label->setBuddy( mIMWidget );
249  internetLayout->addWidget( mIMWidget, 3, 1 );
250 
251  internetLayout->setRowStretch( 4, 1 );
252 
253  // setup phones group box
254  mPhonesWidget = new PhoneEditWidget;
255  phonesLayout->addWidget( mPhonesWidget, 0, 0 );
256 
257  phonesLayout->setRowStretch( 1, 1 );
258 
259  // setup categories section
260  const bool nepomukInitialized(Nepomuk::ResourceManager::instance()->initialized());
261  QHBoxLayout *categoriesLayout = new QHBoxLayout;
262  label = new QLabel( i18nc( "@label The categories of a contact", "Categories:" ) );
263  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
264  label->setVisible(nepomukInitialized);
265 
266  mCategoriesWidget = new CategoriesEditWidget;
267  mCategoriesWidget->setVisible(nepomukInitialized);
268  label->setBuddy( mCategoriesWidget );
269 
270  categoriesLayout->addWidget( label );
271  categoriesLayout->addWidget( mCategoriesWidget );
272 
273  layout->addLayout( categoriesLayout, 1, 1 );
274 
275  QHBoxLayout *mailPreferFormattingLayout = new QHBoxLayout;
276  label = new QLabel( i18n( "Prefers to receive messages formatted as:" ) );
277  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
278  mMailPreferFormatting = new KComboBox;
279  QStringList listFormat;
280  listFormat<<i18n( "Unknown" ) <<i18n( "Plain Text" ) << i18n( "HTML" );
281  mMailPreferFormatting->addItems( listFormat );
282  mailPreferFormattingLayout->addWidget( label );
283  mailPreferFormattingLayout->addWidget( mMailPreferFormatting );
284  layout->addLayout( mailPreferFormattingLayout, 2, 1 );
285 
286  mAllowRemoteContent = new QCheckBox( i18n( "Allow remote content." ) );
287  layout->addWidget( mAllowRemoteContent, 3,1 );
288 
289  layout->setRowStretch( 4,1 );
290 }
291 
292 void ContactEditorWidget::Private::initGuiLocationTab()
293 {
294  QWidget *widget = new QWidget;
295  QHBoxLayout *layout = new QHBoxLayout( widget );
296 
297  mTabWidget->addTab( widget, i18nc( "@title:tab", "Location" ) );
298 
299  QGroupBox *addressesGroupBox = new QGroupBox( i18nc( "@title:group", "Addresses" ) );
300  QGroupBox *coordinatesGroupBox = new QGroupBox( i18nc( "@title:group", "Coordinates" ) );
301 
302  layout->addWidget( addressesGroupBox );
303  layout->addWidget( coordinatesGroupBox );
304 
305  QGridLayout *addressesLayout = new QGridLayout( addressesGroupBox );
306  QGridLayout *coordinatesLayout = new QGridLayout( coordinatesGroupBox );
307 
308  // setup addresses group box
309  mAddressesWidget = new AddressEditWidget( addressesGroupBox );
310  mAddressesWidget->setMinimumHeight( 200 );
311  addressesLayout->addWidget( mAddressesWidget, 0, 0 );
312  addressesLayout->setRowStretch( 1, 1 );
313 
314  // setup coordinates group box
315  mCoordinatesWidget = new GeoEditWidget;
316  coordinatesLayout->addWidget( mCoordinatesWidget, 0, 0 );
317  coordinatesLayout->setRowStretch( 1, 1 );
318 }
319 
320 void ContactEditorWidget::Private::initGuiBusinessTab()
321 {
322  QWidget *widget = new QWidget;
323  QVBoxLayout *layout = new QVBoxLayout( widget );
324 
325  mTabWidget->addTab( widget, i18nc( "@title:tab", "Business" ) );
326 
327  QGroupBox *generalGroupBox = new QGroupBox( i18nc( "@title:group General properties of a contact", "General" ) );
328  QGroupBox *groupwareGroupBox = new QGroupBox( i18nc( "@title:group", "Groupware" ) );
329 
330  layout->addWidget( generalGroupBox );
331  layout->addWidget( groupwareGroupBox );
332 
333  QGridLayout *generalLayout = new QGridLayout( generalGroupBox );
334  QGridLayout *groupwareLayout = new QGridLayout( groupwareGroupBox );
335 
336  QLabel *label = 0;
337 
338  // setup general group box
339  mLogoWidget = new ImageWidget( ImageWidget::Logo );
340  generalLayout->addWidget( mLogoWidget, 0, 2, 6, 1, Qt::AlignTop );
341 
342  label = new QLabel( i18nc( "@label The organization of a contact", "Organization:" ) );
343  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
344  generalLayout->addWidget( label, 0, 0 );
345 
346  mOrganizationWidget = new KLineEdit;
347  label->setBuddy( mOrganizationWidget );
348  generalLayout->addWidget( mOrganizationWidget, 0, 1 );
349 
350  label = new QLabel( i18nc( "@label The profession of a contact", "Profession:" ) );
351  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
352  generalLayout->addWidget( label, 1, 0 );
353 
354  mProfessionWidget = new KLineEdit;
355  label->setBuddy( mProfessionWidget );
356  generalLayout->addWidget( mProfessionWidget, 1, 1 );
357 
358  label = new QLabel( i18nc( "@label The title of a contact", "Title:" ) );
359  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
360  generalLayout->addWidget( label, 2, 0 );
361 
362  mTitleWidget = new KLineEdit;
363  label->setBuddy( mTitleWidget );
364  generalLayout->addWidget( mTitleWidget , 2, 1 );
365 
366  label = new QLabel( i18nc( "@label The department of a contact", "Department:" ) );
367  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
368  generalLayout->addWidget( label, 3, 0 );
369 
370  mDepartmentWidget = new KLineEdit;
371  label->setBuddy( mDepartmentWidget );
372  generalLayout->addWidget( mDepartmentWidget, 3, 1 );
373 
374  label = new QLabel( i18nc( "@label The office of a contact", "Office:" ) );
375  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
376  generalLayout->addWidget( label, 4, 0 );
377 
378  mOfficeWidget = new KLineEdit;
379  label->setBuddy( mOfficeWidget );
380  generalLayout->addWidget( mOfficeWidget, 4, 1 );
381 
382  label = new QLabel( i18nc( "@label The manager's name of a contact", "Manager's name:" ) );
383  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
384  generalLayout->addWidget( label, 5, 0 );
385 
386  mManagerWidget = new KLineEdit;
387  label->setBuddy( mManagerWidget );
388  generalLayout->addWidget( mManagerWidget, 5, 1 );
389 
390  label = new QLabel( i18nc( "@label The assistant's name of a contact", "Assistant's name:" ) );
391  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
392  generalLayout->addWidget( label, 6, 0 );
393 
394  mAssistantWidget = new KLineEdit;
395  label->setBuddy( mAssistantWidget );
396  generalLayout->addWidget( mAssistantWidget, 6, 1 );
397 
398  // setup groupware group box
399  label = new QLabel( i18nc( "@label The free/busy information of a contact", "Free/Busy:" ) );
400  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
401  groupwareLayout->addWidget( label, 0, 0 );
402 
403  mFreeBusyWidget = new FreeBusyEditWidget;
404  label->setBuddy( mFreeBusyWidget );
405  groupwareLayout->addWidget( mFreeBusyWidget, 0, 1 );
406  groupwareLayout->setRowStretch( 1, 1 );
407 }
408 
409 void ContactEditorWidget::Private::initGuiPersonalTab()
410 {
411  QWidget *widget = new QWidget;
412  QVBoxLayout *layout = new QVBoxLayout( widget );
413 
414  mTabWidget->addTab( widget, i18nc( "@title:tab Personal properties of a contact", "Personal" ) );
415 
416  QGroupBox *datesGroupBox = new QGroupBox( i18nc( "@title:group Date related properties of a contact", "Dates" ) );
417  QGroupBox *familyGroupBox = new QGroupBox( i18nc( "@title:group Family related properties of a contact", "Family" ) );
418 
419  layout->addWidget( datesGroupBox );
420  layout->addWidget( familyGroupBox );
421 
422  QGridLayout *datesLayout = new QGridLayout( datesGroupBox );
423  QGridLayout *familyLayout = new QGridLayout( familyGroupBox );
424 
425  QLabel *label = 0;
426 
427  // setup dates group box
428  label = new QLabel( i18nc( "@label The birthdate of a contact", "Birthdate:" ) );
429  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
430  datesLayout->addWidget( label, 0, 0 );
431 
432  mBirthdateWidget = new DateEditWidget( DateEditWidget::Birthday );
433  label->setBuddy( mBirthdateWidget );
434  datesLayout->addWidget( mBirthdateWidget, 0, 1 );
435 
436  label = new QLabel( i18nc( "@label The anniversary of a contact", "Anniversary:" ) );
437  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
438  datesLayout->addWidget( label, 1, 0 );
439 
440  mAnniversaryWidget = new DateEditWidget( DateEditWidget::Anniversary );
441  label->setBuddy( mAnniversaryWidget );
442  datesLayout->addWidget( mAnniversaryWidget, 1, 1 );
443 
444  datesLayout->setRowStretch( 2, 1 );
445  datesLayout->setColumnStretch( 1, 1 );
446 
447  // widgets from family group
448  label = new QLabel( i18nc( "@label The partner's name of a contact", "Partner's name:" ) );
449  label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
450  familyLayout->addWidget( label, 0, 0 );
451 
452  mPartnerWidget = new KLineEdit;
453  label->setBuddy( mPartnerWidget );
454  familyLayout->addWidget( mPartnerWidget, 0, 1 );
455 
456  familyLayout->setRowStretch( 1, 1 );
457 }
458 
459 void ContactEditorWidget::Private::initGuiNotesTab()
460 {
461  QWidget *widget = new QWidget;
462  QVBoxLayout *layout = new QVBoxLayout( widget );
463 
464  mTabWidget->addTab( widget, i18nc( "@title:tab", "Notes" ) );
465 
466  mNotesWidget = new KTextEdit;
467  mNotesWidget->setAcceptRichText(false);
468  layout->addWidget( mNotesWidget );
469 }
470 
471 void ContactEditorWidget::Private::initGuiCustomFieldsTab()
472 {
473  QWidget *widget = new QWidget;
474  QVBoxLayout *layout = new QVBoxLayout( widget );
475 
476  mTabWidget->addTab( widget, i18nc( "@title:tab", "Custom Fields" ) );
477 
478  mCustomFieldsWidget = new CustomFieldsEditWidget;
479  layout->addWidget( mCustomFieldsWidget );
480 }
481 
482 void ContactEditorWidget::Private::loadCustomPages()
483 {
484  qDeleteAll( mCustomPages );
485  mCustomPages.clear();
486 
487  const QString pluginDirectory = KStandardDirs::locate( "lib", QLatin1String( "akonadi/contact/editorpageplugins/" ) );
488  QDirIterator it( pluginDirectory, QDir::Files );
489  while ( it.hasNext() ) {
490  QPluginLoader loader( it.next() );
491  if ( !loader.load() )
492  continue;
493 
494  Akonadi::ContactEditorPagePlugin *plugin = qobject_cast<Akonadi::ContactEditorPagePlugin*>( loader.instance() );
495  if ( !plugin )
496  continue;
497 
498  mCustomPages.append( plugin );
499  }
500 
501  foreach ( Akonadi::ContactEditorPagePlugin *plugin, mCustomPages )
502  mTabWidget->addTab( plugin, plugin->title() );
503 }
504 
505 QString ContactEditorWidget::Private::loadCustom( const KABC::Addressee &contact, const QString &key ) const
506 {
507  return contact.custom( QLatin1String( "KADDRESSBOOK" ), key );
508 }
509 
510 void ContactEditorWidget::Private::storeCustom( KABC::Addressee &contact, const QString &key, const QString &value ) const
511 {
512  if ( value.isEmpty() )
513  contact.removeCustom( QLatin1String( "KADDRESSBOOK" ), key );
514  else
515  contact.insertCustom( QLatin1String( "KADDRESSBOOK" ), key, value );
516 }
517 
518 ContactEditorWidget::ContactEditorWidget( QWidget* )
519  : d( new Private( this ) )
520 {
521  d->initGui();
522 
523  connect( d->mNameWidget, SIGNAL(nameChanged(KABC::Addressee)),
524  d->mDisplayNameWidget, SLOT(changeName(KABC::Addressee)) );
525  connect( d->mOrganizationWidget, SIGNAL(textChanged(QString)),
526  d->mDisplayNameWidget, SLOT(changeOrganization(QString)) );
527 }
528 
529 ContactEditorWidget::~ContactEditorWidget()
530 {
531  delete d;
532 }
533 
534 void ContactEditorWidget::loadContact( const KABC::Addressee &contact, const Akonadi::ContactMetaData &metaData )
535 {
536  // name group
537  d->mPhotoWidget->loadContact( contact );
538  d->mNameWidget->loadContact( contact );
539  d->mDisplayNameWidget->loadContact( contact );
540  d->mNickNameWidget->setText( contact.nickName() );
541  d->mPronunciationWidget->loadContact( contact );
542 
543  // Internet group
544  d->mEmailWidget->loadContact( contact );
545  d->mHomepageWidget->setUrl( contact.url() );
546  d->mBlogWidget->setText( d->loadCustom( contact, QLatin1String( "BlogFeed" ) ) );
547  d->mIMWidget->loadContact( contact );
548 
549  // phones group
550  d->mPhonesWidget->loadContact( contact );
551 
552  // categories section
553  d->mCategoriesWidget->loadContact( contact );
554 
555 
556  const QString mailPreferedFormatting = d->loadCustom( contact, QLatin1String( "MailPreferedFormatting" ) );
557  if ( mailPreferedFormatting.isEmpty() )
558  d->mMailPreferFormatting->setCurrentIndex( 0 );
559  else if ( mailPreferedFormatting == QLatin1String( "TEXT" ) )
560  d->mMailPreferFormatting->setCurrentIndex( 1 );
561  else if ( mailPreferedFormatting == QLatin1String( "HTML" ) )
562  d->mMailPreferFormatting->setCurrentIndex( 2 );
563  else
564  d->mMailPreferFormatting->setCurrentIndex( 0 );
565 
566  const QString mailAllowToRemoteContent = d->loadCustom( contact, QLatin1String( "MailAllowToRemoteContent" ) );
567  d->mAllowRemoteContent->setChecked( mailAllowToRemoteContent == QLatin1String( "TRUE" ) );
568 
569  // address group
570  d->mAddressesWidget->loadContact( contact );
571 
572  // coordinates group
573  d->mCoordinatesWidget->loadContact( contact );
574 
575  // general group
576  d->mLogoWidget->loadContact( contact );
577  d->mOrganizationWidget->setText( contact.organization() );
578  d->mProfessionWidget->setText( d->loadCustom( contact, QLatin1String( "X-Profession" ) ) );
579  d->mTitleWidget->setText( contact.title() );
580  d->mDepartmentWidget->setText( contact.department() );
581  d->mOfficeWidget->setText( d->loadCustom( contact, QLatin1String( "X-Office" ) ) );
582  d->mManagerWidget->setText( d->loadCustom( contact, QLatin1String( "X-ManagersName" ) ) );
583  d->mAssistantWidget->setText( d->loadCustom( contact, QLatin1String( "X-AssistantsName" ) ) );
584 
585  // groupware group
586  d->mFreeBusyWidget->loadContact( contact );
587 
588  // notes group
589  d->mNotesWidget->setPlainText( contact.note() );
590 
591  // dates group
592  d->mBirthdateWidget->setDate( contact.birthday().date() );
593  d->mAnniversaryWidget->setDate( QDate::fromString( d->loadCustom( contact, QLatin1String( "X-Anniversary" ) ),
594  Qt::ISODate ) );
595 
596  // family group
597  d->mPartnerWidget->setText( d->loadCustom( contact, QLatin1String( "X-SpousesName" ) ) );
598 
599  d->mDisplayNameWidget->setDisplayType( (DisplayNameEditWidget::DisplayType)metaData.displayNameMode() );
600 
601  // custom fields group
602  d->mCustomFieldsWidget->setLocalCustomFieldDescriptions( metaData.customFieldDescriptions() );
603  d->mCustomFieldsWidget->loadContact( contact );
604 
605  // custom pages
606  foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages )
607  plugin->loadContact( contact );
608 }
609 
610 void ContactEditorWidget::storeContact( KABC::Addressee &contact, Akonadi::ContactMetaData &metaData ) const
611 {
612  // name group
613  d->mPhotoWidget->storeContact( contact );
614  d->mNameWidget->storeContact( contact );
615  d->mDisplayNameWidget->storeContact( contact );
616  contact.setNickName( d->mNickNameWidget->text().trimmed() );
617  d->mPronunciationWidget->storeContact( contact );
618 
619  // Internet group
620  d->mEmailWidget->storeContact( contact );
621  contact.setUrl( KUrl( d->mHomepageWidget->text().trimmed() ) );
622  d->storeCustom( contact, QLatin1String( "BlogFeed" ), d->mBlogWidget->text().trimmed() );
623  d->mIMWidget->storeContact( contact );
624 
625  // phones group
626  d->mPhonesWidget->storeContact( contact );
627 
628  // categories section
629  d->mCategoriesWidget->storeContact( contact );
630 
631 
632 
633  QString mailPreferedFormatting;
634  const int index = d->mMailPreferFormatting->currentIndex();
635  if ( index == 0 ) {
636  //Nothing => remove custom variable
637  } else if ( index == 1 ) {
638  mailPreferedFormatting = QLatin1String( "TEXT" );
639  } else if ( index == 2 ) {
640  mailPreferedFormatting = QLatin1String( "HTML" );
641  }
642  d->storeCustom( contact, QLatin1String( "MailPreferedFormatting" ), mailPreferedFormatting );
643 
644  QString mailAllowToRemoteContent;
645  if ( d->mAllowRemoteContent->isChecked() )
646  mailAllowToRemoteContent = QLatin1String( "TRUE" );
647  d->storeCustom( contact, QLatin1String( "MailAllowToRemoteContent" ), mailAllowToRemoteContent );
648 
649  // address group
650  d->mAddressesWidget->storeContact( contact );
651 
652  // coordinates group
653  d->mCoordinatesWidget->storeContact( contact );
654 
655  // general group
656  d->mLogoWidget->storeContact( contact );
657  contact.setOrganization( d->mOrganizationWidget->text() );
658  d->storeCustom( contact, QLatin1String( "X-Profession" ), d->mProfessionWidget->text().trimmed() );
659  contact.setTitle( d->mTitleWidget->text().trimmed() );
660  contact.setDepartment( d->mDepartmentWidget->text().trimmed() );
661  d->storeCustom( contact, QLatin1String( "X-Office" ), d->mOfficeWidget->text().trimmed() );
662  d->storeCustom( contact, QLatin1String( "X-ManagersName" ), d->mManagerWidget->text().trimmed() );
663  d->storeCustom( contact, QLatin1String( "X-AssistantsName" ), d->mAssistantWidget->text().trimmed() );
664 
665  // groupware group
666  d->mFreeBusyWidget->storeContact( contact );
667 
668  // notes group
669  contact.setNote( d->mNotesWidget->toPlainText() );
670 
671  // dates group
672  QDateTime birthday = QDateTime( d->mBirthdateWidget->date(), QTime(), contact.birthday().timeSpec() );
673  // This is needed because the constructor above sets the time component
674  // of the QDateTime to midnight. We want it to stay invalid.
675  birthday.setTime( QTime() );
676 
677  contact.setBirthday( birthday );
678  d->storeCustom( contact, QLatin1String( "X-Anniversary" ), d->mAnniversaryWidget->date().toString( Qt::ISODate ) );
679 
680  // family group
681  d->storeCustom( contact, QLatin1String( "X-SpousesName" ), d->mPartnerWidget->text().trimmed() );
682 
683  // custom fields group
684  d->mCustomFieldsWidget->storeContact( contact );
685  metaData.setCustomFieldDescriptions( d->mCustomFieldsWidget->localCustomFieldDescriptions() );
686 
687  metaData.setDisplayNameMode( d->mDisplayNameWidget->displayType() );
688 
689  // custom pages
690  foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages )
691  plugin->storeContact( contact );
692 }
693 
694 void ContactEditorWidget::setReadOnly( bool readOnly )
695 {
696  // widgets from name group
697  d->mNameWidget->setReadOnly( readOnly );
698  d->mPhotoWidget->setReadOnly( readOnly );
699  d->mDisplayNameWidget->setReadOnly( readOnly );
700  d->mNickNameWidget->setReadOnly( readOnly );
701  d->mPronunciationWidget->setReadOnly( readOnly );
702 
703  // widgets from Internet group
704  d->mEmailWidget->setReadOnly( readOnly );
705  d->mHomepageWidget->setReadOnly( readOnly );
706  d->mBlogWidget->setReadOnly( readOnly );
707  d->mIMWidget->setReadOnly( readOnly );
708 
709  // widgets from phones group
710  d->mPhonesWidget->setReadOnly( readOnly );
711 
712  // widgets from categories section
713  d->mCategoriesWidget->setReadOnly( readOnly );
714 
715  // Preferred Mail formatting option
716  d->mMailPreferFormatting->setEnabled( !readOnly );
717  d->mAllowRemoteContent->setEnabled( !readOnly );
718 
719  // widgets from addresses group
720  d->mAddressesWidget->setReadOnly( readOnly );
721 
722  // widgets from coordinates group
723  d->mCoordinatesWidget->setReadOnly( readOnly );
724 
725  // widgets from general group
726  d->mLogoWidget->setReadOnly( readOnly );
727  d->mOrganizationWidget->setReadOnly( readOnly );
728  d->mProfessionWidget->setReadOnly( readOnly );
729  d->mTitleWidget->setReadOnly( readOnly );
730  d->mDepartmentWidget->setReadOnly( readOnly );
731  d->mOfficeWidget->setReadOnly( readOnly );
732  d->mManagerWidget->setReadOnly( readOnly );
733  d->mAssistantWidget->setReadOnly( readOnly );
734 
735  // widgets from groupware group
736  d->mFreeBusyWidget->setReadOnly( readOnly );
737 
738  // widgets from notes group
739  d->mNotesWidget->setReadOnly( readOnly );
740 
741  // widgets from dates group
742  d->mBirthdateWidget->setReadOnly( readOnly );
743  d->mAnniversaryWidget->setReadOnly( readOnly );
744 
745  // widgets from family group
746  d->mPartnerWidget->setReadOnly( readOnly );
747 
748  // widgets from custom fields group
749  d->mCustomFieldsWidget->setReadOnly( readOnly );
750 
751  // custom pages
752  foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages )
753  plugin->setReadOnly( readOnly );
754 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed Nov 28 2012 21:51:27 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

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

kdepimlibs-4.9.3 API Reference

Skip menu "kdepimlibs-4.9.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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