From de0cb89ddacf6cc1509a99089b098ad7f6ddd908 Mon Sep 17 00:00:00 2001 From: Anmol Gautam Date: Sat, 4 Aug 2018 09:34:54 +0530 Subject: [PATCH] fixed code --- src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp | 8 ++++---- src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp | 2 +- src/lib/plugins/qml/api/fileutils/qmlfileutils.cpp | 2 +- src/lib/plugins/qml/api/history/qmlhistory.cpp | 2 +- src/lib/plugins/qml/api/menus/qmlaction.cpp | 5 ++++- src/lib/plugins/qml/api/menus/qmlmenu.cpp | 4 +++- src/lib/plugins/qml/api/tabs/qmltabs.cpp | 2 +- src/lib/plugins/qml/api/userscript/qmluserscripts.cpp | 4 ++-- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp b/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp index 9663af14f..9d40775d9 100644 --- a/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp +++ b/src/lib/plugins/qml/api/bookmarks/qmlbookmarks.cpp @@ -65,7 +65,7 @@ BookmarkItem *QmlBookmarks::getBookmarkItem(QmlBookmarkTreeNode *treeNode) const items = bookmarks->searchBookmarks(QUrl::fromEncoded(treeNode->url().toUtf8())); } - for (auto item : items) { + for (const auto item : qAsConst(items)) { if (isTreeNodeEqualsItem(treeNode, item)) { return item; } @@ -242,7 +242,7 @@ QList QmlBookmarks::search(const QVariantMap &map) const items = mApp->bookmarks()->searchBookmarks(QUrl::fromEncoded(urlString.toUtf8())); } QList ret; - for (auto item : items) { + for (auto item : qAsConst(items)) { ret.append(bookmarkTreeNodeData->get(item)); } return ret; @@ -308,7 +308,7 @@ bool QmlBookmarks::update(QObject *object, const QVariantMap &changes) const QmlBookmarkTreeNode *QmlBookmarks::get(const QString &string) const { auto items = mApp->bookmarks()->searchBookmarks(QUrl(string)); - for (auto item : items) { + for (const auto item : qAsConst(items)) { if (item->urlString() == string) { return bookmarkTreeNodeData->get(item); } @@ -334,7 +334,7 @@ QList QmlBookmarks::getChildren(QObject *object) const } auto items = bookmarkItem->children(); - for (auto item : items) { + for (auto item : qAsConst(items)) { ret.append(bookmarkTreeNodeData->get(item)); } diff --git a/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp b/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp index f3d1cba38..1648ae79f 100644 --- a/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp +++ b/src/lib/plugins/qml/api/bookmarks/qmlbookmarktreenode.cpp @@ -116,7 +116,7 @@ QList QmlBookmarkTreeNode::children() const { const auto items = m_item->children(); QList ret; - for (const auto &item : items) { + for (const auto &item : qAsConst(items)) { ret.append(bookmarkTreeNodeData->get(item)); } return ret; diff --git a/src/lib/plugins/qml/api/fileutils/qmlfileutils.cpp b/src/lib/plugins/qml/api/fileutils/qmlfileutils.cpp index 02adfcfae..8e6b01620 100644 --- a/src/lib/plugins/qml/api/fileutils/qmlfileutils.cpp +++ b/src/lib/plugins/qml/api/fileutils/qmlfileutils.cpp @@ -27,7 +27,7 @@ QmlFileUtils::QmlFileUtils(QString filePath, QObject *parent) // Get the plugin root directory - of the form // some-path-in-plugin-paths/qml/plugin-directory const QStringList dirs = DataPaths::allPaths(DataPaths::Plugins); - for (QString path : dirs) { + for (QString path : qAsConst(dirs)) { path.append(QSL("/qml/")); if (filePath.contains(path)) { m_path = path; diff --git a/src/lib/plugins/qml/api/history/qmlhistory.cpp b/src/lib/plugins/qml/api/history/qmlhistory.cpp index 0c83b246f..539417d7e 100644 --- a/src/lib/plugins/qml/api/history/qmlhistory.cpp +++ b/src/lib/plugins/qml/api/history/qmlhistory.cpp @@ -46,7 +46,7 @@ QList QmlHistory::search(const QString &text) QList list; QList result = mApp->history()->searchHistoryEntry(text); - foreach(auto entry, result) { + for (const auto entry : qAsConst(result)) { auto item = historyItemData->get(entry); list.append(item); } diff --git a/src/lib/plugins/qml/api/menus/qmlaction.cpp b/src/lib/plugins/qml/api/menus/qmlaction.cpp index c6e709db6..2895a934f 100644 --- a/src/lib/plugins/qml/api/menus/qmlaction.cpp +++ b/src/lib/plugins/qml/api/menus/qmlaction.cpp @@ -32,7 +32,10 @@ void QmlAction::setProperties(const QVariantMap &map) return; } - for (const QString &key : map.keys()) { + QMapIterator it(map); + while (it.hasNext()) { + it.next(); + const QString key = it.key(); if (key == QSL("icon")) { QString iconPath = map.value(key).toString(); QIcon icon; diff --git a/src/lib/plugins/qml/api/menus/qmlmenu.cpp b/src/lib/plugins/qml/api/menus/qmlmenu.cpp index 85ba04fb4..35a68b1be 100644 --- a/src/lib/plugins/qml/api/menus/qmlmenu.cpp +++ b/src/lib/plugins/qml/api/menus/qmlmenu.cpp @@ -64,7 +64,9 @@ QmlMenu *QmlMenu::addMenu(const QVariantMap &map) } QMenu *newMenu = new QMenu(); - for (const QString &key : map.keys()) { + QMapIterator it(map); + while (it.hasNext()) { + const QString key = it.key(); if (key == QSL("icon")) { QString iconPath = map.value(key).toString(); QIcon icon; diff --git a/src/lib/plugins/qml/api/tabs/qmltabs.cpp b/src/lib/plugins/qml/api/tabs/qmltabs.cpp index 74a0553b9..a423e8cfd 100644 --- a/src/lib/plugins/qml/api/tabs/qmltabs.cpp +++ b/src/lib/plugins/qml/api/tabs/qmltabs.cpp @@ -460,7 +460,7 @@ BrowserWindow *QmlTabs::getWindow(int windowId) const return mApp->getWindow(); } - for(BrowserWindow *window : mApp->windowIdHash().keys()) { + for (BrowserWindow *window : mApp->windowIdHash().keys()) { if (mApp->windowIdHash().value(window) == windowId) { return window; } diff --git a/src/lib/plugins/qml/api/userscript/qmluserscripts.cpp b/src/lib/plugins/qml/api/userscript/qmluserscripts.cpp index dacb07909..2842f8056 100644 --- a/src/lib/plugins/qml/api/userscript/qmluserscripts.cpp +++ b/src/lib/plugins/qml/api/userscript/qmluserscripts.cpp @@ -28,7 +28,7 @@ QmlUserScripts::QmlUserScripts(QObject *parent) QmlUserScripts::~QmlUserScripts() { // remove scripts added by the plugin - for (const QWebEngineScript &webEngineScript : m_webEngineScripts) { + for (const QWebEngineScript &webEngineScript : qAsConst(m_webEngineScripts)) { mApp->webProfile()->scripts()->remove(webEngineScript); } } @@ -51,7 +51,7 @@ bool QmlUserScripts::empty() const QList QmlUserScripts::toQObjectList(QList list) const { QList userScriptList; - for (const QWebEngineScript &script : list) { + for (const QWebEngineScript &script : qAsConst(list)) { QmlUserScript *userScript = new QmlUserScript(); userScript->setWebEngineScript(script); userScriptList.append(userScript);