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

akonadi

contacteditorwidget.cpp
00001 /*
00002     This file is part of Akonadi Contact.
00003 
00004     Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU Library General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or (at your
00009     option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful, but WITHOUT
00012     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014     License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to the
00018     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019     02110-1301, USA.
00020 */
00021 
00022 #include "contacteditorwidget.h"
00023 
00024 #include "addresseditwidget.h"
00025 #include "categorieseditwidget.h"
00026 #include "contacteditorpageplugin.h"
00027 #include "contactmetadata_p.h"
00028 #include "customfieldseditwidget.h"
00029 #include "dateeditwidget.h"
00030 #include "displaynameeditwidget.h"
00031 #include "emaileditwidget.h"
00032 #include "freebusyeditwidget.h"
00033 #include "geoeditwidget.h"
00034 #include "imagewidget.h"
00035 #include "imeditwidget.h"
00036 #include "nameeditwidget.h"
00037 #include "phoneeditwidget.h"
00038 #include "soundeditwidget.h"
00039 
00040 #include <kconfig.h>
00041 #include <kconfiggroup.h>
00042 #include <klineedit.h>
00043 #include <klocale.h>
00044 #include <kstandarddirs.h>
00045 #include <ktabwidget.h>
00046 #include <ktextedit.h>
00047 #include <kurlrequester.h>
00048 
00049 #include <Nepomuk/ResourceManager>
00050 
00051 #include <QtCore/QDirIterator>
00052 #include <QtCore/QPluginLoader>
00053 #include <QtGui/QGroupBox>
00054 #include <QtGui/QLabel>
00055 #include <QtGui/QLayout>
00056 
00057 class ContactEditorWidget::Private
00058 {
00059   public:
00060     Private( ContactEditorWidget *parent )
00061       : mParent( parent )
00062     {
00063     }
00064 
00065     void initGui();
00066     void initGuiContactTab();
00067     void initGuiLocationTab();
00068     void initGuiBusinessTab();
00069     void initGuiPersonalTab();
00070     void initGuiNotesTab();
00071     void initGuiCustomFieldsTab();
00072 
00073     void loadCustomPages();
00074 
00075     QString loadCustom( const KABC::Addressee &contact, const QString &key ) const;
00076     void storeCustom( KABC::Addressee &contact, const QString &key, const QString &value ) const;
00077 
00078     ContactEditorWidget *mParent;
00079     KTabWidget *mTabWidget;
00080 
00081     // widgets from name group
00082     NameEditWidget *mNameWidget;
00083     ImageWidget *mPhotoWidget;
00084     DisplayNameEditWidget *mDisplayNameWidget;
00085     KLineEdit *mNickNameWidget;
00086     SoundEditWidget *mPronunciationWidget;
00087 
00088     // widgets from Internet group
00089     EmailEditWidget *mEmailWidget;
00090     KLineEdit *mHomepageWidget;
00091     KLineEdit *mBlogWidget;
00092     IMEditWidget *mIMWidget;
00093 
00094     // widgets from phones group
00095     PhoneEditWidget *mPhonesWidget;
00096 
00097     CategoriesEditWidget *mCategoriesWidget;
00098 
00099     // widgets from addresses group
00100     AddressEditWidget *mAddressesWidget;
00101 
00102     // widgets from coordinates group
00103     GeoEditWidget *mCoordinatesWidget;
00104 
00105     // widgets from general group
00106     ImageWidget *mLogoWidget;
00107     KLineEdit *mOrganizationWidget;
00108     KLineEdit *mProfessionWidget;
00109     KLineEdit *mTitleWidget;
00110     KLineEdit *mDepartmentWidget;
00111     KLineEdit *mOfficeWidget;
00112     KLineEdit *mManagerWidget;
00113     KLineEdit *mAssistantWidget;
00114 
00115     // widgets from groupware group
00116     FreeBusyEditWidget *mFreeBusyWidget;
00117 
00118     // widgets from notes group
00119     KTextEdit *mNotesWidget;
00120 
00121     // widgets from dates group
00122     DateEditWidget *mBirthdateWidget;
00123     DateEditWidget *mAnniversaryWidget;
00124 
00125     // widgets from family group
00126     KLineEdit *mPartnerWidget;
00127 
00128     // widgets from custom fields group
00129     CustomFieldsEditWidget *mCustomFieldsWidget;
00130 
00131     // custom editor pages
00132     QList<Akonadi::ContactEditorPagePlugin*> mCustomPages;
00133 };
00134 
00135 void ContactEditorWidget::Private::initGui()
00136 {
00137   QVBoxLayout *layout = new QVBoxLayout( mParent );
00138   layout->setMargin( 0 );
00139 
00140   mTabWidget = new KTabWidget( mParent );
00141   layout->addWidget( mTabWidget );
00142 
00143   initGuiContactTab();
00144   initGuiLocationTab();
00145   initGuiBusinessTab();
00146   initGuiPersonalTab();
00147   initGuiNotesTab();
00148   initGuiCustomFieldsTab();
00149 
00150   loadCustomPages();
00151 }
00152 
00153 void ContactEditorWidget::Private::initGuiContactTab()
00154 {
00155   QWidget *widget = new QWidget;
00156   QGridLayout *layout = new QGridLayout( widget );
00157 
00158   mTabWidget->addTab( widget, i18nc( "@title:tab", "Contact" ) );
00159 
00160   QGroupBox *nameGroupBox = new QGroupBox( i18nc( "@title:group Name related properties of a contact", "Name" ) );
00161   QGroupBox *internetGroupBox = new QGroupBox( i18nc( "@title:group", "Internet" ) );
00162   QGroupBox *phonesGroupBox = new QGroupBox( i18nc( "@title:group", "Phones" ) );
00163 
00164   layout->addWidget( nameGroupBox, 0, 0 );
00165   layout->addWidget( internetGroupBox, 0, 1 );
00166   layout->addWidget( phonesGroupBox, 1, 0, 2, 1 );
00167 
00168   QGridLayout *nameLayout = new QGridLayout( nameGroupBox );
00169   QGridLayout *internetLayout = new QGridLayout( internetGroupBox );
00170   QGridLayout *phonesLayout = new QGridLayout( phonesGroupBox );
00171 
00172   QLabel *label = 0;
00173 
00174   // setup name group box
00175   label = new QLabel( i18nc( "@label The name of a contact", "Name:" ) );
00176   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00177   nameLayout->addWidget( label, 0, 0 );
00178 
00179   mNameWidget = new NameEditWidget;
00180   label->setBuddy( mNameWidget );
00181   nameLayout->addWidget( mNameWidget, 0, 1 );
00182 
00183   mPhotoWidget = new ImageWidget( ImageWidget::Photo );
00184   mPhotoWidget->setMinimumSize( QSize( 100, 140 ) );
00185   nameLayout->addWidget( mPhotoWidget, 0, 2, 4, 1 );
00186 
00187   label = new QLabel( i18nc( "@label The display name of a contact", "Display:" ) );
00188   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00189   nameLayout->addWidget( label, 1, 0 );
00190 
00191   mDisplayNameWidget = new DisplayNameEditWidget;
00192   label->setBuddy( mDisplayNameWidget );
00193   nameLayout->addWidget( mDisplayNameWidget, 1, 1 );
00194 
00195   label = new QLabel( i18nc( "@label The nickname of a contact", "Nickname:" ) );
00196   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00197   nameLayout->addWidget( label, 2, 0 );
00198 
00199   mNickNameWidget = new KLineEdit;
00200   label->setBuddy( mNickNameWidget );
00201   nameLayout->addWidget( mNickNameWidget, 2, 1 );
00202 
00203   label = new QLabel( i18nc( "@label The pronunciation of a contact's name", "Pronunciation:" ) );
00204   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00205   nameLayout->addWidget( label, 3, 0 );
00206 
00207   mPronunciationWidget = new SoundEditWidget;
00208   label->setBuddy( mPronunciationWidget );
00209   nameLayout->addWidget( mPronunciationWidget, 3, 1 );
00210 
00211   nameLayout->setRowStretch( 4, 1 );
00212 
00213   // setup Internet group box
00214   label = new QLabel( i18nc( "@label The email address of a contact", "Email:" ) );
00215   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00216   internetLayout->addWidget( label, 0, 0 );
00217 
00218   mEmailWidget = new EmailEditWidget;
00219   label->setBuddy( mEmailWidget );
00220   internetLayout->addWidget( mEmailWidget, 0, 1 );
00221 
00222   label = new QLabel( i18nc( "@label The homepage URL of a contact", "Homepage:" ) );
00223   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00224   internetLayout->addWidget( label, 1, 0 );
00225 
00226   mHomepageWidget = new KLineEdit;
00227   label->setBuddy( mHomepageWidget );
00228   internetLayout->addWidget( mHomepageWidget, 1, 1 );
00229 
00230   label = new QLabel( i18nc( "@label The blog URL of a contact", "Blog:" ) );
00231   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00232   internetLayout->addWidget( label, 2, 0 );
00233 
00234   mBlogWidget = new KLineEdit;
00235   label->setBuddy( mBlogWidget );
00236   internetLayout->addWidget( mBlogWidget, 2, 1 );
00237 
00238   label = new QLabel( i18nc( "@label The instant messaging address of a contact", "Messaging:" ) );
00239   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00240   internetLayout->addWidget( label, 3, 0 );
00241 
00242   mIMWidget = new IMEditWidget;
00243   label->setBuddy( mIMWidget );
00244   internetLayout->addWidget( mIMWidget, 3, 1 );
00245 
00246   internetLayout->setRowStretch( 4, 1 );
00247 
00248   // setup phones group box
00249   mPhonesWidget = new PhoneEditWidget;
00250   phonesLayout->addWidget( mPhonesWidget, 0, 0 );
00251 
00252   phonesLayout->setRowStretch( 1, 1 );
00253 
00254   // setup categories section
00255   const bool nepomukInitialized(Nepomuk::ResourceManager::instance()->initialized());
00256   QHBoxLayout *categoriesLayout = new QHBoxLayout;
00257   label = new QLabel( i18nc( "@label The categories of a contact", "Categories:" ) );
00258   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00259   label->setVisible(nepomukInitialized);
00260 
00261   mCategoriesWidget = new CategoriesEditWidget;
00262   mCategoriesWidget->setVisible(nepomukInitialized);
00263   label->setBuddy( mCategoriesWidget );
00264 
00265   categoriesLayout->addWidget( label );
00266   categoriesLayout->addWidget( mCategoriesWidget );
00267 
00268   layout->addLayout( categoriesLayout, 1, 1 );
00269   layout->setRowStretch( 2, 1 );
00270 }
00271 
00272 void ContactEditorWidget::Private::initGuiLocationTab()
00273 {
00274   QWidget *widget = new QWidget;
00275   QHBoxLayout *layout = new QHBoxLayout( widget );
00276 
00277   mTabWidget->addTab( widget, i18nc( "@title:tab", "Location" ) );
00278 
00279   QGroupBox *addressesGroupBox = new QGroupBox( i18nc( "@title:group", "Addresses" ) );
00280   QGroupBox *coordinatesGroupBox = new QGroupBox( i18nc( "@title:group", "Coordinates" ) );
00281 
00282   layout->addWidget( addressesGroupBox );
00283   layout->addWidget( coordinatesGroupBox );
00284 
00285   QGridLayout *addressesLayout = new QGridLayout( addressesGroupBox );
00286   QGridLayout *coordinatesLayout = new QGridLayout( coordinatesGroupBox );
00287 
00288   // setup addresses group box
00289   mAddressesWidget = new AddressEditWidget( addressesGroupBox );
00290   mAddressesWidget->setMinimumHeight( 200 );
00291   addressesLayout->addWidget( mAddressesWidget, 0, 0 );
00292   addressesLayout->setRowStretch( 1, 1 );
00293 
00294   // setup coordinates group box
00295   mCoordinatesWidget = new GeoEditWidget;
00296   coordinatesLayout->addWidget( mCoordinatesWidget, 0, 0 );
00297   coordinatesLayout->setRowStretch( 1, 1 );
00298 }
00299 
00300 void ContactEditorWidget::Private::initGuiBusinessTab()
00301 {
00302   QWidget *widget = new QWidget;
00303   QVBoxLayout *layout = new QVBoxLayout( widget );
00304 
00305   mTabWidget->addTab( widget, i18nc( "@title:tab", "Business" ) );
00306 
00307   QGroupBox *generalGroupBox = new QGroupBox( i18nc( "@title:group General properties of a contact", "General" ) );
00308   QGroupBox *groupwareGroupBox = new QGroupBox( i18nc( "@title:group", "Groupware" ) );
00309 
00310   layout->addWidget( generalGroupBox );
00311   layout->addWidget( groupwareGroupBox );
00312 
00313   QGridLayout *generalLayout = new QGridLayout( generalGroupBox );
00314   QGridLayout *groupwareLayout = new QGridLayout( groupwareGroupBox );
00315 
00316   QLabel *label = 0;
00317 
00318   // setup general group box
00319   mLogoWidget = new ImageWidget( ImageWidget::Logo );
00320   generalLayout->addWidget( mLogoWidget, 0, 2, 6, 1, Qt::AlignTop );
00321 
00322   label = new QLabel( i18nc( "@label The organization of a contact", "Organization:" ) );
00323   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00324   generalLayout->addWidget( label, 0, 0 );
00325 
00326   mOrganizationWidget = new KLineEdit;
00327   label->setBuddy( mOrganizationWidget );
00328   generalLayout->addWidget( mOrganizationWidget, 0, 1 );
00329 
00330   label = new QLabel( i18nc( "@label The profession of a contact", "Profession:" ) );
00331   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00332   generalLayout->addWidget( label, 1, 0 );
00333 
00334   mProfessionWidget = new KLineEdit;
00335   label->setBuddy( mProfessionWidget );
00336   generalLayout->addWidget( mProfessionWidget, 1, 1 );
00337 
00338   label = new QLabel( i18nc( "@label The title of a contact", "Title:" ) );
00339   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00340   generalLayout->addWidget( label, 2, 0 );
00341 
00342   mTitleWidget = new KLineEdit;
00343   label->setBuddy( mTitleWidget );
00344   generalLayout->addWidget( mTitleWidget , 2, 1 );
00345 
00346   label = new QLabel( i18nc( "@label The department of a contact", "Department:" ) );
00347   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00348   generalLayout->addWidget( label, 3, 0 );
00349 
00350   mDepartmentWidget = new KLineEdit;
00351   label->setBuddy( mDepartmentWidget );
00352   generalLayout->addWidget( mDepartmentWidget, 3, 1 );
00353 
00354   label = new QLabel( i18nc( "@label The office of a contact", "Office:" ) );
00355   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00356   generalLayout->addWidget( label, 4, 0 );
00357 
00358   mOfficeWidget = new KLineEdit;
00359   label->setBuddy( mOfficeWidget );
00360   generalLayout->addWidget( mOfficeWidget, 4, 1 );
00361 
00362   label = new QLabel( i18nc( "@label The manager's name of a contact", "Manager's name:" ) );
00363   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00364   generalLayout->addWidget( label, 5, 0 );
00365 
00366   mManagerWidget = new KLineEdit;
00367   label->setBuddy( mManagerWidget );
00368   generalLayout->addWidget( mManagerWidget, 5, 1 );
00369 
00370   label = new QLabel( i18nc( "@label The assistant's name of a contact", "Assistant's name:" ) );
00371   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00372   generalLayout->addWidget( label, 6, 0 );
00373 
00374   mAssistantWidget = new KLineEdit;
00375   label->setBuddy( mAssistantWidget );
00376   generalLayout->addWidget( mAssistantWidget, 6, 1 );
00377 
00378   // setup groupware group box
00379   label = new QLabel( i18nc( "@label The free/busy information of a contact", "Free/Busy:" ) );
00380   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00381   groupwareLayout->addWidget( label, 0, 0 );
00382 
00383   mFreeBusyWidget = new FreeBusyEditWidget;
00384   label->setBuddy( mFreeBusyWidget );
00385   groupwareLayout->addWidget( mFreeBusyWidget, 0, 1 );
00386   groupwareLayout->setRowStretch( 1, 1 );
00387 }
00388 
00389 void ContactEditorWidget::Private::initGuiPersonalTab()
00390 {
00391   QWidget *widget = new QWidget;
00392   QVBoxLayout *layout = new QVBoxLayout( widget );
00393 
00394   mTabWidget->addTab( widget, i18nc( "@title:tab Personal properties of a contact", "Personal" ) );
00395 
00396   QGroupBox *datesGroupBox = new QGroupBox( i18nc( "@title:group Date related properties of a contact", "Dates" ) );
00397   QGroupBox *familyGroupBox = new QGroupBox( i18nc( "@title:group Family related properties of a contact", "Family" ) );
00398 
00399   layout->addWidget( datesGroupBox );
00400   layout->addWidget( familyGroupBox );
00401 
00402   QGridLayout *datesLayout = new QGridLayout( datesGroupBox );
00403   QGridLayout *familyLayout = new QGridLayout( familyGroupBox );
00404 
00405   QLabel *label = 0;
00406 
00407   // setup dates group box
00408   label = new QLabel( i18nc( "@label The birthdate of a contact", "Birthdate:" ) );
00409   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00410   datesLayout->addWidget( label, 0, 0 );
00411 
00412   mBirthdateWidget = new DateEditWidget( DateEditWidget::Birthday );
00413   label->setBuddy( mBirthdateWidget );
00414   datesLayout->addWidget( mBirthdateWidget, 0, 1 );
00415 
00416   label = new QLabel( i18nc( "@label The anniversary of a contact", "Anniversary:" ) );
00417   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00418   datesLayout->addWidget( label, 1, 0 );
00419 
00420   mAnniversaryWidget = new DateEditWidget( DateEditWidget::Anniversary );
00421   label->setBuddy( mAnniversaryWidget );
00422   datesLayout->addWidget( mAnniversaryWidget, 1, 1 );
00423 
00424   datesLayout->setRowStretch( 2, 1 );
00425   datesLayout->setColumnStretch( 1, 1 );
00426 
00427   // widgets from family group
00428   label = new QLabel( i18nc( "@label The partner's name of a contact", "Partner's name:" ) );
00429   label->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00430   familyLayout->addWidget( label, 0, 0 );
00431 
00432   mPartnerWidget = new KLineEdit;
00433   label->setBuddy( mPartnerWidget );
00434   familyLayout->addWidget( mPartnerWidget, 0, 1 );
00435 
00436   familyLayout->setRowStretch( 1, 1 );
00437 }
00438 
00439 void ContactEditorWidget::Private::initGuiNotesTab()
00440 {
00441   QWidget *widget = new QWidget;
00442   QVBoxLayout *layout = new QVBoxLayout( widget );
00443 
00444   mTabWidget->addTab( widget, i18nc( "@title:tab", "Notes" ) );
00445 
00446   mNotesWidget = new KTextEdit;
00447   layout->addWidget( mNotesWidget );
00448 }
00449 
00450 void ContactEditorWidget::Private::initGuiCustomFieldsTab()
00451 {
00452   QWidget *widget = new QWidget;
00453   QVBoxLayout *layout = new QVBoxLayout( widget );
00454 
00455   mTabWidget->addTab( widget, i18nc( "@title:tab", "Custom Fields" ) );
00456 
00457   mCustomFieldsWidget = new CustomFieldsEditWidget;
00458   layout->addWidget( mCustomFieldsWidget );
00459 }
00460 
00461 void ContactEditorWidget::Private::loadCustomPages()
00462 {
00463   qDeleteAll( mCustomPages );
00464   mCustomPages.clear();
00465 
00466   const QString pluginDirectory = KStandardDirs::locate( "lib", QLatin1String( "akonadi/contact/editorpageplugins/" ) );
00467   QDirIterator it( pluginDirectory, QDir::Files );
00468   while ( it.hasNext() ) {
00469     QPluginLoader loader( it.next() );
00470     if ( !loader.load() )
00471       continue;
00472 
00473     Akonadi::ContactEditorPagePlugin *plugin = qobject_cast<Akonadi::ContactEditorPagePlugin*>( loader.instance() );
00474     if ( !plugin )
00475       continue;
00476 
00477     mCustomPages.append( plugin );
00478   }
00479 
00480   foreach ( Akonadi::ContactEditorPagePlugin *plugin, mCustomPages )
00481     mTabWidget->addTab( plugin, plugin->title() );
00482 }
00483 
00484 QString ContactEditorWidget::Private::loadCustom( const KABC::Addressee &contact, const QString &key ) const
00485 {
00486   return contact.custom( QLatin1String( "KADDRESSBOOK" ), key );
00487 }
00488 
00489 void ContactEditorWidget::Private::storeCustom( KABC::Addressee &contact, const QString &key, const QString &value ) const
00490 {
00491   if ( value.isEmpty() )
00492     contact.removeCustom( QLatin1String( "KADDRESSBOOK" ), key );
00493   else
00494     contact.insertCustom( QLatin1String( "KADDRESSBOOK" ), key, value );
00495 }
00496 
00497 ContactEditorWidget::ContactEditorWidget( QWidget* )
00498   : d( new Private( this ) )
00499 {
00500   d->initGui();
00501 
00502   connect( d->mNameWidget, SIGNAL(nameChanged(KABC::Addressee)),
00503            d->mDisplayNameWidget, SLOT(changeName(KABC::Addressee)) );
00504   connect( d->mOrganizationWidget, SIGNAL(textChanged(QString)),
00505            d->mDisplayNameWidget, SLOT(changeOrganization(QString)) );
00506 }
00507 
00508 ContactEditorWidget::~ContactEditorWidget()
00509 {
00510   delete d;
00511 }
00512 
00513 void ContactEditorWidget::loadContact( const KABC::Addressee &contact, const Akonadi::ContactMetaData &metaData )
00514 {
00515   // name group
00516   d->mPhotoWidget->loadContact( contact );
00517   d->mNameWidget->loadContact( contact );
00518   d->mDisplayNameWidget->loadContact( contact );
00519   d->mNickNameWidget->setText( contact.nickName() );
00520   d->mPronunciationWidget->loadContact( contact );
00521 
00522   // Internet group
00523   d->mEmailWidget->loadContact( contact );
00524   d->mHomepageWidget->setUrl( contact.url() );
00525   d->mBlogWidget->setText( d->loadCustom( contact, QLatin1String( "BlogFeed" ) ) );
00526   d->mIMWidget->loadContact( contact );
00527 
00528   // phones group
00529   d->mPhonesWidget->loadContact( contact );
00530 
00531   // categories section
00532   d->mCategoriesWidget->loadContact( contact );
00533 
00534   // address group
00535   d->mAddressesWidget->loadContact( contact );
00536 
00537   // coordinates group
00538   d->mCoordinatesWidget->loadContact( contact );
00539 
00540   // general group
00541   d->mLogoWidget->loadContact( contact );
00542   d->mOrganizationWidget->setText( contact.organization() );
00543   d->mProfessionWidget->setText( d->loadCustom( contact, QLatin1String( "X-Profession" ) ) );
00544   d->mTitleWidget->setText( contact.title() );
00545   d->mDepartmentWidget->setText( contact.department() );
00546   d->mOfficeWidget->setText( d->loadCustom( contact, QLatin1String( "X-Office" ) ) );
00547   d->mManagerWidget->setText( d->loadCustom( contact, QLatin1String( "X-ManagersName" ) ) );
00548   d->mAssistantWidget->setText( d->loadCustom( contact, QLatin1String( "X-AssistantsName" ) ) );
00549 
00550   // groupware group
00551   d->mFreeBusyWidget->loadContact( contact );
00552 
00553   // notes group
00554   d->mNotesWidget->setPlainText( contact.note() );
00555 
00556   // dates group
00557   d->mBirthdateWidget->setDate( contact.birthday().date() );
00558   d->mAnniversaryWidget->setDate( QDate::fromString( d->loadCustom( contact, QLatin1String( "X-Anniversary" ) ),
00559                                                      Qt::ISODate ) );
00560 
00561   // family group
00562   d->mPartnerWidget->setText( d->loadCustom( contact, QLatin1String( "X-SpousesName" ) ) );
00563 
00564   d->mDisplayNameWidget->setDisplayType( (DisplayNameEditWidget::DisplayType)metaData.displayNameMode() );
00565 
00566   // custom fields group
00567   d->mCustomFieldsWidget->setLocalCustomFieldDescriptions( metaData.customFieldDescriptions() );
00568   d->mCustomFieldsWidget->loadContact( contact );
00569 
00570   // custom pages
00571   foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages )
00572     plugin->loadContact( contact );
00573 }
00574 
00575 void ContactEditorWidget::storeContact( KABC::Addressee &contact, Akonadi::ContactMetaData &metaData ) const
00576 {
00577   // name group
00578   d->mPhotoWidget->storeContact( contact );
00579   d->mNameWidget->storeContact( contact );
00580   d->mDisplayNameWidget->storeContact( contact );
00581   contact.setNickName( d->mNickNameWidget->text().trimmed() );
00582   d->mPronunciationWidget->storeContact( contact );
00583 
00584   // Internet group
00585   d->mEmailWidget->storeContact( contact );
00586   contact.setUrl( KUrl( d->mHomepageWidget->text().trimmed() ) );
00587   d->storeCustom( contact, QLatin1String( "BlogFeed" ), d->mBlogWidget->text().trimmed() );
00588   d->mIMWidget->storeContact( contact );
00589 
00590   // phones group
00591   d->mPhonesWidget->storeContact( contact );
00592 
00593   // categories section
00594   d->mCategoriesWidget->storeContact( contact );
00595 
00596   // address group
00597   d->mAddressesWidget->storeContact( contact );
00598 
00599   // coordinates group
00600   d->mCoordinatesWidget->storeContact( contact );
00601 
00602   // general group
00603   d->mLogoWidget->storeContact( contact );
00604   contact.setOrganization( d->mOrganizationWidget->text() );
00605   d->storeCustom( contact, QLatin1String( "X-Profession" ), d->mProfessionWidget->text().trimmed() );
00606   contact.setTitle( d->mTitleWidget->text().trimmed() );
00607   contact.setDepartment( d->mDepartmentWidget->text().trimmed() );
00608   d->storeCustom( contact, QLatin1String( "X-Office" ), d->mOfficeWidget->text().trimmed() );
00609   d->storeCustom( contact, QLatin1String( "X-ManagersName" ), d->mManagerWidget->text().trimmed() );
00610   d->storeCustom( contact, QLatin1String( "X-AssistantsName" ), d->mAssistantWidget->text().trimmed() );
00611 
00612   // groupware group
00613   d->mFreeBusyWidget->storeContact( contact );
00614 
00615   // notes group
00616   contact.setNote( d->mNotesWidget->toPlainText() );
00617 
00618   // dates group
00619   QDateTime birthday = QDateTime( d->mBirthdateWidget->date(), QTime(), contact.birthday().timeSpec() );
00620   // This is needed because the constructor above sets the time component
00621   // of the QDateTime to midnight.  We want it to stay invalid.
00622   birthday.setTime( QTime() );
00623 
00624   contact.setBirthday( birthday );
00625   d->storeCustom( contact, QLatin1String( "X-Anniversary" ), d->mAnniversaryWidget->date().toString( Qt::ISODate ) );
00626 
00627   // family group
00628   d->storeCustom( contact, QLatin1String( "X-SpousesName" ), d->mPartnerWidget->text().trimmed() );
00629 
00630   // custom fields group
00631   d->mCustomFieldsWidget->storeContact( contact );
00632   metaData.setCustomFieldDescriptions( d->mCustomFieldsWidget->localCustomFieldDescriptions() );
00633 
00634   metaData.setDisplayNameMode( d->mDisplayNameWidget->displayType() );
00635 
00636   // custom pages
00637   foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages )
00638     plugin->storeContact( contact );
00639 }
00640 
00641 void ContactEditorWidget::setReadOnly( bool readOnly )
00642 {
00643   // widgets from name group
00644   d->mNameWidget->setReadOnly( readOnly );
00645   d->mPhotoWidget->setReadOnly( readOnly );
00646   d->mDisplayNameWidget->setReadOnly( readOnly );
00647   d->mNickNameWidget->setReadOnly( readOnly );
00648   d->mPronunciationWidget->setReadOnly( readOnly );
00649 
00650   // widgets from Internet group
00651   d->mEmailWidget->setReadOnly( readOnly );
00652   d->mHomepageWidget->setReadOnly( readOnly );
00653   d->mBlogWidget->setReadOnly( readOnly );
00654   d->mIMWidget->setReadOnly( readOnly );
00655 
00656   // widgets from phones group
00657   d->mPhonesWidget->setReadOnly( readOnly );
00658 
00659   // widgets from categories section
00660   d->mCategoriesWidget->setReadOnly( readOnly );
00661 
00662   // widgets from addresses group
00663   d->mAddressesWidget->setReadOnly( readOnly );
00664 
00665   // widgets from coordinates group
00666   d->mCoordinatesWidget->setReadOnly( readOnly );
00667 
00668   // widgets from general group
00669   d->mLogoWidget->setReadOnly( readOnly );
00670   d->mOrganizationWidget->setReadOnly( readOnly );
00671   d->mProfessionWidget->setReadOnly( readOnly );
00672   d->mTitleWidget->setReadOnly( readOnly );
00673   d->mDepartmentWidget->setReadOnly( readOnly );
00674   d->mOfficeWidget->setReadOnly( readOnly );
00675   d->mManagerWidget->setReadOnly( readOnly );
00676   d->mAssistantWidget->setReadOnly( readOnly );
00677 
00678   // widgets from groupware group
00679   d->mFreeBusyWidget->setReadOnly( readOnly );
00680 
00681   // widgets from notes group
00682   d->mNotesWidget->setReadOnly( readOnly );
00683 
00684   // widgets from dates group
00685   d->mBirthdateWidget->setReadOnly( readOnly );
00686   d->mAnniversaryWidget->setReadOnly( readOnly );
00687 
00688   // widgets from family group
00689   d->mPartnerWidget->setReadOnly( readOnly );
00690 
00691   // widgets from custom fields group
00692   d->mCustomFieldsWidget->setReadOnly( readOnly );
00693 
00694   // custom pages
00695   foreach ( Akonadi::ContactEditorPagePlugin *plugin, d->mCustomPages )
00696     plugin->setReadOnly( readOnly );
00697 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:49:15 by doxygen 1.8.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
  • Modules
  • Related Pages

kdepimlibs-4.8.3 API Reference

Skip menu "kdepimlibs-4.8.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