1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 Copyright (C) 2006 Daniel Teske <teske@squorn.de>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
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
21#ifndef __konqbookmarkmenu_h__
22#define __konqbookmarkmenu_h__
23#include "kbookmarkmenu.h"
24
25class KIO_EXPORT KonqBookmarkOwner : public KBookmarkOwner // KDE5 TODO: merge with KBookmarkOwner
26{
27public:
28 virtual ~KonqBookmarkOwner();
29 virtual void openInNewTab(const KBookmark &bm) = 0;
30 virtual void openInNewWindow(const KBookmark &bm) = 0;
31};
32
33class KIO_EXPORT KonqBookmarkMenu : public KBookmarkMenu
34{
35 //friend class KBookmarkBar;
36 Q_OBJECT
37public:
38 /**
39 * Fills a bookmark menu with konquerors bookmarks
40 * (one instance of KonqBookmarkMenu is created for the toplevel menu,
41 * but also one per submenu).
42 *
43 * @param mgr The bookmark manager to use (i.e. for reading and writing)
44 * @param owner implementation of the KonqBookmarkOwner callback interface.
45 * Note: If you pass a null KonqBookmarkOwner to the constructor, the
46 * URLs are openend by KRun and "Add Bookmark" is disabled.
47 * @param parentMenu menu to be filled
48 * @param collec parent collection for the KActions.
49 */
50 KonqBookmarkMenu( KBookmarkManager* mgr, KonqBookmarkOwner * owner, KBookmarkActionMenu * parentMenu, KActionCollection *collec)
51 : KBookmarkMenu( mgr, owner, parentMenu->menu(), collec)
52 {
53 }
54 ~KonqBookmarkMenu()
55 {}
56
57 /**
58 * Creates a bookmark submenu.
59 * Only used internally and for bookmark toolbar.
60 */
61 KonqBookmarkMenu( KBookmarkManager* mgr, KonqBookmarkOwner * owner, KBookmarkActionMenu * parentMenu, QString parentAddress)
62 : KBookmarkMenu( mgr, owner, parentMenu->menu(), parentAddress)
63 {
64 }
65
66protected:
67 /**
68 * Structure used for storing information about
69 * the dynamic menu setting
70 */
71 struct DynMenuInfo {
72 bool show;
73 QString location;
74 QString type;
75 QString name;
76 class DynMenuInfoPrivate *d;
77 };
78
79 /**
80 * @return dynmenu info block for the given dynmenu name
81 */
82 static DynMenuInfo showDynamicBookmarks( const QString &id );
83
84 /**
85 * Shows an extra menu for the given bookmarks file and type.
86 * Upgrades from option inside XBEL to option in rc file
87 * on first call of this function.
88 * @param id the unique identification for the dynamic menu
89 * @param info a DynMenuInfo struct containing the to be added/modified data
90 */
91 static void setDynamicBookmarks( const QString &id, const DynMenuInfo &info );
92
93 /**
94 * @return list of dynamic menu ids
95 */
96 static QStringList dynamicBookmarksList();
97
98 virtual void refill();
99 virtual QAction* actionForBookmark(const KBookmark &bm);
100 virtual KMenu * contextMenu(QAction * act);
101 void fillDynamicBookmarks();
102private:
103 KonqBookmarkOwner * owner()
104 { return static_cast<KonqBookmarkOwner *>(KBookmarkMenu::owner());}
105};
106
107class KIO_EXPORT KonqBookmarkContextMenu : public KBookmarkContextMenu
108{
109 Q_OBJECT
110public:
111 KonqBookmarkContextMenu(const KBookmark & bm, KBookmarkManager * mgr, KonqBookmarkOwner * owner );
112 virtual ~KonqBookmarkContextMenu();
113 virtual void addActions();
114
115public Q_SLOTS:
116 void openInNewTab();
117 void openInNewWindow();
118 void toggleShowInToolbar();
119private:
120 KonqBookmarkOwner * owner()
121 { return static_cast<KonqBookmarkOwner *>(KBookmarkContextMenu::owner());}
122};
123#endif
124
125