kate Library API Documentation

kbookmarkhandler.cpp

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 #include <stdio.h>
00021 #include <stdlib.h>
00022 
00023 #include <qtextstream.h>
00024 
00025 #include <kbookmarkimporter.h>
00026 #include <kpopupmenu.h>
00027 #include <ksavefile.h>
00028 #include <kstandarddirs.h>
00029 #include <kdiroperator.h>
00030 #include <kaction.h>
00031 
00032 #include "kbookmarkhandler.h"
00033 #include "kbookmarkhandler.moc"
00034 
00035 
00036 KBookmarkHandler::KBookmarkHandler( KateFileSelector *parent, KPopupMenu* kpopupmenu )
00037     : QObject( parent, "KBookmarkHandler" ),
00038       KBookmarkOwner(),
00039       mParent( parent ),
00040       m_menu( kpopupmenu ),
00041       m_importStream( 0L )
00042 {
00043     if (!m_menu)
00044       m_menu = new KPopupMenu( parent, "bookmark menu" );
00045 
00046     QString file = locate( "data", "kate/fsbookmarks.xml" );
00047     if ( file.isEmpty() )
00048         file = locateLocal( "data", "kate/fsbookmarks.xml" );
00049 
00050     KBookmarkManager *manager = KBookmarkManager::managerForFile( file, false);
00051     manager->setUpdate( true );
00052     manager->setShowNSBookmarks( false );
00053 
00054     m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, 0, true );
00055 }
00056 
00057 KBookmarkHandler::~KBookmarkHandler()
00058 {
00059     //     delete m_bookmarkMenu; ###
00060 }
00061 
00062 QString KBookmarkHandler::currentURL() const
00063 {
00064     return mParent->dirOperator()->url().url();
00065 }
00066 
00067 
00068 void KBookmarkHandler::slotNewBookmark( const QString& /*text*/,
00069                                             const QCString& url,
00070                                             const QString& additionalInfo )
00071 {
00072     *m_importStream << "<bookmark icon=\"" << KMimeType::iconForURL( KURL( url ) );
00073     *m_importStream << "\" href=\"" << QString::fromUtf8(url) << "\">\n";
00074     *m_importStream << "<title>" << (additionalInfo.isEmpty() ? QString::fromUtf8(url) : additionalInfo) << "</title>\n</bookmark>\n";
00075 }
00076 
00077 void KBookmarkHandler::slotNewFolder( const QString& text, bool /*open*/,
00078                                           const QString& /*additionalInfo*/ )
00079 {
00080     *m_importStream << "<folder icon=\"bookmark_folder\">\n<title=\"";
00081     *m_importStream << text << "\">\n";
00082 }
00083 
00084 void KBookmarkHandler::newSeparator()
00085 {
00086     *m_importStream << "<separator/>\n";
00087 }
00088 
00089 void KBookmarkHandler::endFolder()
00090 {
00091     *m_importStream << "</folder>\n";
00092 }
00093 
00094 void KBookmarkHandler::virtual_hook( int id, void* data )
00095 { KBookmarkOwner::virtual_hook( id, data ); }
00096 
KDE Logo
This file is part of the documentation for kate Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Apr 4 11:21:45 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003