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

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • 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