Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / konsole / src / BookmarkHandler.h
blob8b95eb71426b04ea581ea008fa67ee448ba4d783
1 /* This file was part of the KDE libraries
3 Copyright 2002 Carsten Pfeiffer <pfeiffer@kde.org>
4 Copyright 2007-2008 Robert Knight <robertknight@gmail.com>
6 library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation, version 2
9 or (at your option) any later version.
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.
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.
22 // Born as kdelibs/kio/kfile/kfilebookmarkhandler.h
24 #ifndef KONSOLEBOOKMARKHANDLER_H
25 #define KONSOLEBOOKMARKHANDLER_H
27 // Qt
28 #include <QtGui/QMenu>
30 // KDE
31 #include <KBookmarkManager>
33 class KMenu;
34 class KBookmarkMenu;
35 class KBookmarkManager;
36 class KActionCollection;
38 namespace Konsole
41 class ViewProperties;
43 /**
44 * This class handles the communication between the bookmark menu and the active session,
45 * providing a suggested title and URL when the user clicks the "Add Bookmark" item in
46 * the bookmarks menu.
48 * The bookmark handler is associated with a session controller, which is used to
49 * determine the working URL of the current session. When the user changes the active
50 * view, the bookmark handler's controller should be changed using setController()
52 * When the user selects a bookmark, the openUrl() signal is emitted.
54 class BookmarkHandler : public QObject, public KBookmarkOwner
56 Q_OBJECT
58 public:
60 /**
61 * Constructs a new bookmark handler for Konsole bookmarks.
63 * @param collection The collection which the boomark menu's actions should be added to
64 * @param menu The menu which the bookmark actions should be added to
65 * @param toplevel TODO: Document me
67 BookmarkHandler( KActionCollection* collection , KMenu* menu, bool toplevel , QObject* parent );
68 ~BookmarkHandler();
70 QMenu * popupMenu();
72 virtual QString currentUrl() const;
73 virtual QString currentTitle() const;
74 virtual bool enableOption(BookmarkOption option) const;
75 virtual bool supportsTabs() const;
76 virtual QList<QPair<QString,QString> > currentBookmarkList() const;
77 virtual void openFolderinTabs(const KBookmarkGroup& group);
79 /**
80 * Returns the menu which this bookmark handler inserts its actions into.
82 KMenu *menu() const { return m_menu; }
84 QList<ViewProperties*> views() const;
85 ViewProperties* activeView() const;
87 public slots:
88 /**
91 void setViews( const QList<ViewProperties*>& views );
93 void setActiveView( ViewProperties* view );
95 signals:
96 /**
97 * Emitted when the user selects a bookmark from the bookmark menu.
99 * @param url The url of the bookmark which was selected by the user.
100 * @param text TODO: Document me
102 void openUrl( const KUrl& url );
105 * Emitted when the user selects 'Open Folder in Tabs'
106 * from the bookmark menu.
108 * @param urls The urls of the bookmarks in the folder whoose
109 * 'Open Folder in Tabs' action was triggered
111 void openUrls( const QList<KUrl>& urls );
113 private Q_SLOTS:
114 void openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers );
116 private:
117 QString titleForView( ViewProperties* view ) const;
118 QString urlForView( ViewProperties* view ) const;
120 KMenu* m_menu;
121 KBookmarkMenu* m_bookmarkMenu;
122 QString m_file;
123 bool m_toplevel;
124 ViewProperties* m_activeView;
125 QList<ViewProperties*> m_views;
130 #endif // KONSOLEBOOKMARKHANDLER_H