parts/fileselector/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
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(
KDevFileSelector *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",
"kdevfileselector/fsbookmarks.xml" );
00049
if (
file.isEmpty() )
00050
file =
locateLocal(
"data",
"kdevfileselector/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& text,
00071
const QCString& url,
00072
const QString& additionalInfo )
00073 {
00074 Q_UNUSED(
text );
00075 *
m_importStream <<
"<bookmark icon=\"" << KMimeType::iconForURL( url );
00076 *
m_importStream <<
"\" href=\"" << QString::fromUtf8(url) <<
"\">\n";
00077 *
m_importStream <<
"<title>" << (additionalInfo.isEmpty() ? QString::fromUtf8(url) : additionalInfo) <<
"</title>\n</bookmark>\n";
00078 }
00079
00080 void KBookmarkHandler::slotNewFolder(
const QString& text,
bool ,
00081
const QString& )
00082 {
00083 *
m_importStream <<
"<folder icon=\"bookmark_folder\">\n<title=\"";
00084 *
m_importStream <<
text <<
"\">\n";
00085 }
00086
00087 void KBookmarkHandler::newSeparator()
00088 {
00089 *
m_importStream <<
"<separator/>\n";
00090 }
00091
00092 void KBookmarkHandler::endFolder()
00093 {
00094 *
m_importStream <<
"</folder>\n";
00095 }
00096
00097 void KBookmarkHandler::virtual_hook(
int id,
void* data )
00098 { KBookmarkOwner::virtual_hook(
id, data ); }
00099
This file is part of the documentation for KDevelop Version 3.0.4.