From da73eb5c77077be5bcfcfa12ba06cca55726b522 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Mon, 30 Dec 2019 20:35:42 +0100 Subject: [PATCH] sidebar: port foreach -> range-based for Signed-off-by: Juraj Oravec --- src/lib/sidebar/bookmarkssidebar.cpp | 8 ++++---- src/lib/sidebar/sidebar.cpp | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/sidebar/bookmarkssidebar.cpp b/src/lib/sidebar/bookmarkssidebar.cpp index 116c3e5ea..a15c66443 100644 --- a/src/lib/sidebar/bookmarkssidebar.cpp +++ b/src/lib/sidebar/bookmarkssidebar.cpp @@ -88,9 +88,9 @@ void BookmarksSidebar::openBookmarkInNewPrivateWindow(BookmarkItem* item) void BookmarksSidebar::deleteBookmarks() { - QList items = ui->tree->selectedBookmarks(); + const QList items = ui->tree->selectedBookmarks(); - foreach (BookmarkItem* item, items) { + for (BookmarkItem* item : items) { if (m_bookmarks->canBeModified(item)) { m_bookmarks->removeBookmark(item); } @@ -113,9 +113,9 @@ void BookmarksSidebar::createContextMenu(const QPoint &pos) connect(actDelete, &QAction::triggered, this, &BookmarksSidebar::deleteBookmarks); bool canBeDeleted = false; - QList items = ui->tree->selectedBookmarks(); + const QList items = ui->tree->selectedBookmarks(); - foreach (BookmarkItem* item, items) { + for (BookmarkItem* item : items) { if (m_bookmarks->canBeModified(item)) { canBeDeleted = true; break; diff --git a/src/lib/sidebar/sidebar.cpp b/src/lib/sidebar/sidebar.cpp index 5b2fa1850..481fbc19d 100644 --- a/src/lib/sidebar/sidebar.cpp +++ b/src/lib/sidebar/sidebar.cpp @@ -118,7 +118,7 @@ void SideBarManager::createMenu(QMenu* menu) act->setChecked(m_activeBar == QL1S("History")); group->addAction(act); - foreach (const QPointer &sidebar, s_sidebars) { + for (const QPointer &sidebar : qAsConst(s_sidebars)) { if (sidebar) { QAction* act = sidebar.data()->createMenuAction(); act->setData(s_sidebars.key(sidebar)); @@ -146,7 +146,8 @@ void SideBarManager::removeSidebar(SideBarInterface *interface) s_sidebars.remove(id); - foreach (BrowserWindow* window, mApp->windows()) { + const auto windows = mApp->windows(); + for (BrowserWindow* window : windows) { window->sideBarManager()->sideBarRemoved(id); } }