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

kmobiletools

exportphonebookdlg.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002    Copyright (C) 2007
00003    by Marco Gulino <marco@kmobiletools.org>
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the
00017    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019  ***************************************************************************/
00020 #include "exportphonebookdlg.h"
00021 
00022 #include <klocale.h>
00023 #include <q3buttongroup.h>
00024 #include <kfiledialog.h>
00025 #include <kabc/vcardformat.h>
00026 #include <kabc/stdaddressbook.h>
00027 
00028 #define SAVE_TO_FILE 1
00029 #define APPEND_TO_KABC 0
00030 
00031 exportPhonebookDlg::exportPhonebookDlg(ContactsList *addresseeList, QWidget *parent, const char *name)
00032     : KDialog(parent)
00033 {
00034     setCaption(i18n("Export Phonebook"));
00035     setButtons(Ok|Cancel);
00036     p_addresseeList=addresseeList;
00037     ui.setupUi(mainWidget());
00038     connect(this, SIGNAL(okClicked()), SLOT(slotOk()));
00039 }
00040 
00041 
00042 exportPhonebookDlg::~exportPhonebookDlg()
00043 {
00044 }
00045 
00046 
00047 #include "exportphonebookdlg.moc"
00048 
00049 
00053 void exportPhonebookDlg::slotOk()
00054 {
00055     KABC::AddressBook *addressbook;
00056     if ( ui.exportOptions->selectedId() == SAVE_TO_FILE )
00057     {
00058         QString saveFileName=KFileDialog::getSaveFileName(KUrl("kfiledialog://vcf"), " text/directory", this);
00059         if(saveFileName.isNull()) return;
00060         QFile abcfile(saveFileName);
00061         KABC::VCardFormat vcard;
00062         addressbook=new KABC::AddressBook();
00063         for(KABC::Addressee::List::Iterator it=p_addresseeList->begin(); it != p_addresseeList->end(); ++it)
00064             vcard.save((*it), &abcfile);
00065         
00066 /*        KABC::Resource* resource=new KABC::ResourceFile( saveFileName );
00067         resource->setReadOnly (false);
00068         addressbook=new KABC::AddressBook();
00069         addressbook->addResource(resource);
00070 //         addressbook->load();
00071 //         addressbook->clear();
00072         KABC::Ticket *saveTicket=addressbook->requestSaveTicket();
00073 
00074         addressbook->save( saveTicket );
00075 //         addressbook->releaseSaveTicket( saveTicket );
00076         resource->close();*/
00077     }
00078     if ( ui.exportOptions->selectedId() == APPEND_TO_KABC )
00079     {
00080         addressbook=KABC::StdAddressBook::self();
00081         for(KABC::Addressee::List::Iterator it=p_addresseeList->begin(); it != p_addresseeList->end(); ++it)
00082             addressbook->insertAddressee( *it );
00083         addressbook->save(addressbook->requestSaveTicket() );
00084     }
00085 }

kmobiletools

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

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal