From c4c8094e32ad78dee558a80584470172f48c45b1 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 1 Apr 2019 22:15:19 +0200 Subject: get rid of some foreach and Q_FOREACH constructs See https://www.kdab.com/goodbye-q_foreach/ This is reduced to the places where the container is const or can be made const without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7) and std::as_const (C++17) are not available in all supported setups. Also do some minor cleanups along the way. Signed-off-by: Rolf Eike Beer --- qt-models/divelistmodel.cpp | 4 ++-- qt-models/divelistmodel.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 6edb69705..4d66c5406 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -144,12 +144,12 @@ DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent) m_instance = this; } -void DiveListModel::addDive(QListlistOfDives) +void DiveListModel::addDive(const QList &listOfDives) { if (listOfDives.isEmpty()) return; beginInsertRows(QModelIndex(), rowCount(), rowCount() + listOfDives.count() - 1); - foreach (dive *d, listOfDives) { + for (dive *d: listOfDives) { m_dives.append(new DiveObjectHelper(d)); } endInsertRows(); diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 50b45caa9..37d3513bf 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -44,7 +44,7 @@ public: static DiveListModel *instance(); DiveListModel(QObject *parent = 0); - void addDive(QList listOfDives); + void addDive(const QList &listOfDives); void addAllDives(); void insertDive(int i, DiveObjectHelper *newDive); void removeDive(int i); -- cgit v1.2.3-70-g09d2