kaddressbook
kde2_xxport.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <QtCore/QFile>
00025
00026 #include <kdebug.h>
00027 #include <kfiledialog.h>
00028 #include <kio/netaccess.h>
00029 #include <klocale.h>
00030 #include <kmessagebox.h>
00031 #include <kprocess.h>
00032 #include <kstandarddirs.h>
00033 #include <ktemporaryfile.h>
00034 #include <kurl.h>
00035
00036 #include "xxportmanager.h"
00037
00038 #include "kde2_xxport.h"
00039
00040 K_EXPORT_KADDRESSBOOK_XXFILTER( kaddrbk_kde2_xxport, KDE2XXPort )
00041
00042 KDE2XXPort::KDE2XXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
00043 : KAB::XXPort( ab, parent, name )
00044 {
00045 createImportAction( i18n( "Import KDE 2 Addressbook..." ) );
00046 }
00047
00048 KABC::Addressee::List KDE2XXPort::importContacts( const QString& ) const
00049 {
00050 QString fileName = KStandardDirs::locateLocal( "data", "kabc/std.vcf" );
00051 if ( !QFile::exists( fileName ) ) {
00052 KMessageBox::sorry( parentWidget(), i18n( "<qt>Could not find a KDE 2 address book <b>%1</b>.</qt>", fileName ) );
00053 return KABC::AddresseeList();
00054 }
00055
00056 int result = KMessageBox::questionYesNoCancel( parentWidget(),
00057 i18n( "Override previously imported entries?" ),
00058 i18n( "Import KDE 2 Addressbook" ), KGuiItem(i18n("Import")), KGuiItem(i18n("Do Not Import")) );
00059
00060 if ( !result ) return KABC::AddresseeList();
00061
00062 KProcess proc;
00063
00064 if ( result == KMessageBox::Yes ) {
00065 proc << "kab2kabc";
00066 proc << "--override";
00067 } else if ( result == KMessageBox::No )
00068 proc << "kab2kabc";
00069 else
00070 kDebug(5720) <<"KAddressBook::importKDE2(): Unknow return value.";
00071
00072 proc.execute();
00073
00074 addressBook()->load();
00075
00076 return KABC::AddresseeList();
00077 }
00078
00079 #include "kde2_xxport.moc"