Falkon Develop
Cross-platform Qt-based web browser
qmlstaticdata.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program 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
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#pragma once
19
20#include "mainapplication.h"
21#include "browserwindow.h"
22#include "bookmarkitem.h"
23#include "historyitem.h"
28#include "api/tabs/qmltabs.h"
33#include <QObject>
34#include <QString>
35#include <QNetworkCookie>
36
38class QmlCookie;
39class QmlHistoryItem;
40class QmlTab;
42class QmlWindow;
43
44class QmlStaticData : public QObject
45{
46 Q_OBJECT
47
48public:
49 explicit QmlStaticData(QObject *parent = nullptr);
51
52 static QmlStaticData &instance();
54 QmlCookie *getCookie(const QNetworkCookie &cookie);
56 QmlTab *getTab(WebTab *webTab);
57 QmlMostVisitedUrl *getMostVisitedUrl(const QString &title = QString(), const QString &url = QString());
59
60 QHash<BrowserWindow*, int> windowIdHash();
61 QIcon getIcon(const QString &iconPath, const QString &pluginPath);
62
72private:
73 QHash<BookmarkItem*, QmlBookmarkTreeNode*> m_bookmarkTreeNodes;
74 QHash<QNetworkCookie, QmlCookie*> m_cookies;
75 QHash<HistoryEntry, QmlHistoryItem*> m_historyItems;
76 QHash<WebTab*, QmlTab*> m_tabs;
77 QHash<QPair<QString, QString>, QmlMostVisitedUrl*> m_urls;
78 QHash<BrowserWindow*, QmlWindow*> m_windows;
79
80 int m_newWindowId = 0;
81 QHash<BrowserWindow*, int> m_windowIdHash;
82};
83
84inline bool operator ==(const HistoryEntry &x, const HistoryEntry &y) {
85 return x.title == y.title && x.urlString == y.urlString && x.date == y.date && x.count == y.count;
86}
87
88inline uint qHash(const HistoryEntry &entry) {
89 return qHash(QSL("%1 %2 %3 %4").arg(entry.title, entry.urlString, entry.date.toString(), QString::number(entry.count)));
90}
91
92inline uint qHash(const QNetworkCookie &cookie) {
93 return qHash(QString::fromUtf8(cookie.toRawForm()));
94}
The class exposing the bookmark item to QML.
The class exposing the Bookmarks API to QML.
Definition: qmlbookmarks.h:29
The class exposing application clipboard to QML.
Definition: qmlclipboard.h:27
The class exposing Cookies API to QML.
Definition: qmlcookies.h:27
The class exposing the History API to QML.
Definition: qmlhistory.h:27
The class exposing HistoryEntry to QML.
The class exposing MostVisitedUrl type to QML.
QmlClipboard * getClipboardSingleton()
QHash< BrowserWindow *, int > windowIdHash()
QmlCookie * getCookie(const QNetworkCookie &cookie)
QmlBookmarks * getBookmarksSingleton()
QmlTab * getTab(WebTab *webTab)
QmlUserScripts * getUserScriptsSingleton()
QmlHistoryItem * getHistoryItem(const HistoryEntry &entry)
QmlExternalJsObject * getExternalJsObjectSingleton()
QmlTopSites * getTopSitesSingleton()
QmlStaticData(QObject *parent=nullptr)
static QmlStaticData & instance()
QmlWindow * getWindow(BrowserWindow *window)
QIcon getIcon(const QString &iconPath, const QString &pluginPath)
QmlTabs * getTabsSingleton()
QmlCookies * getCookiesSingleton()
QmlMostVisitedUrl * getMostVisitedUrl(const QString &title=QString(), const QString &url=QString())
QmlBookmarkTreeNode * getBookmarkTreeNode(BookmarkItem *item)
QmlWindows * getWindowsSingleton()
QmlHistory * getHistorySingleton()
The class exposing a browser tab to QML.
Definition: qmltab.h:32
The class exposing Tabs API to QML.
Definition: qmltabs.h:28
The class exposing TopSites API to QML.
Definition: qmltopsites.h:27
The class exposing QWebEngineScriptCollection to QML.
The class exposing Browser window to QML.
Definition: qmlwindow.h:27
The class exposing Windows API to QML.
Definition: qmlwindows.h:27
Definition: webtab.h:40
uint qHash(const HistoryEntry &entry)
Definition: qmlstaticdata.h:88
bool operator==(const HistoryEntry &x, const HistoryEntry &y)
Definition: qmlstaticdata.h:84
#define QSL(x)
Definition: qzcommon.h:40
Definition: history.h:39
QDateTime date
Definition: history.h:42
QString title
Definition: history.h:45
QString urlString
Definition: history.h:44
int count
Definition: history.h:41