From 6c1454765683adaf3cb100b9837ca8faaa1b6051 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Mon, 30 Dec 2019 18:32:20 +0100 Subject: [PATCH] history: port foreach -> range-based for Signed-off-by: Juraj Oravec --- src/lib/history/history.cpp | 2 +- src/lib/history/historymenu.cpp | 2 +- src/lib/history/historymodel.cpp | 4 ++-- src/lib/history/historytreeview.cpp | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/history/history.cpp b/src/lib/history/history.cpp index 82fbaeb15..1bc528d0c 100644 --- a/src/lib/history/history.cpp +++ b/src/lib/history/history.cpp @@ -148,7 +148,7 @@ void History::deleteHistoryEntry(const QList &list) QSqlDatabase db = SqlDatabase::instance()->database(); db.transaction(); - foreach (int index, list) { + for (int index : list) { QSqlQuery query(SqlDatabase::instance()->database()); query.prepare("SELECT count, date, url, title FROM history WHERE id=?"); query.addBindValue(index); diff --git a/src/lib/history/historymenu.cpp b/src/lib/history/historymenu.cpp index 5ad585750..d6dabc7bd 100644 --- a/src/lib/history/historymenu.cpp +++ b/src/lib/history/historymenu.cpp @@ -121,7 +121,7 @@ void HistoryMenu::aboutToShowMostVisited() const QVector mostVisited = mApp->history()->mostVisited(10); - foreach (const HistoryEntry &entry, mostVisited) { + for (const HistoryEntry &entry : mostVisited) { Action* act = new Action(QzTools::truncatedText(entry.title, 40)); act->setData(entry.url); act->setIcon(IconProvider::iconForUrl(entry.url)); diff --git a/src/lib/history/historymodel.cpp b/src/lib/history/historymodel.cpp index ad01535d1..45b87e83c 100644 --- a/src/lib/history/historymodel.cpp +++ b/src/lib/history/historymodel.cpp @@ -236,7 +236,7 @@ HistoryItem* HistoryModel::itemFromIndex(const QModelIndex &index) const void HistoryModel::removeTopLevelIndexes(const QList &indexes) { - foreach (const QPersistentModelIndex &index, indexes) { + for (const QPersistentModelIndex &index : indexes) { if (index.parent().isValid()) { continue; } @@ -321,7 +321,7 @@ void HistoryModel::fetchMore(const QModelIndex &parent) beginInsertRows(parent, 0, list.size() - 1); - foreach (const HistoryEntry &entry, list) { + for (const HistoryEntry &entry : qAsConst(list)) { HistoryItem* newItem = new HistoryItem(parentItem); newItem->historyEntry = entry; } diff --git a/src/lib/history/historytreeview.cpp b/src/lib/history/historytreeview.cpp index 4b99e5b63..5e94e8887 100644 --- a/src/lib/history/historytreeview.cpp +++ b/src/lib/history/historytreeview.cpp @@ -105,7 +105,8 @@ void HistoryTreeView::removeSelectedItems() QList topLevelIndexes; - foreach (const QModelIndex &index, selectedIndexes()) { + const auto indexes = selectedIndexes(); + for (const QModelIndex &index : indexes) { if (index.column() > 0) { continue; }