kaddressbook
bookmark_xxport.cpp00001
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 <kbookmarkdombuilder.h>
00029 #include <klocale.h>
00030 #include <kstandarddirs.h>
00031
00032 #include "bookmark_xxport.h"
00033
00034 K_EXPORT_KADDRESSBOOK_XXFILTER( libkaddrbk_bookmark_xxport, BookmarkXXPort )
00035
00036 BookmarkXXPort::BookmarkXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
00037 : KAB::XXPort( ab, parent, name )
00038 {
00039 createExportAction( i18n( "Export Bookmarks Menu..." ) );
00040 }
00041
00042 bool BookmarkXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
00043 {
00044 QString fileName = locateLocal( "data", "kabc/bookmarks.xml" );
00045
00046 KBookmarkManager *mgr = KBookmarkManager::managerForFile( fileName );
00047 KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( mgr->root(), mgr );
00048 builder->connectImporter( this );
00049
00050 KABC::AddresseeList::ConstIterator it;
00051 emit newFolder( i18n( "AddressBook" ), false, "" );
00052 for ( it = list.begin(); it != list.end(); ++it ) {
00053 if ( !(*it).url().isEmpty() ) {
00054 QString name = (*it).givenName() + " " + (*it).familyName();
00055 emit newBookmark( name, (*it).url().url().latin1(), QString( "" ) );
00056 }
00057 }
00058 emit endFolder();
00059 delete builder;
00060 mgr->save();
00061
00062 KBookmarkMenu::DynMenuInfo menu;
00063 menu.name = i18n( "Addressbook Bookmarks" );
00064 menu.location = fileName;
00065 menu.type = "xbel";
00066 menu.show = true;
00067 KBookmarkMenu::setDynamicBookmarks( "kabc", menu );
00068
00069 return true;
00070 }
00071
00072 #include "bookmark_xxport.moc"
|