summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets
diff options
context:
space:
mode:
authorGravatar Rolf Eike Beer <eike@sf-mail.de>2019-04-01 22:15:19 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 12:59:17 +0300
commitc4c8094e32ad78dee558a80584470172f48c45b1 (patch)
tree4fede2acf0f1a3cee2182d96b1b3efa33e4fd8ff /desktop-widgets/tab-widgets
parent2b9ca488fd18dc9d65d42dc5900e120a07e5b3f6 (diff)
downloadsubsurface-c4c8094e32ad78dee558a80584470172f48c45b1.tar.gz
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 <eike@sf-mail.de>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r--desktop-widgets/tab-widgets/TabDiveStatistics.cpp6
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp9
2 files changed, 7 insertions, 8 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp
index 1b3fe9522..dacb01721 100644
--- a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp
@@ -21,9 +21,9 @@ TabDiveStatistics::TabDiveStatistics(QWidget *parent) : TabBase(parent), ui(new
ui->timeLimits->overrideMinToolTipText(tr("Shortest dive"));
ui->timeLimits->overrideAvgToolTipText(tr("Average length of all selected dives"));
- Q_FOREACH (QObject *obj, children()) {
- if (QLabel *label = qobject_cast<QLabel *>(obj))
- label->setAlignment(Qt::AlignHCenter);
+ const auto l = findChildren<QLabel *>(QString(), Qt::FindDirectChildrenOnly);
+ for (QLabel *label: l) {
+ label->setAlignment(Qt::AlignHCenter);
}
}
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 98b8904c2..c934cdb16 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -1271,14 +1271,13 @@ void MainTab::saveTaggedStrings(const QVector<dive *> &selectedDives)
int MainTab::diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList)
{
- QStringList displayedList, currentList;
- currentList = currentString.split(',', QString::SkipEmptyParts);
- displayedList = displayedString.split(',', QString::SkipEmptyParts);
- Q_FOREACH ( const QString tag, currentList) {
+ const QStringList currentList = currentString.split(',', QString::SkipEmptyParts);
+ const QStringList displayedList = displayedString.split(',', QString::SkipEmptyParts);
+ for (const QString &tag: currentList) {
if (!displayedList.contains(tag, Qt::CaseInsensitive))
removedList << tag.trimmed();
}
- Q_FOREACH (const QString tag, displayedList) {
+ for (const QString &tag: displayedList) {
if (!currentList.contains(tag, Qt::CaseInsensitive))
addedList << tag.trimmed();
}