TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bookmark_xxport.cpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. This file is part of KAddressbook.
  3. Copyright (c) 2003 Alexander Kellett <lypanov@kde.org>
  4. Tobias Koenig <tokoe@kde.org>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. As a special exception, permission is given to link this program
  17. with any edition of TQt, and distribute the resulting executable,
  18. without including the source code for TQt in the source distribution.
  19. */
  20. #include <kbookmark.h>
  21. #include <kbookmarkmanager.h>
  22. #include <kbookmarkmenu.h>
  23. #include <kbookmarkdombuilder.h>
  24. #include <tdelocale.h>
  25. #include <kstandarddirs.h>
  26. #include "bookmark_xxport.h"
  27. K_EXPORT_KADDRESSBOOK_XXFILTER( libkaddrbk_bookmark_xxport, BookmarkXXPort )
  28. BookmarkXXPort::BookmarkXXPort( TDEABC::AddressBook *ab, TQWidget *parent, const char *name )
  29. : KAB::XXPort( ab, parent, name )
  30. {
  31. createExportAction( i18n( "Export Bookmarks Menu..." ) );
  32. }
  33. bool BookmarkXXPort::exportContacts( const TDEABC::AddresseeList &list, const TQString& )
  34. {
  35. TQString fileName = locateLocal( "data", "tdeabc/bookmarks.xml" );
  36. KBookmarkManager *mgr = KBookmarkManager::managerForFile( fileName );
  37. KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( mgr->root(), mgr );
  38. builder->connectImporter( this );
  39. TDEABC::AddresseeList::ConstIterator it;
  40. emit newFolder( i18n( "AddressBook" ), false, "" );
  41. for ( it = list.begin(); it != list.end(); ++it ) {
  42. if ( !(*it).url().isEmpty() ) {
  43. TQString name = (*it).givenName() + " " + (*it).familyName();
  44. emit newBookmark( name, (*it).url().url().latin1(), TQString( "" ) );
  45. }
  46. }
  47. emit endFolder();
  48. delete builder;
  49. mgr->save();
  50. KBookmarkMenu::DynMenuInfo menu;
  51. menu.name = i18n( "Addressbook Bookmarks" );
  52. menu.location = fileName;
  53. menu.type = "xbel";
  54. menu.show = true;
  55. KBookmarkMenu::setDynamicBookmarks( "tdeabc", menu );
  56. return true;
  57. }
  58. #include "bookmark_xxport.moc"