kbookmarkhandler.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00060 }
00061
00062 QString KBookmarkHandler::currentURL() const
00063 {
00064 return mParent->dirOperator()->url().url();
00065 }
00066
00067
00068 void KBookmarkHandler::slotNewBookmark( const QString& ,
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 ,
00078 const QString& )
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
This file is part of the documentation for kate Library Version 3.3.2.