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) 2009 Dominik Haumann <dhaumann kde org>
5 Copyright (C) 2007 Mirko Stocker <me@misto.ch>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include "katebookmarkhandler.h"
23#include "katebookmarkhandler.moc"
24#include "katefilebrowser.h"
25
26#include <kdiroperator.h>
27#include <kstandarddirs.h>
28
29
30KateBookmarkHandler::KateBookmarkHandler( KateFileBrowser *parent, KMenu* kpopupmenu )
31 : QObject( parent ),
32 KBookmarkOwner(),
33 mParent( parent ),
34 m_menu( kpopupmenu )
35{
36 setObjectName( "KateBookmarkHandler" );
37 if (!m_menu)
38 m_menu = new KMenu( parent);
39
40 QString file = KStandardDirs::locate( "data", "kate/fsbookmarks.xml" );
41 if ( file.isEmpty() )
42 file = KStandardDirs::locateLocal( "data", "kate/fsbookmarks.xml" );
43
44 KBookmarkManager *manager = KBookmarkManager::managerForFile( file, "kate" );
45 manager->setUpdate( true );
46
47 m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, parent->actionCollection() );
48}
49
50KateBookmarkHandler::~KateBookmarkHandler()
51{
52 delete m_bookmarkMenu;
53}
54
55QString KateBookmarkHandler::currentUrl() const
56{
57 return mParent->dirOperator()->url().url();
58}
59
60QString KateBookmarkHandler::currentTitle() const
61{
62 return currentUrl();
63}
64
65void KateBookmarkHandler::openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers )
66{
67 emit openUrl(bm.url().url());
68}
69
70// kate: space-indent on; indent-width 2; replace-tabs on;
71