summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-09-21 12:21:34 -0700
committerLars Knoll <lars.knoll@qt.io>2017-11-03 09:13:37 +0000
commit567b5bc67e54f496027da2e6d99aa7b39d64a606 (patch)
tree9bdb47dfba0e69e4d31c27e40bd4b25eefb624b2
parentdad8cdbac13eaf3ed33fdf4157ebc242d5c13db5 (diff)
Update to new QRandomGenerator API
Change-Id: I69f37f9304f24709a823fffd14e676c097712329 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--examples/charts/barmodelmapper/customtablemodel.cpp4
-rw-r--r--examples/charts/chartthemes/themewidget.cpp4
-rw-r--r--examples/charts/dynamicspline/chart.cpp2
-rw-r--r--examples/charts/modeldata/customtablemodel.cpp4
-rw-r--r--examples/charts/nesteddonuts/widget.cpp6
-rw-r--r--examples/charts/openglseries/datasource.cpp2
-rw-r--r--examples/charts/piechartdrilldown/main.cpp2
-rw-r--r--examples/charts/qmloscilloscope/datasource.cpp2
-rw-r--r--examples/charts/stackedbarchartdrilldown/main.cpp2
-rw-r--r--examples/charts/zoomlinechart/main.cpp2
-rw-r--r--tests/auto/qxyseries/tst_qxyseries.cpp8
-rw-r--r--tests/manual/candlesticktester/mainwidget.cpp2
-rw-r--r--tests/manual/chartviewer/model.h4
-rw-r--r--tests/manual/chartwidgettest/mainwidget.cpp4
-rw-r--r--tests/manual/openglseriestest/datasource.cpp2
-rw-r--r--tests/manual/openglseriestest/mainwindow.cpp2
-rw-r--r--tests/manual/presenterchart/chartview.cpp2
-rw-r--r--tests/manual/wavechart/wavechart.cpp2
18 files changed, 28 insertions, 28 deletions
diff --git a/examples/charts/barmodelmapper/customtablemodel.cpp b/examples/charts/barmodelmapper/customtablemodel.cpp
index 71165dff..4bbf4191 100644
--- a/examples/charts/barmodelmapper/customtablemodel.cpp
+++ b/examples/charts/barmodelmapper/customtablemodel.cpp
@@ -45,9 +45,9 @@ CustomTableModel::CustomTableModel(QObject *parent) :
QVector<qreal>* dataVec = new QVector<qreal>(m_columnCount);
for (int k = 0; k < dataVec->size(); k++) {
if (k % 2 == 0)
- dataVec->replace(k, i * 50 + QRandomGenerator::bounded(20));
+ dataVec->replace(k, i * 50 + QRandomGenerator::global()->bounded(20));
else
- dataVec->replace(k, QRandomGenerator::bounded(100));
+ dataVec->replace(k, QRandomGenerator::global()->bounded(100));
}
m_data.append(dataVec);
}
diff --git a/examples/charts/chartthemes/themewidget.cpp b/examples/charts/chartthemes/themewidget.cpp
index ed49ce9b..84ea8231 100644
--- a/examples/charts/chartthemes/themewidget.cpp
+++ b/examples/charts/chartthemes/themewidget.cpp
@@ -126,8 +126,8 @@ DataTable ThemeWidget::generateRandomData(int listCount, int valueMax, int value
DataList dataList;
qreal yValue(0);
for (int j(0); j < valueCount; j++) {
- yValue = yValue + QRandomGenerator::bounded(valueMax / (qreal) valueCount);
- QPointF value((j + QRandomGenerator::getReal()) * ((qreal) m_valueMax / (qreal) valueCount),
+ yValue = yValue + QRandomGenerator::global()->bounded(valueMax / (qreal) valueCount);
+ QPointF value((j + QRandomGenerator::global()->generateDouble()) * ((qreal) m_valueMax / (qreal) valueCount),
yValue);
QString label = "Slice " + QString::number(i) + ":" + QString::number(j);
dataList << Data(value, label);
diff --git a/examples/charts/dynamicspline/chart.cpp b/examples/charts/dynamicspline/chart.cpp
index ee7061d2..beba2513 100644
--- a/examples/charts/dynamicspline/chart.cpp
+++ b/examples/charts/dynamicspline/chart.cpp
@@ -71,7 +71,7 @@ void Chart::handleTimeout()
qreal x = plotArea().width() / m_axis->tickCount();
qreal y = (m_axis->max() - m_axis->min()) / m_axis->tickCount();
m_x += y;
- m_y = QRandomGenerator::bounded(5) - 2.5;
+ m_y = QRandomGenerator::global()->bounded(5) - 2.5;
m_series->append(m_x, m_y);
scroll(x, 0);
if (m_x == 100)
diff --git a/examples/charts/modeldata/customtablemodel.cpp b/examples/charts/modeldata/customtablemodel.cpp
index e36a5d3d..8ef3c2a9 100644
--- a/examples/charts/modeldata/customtablemodel.cpp
+++ b/examples/charts/modeldata/customtablemodel.cpp
@@ -44,9 +44,9 @@ CustomTableModel::CustomTableModel(QObject *parent) :
QVector<qreal>* dataVec = new QVector<qreal>(m_columnCount);
for (int k = 0; k < dataVec->size(); k++) {
if (k % 2 == 0)
- dataVec->replace(k, i * 50 + QRandomGenerator::bounded(20));
+ dataVec->replace(k, i * 50 + QRandomGenerator::global()->bounded(20));
else
- dataVec->replace(k, QRandomGenerator::bounded(100));
+ dataVec->replace(k, QRandomGenerator::global()->bounded(100));
}
m_data.append(dataVec);
}
diff --git a/examples/charts/nesteddonuts/widget.cpp b/examples/charts/nesteddonuts/widget.cpp
index f8090455..92c6415c 100644
--- a/examples/charts/nesteddonuts/widget.cpp
+++ b/examples/charts/nesteddonuts/widget.cpp
@@ -61,9 +61,9 @@ Widget::Widget(QWidget *parent)
//! [3]
for (int i = 0; i < donutCount; i++) {
QPieSeries *donut = new QPieSeries;
- int sliceCount = 3 + QRandomGenerator::bounded(3);
+ int sliceCount = 3 + QRandomGenerator::global()->bounded(3);
for (int j = 0; j < sliceCount; j++) {
- qreal value = 100 + QRandomGenerator::bounded(100);
+ qreal value = 100 + QRandomGenerator::global()->bounded(100);
QPieSlice *slice = new QPieSlice(QString("%1").arg(value), value);
slice->setLabelVisible(true);
slice->setLabelColor(Qt::white);
@@ -102,7 +102,7 @@ void Widget::updateRotation()
{
for (int i = 0; i < m_donuts.count(); i++) {
QPieSeries *donut = m_donuts.at(i);
- qreal phaseShift = -50 + QRandomGenerator::bounded(100);
+ qreal phaseShift = -50 + QRandomGenerator::global()->bounded(100);
donut->setPieStartAngle(donut->pieStartAngle() + phaseShift);
donut->setPieEndAngle(donut->pieEndAngle() + phaseShift);
}
diff --git a/examples/charts/openglseries/datasource.cpp b/examples/charts/openglseries/datasource.cpp
index b5992214..af2dc10e 100644
--- a/examples/charts/openglseries/datasource.cpp
+++ b/examples/charts/openglseries/datasource.cpp
@@ -113,7 +113,7 @@ void DataSource::generateData(int seriesCount, int rowCount, int colCount)
qreal y(0);
// data with sin + random component
y = height + (yMultiplier * qSin(M_PI / 50 * j)
- + (yMultiplier * QRandomGenerator::getReal()));
+ + (yMultiplier * QRandomGenerator::global()->generateDouble()));
// 0.000001 added to make values logaxis compatible
x = 0.000001 + 20.0 * (qreal(j) / qreal(colCount)) + (xAdjustment * qreal(i));
points.append(QPointF(x, y));
diff --git a/examples/charts/piechartdrilldown/main.cpp b/examples/charts/piechartdrilldown/main.cpp
index 1fed557a..e18f07f3 100644
--- a/examples/charts/piechartdrilldown/main.cpp
+++ b/examples/charts/piechartdrilldown/main.cpp
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
series->setName("Sales by month - " + name);
for (const QString &month : months)
- *series << new DrilldownSlice(QRandomGenerator::bounded(1000), month, yearSeries);
+ *series << new DrilldownSlice(QRandomGenerator::global()->bounded(1000), month, yearSeries);
QObject::connect(series, &QPieSeries::clicked, chart, &DrilldownChart::handleSliceClicked);
diff --git a/examples/charts/qmloscilloscope/datasource.cpp b/examples/charts/qmloscilloscope/datasource.cpp
index dddee543..b773217b 100644
--- a/examples/charts/qmloscilloscope/datasource.cpp
+++ b/examples/charts/qmloscilloscope/datasource.cpp
@@ -81,7 +81,7 @@ void DataSource::generateData(int type, int rowCount, int colCount)
switch (type) {
case 0:
// data with sin + random component
- y = qSin(M_PI / 50 * j) + 0.5 + QRandomGenerator::getReal();
+ y = qSin(M_PI / 50 * j) + 0.5 + QRandomGenerator::global()->generateDouble();
x = j;
break;
case 1:
diff --git a/examples/charts/stackedbarchartdrilldown/main.cpp b/examples/charts/stackedbarchartdrilldown/main.cpp
index 46d00190..87035aea 100644
--- a/examples/charts/stackedbarchartdrilldown/main.cpp
+++ b/examples/charts/stackedbarchartdrilldown/main.cpp
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
for (int month = 0; month < months.count(); month++) {
QBarSet *weeklyCrop = new QBarSet(plant);
for (int week = 0; week < weeks.count(); week++)
- *weeklyCrop << QRandomGenerator::bounded(20);
+ *weeklyCrop << QRandomGenerator::global()->bounded(20);
// Get the drilldown series from season series and add crop to it.
seasonSeries->drilldownSeries(month)->append(weeklyCrop);
*monthlyCrop << weeklyCrop->sum();
diff --git a/examples/charts/zoomlinechart/main.cpp b/examples/charts/zoomlinechart/main.cpp
index b3c6a33f..28a3d913 100644
--- a/examples/charts/zoomlinechart/main.cpp
+++ b/examples/charts/zoomlinechart/main.cpp
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
QLineSeries *series = new QLineSeries();
for (int i = 0; i < 500; i++) {
QPointF p((qreal) i, qSin(M_PI / 50 * i) * 100);
- p.ry() += QRandomGenerator::bounded(20);
+ p.ry() += QRandomGenerator::global()->bounded(20);
*series << p;
}
//![1]
diff --git a/tests/auto/qxyseries/tst_qxyseries.cpp b/tests/auto/qxyseries/tst_qxyseries.cpp
index f55f5147..de878679 100644
--- a/tests/auto/qxyseries/tst_qxyseries.cpp
+++ b/tests/auto/qxyseries/tst_qxyseries.cpp
@@ -325,7 +325,7 @@ void tst_QXYSeries::remove_raw()
// (simulate e.g. spamming a hypothetical "remove last point"-button)
QList<QPointF> bunchOfPoints;
for (int i = 0; i < 10; i++)
- bunchOfPoints.append(QPointF(i, QRandomGenerator::getReal()));
+ bunchOfPoints.append(QPointF(i, QRandomGenerator::global()->generateDouble()));
m_series->replace(bunchOfPoints);
QCOMPARE(m_series->points(), bunchOfPoints);
QTest::qWait(1500); // Wait for append animations to be over
@@ -337,7 +337,7 @@ void tst_QXYSeries::remove_raw()
// Removal using index
for (int i = 0; i < 10; i++)
- bunchOfPoints.append(QPointF(i, QRandomGenerator::getReal()));
+ bunchOfPoints.append(QPointF(i, QRandomGenerator::global()->generateDouble()));
m_series->replace(bunchOfPoints);
m_series->remove(5);
m_series->remove(0);
@@ -350,7 +350,7 @@ void tst_QXYSeries::remove_raw()
// Multiple removal using index
for (int i = 0; i < 10; i++)
- bunchOfPoints.append(QPointF(i, QRandomGenerator::getReal()));
+ bunchOfPoints.append(QPointF(i, QRandomGenerator::global()->generateDouble()));
m_series->replace(bunchOfPoints);
m_series->removePoints(5, 2);
m_series->removePoints(0, 3);
@@ -463,7 +463,7 @@ void tst_QXYSeries::replace_raw()
// Replace all points
QList<QPointF> allPoints;
for (int i = 0; i < 10; i++)
- allPoints.append(QPointF(i, QRandomGenerator::getReal()));
+ allPoints.append(QPointF(i, QRandomGenerator::global()->generateDouble()));
m_series->replace(allPoints);
TRY_COMPARE(pointReplacedSpy.count(), points.count());
TRY_COMPARE(pointsReplacedSpy.count(), 1);
diff --git a/tests/manual/candlesticktester/mainwidget.cpp b/tests/manual/candlesticktester/mainwidget.cpp
index f45a7793..ec2d5bd8 100644
--- a/tests/manual/candlesticktester/mainwidget.cpp
+++ b/tests/manual/candlesticktester/mainwidget.cpp
@@ -286,7 +286,7 @@ qreal MainWidget::randomValue(int min, int max) const
{
if (min > max)
qSwap(min, max);
- return QRandomGenerator::bounded(min, max);
+ return QRandomGenerator::global()->bounded(min, max);
}
QCandlestickSet *MainWidget::randomSet(qreal timestamp)
diff --git a/tests/manual/chartviewer/model.h b/tests/manual/chartviewer/model.h
index 5db91e8e..a4c3aa3c 100644
--- a/tests/manual/chartviewer/model.h
+++ b/tests/manual/chartviewer/model.h
@@ -56,9 +56,9 @@ public:
DataList dataList;
qreal yValue(0.1);
for (int j(0); j < valueCount; j++) {
- yValue = yValue + QRandomGenerator::bounded(valueMax / (qreal) valueCount);
+ yValue = yValue + QRandomGenerator::global()->bounded(valueMax / (qreal) valueCount);
QPointF value(
- (j + QRandomGenerator::getReal())
+ (j + QRandomGenerator::global()->generateDouble())
* ((qreal) valueMax / (qreal) valueCount), yValue);
QString label = "Slice " + QString::number(i) + ":" + QString::number(j);
dataList << Data(value, label);
diff --git a/tests/manual/chartwidgettest/mainwidget.cpp b/tests/manual/chartwidgettest/mainwidget.cpp
index 2850de0e..3ff15810 100644
--- a/tests/manual/chartwidgettest/mainwidget.cpp
+++ b/tests/manual/chartwidgettest/mainwidget.cpp
@@ -219,9 +219,9 @@ QList<RealList> MainWidget::generateTestData(int columnCount, int rowCount, QStr
if (dataCharacteristics == "Sin") {
newColumn.append(std::abs(sin(M_PI / 50 * i) * 100));
} else if (dataCharacteristics == "Sin + random") {
- newColumn.append(std::abs(sin(M_PI / 50 * i) * 100) + QRandomGenerator::bounded(5));
+ newColumn.append(std::abs(sin(M_PI / 50 * i) * 100) + QRandomGenerator::global()->bounded(5));
} else if (dataCharacteristics == "Random") {
- newColumn.append(QRandomGenerator::bounded(11.0));
+ newColumn.append(QRandomGenerator::global()->bounded(11.0));
} else if (dataCharacteristics == "Linear") {
//newColumn.append(i * (j + 1.0));
// TODO: temporary hack to make pie work; prevent zero values:
diff --git a/tests/manual/openglseriestest/datasource.cpp b/tests/manual/openglseriestest/datasource.cpp
index 29d7e2ba..dbf6874c 100644
--- a/tests/manual/openglseriestest/datasource.cpp
+++ b/tests/manual/openglseriestest/datasource.cpp
@@ -119,7 +119,7 @@ void DataSource::generateData(int seriesIndex, int rowCount, int colCount)
qreal y(0);
// data with sin + random component
y = height + (yMultiplier * qSin(M_PI / 50 * j)
- + (yMultiplier * QRandomGenerator::getReal()));
+ + (yMultiplier * QRandomGenerator::global()->generateDouble()));
// 0.000001 added to make values logaxis compatible
x = 0.000001 + 20.0 * (qreal(j) / qreal(colCount)) + (xAdjustment * qreal(i));
points.append(QPointF(x, y));
diff --git a/tests/manual/openglseriestest/mainwindow.cpp b/tests/manual/openglseriestest/mainwindow.cpp
index 2d59f18c..1497dad8 100644
--- a/tests/manual/openglseriestest/mainwindow.cpp
+++ b/tests/manual/openglseriestest/mainwindow.cpp
@@ -549,7 +549,7 @@ void MainWindow::addSeries(bool gl)
if (m_seriesList.size() < maxSeriesCount) {
QXYSeries *series;
- if (QRandomGenerator::bounded(2)) {
+ if (QRandomGenerator::global()->bounded(2)) {
series = new QLineSeries;
series->setPen(QPen(QBrush(color), width));
} else {
diff --git a/tests/manual/presenterchart/chartview.cpp b/tests/manual/presenterchart/chartview.cpp
index 86d144ad..b7d575de 100644
--- a/tests/manual/presenterchart/chartview.cpp
+++ b/tests/manual/presenterchart/chartview.cpp
@@ -62,7 +62,7 @@ ChartView::ChartView(QChart *chart, QWidget *parent)
int numPoints = 10;
for (int x = 0; x <= numPoints; ++x) {
- qreal y = QRandomGenerator::bounded(100);
+ qreal y = QRandomGenerator::global()->bounded(100);
series0->append(x, y);
series1->append(x, y);
series2->append(x, y);
diff --git a/tests/manual/wavechart/wavechart.cpp b/tests/manual/wavechart/wavechart.cpp
index 522d2a7c..695ddc72 100644
--- a/tests/manual/wavechart/wavechart.cpp
+++ b/tests/manual/wavechart/wavechart.cpp
@@ -67,7 +67,7 @@ void WaveChart::update()
int fluctuate;
const QList<QPointF>& points = m_series->points();
for (qreal i = 0, x = 0; x <= 2 * M_PI; x += m_step, i++) {
- fluctuate = QRandomGenerator::bounded(100);
+ fluctuate = QRandomGenerator::global()->bounded(100);
m_series->replace(x,points[i].y(),x,fabs(sin(x) * fluctuate));
}