Commit 4addfa23 authored by Robert Knight's avatar Robert Knight
Browse files

Uncouple KonsoleBookmarkHandler and KMainWindow. Document methods. Remove unnecessary includes.

svn path=/branches/work/konsole-split-view/; revision=637893
parent 92ed4c39
/* This file was part of the KDE libraries
Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
/* This file was part of the KDE libraries
Copyright 2002 Carsten Pfeiffer <pfeiffer@kde.org>
Copyright 2007 Robert Knight <robertknight@gmail.com>
library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -28,7 +30,6 @@
#include <KDebug>
#include <KIO/Job>
#include <KIO/NetAccess>
#include <KMainWindow>
#include <KMenu>
#include <KStandardDirs>
......@@ -36,10 +37,9 @@
#include "KonsoleBookmarkHandler.h"
#include "SessionController.h"
KonsoleBookmarkHandler::KonsoleBookmarkHandler( KMainWindow* konsole, KMenu* menu, bool toplevel )
: QObject( konsole ),
KonsoleBookmarkHandler::KonsoleBookmarkHandler( KActionCollection* collection, KMenu* menu, bool toplevel )
: QObject( collection ),
KBookmarkOwner(),
m_konsole( konsole ),
m_toplevel(toplevel),
m_controller( 0 )
{
......@@ -70,7 +70,7 @@ KonsoleBookmarkHandler::KonsoleBookmarkHandler( KMainWindow* konsole, KMenu* men
if (toplevel) {
m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu,
konsole->actionCollection() );
collection );
} else {
m_bookmarkMenu = new KBookmarkMenu( manager, this, m_menu,
NULL);
......@@ -105,7 +105,7 @@ QString KonsoleBookmarkHandler::currentUrl() const
}
else
{
return QString(); //m_konsole->baseURL().prettyUrl();
return QString();
}
}
......
......@@ -21,10 +21,7 @@
#ifndef KONSOLEBOOKMARKHANDLER_H
#define KONSOLEBOOKMARKHANDLER_H
#include <kbookmarkmanager.h>
//Added by qt3to4:
#include <QTextStream>
#include <QMenu>
#include <KBookmarkManager>
class KMenu;
class KBookmarkMenu;
......@@ -33,12 +30,31 @@ class KMainWindow;
class SessionController;
/**
* This class handles the communication between the bookmark menu and the active session,
* providing a suggested title and URL when the user clicks the "Add Bookmark" item in
* the bookmarks menu.
*
* The bookmark handler is associated with a session controller, which is used to
* determine the working URL of the current session. When the user changes the active
* view, the bookmark handler's controller should be changed using setController()
*
* When the user selects a bookmark, the openUrl() signal is emitted.
*/
class KonsoleBookmarkHandler : public QObject, public KBookmarkOwner
{
Q_OBJECT
public:
KonsoleBookmarkHandler( KMainWindow* konsole, KMenu* menu, bool toplevel );
/**
* Constructs a new bookmark handler for Konsole bookmarks.
*
* @param collection The collection which the boomark menu's actions should be added to
* @param menu The menu which the bookmark actions should be added to
* @param toplevel TODO: Document me
*/
KonsoleBookmarkHandler( KActionCollection* collection , KMenu* menu, bool toplevel );
~KonsoleBookmarkHandler();
QMenu * popupMenu();
......@@ -48,6 +64,9 @@ public:
virtual bool addBookmarkEntry() const;
virtual bool editBookmarkEntry() const;
/**
* Returns the menu which this bookmark handler inserts its actions into.
*/
KMenu *menu() const { return m_menu; }
/**
......@@ -62,13 +81,18 @@ public:
SessionController* controller() const;
Q_SIGNALS:
/**
* Emitted when the user selects a bookmark from the bookmark menu.
*
* @param url The url of the bookmark which was selected by the user.
* @param text TODO: Document me
*/
void openUrl( const QString& url , const QString& text );
private Q_SLOTS:
void openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers );
private:
KMainWindow* m_konsole;
KMenu* m_menu;
KBookmarkMenu* m_bookmarkMenu;
QString m_file;
......
......@@ -86,7 +86,7 @@ void KonsoleMainWindow::setupActions()
// Bookmark Menu
KActionMenu* bookmarkMenu = new KActionMenu(i18n("&Bookmarks") , collection );
_bookmarkHandler = new KonsoleBookmarkHandler( this , bookmarkMenu->menu() , true );
_bookmarkHandler = new KonsoleBookmarkHandler( collection , bookmarkMenu->menu() , true );
collection->addAction("bookmark" , bookmarkMenu);
// Settings Menu
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment