20 #include "katefileselector.h"
25 #include <tqtextstream.h>
27 #include <kbookmarkimporter.h>
28 #include <tdepopupmenu.h>
29 #include <ksavefile.h>
30 #include <kstandarddirs.h>
31 #include <tdediroperator.h>
32 #include <tdeaction.h>
34 #include "kbookmarkhandler.h"
35 #include "kbookmarkhandler.moc"
38 KBookmarkHandler::KBookmarkHandler( KateFileSelector *parent, TDEPopupMenu* tdepopupmenu )
39 : TQObject( parent,
"KBookmarkHandler" ),
42 m_menu( tdepopupmenu ),
46 m_menu =
new TDEPopupMenu( parent,
"bookmark menu" );
48 TQString file = locate(
"data",
"kate/fsbookmarks.xml" );
50 file = locateLocal(
"data",
"kate/fsbookmarks.xml" );
52 KBookmarkManager *manager = KBookmarkManager::managerForFile( file,
false);
53 manager->setUpdate(
true );
54 manager->setShowNSBookmarks(
false );
56 m_bookmarkMenu =
new KBookmarkMenu( manager,
this, m_menu, 0,
true );
59 KBookmarkHandler::~KBookmarkHandler()
64 TQString KBookmarkHandler::currentURL()
const
66 return mParent->dirOperator()->url().url();
70 void KBookmarkHandler::slotNewBookmark(
const TQString& ,
72 const TQString& additionalInfo )
74 *m_importStream <<
"<bookmark icon=\"" << KMimeType::iconForURL( KURL( url ) );
75 *m_importStream <<
"\" href=\"" << TQString::fromUtf8(url) <<
"\">\n";
76 *m_importStream <<
"<title>" << (additionalInfo.isEmpty() ? TQString(TQString::fromUtf8(url)) : additionalInfo) <<
"</title>\n</bookmark>\n";
79 void KBookmarkHandler::slotNewFolder(
const TQString& text,
bool ,
82 *m_importStream <<
"<folder icon=\"bookmark_folder\">\n<title=\"";
83 *m_importStream << text <<
"\">\n";
86 void KBookmarkHandler::newSeparator()
88 *m_importStream <<
"<separator/>\n";
91 void KBookmarkHandler::endFolder()
93 *m_importStream <<
"</folder>\n";
96 void KBookmarkHandler::virtual_hook(
int id,
void* data )
97 { KBookmarkOwner::virtual_hook(
id, data ); }