1
/* This file is part of the KDE project
2
Copyright (C) xxxx KFile Authors
3
Copyright (C) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk>
4
Copyright (C) 2007 Mirko Stocker <me@misto.ch>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License version 2 as published by the Free Software Foundation.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
Boston, MA 02110-1301, USA.
20
#include "kbookmarkhandler.h"
27
#include <kbookmarkimporter.h>
28
#include <kdiroperator.h>
30
#include <ksavefile.h>
31
#include <kstandarddirs.h>
34
#include "katefileselector.h"
36
#include "kbookmarkhandler.moc"
38
KBookmarkHandler::KBookmarkHandler( KateFileSelector *parent, KMenu* kpopupmenu )
45
setObjectName( "KBookmarkHandler" );
47
m_menu = new KMenu( parent);
49
QString file = KStandardDirs::locate( "data", "kate/fsbookmarks.xml" );
51
file = KStandardDirs::locateLocal( "data", "kate/fsbookmarks.xml" );
53
KBookmarkManager *manager = KBookmarkManager::managerForFile( file, "kate" );
54
manager->setUpdate( true );
56
m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, parent->actionCollection() );
59
KBookmarkHandler::~KBookmarkHandler()
61
delete m_bookmarkMenu;
64
QString KBookmarkHandler::currentUrl() const
66
return mParent->dirOperator()->url().url();
69
QString KBookmarkHandler::currentTitle() const
74
void KBookmarkHandler::openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers )
76
emit openUrl(bm.url().url());
79
void KBookmarkHandler::slotNewBookmark( const QString& /*text*/,
80
const QByteArray& url,
81
const QString& additionalInfo )
83
*m_importStream << "<bookmark icon=\"" << KMimeType::iconNameForUrl( KUrl( url ) );
84
*m_importStream << "\" href=\"" << QString::fromUtf8(url) << "\">\n";
85
*m_importStream << "<title>" << (additionalInfo.isEmpty() ? QString::fromUtf8(url) : additionalInfo) << "</title>\n</bookmark>\n";
88
void KBookmarkHandler::slotNewFolder( const QString& text, bool /*open*/,
89
const QString& /*additionalInfo*/ )
91
*m_importStream << "<folder icon=\"bookmark_folder\">\n<title=\"";
92
*m_importStream << text << "\">\n";
95
void KBookmarkHandler::newSeparator()
97
*m_importStream << "<separator/>\n";
100
void KBookmarkHandler::endFolder()
102
*m_importStream << "</folder>\n";
105
// kate: space-indent on; indent-width 2; replace-tabs on;