diff --git a/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp b/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp index 66a154f52..9f11643cd 100644 --- a/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp +++ b/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp @@ -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 QmlBookmarks::search(const QVariantMap &map) const return QList(); } - 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 items; if (urlString.isEmpty()) { items = mApp->bookmarks()->searchBookmarks(query); diff --git a/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.h b/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.h index 034c8930e..88b07d810 100644 --- a/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.h +++ b/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.h @@ -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; diff --git a/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp b/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp index 21b7dbf8e..f3d1cba38 100644 --- a/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp +++ b/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp @@ -114,9 +114,9 @@ bool QmlBookmarkTreeNode::unmodifiable() const QList QmlBookmarkTreeNode::children() const { - auto items = m_item->children(); + const auto items = m_item->children(); QList 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) diff --git a/src/lib/plugins/qml/api/clipboard/qmlclipboard.h b/src/lib/plugins/qml/api/clipboard/qmlclipboard.h index 21c23e913..64978cf43 100644 --- a/src/lib/plugins/qml/api/clipboard/qmlclipboard.h +++ b/src/lib/plugins/qml/api/clipboard/qmlclipboard.h @@ -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); }; diff --git a/src/lib/plugins/qml/api/cookies/qmlcookie.cpp b/src/lib/plugins/qml/api/cookies/qmlcookie.cpp index 7d12535d3..608f65a58 100644 --- a/src/lib/plugins/qml/api/cookies/qmlcookie.cpp +++ b/src/lib/plugins/qml/api/cookies/qmlcookie.cpp @@ -88,9 +88,7 @@ QmlCookieData::QmlCookieData() QmlCookieData::~QmlCookieData() { - for (QmlCookie *qmlCookie : m_cookies.values()) { - qmlCookie->deleteLater(); - } + qDeleteAll(m_cookies); } QmlCookie *QmlCookieData::get(QNetworkCookie *cookie) diff --git a/src/lib/plugins/qml/api/cookies/qmlcookie.h b/src/lib/plugins/qml/api/cookies/qmlcookie.h index 4e454c246..581c80b5c 100644 --- a/src/lib/plugins/qml/api/cookies/qmlcookie.h +++ b/src/lib/plugins/qml/api/cookies/qmlcookie.h @@ -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; diff --git a/src/lib/plugins/qml/api/cookies/qmlcookies.cpp b/src/lib/plugins/qml/api/cookies/qmlcookies.cpp index 3bb0521fb..3fd1b4a08 100644 --- a/src/lib/plugins/qml/api/cookies/qmlcookies.cpp +++ b/src/lib/plugins/qml/api/cookies/qmlcookies.cpp @@ -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 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 QmlCookies::getAll(const QVariantMap &map) { QList 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 cookies = mApp->cookieJar()->getAllCookies(); for (QNetworkCookie cookie : cookies) { if ((!map.contains(QSL("name")) || cookie.name() == name) @@ -96,13 +96,13 @@ QList 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); diff --git a/src/lib/plugins/qml/api/cookies/qmlcookies.h b/src/lib/plugins/qml/api/cookies/qmlcookies.h index 96ac173ef..2dc2b1b0f 100644 --- a/src/lib/plugins/qml/api/cookies/qmlcookies.h +++ b/src/lib/plugins/qml/api/cookies/qmlcookies.h @@ -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 getAll(const QVariantMap &map); Q_INVOKABLE void set(const QVariantMap &map); diff --git a/src/lib/plugins/qml/api/history/qmlhistory.cpp b/src/lib/plugins/qml/api/history/qmlhistory.cpp index 49bfd9872..b82ed1278 100644 --- a/src/lib/plugins/qml/api/history/qmlhistory.cpp +++ b/src/lib/plugins/qml/api/history/qmlhistory.cpp @@ -43,7 +43,7 @@ QList 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 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); } diff --git a/src/lib/plugins/qml/api/history/qmlhistory.h b/src/lib/plugins/qml/api/history/qmlhistory.h index 57107a0d6..766ead0d5 100644 --- a/src/lib/plugins/qml/api/history/qmlhistory.h +++ b/src/lib/plugins/qml/api/history/qmlhistory.h @@ -24,7 +24,7 @@ class QmlHistory : public QObject { Q_OBJECT public: - explicit QmlHistory(QObject *parent = 0); + explicit QmlHistory(QObject *parent = nullptr); Q_INVOKABLE QList search(const QVariantMap &map); Q_INVOKABLE int getVisits(const QVariantMap &map); Q_INVOKABLE void addUrl(const QVariantMap &map); diff --git a/src/lib/plugins/qml/api/history/qmlhistoryitem.cpp b/src/lib/plugins/qml/api/history/qmlhistoryitem.cpp index d92ba9ff5..08b6bc137 100644 --- a/src/lib/plugins/qml/api/history/qmlhistoryitem.cpp +++ b/src/lib/plugins/qml/api/history/qmlhistoryitem.cpp @@ -71,9 +71,7 @@ QmlHistoryItemData::QmlHistoryItemData() QmlHistoryItemData::~QmlHistoryItemData() { - for (QmlHistoryItem *item : m_items.values()) { - item->deleteLater(); - } + qDeleteAll(m_items); } QmlHistoryItem *QmlHistoryItemData::get(HistoryEntry *entry) diff --git a/src/lib/plugins/qml/api/history/qmlhistoryitem.h b/src/lib/plugins/qml/api/history/qmlhistoryitem.h index cbca677f9..0f3e8235a 100644 --- a/src/lib/plugins/qml/api/history/qmlhistoryitem.h +++ b/src/lib/plugins/qml/api/history/qmlhistoryitem.h @@ -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; diff --git a/src/lib/plugins/qml/api/notifications/qmlnotifications.h b/src/lib/plugins/qml/api/notifications/qmlnotifications.h index 823cbd86c..48bdde52a 100644 --- a/src/lib/plugins/qml/api/notifications/qmlnotifications.h +++ b/src/lib/plugins/qml/api/notifications/qmlnotifications.h @@ -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); }; diff --git a/src/lib/plugins/qml/api/tabs/qmltab.cpp b/src/lib/plugins/qml/api/tabs/qmltab.cpp index 66af2e61d..a4f57b128 100644 --- a/src/lib/plugins/qml/api/tabs/qmltab.cpp +++ b/src/lib/plugins/qml/api/tabs/qmltab.cpp @@ -21,6 +21,8 @@ #include #include +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) diff --git a/src/lib/plugins/qml/api/tabs/qmltab.h b/src/lib/plugins/qml/api/tabs/qmltab.h index c11d9ddb5..18011bb25 100644 --- a/src/lib/plugins/qml/api/tabs/qmltab.h +++ b/src/lib/plugins/qml/api/tabs/qmltab.h @@ -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; diff --git a/src/lib/plugins/qml/api/tabs/qmltabs.cpp b/src/lib/plugins/qml/api/tabs/qmltabs.cpp index 3e0d06717..2c7feb69d 100644 --- a/src/lib/plugins/qml/api/tabs/qmltabs.cpp +++ b/src/lib/plugins/qml/api/tabs/qmltabs.cpp @@ -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 QmlTabs::getAll(const QVariantMap &map) const return QList(); } - bool withPinned = map.value(QSL("withPinned")).toBool(); + const bool withPinned = map.value(QSL("withPinned")).toBool(); const auto tabList = window->tabWidget()->allTabs(withPinned); QList list; - for (const auto tab : tabList) { + for (auto tab : tabList) { list.append(tabData->get(tab)); } @@ -278,9 +278,9 @@ QList QmlTabs::getAll(const QVariantMap &map) const QList 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 list; foreach (BrowserWindow *window, mApp->windows()) { foreach (WebTab *webTab, window->tabWidget()->allTabs(withPinned)) { @@ -295,7 +295,7 @@ QList 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); diff --git a/src/lib/plugins/qml/api/tabs/qmltabs.h b/src/lib/plugins/qml/api/tabs/qmltabs.h index def6a1678..87b9a48dc 100644 --- a/src/lib/plugins/qml/api/tabs/qmltabs.h +++ b/src/lib/plugins/qml/api/tabs/qmltabs.h @@ -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); diff --git a/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.cpp b/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.cpp index 5963666b1..966bd1dce 100644 --- a/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.cpp +++ b/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.cpp @@ -18,7 +18,7 @@ #include "qmlmostvisitedurl.h" #include -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(title, url)); + QmlMostVisitedUrl *visitedUrl = m_urls.value({title, url}); if (!visitedUrl) { - visitedUrl = new QmlMostVisitedUrl(title, url, parent); - m_urls.insert(QPair(title, url), visitedUrl); + visitedUrl = new QmlMostVisitedUrl(title, url); + m_urls.insert({title, url}, visitedUrl); } return visitedUrl; } diff --git a/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.h b/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.h index 75148e74c..e3fb3f155 100644 --- a/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.h +++ b/src/lib/plugins/qml/api/topsites/qmlmostvisitedurl.h @@ -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, QmlMostVisitedUrl*> m_urls; }; diff --git a/src/lib/plugins/qml/api/topsites/qmltopsites.h b/src/lib/plugins/qml/api/topsites/qmltopsites.h index d99519c96..d3d699c1b 100644 --- a/src/lib/plugins/qml/api/topsites/qmltopsites.h +++ b/src/lib/plugins/qml/api/topsites/qmltopsites.h @@ -24,6 +24,6 @@ class QmlTopSites : public QObject { Q_OBJECT public: - explicit QmlTopSites(QObject *parent = 0); + explicit QmlTopSites(QObject *parent = nullptr); Q_INVOKABLE QList get() const; }; diff --git a/src/lib/plugins/qml/api/windows/qmlwindow.cpp b/src/lib/plugins/qml/api/windows/qmlwindow.cpp index e35fe769c..81689928a 100644 --- a/src/lib/plugins/qml/api/windows/qmlwindow.cpp +++ b/src/lib/plugins/qml/api/windows/qmlwindow.cpp @@ -134,9 +134,7 @@ QmlWindowData::QmlWindowData() QmlWindowData::~QmlWindowData() { - for (QmlWindow *window : m_windows.values()) { - window->deleteLater(); - } + qDeleteAll(m_windows); } QmlWindow *QmlWindowData::get(BrowserWindow *window) diff --git a/src/lib/plugins/qml/api/windows/qmlwindow.h b/src/lib/plugins/qml/api/windows/qmlwindow.h index 6c42b92d9..066fddee6 100644 --- a/src/lib/plugins/qml/api/windows/qmlwindow.h +++ b/src/lib/plugins/qml/api/windows/qmlwindow.h @@ -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; diff --git a/src/lib/plugins/qml/api/windows/qmlwindows.cpp b/src/lib/plugins/qml/api/windows/qmlwindows.cpp index 6b79cfd87..88ac6d94c 100644 --- a/src/lib/plugins/qml/api/windows/qmlwindows.cpp +++ b/src/lib/plugins/qml/api/windows/qmlwindows.cpp @@ -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 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); } diff --git a/src/lib/plugins/qml/api/windows/qmlwindows.h b/src/lib/plugins/qml/api/windows/qmlwindows.h index be0b8d218..b1de338f4 100644 --- a/src/lib/plugins/qml/api/windows/qmlwindows.h +++ b/src/lib/plugins/qml/api/windows/qmlwindows.h @@ -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 getAll() const; diff --git a/src/lib/plugins/qml/api/windows/qmlwindowstate.h b/src/lib/plugins/qml/api/windows/qmlwindowstate.h index cd41e14e3..8f675f197 100644 --- a/src/lib/plugins/qml/api/windows/qmlwindowstate.h +++ b/src/lib/plugins/qml/api/windows/qmlwindowstate.h @@ -32,5 +32,5 @@ public: }; Q_ENUMS(WindowState) - QmlWindowState(QObject *parent = 0); + QmlWindowState(QObject *parent = nullptr); }; diff --git a/src/lib/plugins/qml/api/windows/qmlwindowtype.h b/src/lib/plugins/qml/api/windows/qmlwindowtype.h index c3c6338c0..12bf128ea 100644 --- a/src/lib/plugins/qml/api/windows/qmlwindowtype.h +++ b/src/lib/plugins/qml/api/windows/qmlwindowtype.h @@ -32,5 +32,5 @@ public: }; Q_ENUMS(WindowType) - QmlWindowType(QObject *parent = 0); + QmlWindowType(QObject *parent = nullptr); };