File indexing completed on 2024-05-12 16:23:41
0001 // SPDX-FileCopyrightText: 2014 Sebastian Kügler <sebas@kde.org> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #ifndef BOOKMARKSMANAGER_H 0006 #define BOOKMARKSMANAGER_H 0007 0008 #include <QObject> 0009 #include <QUrl> 0010 0011 #include "dbmanager.h" 0012 0013 class QSettings; 0014 0015 /** 0016 * @class BookmarksManager 0017 * @short Access to Bookmarks and History. This is a singleton for 0018 * administration and access to the various models and browser-internal 0019 * data. 0020 */ 0021 class BrowserManager : public QObject 0022 { 0023 Q_OBJECT 0024 0025 Q_PROPERTY(QUrl initialUrl READ initialUrl WRITE setInitialUrl NOTIFY initialUrlChanged) 0026 0027 public: 0028 static BrowserManager *instance(); 0029 0030 QUrl initialUrl() const; 0031 void setInitialUrl(const QUrl &initialUrl); 0032 0033 QCoro::Task<bool> isBookmarked(const QString &url) const; 0034 0035 inline DBManager *databaseManager() { 0036 return m_dbmanager; 0037 } 0038 0039 Q_SIGNALS: 0040 void updated(); 0041 0042 void initialUrlChanged(); 0043 0044 void databaseTableChanged(QString table); 0045 0046 public Q_SLOTS: 0047 void addBookmark(const QVariantMap &bookmarkdata); 0048 void removeBookmark(const QString &url); 0049 0050 void addToHistory(const QVariantMap &pagedata); 0051 void removeFromHistory(const QString &url); 0052 void clearHistory(); 0053 0054 void updateLastVisited(const QString &url); 0055 void updateIcon(const QString &url, const QString &iconSource); 0056 0057 QString tempDirectory() const; 0058 QString downloadDirectory() const; 0059 0060 private: 0061 // BrowserManager should only be createdd by calling the instance() function 0062 BrowserManager(QObject *parent = nullptr); 0063 0064 DBManager *m_dbmanager; 0065 0066 QUrl m_initialUrl; 0067 0068 static BrowserManager *s_instance; 0069 }; 0070 0071 #endif // BOOKMARKSMANAGER_H