From 2b1698862d93c4256ea4deae720d00269c448d5e Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 23 Jun 2020 17:14:06 +0200 Subject: Use QList instead of QVector in qtcharts examples Task-number: QTBUG-84469 Change-Id: I724c4d793294d890e26ff7d39021bbdc9438e978 Reviewed-by: Sona Kurazyan --- examples/charts/audio/xyseriesiodevice.h | 4 ++-- examples/charts/barmodelmapper/customtablemodel.cpp | 12 ++++++------ examples/charts/barmodelmapper/customtablemodel.h | 2 +- examples/charts/chartthemes/themewidget.cpp | 2 +- examples/charts/modeldata/customtablemodel.cpp | 12 ++++++------ examples/charts/modeldata/customtablemodel.h | 2 +- examples/charts/openglseries/datasource.cpp | 8 ++++---- examples/charts/openglseries/datasource.h | 2 +- examples/charts/qmloscilloscope/datasource.cpp | 4 ++-- examples/charts/qmloscilloscope/datasource.h | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) (limited to 'examples/charts') diff --git a/examples/charts/audio/xyseriesiodevice.h b/examples/charts/audio/xyseriesiodevice.h index cbbf2271..52f4bf05 100644 --- a/examples/charts/audio/xyseriesiodevice.h +++ b/examples/charts/audio/xyseriesiodevice.h @@ -32,7 +32,7 @@ #include #include -#include +#include #include QT_CHARTS_BEGIN_NAMESPACE @@ -55,7 +55,7 @@ protected: private: QXYSeries *m_series; - QVector m_buffer; + QList m_buffer; }; #endif // XYSERIESIODEVICE_H diff --git a/examples/charts/barmodelmapper/customtablemodel.cpp b/examples/charts/barmodelmapper/customtablemodel.cpp index 4bbf4191..37730042 100644 --- a/examples/charts/barmodelmapper/customtablemodel.cpp +++ b/examples/charts/barmodelmapper/customtablemodel.cpp @@ -28,7 +28,7 @@ ****************************************************************************/ #include "customtablemodel.h" -#include +#include #include #include #include @@ -42,14 +42,14 @@ CustomTableModel::CustomTableModel(QObject *parent) : // m_data for (int i = 0; i < m_rowCount; i++) { - QVector* dataVec = new QVector(m_columnCount); - for (int k = 0; k < dataVec->size(); k++) { + QList *dataList = new QList(m_columnCount); + for (int k = 0; k < dataList->size(); k++) { if (k % 2 == 0) - dataVec->replace(k, i * 50 + QRandomGenerator::global()->bounded(20)); + dataList->replace(k, i * 50 + QRandomGenerator::global()->bounded(20)); else - dataVec->replace(k, QRandomGenerator::global()->bounded(100)); + dataList->replace(k, QRandomGenerator::global()->bounded(100)); } - m_data.append(dataVec); + m_data.append(dataList); } } diff --git a/examples/charts/barmodelmapper/customtablemodel.h b/examples/charts/barmodelmapper/customtablemodel.h index ab4e10cb..d8de5d24 100644 --- a/examples/charts/barmodelmapper/customtablemodel.h +++ b/examples/charts/barmodelmapper/customtablemodel.h @@ -52,7 +52,7 @@ public: void clearMapping() { m_mapping.clear(); } private: - QList * > m_data; + QList *> m_data; QHash m_mapping; int m_columnCount; int m_rowCount; diff --git a/examples/charts/chartthemes/themewidget.cpp b/examples/charts/chartthemes/themewidget.cpp index cbcdb5c9..93894972 100644 --- a/examples/charts/chartthemes/themewidget.cpp +++ b/examples/charts/chartthemes/themewidget.cpp @@ -184,7 +184,7 @@ QChart *ThemeWidget::createAreaChart() const for (int j(0); j < m_dataTable[i].count(); j++) { Data data = m_dataTable[i].at(j); if (lowerSeries) { - const QVector& points = lowerSeries->pointsVector(); + const auto &points = lowerSeries->pointsVector(); upperSeries->append(QPointF(j, points[i].y() + data.first.y())); } else { upperSeries->append(QPointF(j, data.first.y())); diff --git a/examples/charts/modeldata/customtablemodel.cpp b/examples/charts/modeldata/customtablemodel.cpp index 8ef3c2a9..96256232 100644 --- a/examples/charts/modeldata/customtablemodel.cpp +++ b/examples/charts/modeldata/customtablemodel.cpp @@ -28,7 +28,7 @@ ****************************************************************************/ #include "customtablemodel.h" -#include +#include #include #include #include @@ -41,14 +41,14 @@ CustomTableModel::CustomTableModel(QObject *parent) : // m_data for (int i = 0; i < m_rowCount; i++) { - QVector* dataVec = new QVector(m_columnCount); - for (int k = 0; k < dataVec->size(); k++) { + QList *dataList = new QList(m_columnCount); + for (int k = 0; k < dataList->size(); k++) { if (k % 2 == 0) - dataVec->replace(k, i * 50 + QRandomGenerator::global()->bounded(20)); + dataList->replace(k, i * 50 + QRandomGenerator::global()->bounded(20)); else - dataVec->replace(k, QRandomGenerator::global()->bounded(100)); + dataList->replace(k, QRandomGenerator::global()->bounded(100)); } - m_data.append(dataVec); + m_data.append(dataList); } } diff --git a/examples/charts/modeldata/customtablemodel.h b/examples/charts/modeldata/customtablemodel.h index 95e13d8b..66396204 100644 --- a/examples/charts/modeldata/customtablemodel.h +++ b/examples/charts/modeldata/customtablemodel.h @@ -51,7 +51,7 @@ public: void clearMapping() { m_mapping.clear(); } private: - QList * > m_data; + QList *> m_data; QHash m_mapping; int m_columnCount; int m_rowCount; diff --git a/examples/charts/openglseries/datasource.cpp b/examples/charts/openglseries/datasource.cpp index af2dc10e..6969ba95 100644 --- a/examples/charts/openglseries/datasource.cpp +++ b/examples/charts/openglseries/datasource.cpp @@ -44,13 +44,13 @@ void DataSource::update(QAbstractSeries *series, int seriesIndex) { if (series) { QXYSeries *xySeries = static_cast(series); - const QVector > &seriesData = m_data.at(seriesIndex); + const QList> &seriesData = m_data.at(seriesIndex); if (seriesIndex == 0) m_index++; if (m_index > seriesData.count() - 1) m_index = 0; - QVector points = seriesData.at(m_index); + const auto points = seriesData.at(m_index); // Use replace instead of clear + append, it's optimized for performance xySeries->replace(points); } @@ -103,10 +103,10 @@ void DataSource::generateData(int seriesCount, int rowCount, int colCount) // Append the new data depending on the type for (int k(0); k < seriesCount; k++) { - QVector > seriesData; + QList> seriesData; qreal height = qreal(k) * (10.0 / qreal(seriesCount)) + 0.3; for (int i(0); i < rowCount; i++) { - QVector points; + QList points; points.reserve(colCount); for (int j(0); j < colCount; j++) { qreal x(0); diff --git a/examples/charts/openglseries/datasource.h b/examples/charts/openglseries/datasource.h index d32f717a..652981ea 100644 --- a/examples/charts/openglseries/datasource.h +++ b/examples/charts/openglseries/datasource.h @@ -53,7 +53,7 @@ public slots: void updateAllSeries(); private: - QVector > > m_data; + QList>> m_data; int m_index; QList m_seriesList; QLabel *m_fpsLabel; diff --git a/examples/charts/qmloscilloscope/datasource.cpp b/examples/charts/qmloscilloscope/datasource.cpp index b773217b..d01fa421 100644 --- a/examples/charts/qmloscilloscope/datasource.cpp +++ b/examples/charts/qmloscilloscope/datasource.cpp @@ -60,7 +60,7 @@ void DataSource::update(QAbstractSeries *series) if (m_index > m_data.count() - 1) m_index = 0; - QVector points = m_data.at(m_index); + QList points = m_data.at(m_index); // Use replace instead of clear + append, it's optimized for performance xySeries->replace(points); } @@ -73,7 +73,7 @@ void DataSource::generateData(int type, int rowCount, int colCount) // Append the new data depending on the type for (int i(0); i < rowCount; i++) { - QVector points; + QList points; points.reserve(colCount); for (int j(0); j < colCount; j++) { qreal x(0); diff --git a/examples/charts/qmloscilloscope/datasource.h b/examples/charts/qmloscilloscope/datasource.h index d1b9caee..3fd61614 100644 --- a/examples/charts/qmloscilloscope/datasource.h +++ b/examples/charts/qmloscilloscope/datasource.h @@ -53,7 +53,7 @@ public slots: private: QQuickView *m_appViewer; - QList > m_data; + QList> m_data; int m_index; }; -- cgit v1.2.3