diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-03 22:08:41 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-04 10:16:06 +0200 |
commit | 2372db24d1b5ed482b6c0be7af2e5f6aba75cd36 (patch) | |
tree | 4c522f6130f885eede56e749d738a35e1954c650 /src/charts | |
parent | 248fff483ae1597c62a93edf91841b84b363739b (diff) |
Eradicate Java-style iterators and mark the module free of them
... and of QLinkedList.
Unfortunately, the module contains more than 330 uses of Q_FOREACH,
even though, according to my sources, its use was banned in Qt
implementation from the get-go. So QT_NO_FOREACH is currently not an
option.
Java-style iterators are going to be deprecated, or at the very least
banned from use in Qt code. Ditto QLinkedList.
Change-Id: I505e3472b708fc18a3254dc742e46d14d095fcc1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/charts')
-rw-r--r-- | src/charts/barchart/abstractbarchartitem.cpp | 24 | ||||
-rw-r--r-- | src/charts/glwidget.cpp | 5 | ||||
-rw-r--r-- | src/charts/xychart/glxyseriesdata_p.h | 1 |
3 files changed, 10 insertions, 20 deletions
diff --git a/src/charts/barchart/abstractbarchartitem.cpp b/src/charts/barchart/abstractbarchartitem.cpp index 36bf81e9..56b48773 100644 --- a/src/charts/barchart/abstractbarchartitem.cpp +++ b/src/charts/barchart/abstractbarchartitem.cpp @@ -207,12 +207,9 @@ void AbstractBarChartItem::handleLayoutChanged() void AbstractBarChartItem::handleLabelsVisibleChanged(bool visible) { bool newVisible = visible && m_series->isVisible(); - QMapIterator<QBarSet *, QList<Bar *> > i(m_barMap); - while (i.hasNext()) { - i.next(); - const QList<Bar *> &bars = i.value(); - for (int j = 0; j < bars.size(); j++) { - QGraphicsTextItem *label = bars.at(j)->labelItem(); + for (const QList<Bar *> &bars : qAsConst(m_barMap)) { + for (Bar *bar : bars) { + QGraphicsTextItem *label = bar->labelItem(); if (label) label->setVisible(newVisible); } @@ -235,9 +232,7 @@ void AbstractBarChartItem::handleVisibleChanged() bool visible = m_series->isVisible(); handleLabelsVisibleChanged(m_series->isLabelsVisible()); - QMapIterator<QBarSet *, QList<Bar *> > i(m_barMap); - while (i.hasNext()) { - i.next(); + for (auto i = m_barMap.cbegin(), end = m_barMap.cend(); i != end; ++i) { const QList<Bar *> &bars = i.value(); for (int j = 0; j < bars.size(); j++) { Bar *bar = bars.at(j); @@ -505,17 +500,14 @@ void AbstractBarChartItem::createLabelItems() m_labelItemsMissing = false; - QMapIterator<QBarSet *, QList<Bar *> > i(m_barMap); - while (i.hasNext()) { - i.next(); - const QList<Bar *> &bars = i.value(); - for (int j = 0; j < bars.size(); j++) { - QGraphicsTextItem *label = bars.at(j)->labelItem(); + for (const QList<Bar *> &bars : qAsConst(m_barMap)) { + for (Bar *bar : bars) { + QGraphicsTextItem *label = bar->labelItem(); if (!label) { QGraphicsTextItem *newLabel = new QGraphicsTextItem(this); newLabel->setAcceptHoverEvents(false); newLabel->document()->setDocumentMargin(ChartPresenter::textMargin()); - bars.at(j)->setLabelItem(newLabel); + bar->setLabelItem(newLabel); } } } diff --git a/src/charts/glwidget.cpp b/src/charts/glwidget.cpp index ff22050f..105e489a 100644 --- a/src/charts/glwidget.cpp +++ b/src/charts/glwidget.cpp @@ -327,10 +327,9 @@ void GLWidget::render(bool selection) QOpenGLVertexArrayObject::Binder vaoBinder(&m_vao); m_program->bind(); - GLXYDataMapIterator i(m_xyDataManager->dataMap()); int counter = 0; - while (i.hasNext()) { - i.next(); + const auto &dataMap = m_xyDataManager->dataMap(); + for (auto i = dataMap.begin(), end = dataMap.end(); i != end; ++i) { QOpenGLBuffer *vbo = m_seriesBufferMap.value(i.key()); GLXYSeriesData *data = i.value(); diff --git a/src/charts/xychart/glxyseriesdata_p.h b/src/charts/xychart/glxyseriesdata_p.h index 006a810c..2db3e490 100644 --- a/src/charts/xychart/glxyseriesdata_p.h +++ b/src/charts/xychart/glxyseriesdata_p.h @@ -77,7 +77,6 @@ public: }; typedef QMap<const QXYSeries *, GLXYSeriesData *> GLXYDataMap; -typedef QMapIterator<const QXYSeries *, GLXYSeriesData *> GLXYDataMapIterator; class Q_CHARTS_PRIVATE_EXPORT GLXYSeriesDataManager : public QObject { |