bookmark_xxport.cpp
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 <kbookmarkdombuilder.h>
00029 #include <klocale.h>
00030 #include <kstandarddirs.h>
00031
00032 #include "bookmark_xxport.h"
00033
00034 class BookmarkXXPortFactory : public KAB::XXPortFactory
00035 {
00036 public:
00037 KAB::XXPort *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
00038 {
00039 return new BookmarkXXPort( ab, parent, name );
00040 }
00041 };
00042
00043 extern "C"
00044 {
00045 void *init_libkaddrbk_bookmark_xxport()
00046 {
00047 return ( new BookmarkXXPortFactory() );
00048 }
00049 }
00050
00051
00052 BookmarkXXPort::BookmarkXXPort( KABC::AddressBook *ab, QWidget *parent, const char *name )
00053 : KAB::XXPort( ab, parent, name )
00054 {
00055 createExportAction( i18n( "Export Bookmarks Menu..." ) );
00056 }
00057
00058 bool BookmarkXXPort::exportContacts( const KABC::AddresseeList &list, const QString& )
00059 {
00060 QString fileName = locateLocal( "data", "kabc/bookmarks.xml" );
00061
00062 KBookmarkManager *mgr = KBookmarkManager::managerForFile( fileName );
00063 KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( mgr->root(), mgr );
00064 builder->connectImporter( this );
00065
00066 KABC::AddresseeList::ConstIterator it;
00067 emit newFolder( i18n( "AddressBook" ), false, "" );
00068 for ( it = list.begin(); it != list.end(); ++it ) {
00069 if ( !(*it).url().isEmpty() ) {
00070 QString name = (*it).givenName() + " " + (*it).familyName();
00071 emit newBookmark( name, (*it).url().url().latin1(), QString( "" ) );
00072 }
00073 }
00074 emit endFolder();
00075 delete builder;
00076 mgr->save();
00077
00078 KBookmarkMenu::DynMenuInfo menu;
00079 menu.name = i18n( "Addressbook Bookmarks" );
00080 menu.location = fileName;
00081 menu.type = "xbel";
00082 menu.show = true;
00083 KBookmarkMenu::setDynamicBookmarks( "kabc", menu );
00084
00085 return true;
00086 }
00087
00088 #include "bookmark_xxport.moc"
This file is part of the documentation for kaddressbook Library Version 3.2.2.