~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to kate/plugins/filebrowser/kbookmarkhandler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
5
 
 
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.
 
9
 
 
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.
 
14
 
 
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.
 
19
*/
 
20
#include "kbookmarkhandler.h"
 
21
 
 
22
#include <stdio.h>
 
23
#include <stdlib.h>
 
24
 
 
25
#include <QByteArray>
 
26
 
 
27
#include <kbookmarkimporter.h>
 
28
#include <kdiroperator.h>
 
29
#include <kmenu.h>
 
30
#include <ksavefile.h>
 
31
#include <kstandarddirs.h>
 
32
#include <kdebug.h>
 
33
 
 
34
#include "katefileselector.h"
 
35
 
 
36
#include "kbookmarkhandler.moc"
 
37
 
 
38
KBookmarkHandler::KBookmarkHandler( KateFileSelector *parent, KMenu* kpopupmenu )
 
39
    : QObject( parent ),
 
40
    KBookmarkOwner(),
 
41
    mParent( parent ),
 
42
    m_menu( kpopupmenu ),
 
43
    m_importStream( 0L )
 
44
{
 
45
  setObjectName( "KBookmarkHandler" );
 
46
  if (!m_menu)
 
47
    m_menu = new KMenu( parent);
 
48
 
 
49
  QString file = KStandardDirs::locate( "data", "kate/fsbookmarks.xml" );
 
50
  if ( file.isEmpty() )
 
51
    file = KStandardDirs::locateLocal( "data", "kate/fsbookmarks.xml" );
 
52
 
 
53
  KBookmarkManager *manager = KBookmarkManager::managerForFile( file, "kate" );
 
54
  manager->setUpdate( true );
 
55
 
 
56
  m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu, parent->actionCollection() );
 
57
}
 
58
 
 
59
KBookmarkHandler::~KBookmarkHandler()
 
60
{
 
61
  delete m_bookmarkMenu;
 
62
}
 
63
 
 
64
QString KBookmarkHandler::currentUrl() const
 
65
{
 
66
  return mParent->dirOperator()->url().url();
 
67
}
 
68
 
 
69
QString KBookmarkHandler::currentTitle() const
 
70
{
 
71
  return currentUrl();
 
72
}
 
73
 
 
74
void KBookmarkHandler::openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers )
 
75
{
 
76
  emit openUrl(bm.url().url());
 
77
}
 
78
 
 
79
void KBookmarkHandler::slotNewBookmark( const QString& /*text*/,
 
80
                                        const QByteArray& url,
 
81
                                        const QString& additionalInfo )
 
82
{
 
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";
 
86
}
 
87
 
 
88
void KBookmarkHandler::slotNewFolder( const QString& text, bool /*open*/,
 
89
                                      const QString& /*additionalInfo*/ )
 
90
{
 
91
  *m_importStream << "<folder icon=\"bookmark_folder\">\n<title=\"";
 
92
  *m_importStream << text << "\">\n";
 
93
}
 
94
 
 
95
void KBookmarkHandler::newSeparator()
 
96
{
 
97
  *m_importStream << "<separator/>\n";
 
98
}
 
99
 
 
100
void KBookmarkHandler::endFolder()
 
101
{
 
102
  *m_importStream << "</folder>\n";
 
103
}
 
104
 
 
105
// kate: space-indent on; indent-width 2; replace-tabs on;
 
106