1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Fixed coding style

This commit is contained in:
Anmol Gautam 2018-06-09 23:55:59 +05:30
parent 7d3d53519b
commit 526e6dda31
26 changed files with 82 additions and 92 deletions

View File

@ -126,9 +126,9 @@ bool QmlBookmarks::create(const QVariantMap &map) const
qWarning() << "Unable to create new bookmark:" << "parent not found";
return false;
}
QString title = map.value(QSL("title")).toString();
QString urlString = map.value(QSL("url")).toString();
QString description = map.value(QSL("description")).toString();
const QString title = map.value(QSL("title")).toString();
const QString urlString = map.value(QSL("url")).toString();
const QString description = map.value(QSL("description")).toString();
BookmarkItem::Type type;
if (map.contains(QSL("type"))) {
@ -175,8 +175,8 @@ QList<QObject*> QmlBookmarks::search(const QVariantMap &map) const
return QList<QObject*>();
}
QString query = map.value(QSL("query")).toString();
QString urlString = map.value(QSL("url")).toString();
const QString query = map.value(QSL("query")).toString();
const QString urlString = map.value(QSL("url")).toString();
QList<BookmarkItem*> items;
if (urlString.isEmpty()) {
items = mApp->bookmarks()->searchBookmarks(query);

View File

@ -27,7 +27,7 @@ class QmlBookmarks : public QObject
Q_OBJECT
public:
explicit QmlBookmarks(QObject *parent = 0);
explicit QmlBookmarks(QObject *parent = nullptr);
Q_INVOKABLE bool isBookmarked(const QUrl &url) const;
Q_INVOKABLE QmlBookmarkTreeNode *rootItem() const;

View File

@ -114,9 +114,9 @@ bool QmlBookmarkTreeNode::unmodifiable() const
QList<QObject*> QmlBookmarkTreeNode::children() const
{
auto items = m_item->children();
const auto items = m_item->children();
QList<QObject*> ret;
for (auto item : items) {
for (const auto &item : items) {
ret.append(bookmarkTreeNodeData->get(item));
}
return ret;
@ -128,9 +128,7 @@ QmlBookmarkTreeNodeData::QmlBookmarkTreeNodeData()
QmlBookmarkTreeNodeData::~QmlBookmarkTreeNodeData()
{
for (QmlBookmarkTreeNode *node : m_nodes.values()) {
node->deleteLater();
}
qDeleteAll(m_nodes);
}
QmlBookmarkTreeNode *QmlBookmarkTreeNodeData::get(BookmarkItem *item)

View File

@ -23,6 +23,6 @@ class QmlClipboard : public QObject
{
Q_OBJECT
public:
explicit QmlClipboard(QObject *parent = 0);
explicit QmlClipboard(QObject *parent = nullptr);
Q_INVOKABLE void copy(const QVariantMap &map);
};

View File

@ -88,9 +88,7 @@ QmlCookieData::QmlCookieData()
QmlCookieData::~QmlCookieData()
{
for (QmlCookie *qmlCookie : m_cookies.values()) {
qmlCookie->deleteLater();
}
qDeleteAll(m_cookies);
}
QmlCookie *QmlCookieData::get(QNetworkCookie *cookie)

View File

@ -32,7 +32,7 @@ class QmlCookie : public QObject
Q_PROPERTY(bool session READ session CONSTANT)
Q_PROPERTY(QString value READ value CONSTANT)
public:
explicit QmlCookie(QNetworkCookie *cookie = 0, QObject *parent = 0);
explicit QmlCookie(QNetworkCookie *cookie = nullptr, QObject *parent = nullptr);
QString domain() const;
QDateTime expirationDate() const;
QString name() const;

View File

@ -50,10 +50,10 @@ QNetworkCookie *QmlCookies::getNetworkCookie(const QVariantMap &map)
qWarning() << "Error:" << "Wrong arguments passed to" << __FUNCTION__;
return nullptr;
}
QString name = map.value(QSL("name")).toString();
QString url = map.value(QSL("url")).toString();
const QString name = map.value(QSL("name")).toString();
const QString url = map.value(QSL("url")).toString();
QVector<QNetworkCookie> cookies = mApp->cookieJar()->getAllCookies();
for (QNetworkCookie cookie : cookies) {
for (const QNetworkCookie &cookie : cookies) {
if (cookie.name() == name && cookie.domain() == url) {
QNetworkCookie *netCookie = new QNetworkCookie(cookie);
return netCookie;
@ -74,11 +74,11 @@ QmlCookie *QmlCookies::get(const QVariantMap &map)
QList<QObject*> QmlCookies::getAll(const QVariantMap &map)
{
QList<QObject*> qmlCookies;
QString name = map.value(QSL("name")).toString();
QString url = map.value(QSL("url")).toString();
QString path = map.value(QSL("path")).toString();
bool secure = map.value(QSL("secure")).toBool();
bool session = map.value(QSL("session")).toBool();
const QString name = map.value(QSL("name")).toString();
const QString url = map.value(QSL("url")).toString();
const QString path = map.value(QSL("path")).toString();
const bool secure = map.value(QSL("secure")).toBool();
const bool session = map.value(QSL("session")).toBool();
QVector<QNetworkCookie> cookies = mApp->cookieJar()->getAllCookies();
for (QNetworkCookie cookie : cookies) {
if ((!map.contains(QSL("name")) || cookie.name() == name)
@ -96,13 +96,13 @@ QList<QObject*> QmlCookies::getAll(const QVariantMap &map)
void QmlCookies::set(const QVariantMap &map)
{
QString name = map.value(QSL("name")).toString();
QString url = map.value(QSL("url")).toString();
QString path = map.value(QSL("path")).toString();
bool secure = map.value(QSL("secure")).toBool();
QDateTime expirationDate = QDateTime::fromMSecsSinceEpoch(map.value(QSL("expirationDate")).toDouble());
bool httpOnly = map.value(QSL("httpOnly")).toBool();
QString value = map.value(QSL("value")).toString();
const QString name = map.value(QSL("name")).toString();
const QString url = map.value(QSL("url")).toString();
const QString path = map.value(QSL("path")).toString();
const bool secure = map.value(QSL("secure")).toBool();
const QDateTime expirationDate = QDateTime::fromMSecsSinceEpoch(map.value(QSL("expirationDate")).toDouble());
const bool httpOnly = map.value(QSL("httpOnly")).toBool();
const QString value = map.value(QSL("value")).toString();
QNetworkCookie cookie;
cookie.setName(name.toUtf8());
cookie.setDomain(url);

View File

@ -24,7 +24,7 @@ class QmlCookies : public QObject
{
Q_OBJECT
public:
explicit QmlCookies(QObject *parent = 0);
explicit QmlCookies(QObject *parent = nullptr);
Q_INVOKABLE QmlCookie *get(const QVariantMap &map);
Q_INVOKABLE QList<QObject*> getAll(const QVariantMap &map);
Q_INVOKABLE void set(const QVariantMap &map);

View File

@ -43,7 +43,7 @@ QList<QObject*> QmlHistory::search(const QVariantMap &map)
qWarning() << "Error:" << "wrong arguments passed to" << __FUNCTION__;
return list;
}
QString text = map.value(QSL("text")).toString();
const QString text = map.value(QSL("text")).toString();
QList<HistoryEntry*> result = mApp->history()->searchHistoryEntry(text);
foreach(auto entry, result) {
@ -59,7 +59,7 @@ int QmlHistory::getVisits(const QVariantMap &map)
qWarning() << "Error:" << "wrong arguments passed to" << __FUNCTION__;
return 0;
}
QString url = map.value(QSL("url")).toString();
const QString url = map.value(QSL("url")).toString();
HistoryEntry *entry = mApp->history()->getHistoryEntry(url);
return entry->count;
}
@ -71,7 +71,7 @@ void QmlHistory::addUrl(const QVariantMap &map)
return;
}
QString title = map.value(QSL("title")).toString();
QString url = map.value(QSL("url")).toString();
const QString url = map.value(QSL("url")).toString();
title = title.isEmpty() ? url : title;
@ -84,7 +84,7 @@ void QmlHistory::deleteUrl(const QVariantMap &map)
qWarning() << "Error:" << "wrong arguments passed to" << __FUNCTION__;
return;
}
QString url = map.value(QSL("url")).toString();
const QString url = map.value(QSL("url")).toString();
mApp->history()->deleteHistoryEntry(url);
}
@ -94,8 +94,8 @@ void QmlHistory::deleteRange(const QVariantMap &map)
qWarning() << "Error:" << "wrong arguments passed to" << __FUNCTION__;
return;
}
double startTime = map.value(QSL("startTime")).toDouble();
double endTime = map.value(QSL("endTime")).toDouble();
const double startTime = map.value(QSL("startTime")).toDouble();
const double endTime = map.value(QSL("endTime")).toDouble();
mApp->history()->deleteRange(startTime, endTime);
}

View File

@ -24,7 +24,7 @@ class QmlHistory : public QObject
{
Q_OBJECT
public:
explicit QmlHistory(QObject *parent = 0);
explicit QmlHistory(QObject *parent = nullptr);
Q_INVOKABLE QList<QObject*> search(const QVariantMap &map);
Q_INVOKABLE int getVisits(const QVariantMap &map);
Q_INVOKABLE void addUrl(const QVariantMap &map);

View File

@ -71,9 +71,7 @@ QmlHistoryItemData::QmlHistoryItemData()
QmlHistoryItemData::~QmlHistoryItemData()
{
for (QmlHistoryItem *item : m_items.values()) {
item->deleteLater();
}
qDeleteAll(m_items);
}
QmlHistoryItem *QmlHistoryItemData::get(HistoryEntry *entry)

View File

@ -29,7 +29,7 @@ class QmlHistoryItem : public QObject
Q_PROPERTY(int visitCount READ visitCount CONSTANT)
Q_PROPERTY(QDateTime lastVisitTime READ lastVisitTime CONSTANT)
public:
explicit QmlHistoryItem(HistoryEntry *entry = 0, QObject *parent = 0);
explicit QmlHistoryItem(HistoryEntry *entry = nullptr, QObject *parent = nullptr);
int id() const;
QString url() const;
QString title() const;

View File

@ -23,6 +23,6 @@ class QmlNotifications : public QObject
{
Q_OBJECT
public:
explicit QmlNotifications(QObject *parent = 0);
explicit QmlNotifications(QObject *parent = nullptr);
Q_INVOKABLE void create(const QVariantMap &map);
};

View File

@ -21,6 +21,8 @@
#include <QWebEngineHistory>
#include <QQmlEngine>
Q_GLOBAL_STATIC(QmlWindowData, windowData)
QmlTab::QmlTab(WebTab *webTab, QObject *parent)
: QObject(parent)
, m_webTab(webTab)
@ -154,7 +156,7 @@ QmlWindow *QmlTab::browserWindow() const
return nullptr;
}
return new QmlWindow(m_webTab->browserWindow());
return windowData->get(m_webTab->browserWindow());
}
bool QmlTab::loading() const
@ -264,7 +266,7 @@ void QmlTab::load(const QVariantMap &map)
return;
}
QString url = map.value(QSL("url")).toString();
const QString url = map.value(QSL("url")).toString();
LoadRequest req;
req.setUrl(QUrl::fromEncoded(url.toUtf8()));
m_webTab->load(req);
@ -384,9 +386,7 @@ QmlTabData::QmlTabData()
QmlTabData::~QmlTabData()
{
for (QmlTab *tab : m_tabs.values()) {
tab->deleteLater();
}
qDeleteAll(m_tabs);
}
QmlTab *QmlTabData::get(WebTab *webTab)

View File

@ -40,7 +40,7 @@ class QmlTab : public QObject
Q_PROPERTY(bool canGoBack READ canGoBack CONSTANT)
Q_PROPERTY(bool canGoForward READ canGoForward CONSTANT)
public:
explicit QmlTab(WebTab *webTab = 0, QObject *parent = 0);
explicit QmlTab(WebTab *webTab = nullptr, QObject *parent = nullptr);
QString url() const;
QString title() const;
int zoomLevel() const;

View File

@ -38,7 +38,7 @@ bool QmlTabs::setCurrentIndex(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -79,8 +79,8 @@ bool QmlTabs::moveTab(const QVariantMap &map)
return false;
}
int from = map.value(QSL("from")).toInt();
int to = map.value(QSL("to")).toInt();
const int from = map.value(QSL("from")).toInt();
const int to = map.value(QSL("to")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -97,7 +97,7 @@ bool QmlTabs::pinTab(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -121,7 +121,7 @@ bool QmlTabs::unpinTab(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -145,7 +145,7 @@ bool QmlTabs::detachTab(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -162,7 +162,7 @@ bool QmlTabs::duplicate(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -179,7 +179,7 @@ bool QmlTabs::closeTab(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -196,7 +196,7 @@ bool QmlTabs::reloadTab(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -213,7 +213,7 @@ bool QmlTabs::stopTab(const QVariantMap &map)
return false;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -230,7 +230,7 @@ QmlTab *QmlTabs::get(const QVariantMap &map) const
return nullptr;
}
int index = map.value(QSL("index")).toInt();
const int index = map.value(QSL("index")).toInt();
const auto window = getWindow(map);
if (!window) {
@ -265,11 +265,11 @@ QList<QObject*> QmlTabs::getAll(const QVariantMap &map) const
return QList<QObject*>();
}
bool withPinned = map.value(QSL("withPinned")).toBool();
const bool withPinned = map.value(QSL("withPinned")).toBool();
const auto tabList = window->tabWidget()->allTabs(withPinned);
QList<QObject*> list;
for (const auto tab : tabList) {
for (auto tab : tabList) {
list.append(tabData->get(tab));
}
@ -278,9 +278,9 @@ QList<QObject*> QmlTabs::getAll(const QVariantMap &map) const
QList<QObject*> QmlTabs::search(const QVariantMap &map)
{
QString title = map.value(QSL("title")).toString();
QString url = map.value(QSL("url")).toString();
bool withPinned = map.value(QSL("withPinned")).toBool();
const QString title = map.value(QSL("title")).toString();
const QString url = map.value(QSL("url")).toString();
const bool withPinned = map.value(QSL("withPinned")).toBool();
QList<QObject*> list;
foreach (BrowserWindow *window, mApp->windows()) {
foreach (WebTab *webTab, window->tabWidget()->allTabs(withPinned)) {
@ -295,7 +295,7 @@ QList<QObject*> QmlTabs::search(const QVariantMap &map)
bool QmlTabs::addTab(const QVariantMap &map)
{
QString urlString = map.value(QSL("url")).toString();
const QString urlString = map.value(QSL("url")).toString();
const auto window = getWindow(map);
if (!window) {
qDebug() << "Unable to add tab:" << "window not found";
@ -303,13 +303,13 @@ bool QmlTabs::addTab(const QVariantMap &map)
}
LoadRequest req;
req.setUrl(QUrl::fromEncoded(urlString.toUtf8()));
int ret = window->tabWidget()->addView(req);
const int ret = window->tabWidget()->addView(req);
return ret != -1 ? true : false;
}
BrowserWindow *QmlTabs::getWindow(const QVariantMap &map) const
{
int windowId = map.value(QSL("windowId"), -1).toInt();
const int windowId = map.value(QSL("windowId"), -1).toInt();
return getWindow(windowId);
}
@ -331,7 +331,7 @@ BrowserWindow *QmlTabs::getWindow(int windowId) const
void QmlTabs::windowCreated(BrowserWindow *window)
{
int windowId = mApp->windowIdHash().value(window);
const int windowId = mApp->windowIdHash().value(window);
connect(window->tabWidget(), &TabWidget::changed, this, [this, windowId]{
emit changed(windowId);

View File

@ -25,7 +25,7 @@ class QmlTabs : public QObject
{
Q_OBJECT
public:
explicit QmlTabs(QObject *parent = 0);
explicit QmlTabs(QObject *parent = nullptr);
Q_INVOKABLE bool setCurrentIndex(const QVariantMap &map);
Q_INVOKABLE bool nextTab(int windowId = -1);
Q_INVOKABLE bool previousTab(int windowId = -1);

View File

@ -18,7 +18,7 @@
#include "qmlmostvisitedurl.h"
#include <QQmlEngine>
QmlMostVisitedUrl::QmlMostVisitedUrl(QString title, QString url, QObject *parent)
QmlMostVisitedUrl::QmlMostVisitedUrl(const QString &title, const QString &url, QObject *parent)
: QObject(parent)
, m_title(title)
, m_url(url)
@ -42,17 +42,15 @@ QmlMostVisitedUrlData::QmlMostVisitedUrlData()
QmlMostVisitedUrlData::~QmlMostVisitedUrlData()
{
for (QmlMostVisitedUrl *url : m_urls.values()) {
url->deleteLater();
}
qDeleteAll(m_urls);
}
QmlMostVisitedUrl *QmlMostVisitedUrlData::get(QString title, QString url, QObject *parent)
QmlMostVisitedUrl *QmlMostVisitedUrlData::get(const QString &title, const QString &url)
{
QmlMostVisitedUrl *visitedUrl = m_urls.value(QPair<QString, QString>(title, url));
QmlMostVisitedUrl *visitedUrl = m_urls.value({title, url});
if (!visitedUrl) {
visitedUrl = new QmlMostVisitedUrl(title, url, parent);
m_urls.insert(QPair<QString, QString>(title, url), visitedUrl);
visitedUrl = new QmlMostVisitedUrl(title, url);
m_urls.insert({title, url}, visitedUrl);
}
return visitedUrl;
}

View File

@ -27,7 +27,7 @@ class QmlMostVisitedUrl : public QObject
Q_PROPERTY(QString title READ title CONSTANT)
Q_PROPERTY(QString url READ url CONSTANT)
public:
explicit QmlMostVisitedUrl(QString title = 0, QString url = 0, QObject *parent = 0);
explicit QmlMostVisitedUrl(const QString &title = QString(), const QString &url = QString(), QObject *parent = nullptr);
QString title() const;
QString url() const;
private:
@ -40,7 +40,7 @@ class QmlMostVisitedUrlData
public:
explicit QmlMostVisitedUrlData();
~QmlMostVisitedUrlData();
QmlMostVisitedUrl *get(QString title = 0, QString url = 0, QObject *parent = 0);
QmlMostVisitedUrl *get(const QString &title = QString(), const QString &url = QString());
private:
QHash<QPair<QString, QString>, QmlMostVisitedUrl*> m_urls;
};

View File

@ -24,6 +24,6 @@ class QmlTopSites : public QObject
{
Q_OBJECT
public:
explicit QmlTopSites(QObject *parent = 0);
explicit QmlTopSites(QObject *parent = nullptr);
Q_INVOKABLE QList<QObject*> get() const;
};

View File

@ -134,9 +134,7 @@ QmlWindowData::QmlWindowData()
QmlWindowData::~QmlWindowData()
{
for (QmlWindow *window : m_windows.values()) {
window->deleteLater();
}
qDeleteAll(m_windows);
}
QmlWindow *QmlWindowData::get(BrowserWindow *window)

View File

@ -35,7 +35,7 @@ class QmlWindow : public QObject
Q_PROPERTY(int height READ height CONSTANT)
Q_PROPERTY(int width READ width CONSTANT)
public:
QmlWindow(BrowserWindow *window = 0, QObject *parent = 0);
QmlWindow(BrowserWindow *window = nullptr, QObject *parent = nullptr);
int id() const;
bool incognito() const;
QString title() const;

View File

@ -42,7 +42,7 @@ QmlWindow *QmlWindows::get(const QVariantMap &map) const
return nullptr;
}
int id = map.value(QSL("id")).toInt();
const int id = map.value(QSL("id")).toInt();
return windowData->get(getBrowserWindow(id));
}
@ -62,8 +62,8 @@ QList<QObject*> QmlWindows::getAll() const
QmlWindow *QmlWindows::create(const QVariantMap &map) const
{
QUrl url = QUrl::fromEncoded(map.value(QSL("url")).toString().toUtf8());
Qz::BrowserWindowType type = Qz::BrowserWindowType(map.value(QSL("type"), QmlWindowType::NewWindow).toInt());
const QUrl url = QUrl::fromEncoded(map.value(QSL("url")).toString().toUtf8());
const Qz::BrowserWindowType type = Qz::BrowserWindowType(map.value(QSL("type"), QmlWindowType::NewWindow).toInt());
BrowserWindow *window = mApp->createWindow(type, url);
return windowData->get(window);
}

View File

@ -24,7 +24,7 @@ class QmlWindows : public QObject
{
Q_OBJECT
public:
QmlWindows(QObject *parent = 0);
QmlWindows(QObject *parent = nullptr);
Q_INVOKABLE QmlWindow *get(const QVariantMap &map) const;
Q_INVOKABLE QmlWindow *getCurrent() const;
Q_INVOKABLE QList<QObject*> getAll() const;

View File

@ -32,5 +32,5 @@ public:
};
Q_ENUMS(WindowState)
QmlWindowState(QObject *parent = 0);
QmlWindowState(QObject *parent = nullptr);
};

View File

@ -32,5 +32,5 @@ public:
};
Q_ENUMS(WindowType)
QmlWindowType(QObject *parent = 0);
QmlWindowType(QObject *parent = nullptr);
};