KBookmarks 5.109.0
kbookmarkmenu.h
1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org>
4 SPDX-FileCopyrightText: 2006 Daniel Teske <teske@squorn.de>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef __kbookmarkmenu_h__
10#define __kbookmarkmenu_h__
11
12#include <kbookmarks_export.h>
13
14#include <QObject>
15#include <memory>
16
17class QAction;
18class QMenu;
19class KBookmark;
20class KActionCollection;
22class KBookmarkOwner;
23class KBookmarkMenu;
24
25class KBookmarkMenuPrivate;
26
50class KBOOKMARKS_EXPORT KBookmarkMenu : public QObject
51{
52 Q_OBJECT
53public:
54#if KBOOKMARKS_ENABLE_DEPRECATED_SINCE(5, 69)
95 KBOOKMARKS_DEPRECATED_VERSION(5, 69, "Use overload without KActionCollection and add actions manually to your actionCollection if desired")
96 KBookmarkMenu(KBookmarkManager *mgr, KBookmarkOwner *owner, QMenu *parentMenu, KActionCollection *collec);
97#endif
98
111 KBookmarkMenu(KBookmarkManager *manager, KBookmarkOwner *owner, QMenu *parentMenu);
112
119 KBookmarkMenu(KBookmarkManager *mgr, KBookmarkOwner *owner, QMenu *parentMenu, const QString &parentAddress);
120
121 ~KBookmarkMenu() override;
122
128
135 void setNumberOfOpenTabs(int numberOfOpenTabs);
144 int numberOfOpenTabs() const;
145
157 QAction *addBookmarkAction() const;
158
171
183 QAction *newBookmarkFolderAction() const;
184
196 QAction *editBookmarksAction() const;
197
198public Q_SLOTS:
199 // public for KonqBookmarkBar
200 void slotBookmarksChanged(const QString &);
201
202protected Q_SLOTS:
203 void slotAboutToShow();
204 void slotAddBookmarksList();
205 void slotAddBookmark();
206 void slotNewFolder();
207 void slotOpenFolderInTabs();
208
209protected:
210 virtual void clear();
211 virtual void refill();
212 virtual QAction *actionForBookmark(const KBookmark &bm);
213 virtual QMenu *contextMenu(QAction *action);
214
215 void addActions();
216 void fillBookmarks();
217 void addAddBookmark();
218 void addAddBookmarksList();
219 void addEditBookmarks();
220 void addNewFolder();
221 void addOpenInTabs();
222
223 bool isRoot() const;
224 bool isDirty() const;
225
229 QString parentAddress() const;
230
231 KBookmarkManager *manager() const;
232 KBookmarkOwner *owner() const;
237 QMenu *parentMenu() const;
238
242 QList<KBookmarkMenu *> m_lstSubMenus;
243
244 // This is used to "export" our actions into an actionlist
245 // we got in the constructor. So that the program can show our
246 // actions in their shortcut dialog
247 KActionCollection *m_actionCollection;
251 QList<QAction *> m_actions;
252
253private Q_SLOTS:
254 KBOOKMARKS_NO_EXPORT void slotCustomContextMenu(const QPoint &);
255
256private:
257 KBOOKMARKS_NO_EXPORT void init();
258
259private:
260 std::unique_ptr<KBookmarkMenuPrivate> const d;
261
262 // TODO KF6:: move into KBookmarkMenuPrivate
263 bool m_bIsRoot;
264 bool m_bDirty;
265 KBookmarkManager *m_pManager;
266 KBookmarkOwner *m_pOwner;
267 QMenu *m_parentMenu;
268 QString m_parentAddress;
269};
270
271#endif
This class implements the reading/writing of bookmarks in XML.
Definition kbookmarkmanager.h:52
This class provides a bookmark menu.
Definition kbookmarkmenu.h:51
QAction * editBookmarksAction() const
Returns the action for editing bookmarks.
KBookmarkMenu(KBookmarkManager *manager, KBookmarkOwner *owner, QMenu *parentMenu)
Fills a bookmark menu (one instance of KBookmarkMenu is created for the toplevel menu,...
QList< QAction * > m_actions
List of our actions.
Definition kbookmarkmenu.h:251
QAction * bookmarkTabsAsFolderAction() const
Returns the action for adding all current tabs as bookmarks.
QAction * addBookmarkAction() const
Returns the action for adding a bookmark.
void ensureUpToDate()
Call ensureUpToDate() if you need KBookmarkMenu to adjust to its final size before it is executed.
KBookmarkMenu(KBookmarkManager *mgr, KBookmarkOwner *owner, QMenu *parentMenu, const QString &parentAddress)
Creates a bookmark submenu.
QMenu * parentMenu() const
The menu in which we insert our actions Supplied in the constructor.
void setNumberOfOpenTabs(int numberOfOpenTabs)
Sets the number of currently open tabs.
QAction * newBookmarkFolderAction() const
Returns the action for adding a new bookmarks folder.
QString parentAddress() const
Parent bookmark for this menu.
int numberOfOpenTabs() const
This function returns how many (if any) tabs the application has open.
QList< KBookmarkMenu * > m_lstSubMenus
List of our sub menus.
Definition kbookmarkmenu.h:242
The KBookmarkMenu and KBookmarkBar classes gives the user the ability to either edit bookmarks or add...
Definition kbookmarkowner.h:44
A class representing a bookmark.
Definition kbookmark.h:28