File indexing completed on 2025-04-27 04:37:42
0001 /* 0002 SPDX-FileCopyrightText: 2007 Urs Wolfer <uwolfer@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef BOOKMARKMANAGER_H 0008 #define BOOKMARKMANAGER_H 0009 0010 #include "core/remoteview.h" 0011 0012 #include <KActionCollection> 0013 #include <KBookmarkManager> 0014 #include <KBookmarkMenu> 0015 #include <KBookmarkOwner> 0016 0017 #include <QMenu> 0018 0019 class MainWindow; 0020 0021 class BookmarkManager : public QObject, public KBookmarkOwner 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 BookmarkManager(KActionCollection *collection, QMenu *menu, MainWindow *parent); 0027 ~BookmarkManager() override; 0028 0029 QUrl currentUrl() const override; 0030 QString currentTitle() const override; 0031 virtual bool addBookmarkEntry() const; 0032 virtual bool editBookmarkEntry() const; 0033 bool supportsTabs() const override; 0034 QList<KBookmarkOwner::FutureBookmark> currentBookmarkList() const override; 0035 void addHistoryBookmark(RemoteView *view); 0036 void addManualBookmark(const QUrl &url, const QString &text); 0037 KBookmarkManager *getManager(); 0038 // removes all bookmarks with url, possibly ignore the history folder and update it's title there if it's set 0039 static void removeByUrl(KBookmarkManager *manager, const QString &url, bool ignoreHistory = false, const QString &updateTitle = QString()); 0040 static void updateTitle(KBookmarkManager *manager, const QString &url, const QString &title); 0041 // returns a QStringList for all bookmarks that point to this url using KBookmark::address() 0042 static const QStringList findBookmarkAddresses(const KBookmarkGroup &group, const QString &url); 0043 0044 Q_SIGNALS: 0045 void openUrl(const QUrl &url); 0046 0047 private Q_SLOTS: 0048 void openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers) override; 0049 void openFolderinTabs(const KBookmarkGroup &bookmarkGroup) override; 0050 0051 private: 0052 QString urlForView(RemoteView *view) const; 0053 QString titleForUrl(const QUrl &url) const; 0054 0055 KBookmarkMenu *m_bookmarkMenu; 0056 KBookmarkManager *m_manager; 0057 KBookmarkGroup m_historyGroup; 0058 0059 MainWindow *m_mainWindow; 0060 }; 0061 0062 #endif