summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-03 22:08:41 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-04 10:16:06 +0200
commit2372db24d1b5ed482b6c0be7af2e5f6aba75cd36 (patch)
tree4c522f6130f885eede56e749d738a35e1954c650 /src
parent248fff483ae1597c62a93edf91841b84b363739b (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')
-rw-r--r--src/charts/barchart/abstractbarchartitem.cpp24
-rw-r--r--src/charts/glwidget.cpp5
-rw-r--r--src/charts/xychart/glxyseriesdata_p.h1
-rw-r--r--src/chartsqml2/declarativeopenglrendernode.cpp16
4 files changed, 14 insertions, 32 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
{
diff --git a/src/chartsqml2/declarativeopenglrendernode.cpp b/src/chartsqml2/declarativeopenglrendernode.cpp
index 685c331b..58f7aef6 100644
--- a/src/chartsqml2/declarativeopenglrendernode.cpp
+++ b/src/chartsqml2/declarativeopenglrendernode.cpp
@@ -225,9 +225,7 @@ void DeclarativeOpenGLRenderNode::setSeriesData(bool mapDirty, const GLXYDataMap
GLXYDataMap oldMap = m_xyDataMap;
m_xyDataMap.clear();
- GLXYDataMapIterator i(dataMap);
- while (i.hasNext()) {
- i.next();
+ for (auto i = dataMap.begin(), end = dataMap.end(); i != end; ++i) {
GLXYSeriesData *data = oldMap.take(i.key());
const GLXYSeriesData *newData = i.value();
if (!data || newData->dirty) {
@@ -237,18 +235,14 @@ void DeclarativeOpenGLRenderNode::setSeriesData(bool mapDirty, const GLXYDataMap
m_xyDataMap.insert(i.key(), data);
}
// Delete remaining old data
- i = oldMap;
- while (i.hasNext()) {
- i.next();
+ for (auto i = oldMap.begin(), end = oldMap.end(); i != end; ++i) {
delete i.value();
cleanXYSeriesResources(i.key());
}
dirty = true;
} else {
// Series have not changed, so just copy dirty data over
- GLXYDataMapIterator i(dataMap);
- while (i.hasNext()) {
- i.next();
+ for (auto i = dataMap.begin(), end = dataMap.end(); i != end; ++i) {
const GLXYSeriesData *newData = i.value();
if (i.value()->dirty) {
dirty = true;
@@ -308,10 +302,8 @@ void DeclarativeOpenGLRenderNode::renderGL(bool selection)
glViewport(0, 0, m_textureSize.width(), m_textureSize.height());
- GLXYDataMapIterator i(m_xyDataMap);
int counter = 0;
- while (i.hasNext()) {
- i.next();
+ for (auto i = m_xyDataMap.begin(), end = m_xyDataMap.end(); i != end; ++i) {
QOpenGLBuffer *vbo = m_seriesBufferMap.value(i.key());
GLXYSeriesData *data = i.value();