• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kio

kfilebookmarkhandler.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
00003 
00004     library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation, version 2.
00007 
00008     This library is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011     Library General Public License for more details.
00012 
00013     You should have received a copy of the GNU Library General Public License
00014     along with this library; see the file COPYING.LIB.  If not, write to
00015     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 
00022 #include <kbookmarkimporter.h>
00023 #include <kbookmarkdombuilder.h>
00024 #include <kpopupmenu.h>
00025 #include <kstandarddirs.h>
00026 
00027 #include "kfiledialog.h"
00028 #include "kfilebookmarkhandler.h"
00029 
00030 KFileBookmarkHandler::KFileBookmarkHandler( KFileDialog *dialog )
00031     : QObject( dialog, "KFileBookmarkHandler" ),
00032       KBookmarkOwner(),
00033       m_dialog( dialog )
00034 {
00035     m_menu = new KPopupMenu( dialog, "bookmark menu" );
00036 
00037     QString file = locate( "data", "kfile/bookmarks.xml" );
00038     if ( file.isEmpty() )
00039         file = locateLocal( "data", "kfile/bookmarks.xml" );
00040 
00041     KBookmarkManager *manager = KBookmarkManager::managerForFile( file, false);
00042 
00043     // import old bookmarks
00044     if ( !KStandardDirs::exists( file ) ) {
00045         QString oldFile = locate( "data", "kfile/bookmarks.html" );
00046         if ( !oldFile.isEmpty() )
00047             importOldBookmarks( oldFile, manager );
00048     }
00049 
00050     manager->setUpdate( true );
00051     manager->setShowNSBookmarks( false );
00052 
00053     m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu,
00054                                         dialog->actionCollection(), true );
00055 }
00056 
00057 KFileBookmarkHandler::~KFileBookmarkHandler()
00058 {
00059     delete m_bookmarkMenu;
00060 }
00061 
00062 QString KFileBookmarkHandler::currentURL() const
00063 {
00064     return m_dialog->baseURL().url();
00065 }
00066 
00067 void KFileBookmarkHandler::importOldBookmarks( const QString& path,
00068                                                KBookmarkManager *manager )
00069 {
00070     KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( manager->root(), manager );
00071     KNSBookmarkImporter importer( path );
00072     builder->connectImporter( &importer );
00073     importer.parseNSBookmarks();
00074     delete builder;
00075     manager->save();
00076 }
00077 
00078 void KFileBookmarkHandler::virtual_hook( int id, void* data )
00079 { KBookmarkOwner::virtual_hook( id, data ); }
00080 
00081 #include "kfilebookmarkhandler.moc"

kio

Skip menu "kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal