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

kaddressbook

  • sources
  • kde-4.12
  • kdepim
  • kaddressbook
  • xxport
  • vcard
vcard_xxport.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KAddressBook.
3  Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 #include "vcard_xxport.h"
21 
22 #include "pimcommon/widgets/renamefiledialog.h"
23 
24 #include <kaddressbookgrantlee/widget/grantleecontactviewer.h>
25 
26 #ifdef QGPGME_FOUND
27 #include <gpgme++/context.h>
28 #include <gpgme++/data.h>
29 #include <gpgme++/key.h>
30 #include <qgpgme/dataprovider.h>
31 #endif // QGPGME_FOUND
32 
33 #include <KABC/VCardConverter>
34 
35 #include <KApplication>
36 #include <KDebug>
37 #include <KDialog>
38 #include <KFileDialog>
39 #include <KLocale>
40 #include <KMessageBox>
41 #include <KPushButton>
42 #include <KTemporaryFile>
43 #include <KUrl>
44 #include <KStandardGuiItem>
45 #include <KIO/NetAccess>
46 
47 #include <QtCore/QFile>
48 #include <QtCore/QPointer>
49 #include <QCheckBox>
50 #include <QFont>
51 #include <QFrame>
52 #include <QLabel>
53 #include <QPushButton>
54 #include <QVBoxLayout>
55 #include <QGroupBox>
56 
57 class VCardViewerDialog : public KDialog
58 {
59  Q_OBJECT
60  public:
61  VCardViewerDialog( const KABC::Addressee::List &list,
62  QWidget *parent );
63  ~VCardViewerDialog();
64 
65  KABC::Addressee::List contacts() const;
66 
67  protected Q_SLOTS:
68  void slotYes();
69  void slotNo();
70  void slotApply();
71  void slotCancel();
72 
73  private:
74  void readConfig();
75  void writeConfig();
76  void updateView();
77 
78  KAddressBookGrantlee::GrantleeContactViewer *mView;
79 
80  KABC::Addressee::List mContacts;
81  KABC::Addressee::List::Iterator mIt;
82 };
83 
84 class VCardExportSelectionDialog : public KDialog
85 {
86  public:
87  VCardExportSelectionDialog( QWidget *parent );
88  ~VCardExportSelectionDialog();
89 
90  bool exportPrivateFields() const;
91  bool exportBusinessFields() const;
92  bool exportOtherFields() const;
93  bool exportEncryptionKeys() const;
94  bool exportPictureFields() const;
95  bool exportDisplayName() const;
96 
97  private:
98  QCheckBox *mPrivateBox;
99  QCheckBox *mBusinessBox;
100  QCheckBox *mOtherBox;
101  QCheckBox *mEncryptionKeys;
102  QCheckBox *mPictureBox;
103  QCheckBox *mDisplayNameBox;
104 };
105 
106 VCardXXPort::VCardXXPort( QWidget *parent )
107  : XXPort( parent )
108 {
109 }
110 
111 bool VCardXXPort::exportContacts( const KABC::Addressee::List &contacts ) const
112 {
113  KABC::VCardConverter converter;
114  KUrl url;
115 
116  const KABC::Addressee::List list = filterContacts( contacts );
117  if ( list.isEmpty() ) { // no contact selected
118  return true;
119  }
120 
121  bool ok = true;
122  if ( list.count() == 1 ) {
123  url = KFileDialog::getSaveUrl(
124  QString( list[ 0 ].givenName() +
125  QLatin1Char( QLatin1Char('_') ) +
126  list[ 0 ].familyName() +
127  QLatin1String( ".vcf" ) ) );
128  if ( url.isEmpty() ) { // user canceled export
129  return true;
130  }
131 
132  if ( option( QLatin1String("version") ) == QLatin1String("v21") ) {
133  ok = doExport( url, converter.exportVCards( list, KABC::VCardConverter::v2_1 ) );
134  } else {
135  ok = doExport( url, converter.exportVCards( list, KABC::VCardConverter::v3_0 ) );
136  }
137  } else {
138  const int answer =
139  KMessageBox::questionYesNoCancel(
140  parentWidget(),
141  i18nc( "@info",
142  "You have selected a list of contacts, "
143  "shall they be exported to several files?" ),
144  QString(),
145  KGuiItem( i18nc( "@action:button", "Export to One File" ) ),
146  KGuiItem( i18nc( "@action:button", "Export to Several Files" ) ) );
147 
148  switch( answer ) {
149  case KMessageBox::No:
150  {
151  const KUrl baseUrl = KFileDialog::getExistingDirectoryUrl();
152  if ( baseUrl.isEmpty() ) {
153  return true; // user canceled export
154  }
155 
156  for ( int i = 0; i < list.count(); ++i ) {
157  const KABC::Addressee contact = list.at( i );
158 
159  url = baseUrl.url() + QLatin1Char('/') + contactFileName( contact ) + QLatin1String(".vcf");
160 
161  bool tmpOk = false;
162 
163  if ( option( QLatin1String("version") ) == QLatin1String("v21") ) {
164  tmpOk = doExport( url, converter.exportVCard( contact, KABC::VCardConverter::v2_1 ) );
165  } else {
166  tmpOk = doExport( url, converter.exportVCard( contact, KABC::VCardConverter::v3_0 ) );
167  }
168 
169  ok = ok && tmpOk;
170  }
171  break;
172  }
173  case KMessageBox::Yes:
174  {
175  url = KFileDialog::getSaveUrl( KUrl( QLatin1String("addressbook.vcf") ) );
176  if ( url.isEmpty() ) {
177  return true; // user canceled export
178  }
179 
180  if ( option( QLatin1String("version") ) == QLatin1String("v21") ) {
181  ok = doExport( url, converter.exportVCards( list, KABC::VCardConverter::v2_1 ) );
182  } else {
183  ok = doExport( url, converter.exportVCards( list, KABC::VCardConverter::v3_0 ) );
184  }
185  break;
186  }
187  case KMessageBox::Cancel:
188  default:
189  return true; // user canceled export
190  }
191  }
192 
193  return ok;
194 }
195 
196 KABC::Addressee::List VCardXXPort::importContacts() const
197 {
198  QString fileName;
199  KABC::Addressee::List addrList;
200  KUrl::List urls;
201 
202  if ( !option( QLatin1String("importData") ).isEmpty() ) {
203  addrList = parseVCard( option( QLatin1String("importData") ).toUtf8() );
204  } else {
205  if ( !option( QLatin1String("importUrl") ).isEmpty() ) {
206  urls.append( KUrl( option( QLatin1String("importUrl") ) ) );
207  } else {
208  urls =
209  KFileDialog::getOpenUrls(
210  KUrl(),
211  QLatin1String("*.vcf|vCards"),
212  parentWidget(),
213  i18nc( "@title:window", "Select vCard to Import" ) );
214  }
215 
216  if ( urls.isEmpty() ) {
217  return addrList;
218  }
219 
220  const QString caption( i18nc( "@title:window", "vCard Import Failed" ) );
221  bool anyFailures = false;
222 
223  const int numberOfUrl( urls.count() );
224  for ( int i = 0; i < numberOfUrl; ++i ) {
225  const KUrl url = urls.at( i );
226 
227  if ( KIO::NetAccess::download( url, fileName, parentWidget() ) ) {
228 
229  QFile file( fileName );
230 
231  if ( file.open( QIODevice::ReadOnly ) ) {
232  const QByteArray data = file.readAll();
233  file.close();
234  if ( !data.isEmpty() ) {
235  addrList += parseVCard( data );
236  }
237 
238  KIO::NetAccess::removeTempFile( fileName );
239  } else {
240  const QString msg = i18nc(
241  "@info",
242  "<para>When trying to read the vCard, "
243  "there was an error opening the file <filename>%1</filename>:</para>"
244  "<para>%2</para>",
245  url.pathOrUrl(),
246  i18nc( "QFile", file.errorString().toLatin1() ) );
247  KMessageBox::error( parentWidget(), msg, caption );
248  anyFailures = true;
249  }
250  } else {
251  const QString msg = i18nc(
252  "@info",
253  "<para>Unable to access vCard:</para><para>%1</para>",
254  KIO::NetAccess::lastErrorString() );
255  KMessageBox::error( parentWidget(), msg, caption );
256  anyFailures = true;
257  }
258  }
259 
260  if ( !option( QLatin1String("importUrl") ).isEmpty() ) { // a vcard was passed via cmd
261  if ( addrList.isEmpty() ) {
262  if ( anyFailures && urls.count() > 1 ) {
263  KMessageBox::information(
264  parentWidget(),
265  i18nc( "@info", "No contacts were imported, due to errors with the vCards." ) );
266  } else if ( !anyFailures ) {
267  KMessageBox::information(
268  parentWidget(),
269  i18nc( "@info", "The vCard does not contain any contacts." ) );
270  }
271  } else {
272  QPointer<VCardViewerDialog> dlg = new VCardViewerDialog( addrList, parentWidget() );
273  if ( dlg->exec() && dlg ) {
274  addrList = dlg->contacts();
275  } else {
276  addrList.clear();
277  }
278  delete dlg;
279  }
280  }
281  }
282  return addrList;
283 }
284 
285 KABC::Addressee::List VCardXXPort::parseVCard( const QByteArray &data ) const
286 {
287  KABC::VCardConverter converter;
288 
289  return converter.parseVCards( data );
290 }
291 
292 bool VCardXXPort::doExport( const KUrl &url, const QByteArray &data ) const
293 {
294  KUrl newUrl(url);
295  if ( newUrl.isLocalFile() && QFileInfo( newUrl.toLocalFile() ).exists() ) {
296  PimCommon::RenameFileDialog *dialog = new PimCommon::RenameFileDialog(newUrl, false, parentWidget());
297  PimCommon::RenameFileDialog::RenameFileDialogResult result = static_cast<PimCommon::RenameFileDialog::RenameFileDialogResult>(dialog->exec());
298  if ( result == PimCommon::RenameFileDialog::RENAMEFILE_RENAME ) {
299  newUrl = dialog->newName();
300  } else if (result == PimCommon::RenameFileDialog::RENAMEFILE_IGNORE) {
301  delete dialog;
302  return true;
303  }
304  delete dialog;
305  }
306 
307  KTemporaryFile tmpFile;
308  tmpFile.open();
309 
310  tmpFile.write( data );
311  tmpFile.flush();
312 
313  return KIO::NetAccess::upload( tmpFile.fileName(), newUrl, parentWidget() );
314 }
315 
316 KABC::Addressee::List VCardXXPort::filterContacts( const KABC::Addressee::List &addrList ) const
317 {
318  KABC::Addressee::List list;
319 
320  if ( addrList.isEmpty() ) {
321  return addrList;
322  }
323 
324  QPointer<VCardExportSelectionDialog> dlg = new VCardExportSelectionDialog( parentWidget() );
325  if ( !dlg->exec() || !dlg ) {
326  delete dlg;
327  return list;
328  }
329 
330  KABC::Addressee::List::ConstIterator it;
331  KABC::Addressee::List::ConstIterator end( addrList.end() );
332  for ( it = addrList.begin(); it != end; ++it ) {
333  KABC::Addressee addr;
334 
335  addr.setUid( (*it).uid() );
336  addr.setFormattedName( (*it).formattedName() );
337 
338  bool addrDone = false;
339  if ( dlg->exportDisplayName() ) { // output display name as N field
340  QString fmtName = (*it).formattedName();
341  QStringList splitNames = fmtName.split( QLatin1Char(' '), QString::SkipEmptyParts );
342  if ( splitNames.count() >= 2 ) {
343  addr.setPrefix( QString() );
344  addr.setGivenName( splitNames.takeFirst() );
345  addr.setFamilyName( splitNames.takeLast() );
346  addr.setAdditionalName( splitNames.join( QLatin1String(" ") ) );
347  addr.setSuffix( QString() );
348  addrDone = true;
349  }
350  }
351 
352  if ( !addrDone ) { // not wanted, or could not be split
353  addr.setPrefix( (*it).prefix() );
354  addr.setGivenName( (*it).givenName() );
355  addr.setAdditionalName( (*it).additionalName() );
356  addr.setFamilyName( (*it).familyName() );
357  addr.setSuffix( (*it).suffix() );
358  }
359 
360  addr.setNickName( (*it).nickName() );
361  addr.setMailer( (*it).mailer() );
362  addr.setTimeZone( (*it).timeZone() );
363  addr.setGeo( (*it).geo() );
364  addr.setProductId( (*it).productId() );
365  addr.setSortString( (*it).sortString() );
366  addr.setUrl( (*it).url() );
367  addr.setSecrecy( (*it).secrecy() );
368  addr.setSound( (*it).sound() );
369  addr.setEmails( (*it).emails() );
370  addr.setCategories( (*it).categories() );
371 
372  if ( dlg->exportPrivateFields() ) {
373  addr.setBirthday( (*it).birthday() );
374  addr.setNote( (*it).note() );
375  }
376 
377  if ( dlg->exportPictureFields() ) {
378  if ( dlg->exportPrivateFields() ) {
379  addr.setPhoto( (*it).photo() );
380  }
381 
382  if ( dlg->exportBusinessFields() ) {
383  addr.setLogo( (*it).logo() );
384  }
385  }
386 
387  if ( dlg->exportBusinessFields() ) {
388  addr.setTitle( (*it).title() );
389  addr.setRole( (*it).role() );
390  addr.setOrganization( (*it).organization() );
391  addr.setDepartment( (*it).department() );
392 
393  KABC::PhoneNumber::List phones = (*it).phoneNumbers( KABC::PhoneNumber::Work );
394  KABC::PhoneNumber::List::Iterator phoneIt;
395  for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
396  addr.insertPhoneNumber( *phoneIt );
397  }
398 
399  KABC::Address::List addresses = (*it).addresses( KABC::Address::Work );
400  KABC::Address::List::Iterator addrIt;
401  for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
402  addr.insertAddress( *addrIt );
403  }
404  }
405 
406  KABC::PhoneNumber::List phones = (*it).phoneNumbers();
407  KABC::PhoneNumber::List::Iterator phoneIt;
408  for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
409  int type = (*phoneIt).type();
410 
411  if ( type & KABC::PhoneNumber::Home && dlg->exportPrivateFields() ) {
412  addr.insertPhoneNumber( *phoneIt );
413  } else if ( type & KABC::PhoneNumber::Work && dlg->exportBusinessFields() ) {
414  addr.insertPhoneNumber( *phoneIt );
415  } else if ( dlg->exportOtherFields() ) {
416  addr.insertPhoneNumber( *phoneIt );
417  }
418  }
419 
420  KABC::Address::List addresses = (*it).addresses();
421  KABC::Address::List::Iterator addrIt;
422  for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
423  int type = (*addrIt).type();
424 
425  if ( type & KABC::Address::Home && dlg->exportPrivateFields() ) {
426  addr.insertAddress( *addrIt );
427  } else if ( type & KABC::Address::Work && dlg->exportBusinessFields() ) {
428  addr.insertAddress( *addrIt );
429  } else if ( dlg->exportOtherFields() ) {
430  addr.insertAddress( *addrIt );
431  }
432  }
433 
434  if ( dlg->exportOtherFields() ) {
435  addr.setCustoms( (*it).customs() );
436  }
437 
438  if ( dlg->exportEncryptionKeys() ) {
439  addKey( addr, KABC::Key::PGP );
440  addKey( addr, KABC::Key::X509 );
441  }
442 
443  list.append( addr );
444  }
445 
446  delete dlg;
447 
448  return list;
449 }
450 
451 void VCardXXPort::addKey( KABC::Addressee &addr, KABC::Key::Type type ) const
452 {
453 #ifdef QGPGME_FOUND
454  const QString fingerprint = addr.custom( QLatin1String("KADDRESSBOOK"),
455  ( type == KABC::Key::PGP ? QLatin1String("OPENPGPFP") : QLatin1String("SMIMEFP") ) );
456  if ( fingerprint.isEmpty() ) {
457  return;
458  }
459 
460  GpgME::Context *context = GpgME::Context::createForProtocol( GpgME::OpenPGP );
461  if ( !context ) {
462  kError() << "No context available";
463  return;
464  }
465 
466  context->setArmor( false );
467  context->setTextMode( false );
468 
469  QGpgME::QByteArrayDataProvider dataProvider;
470  GpgME::Data dataObj( &dataProvider );
471  GpgME::Error error = context->exportPublicKeys( fingerprint.toLatin1(), dataObj );
472  delete context;
473 
474  if ( error ) {
475  kError() << error.asString();
476  return;
477  }
478 
479  KABC::Key key;
480  key.setType( type );
481  key.setBinaryData( dataProvider.data() );
482 
483  addr.insertKey( key );
484 #else
485  return;
486 #endif
487 }
488 
489 // ---------- VCardViewer Dialog ---------------- //
490 
491 VCardViewerDialog::VCardViewerDialog( const KABC::Addressee::List &list, QWidget *parent )
492  : KDialog( parent ),
493  mContacts( list )
494 {
495  setCaption( i18nc( "@title:window", "Import vCard" ) );
496  setButtons( User1 | User2 | Apply | Cancel );
497  setButtonGuiItem(User1, KStandardGuiItem::no());
498  setButtonGuiItem(User2, KStandardGuiItem::yes());
499  setDefaultButton( User1 );
500  setModal( true );
501  showButtonSeparator( true );
502 
503  QFrame *page = new QFrame( this );
504  setMainWidget( page );
505 
506  QVBoxLayout *layout = new QVBoxLayout( page );
507  layout->setSpacing( spacingHint() );
508  layout->setMargin( marginHint() );
509 
510  QLabel *label =
511  new QLabel(
512  i18nc( "@info", "Do you want to import this contact into your address book?" ), page );
513  QFont font = label->font();
514  font.setBold( true );
515  label->setFont( font );
516  layout->addWidget( label );
517 
518  mView = new KAddressBookGrantlee::GrantleeContactViewer( page );
519 
520  layout->addWidget( mView );
521 
522  setButtonText( Apply, i18nc( "@action:button", "Import All..." ) );
523 
524  mIt = mContacts.begin();
525 
526  connect( this, SIGNAL(user2Clicked()), this, SLOT(slotYes()) );
527  connect( this, SIGNAL(user1Clicked()), this, SLOT(slotNo()) );
528  connect( this, SIGNAL(applyClicked()), this, SLOT(slotApply()) );
529  connect( this, SIGNAL(cancelClicked()), this, SLOT(slotCancel()) );
530 
531  updateView();
532  readConfig();
533 }
534 
535 VCardViewerDialog::~VCardViewerDialog()
536 {
537  writeConfig();
538 }
539 
540 void VCardViewerDialog::readConfig()
541 {
542  KConfigGroup group( KGlobal::config(), "VCardViewerDialog" );
543  const QSize size = group.readEntry( "Size", QSize(600, 400) );
544  if ( size.isValid() ) {
545  resize( size );
546  }
547 }
548 
549 void VCardViewerDialog::writeConfig()
550 {
551  KConfigGroup group( KGlobal::config(), "VCardViewerDialog" );
552  group.writeEntry( "Size", size() );
553  group.sync();
554 }
555 
556 
557 KABC::Addressee::List VCardViewerDialog::contacts() const
558 {
559  return mContacts;
560 }
561 
562 void VCardViewerDialog::updateView()
563 {
564  mView->setRawContact( *mIt );
565 
566  KABC::Addressee::List::Iterator it = mIt;
567  enableButton( Apply, ( ++it ) != mContacts.end() );
568 }
569 
570 void VCardViewerDialog::slotYes()
571 {
572  mIt++;
573 
574  if ( mIt == mContacts.end() ) {
575  slotApply();
576  return;
577  }
578 
579  updateView();
580 }
581 
582 void VCardViewerDialog::slotNo()
583 {
584  if ( mIt == mContacts.end() ) {
585  accept();
586  return;
587  }
588  // remove the current contact from the result set
589  mIt = mContacts.erase( mIt );
590  if ( mIt == mContacts.end() ) {
591  return;
592  }
593 
594  updateView();
595 }
596 
597 void VCardViewerDialog::slotApply()
598 {
599  KDialog::accept();
600 }
601 
602 void VCardViewerDialog::slotCancel()
603 {
604  mContacts.clear();
605  reject();
606 }
607 
608 // ---------- VCardExportSelection Dialog ---------------- //
609 
610 VCardExportSelectionDialog::VCardExportSelectionDialog( QWidget *parent )
611  : KDialog( parent )
612 {
613  setCaption( i18nc( "@title:window", "Select vCard Fields" ) );
614  setButtons( Ok | Cancel );
615  setDefaultButton( Ok );
616  setModal( true );
617  showButtonSeparator( true );
618 
619  QFrame *page = new QFrame( this );
620  setMainWidget( page );
621 
622  QGridLayout *layout = new QGridLayout( page );
623  layout->setSpacing( spacingHint() );
624  layout->setMargin( marginHint() );
625 
626  QGroupBox *gbox = new QGroupBox(
627  i18nc( "@title:group", "Fields to be exported" ), page );
628  gbox->setFlat( true );
629  layout->addWidget( gbox, 0, 0, 1, 2 );
630 
631  mPrivateBox = new QCheckBox( i18nc( "@option:check", "Private fields" ), page );
632  mPrivateBox->setToolTip(
633  i18nc( "@info:tooltip", "Export private fields" ) );
634  mPrivateBox->setWhatsThis(
635  i18nc( "@info:whatsthis",
636  "Check this box if you want to export the contact's "
637  "private fields to the vCard output file." ) );
638  layout->addWidget( mPrivateBox, 1, 0 );
639 
640  mBusinessBox = new QCheckBox( i18nc( "@option:check", "Business fields" ), page );
641  mBusinessBox->setToolTip(
642  i18nc( "@info:tooltip", "Export business fields" ) );
643  mBusinessBox->setWhatsThis(
644  i18nc( "@info:whatsthis",
645  "Check this box if you want to export the contact's "
646  "business fields to the vCard output file." ) );
647  layout->addWidget( mBusinessBox, 2, 0 );
648 
649  mOtherBox = new QCheckBox( i18nc( "@option:check", "Other fields" ), page );
650  mOtherBox->setToolTip(
651  i18nc( "@info:tooltip", "Export other fields" ) );
652  mOtherBox->setWhatsThis(
653  i18nc( "@info:whatsthis",
654  "Check this box if you want to export the contact's "
655  "other fields to the vCard output file." ) );
656  layout->addWidget( mOtherBox, 3, 0 );
657 
658  mEncryptionKeys = new QCheckBox( i18nc( "@option:check", "Encryption keys" ), page );
659  mEncryptionKeys->setToolTip(
660  i18nc( "@info:tooltip", "Export encryption keys" ) );
661  mEncryptionKeys->setWhatsThis(
662  i18nc( "@info:whatsthis",
663  "Check this box if you want to export the contact's "
664  "encryption keys to the vCard output file." ) );
665  layout->addWidget( mEncryptionKeys, 1, 1 );
666 
667  mPictureBox = new QCheckBox( i18nc( "@option:check", "Pictures" ), page );
668  mPictureBox->setToolTip(
669  i18nc( "@info:tooltip", "Export pictures" ) );
670  mPictureBox->setWhatsThis(
671  i18nc( "@info:whatsthis",
672  "Check this box if you want to export the contact's "
673  "picture to the vCard output file." ) );
674  layout->addWidget( mPictureBox, 2, 1 );
675 
676  gbox = new QGroupBox(
677  i18nc( "@title:group", "Export options" ), page );
678  gbox->setFlat( true );
679  layout->addWidget( gbox, 4, 0, 1, 2 );
680 
681  mDisplayNameBox = new QCheckBox( i18nc( "@option:check", "Display name as full name" ), page );
682  mDisplayNameBox->setToolTip(
683  i18nc( "@info:tooltip", "Export display name as full name" ) );
684  mDisplayNameBox->setWhatsThis(
685  i18nc( "@info:whatsthis",
686  "Check this box if you want to export the contact's display name "
687  "in the vCard's full name field. This may be required to get the "
688  "name shown correctly in GMail or Android." ) );
689  layout->addWidget( mDisplayNameBox, 5, 0, 1, 2 );
690 
691  KConfig config( QLatin1String("kaddressbookrc") );
692  const KConfigGroup group( &config, "XXPortVCard" );
693 
694  mPrivateBox->setChecked( group.readEntry( "ExportPrivateFields", true ) );
695  mBusinessBox->setChecked( group.readEntry( "ExportBusinessFields", true ) );
696  mOtherBox->setChecked( group.readEntry( "ExportOtherFields", true ) );
697  mEncryptionKeys->setChecked( group.readEntry( "ExportEncryptionKeys", true ) );
698  mPictureBox->setChecked( group.readEntry( "ExportPictureFields", true ) );
699  mDisplayNameBox->setChecked( group.readEntry( "ExportDisplayName", false ) );
700 }
701 
702 VCardExportSelectionDialog::~VCardExportSelectionDialog()
703 {
704  KConfig config( QLatin1String("kaddressbookrc") );
705  KConfigGroup group( &config, "XXPortVCard" );
706 
707  group.writeEntry( "ExportPrivateFields", mPrivateBox->isChecked() );
708  group.writeEntry( "ExportBusinessFields", mBusinessBox->isChecked() );
709  group.writeEntry( "ExportOtherFields", mOtherBox->isChecked() );
710  group.writeEntry( "ExportEncryptionKeys", mEncryptionKeys->isChecked() );
711  group.writeEntry( "ExportPictureFields", mPictureBox->isChecked() );
712  group.writeEntry( "ExportDisplayName", mDisplayNameBox->isChecked() );
713 }
714 
715 bool VCardExportSelectionDialog::exportPrivateFields() const
716 {
717  return mPrivateBox->isChecked();
718 }
719 
720 bool VCardExportSelectionDialog::exportBusinessFields() const
721 {
722  return mBusinessBox->isChecked();
723 }
724 
725 bool VCardExportSelectionDialog::exportOtherFields() const
726 {
727  return mOtherBox->isChecked();
728 }
729 
730 bool VCardExportSelectionDialog::exportEncryptionKeys() const
731 {
732  return mEncryptionKeys->isChecked();
733 }
734 
735 bool VCardExportSelectionDialog::exportPictureFields() const
736 {
737  return mPictureBox->isChecked();
738 }
739 
740 bool VCardExportSelectionDialog::exportDisplayName() const
741 {
742  return mDisplayNameBox->isChecked();
743 }
744 #include "vcard_xxport.moc"
XXPort::parentWidget
QWidget * parentWidget() const
Returns the parent widget that can be used as parent for GUI components.
Definition: xxport.cpp:51
KDialog
VCardXXPort::VCardXXPort
VCardXXPort(QWidget *parent=0)
Definition: vcard_xxport.cpp:106
XXPort::contactFileName
QString contactFileName(const KABC::Addressee &contact) const
Returns a file name depending on the passed contact.
Definition: xxport.cpp:56
vcard_xxport.h
XXPort
The base class for all import/export modules.
Definition: xxport.h:32
XXPort::option
QString option(const QString &key) const
Returns the module specific option value for the given key.
Definition: xxport.cpp:46
VCardXXPort::importContacts
KABC::Addressee::List importContacts() const
Imports a list of contacts.
Definition: vcard_xxport.cpp:196
VCardXXPort::exportContacts
bool exportContacts(const KABC::Addressee::List &contacts) const
Exports the list of contacts.
Definition: vcard_xxport.cpp:111
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

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

Search



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

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