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

kate

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., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "katefileselector.h"
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( KateFileSelector *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", "kate/fsbookmarks.xml" );
00049     if ( file.isEmpty() )
00050         file = locateLocal( "data", "kate/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     *m_importStream << "<bookmark icon=\"" << KMimeType::iconForURL( KURL( url ) );
00075     *m_importStream << "\" href=\"" << QString::fromUtf8(url) << "\">\n";
00076     *m_importStream << "<title>" << (additionalInfo.isEmpty() ? QString::fromUtf8(url) : additionalInfo) << "</title>\n</bookmark>\n";
00077 }
00078 
00079 void KBookmarkHandler::slotNewFolder( const QString& text, bool /*open*/,
00080                                           const QString& /*additionalInfo*/ )
00081 {
00082     *m_importStream << "<folder icon=\"bookmark_folder\">\n<title=\"";
00083     *m_importStream << text << "\">\n";
00084 }
00085 
00086 void KBookmarkHandler::newSeparator()
00087 {
00088     *m_importStream << "<separator/>\n";
00089 }
00090 
00091 void KBookmarkHandler::endFolder()
00092 {
00093     *m_importStream << "</folder>\n";
00094 }
00095 
00096 void KBookmarkHandler::virtual_hook( int id, void* data )
00097 { KBookmarkOwner::virtual_hook( id, data ); }
00098 

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kate
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