kate
kbookmarkhandler.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00062 }
00063
00064 QString KBookmarkHandler::currentURL() const
00065 {
00066 return mParent->dirOperator()->url().url();
00067 }
00068
00069
00070 void KBookmarkHandler::slotNewBookmark( const QString& ,
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 ,
00080 const QString& )
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