KDevelop API Documentation

kbookmarkhandler.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) xxxx KFile Authors
00003    Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 // $Id: kbookmarkhandler.cpp,v 1.4 2004/02/22 23:53:43 mueller Exp $
00021 
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 
00025 #include <qtextstream.h>
00026 
00027 #include <kbookmarkimporter.h>
00028 #include <kpopupmenu.h>
00029 #include <ksavefile.h>
00030 #include <kstandarddirs.h>
00031 #include <kdiroperator.h>
00032 #include <kaction.h>
00033 
00034 #include "kbookmarkhandler.h"
00035 #include "kbookmarkhandler.moc"
00036 
00037 
00038 KBookmarkHandler::KBookmarkHandler( KDevFileSelector *parent, KPopupMenu* kpopupmenu )
00039     : QObject( parent, "KBookmarkHandler" ),
00040       KBookmarkOwner(),
00041       mParent( parent ),
00042       m_menu( kpopupmenu ),
00043       m_importStream( 0L )
00044 {
00045     if (!m_menu)
00046       m_menu = new KPopupMenu( parent, "bookmark menu" );
00047 
00048     QString file = locate( "data", "kdevfileselector/fsbookmarks.xml" );
00049     if ( file.isEmpty() )
00050         file = locateLocal( "data", "kdevfileselector/fsbookmarks.xml" );
00051 
00052     KBookmarkManager *manager = KBookmarkManager::managerForFile( file, false);
00053     manager->setUpdate( true );
00054     manager->setShowNSBookmarks( false );
00055 
00056     m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, 0, true );
00057 }
00058 
00059 KBookmarkHandler::~KBookmarkHandler()
00060 {
00061     //     delete m_bookmarkMenu; ###
00062 }
00063 
00064 QString KBookmarkHandler::currentURL() const
00065 {
00066     return mParent->dirOperator()->url().url();
00067 }
00068 
00069 
00070 void KBookmarkHandler::slotNewBookmark( const QString& text,
00071                                             const QCString& url,
00072                                             const QString& additionalInfo )
00073 {
00074     Q_UNUSED( text );
00075     *m_importStream << "<bookmark icon=\"" << KMimeType::iconForURL( KURL(  url ) );
00076     *m_importStream << "\" href=\"" << QString::fromUtf8(url) << "\">\n";
00077     *m_importStream << "<title>" << (additionalInfo.isEmpty() ? QString::fromUtf8(url) : additionalInfo) << "</title>\n</bookmark>\n";
00078 }
00079 
00080 void KBookmarkHandler::slotNewFolder( const QString& text, bool /*open*/,
00081                                           const QString& /*additionalInfo*/ )
00082 {
00083     *m_importStream << "<folder icon=\"bookmark_folder\">\n<title=\"";
00084     *m_importStream << text << "\">\n";
00085 }
00086 
00087 void KBookmarkHandler::newSeparator()
00088 {
00089     *m_importStream << "<separator/>\n";
00090 }
00091 
00092 void KBookmarkHandler::endFolder()
00093 {
00094     *m_importStream << "</folder>\n";
00095 }
00096 
00097 void KBookmarkHandler::virtual_hook( int id, void* data )
00098 { KBookmarkOwner::virtual_hook( id, data ); }
00099 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:57 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003