kaddressbook
bookmark_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
00025 #include <kbookmark.h>
00026 #include <kbookmarkmanager.h>
00027 #include <kbookmarkmenu.h>
00028 #include <konqbookmarkmenu.h>
00029 #include <kbookmarkdombuilder.h>
00030 #include <klocale.h>
00031 #include <kstandarddirs.h>
00032
00033 #include "bookmark_xxport.h"
00034
00035 K_EXPORT_KADDRESSBOOK_XXFILTER( kaddrbk_bookmark_xxport, BookmarkXXPort )
00036
00037 BookmarkXXPort::BookmarkXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
00038 : KAB::XXPort( ab, parent, name )
00039 {
00040 createExportAction( i18n( "Export Bookmarks Menu..." ) );
00041 }
00042
00043 bool BookmarkXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
00044 {
00045 QString fileName = KStandardDirs::locateLocal( "data", "kabc/bookmarks.xml" );
00046
00047 KBookmarkManager *mgr = KBookmarkManager::managerForFile( fileName, "KAddressbook" );
00048 KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( mgr->root(), mgr );
00049 builder->connectImporter( this );
00050
00051 KABC::AddresseeList::ConstIterator it;
00052 emit newFolder( i18n( "AddressBook" ), false, "" );
00053 for ( it = list.begin(); it != list.end(); ++it ) {
00054 if ( !(*it).url().isEmpty() ) {
00055 QString name = (*it).givenName() + ' ' + (*it).familyName();
00056 emit newBookmark( name, (*it).url().url().toLatin1(), QString( "" ) );
00057 }
00058 }
00059 emit endFolder();
00060 delete builder;
00061 mgr->save();
00062
00063 #ifdef __GNUC__
00064 #warning FIXME KonqBookmarkMenu is now protected.
00065 #endif
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 return true;
00076 }
00077
00078 #include "bookmark_xxport.moc"