Update to new QRandomGenerator API
To get latest qtbase dev integrated in qt5 dev again without
qtdeclarative 5.10->dev merge.
Change-Id: I6905649aca2b06302df8cee2f660f1f92398d36a
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
(cherry picked from commit ee00fa01dc
)
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
1dbe0acecb
commit
14599af2f2
|
@ -114,7 +114,7 @@ NoisyNode::NoisyNode(QQuickWindow *window)
|
|||
QImage image(NOISE_SIZE, NOISE_SIZE, QImage::Format_RGB32);
|
||||
uint *data = (uint *) image.bits();
|
||||
for (int i=0; i<NOISE_SIZE * NOISE_SIZE; ++i) {
|
||||
uint g = QRandomGenerator::bounded(0xff);
|
||||
uint g = QRandomGenerator::global()->bounded(0xff);
|
||||
data[i] = 0xff000000 | (g << 16) | (g << 8) | g;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ public:
|
|||
transformNode->appendChildNode(textureNode);
|
||||
parentNode->appendChildNode(transformNode);
|
||||
|
||||
int duration = QRandomGenerator::getReal() * 400 + 800;
|
||||
rotAnimation.setStartValue(QRandomGenerator::getReal() * 720 - 180);
|
||||
rotAnimation.setEndValue(QRandomGenerator::getReal() * 720 - 180);
|
||||
int duration = QRandomGenerator::global()->generateDouble() * 400 + 800;
|
||||
rotAnimation.setStartValue(QRandomGenerator::global()->generateDouble() * 720 - 180);
|
||||
rotAnimation.setEndValue(QRandomGenerator::global()->generateDouble() * 720 - 180);
|
||||
rotAnimation.setDuration(duration);
|
||||
rotAnimation.start();
|
||||
|
||||
|
@ -182,8 +182,8 @@ void Window::addItems()
|
|||
QSGTexture *textures[] = { m_smileTexture.data(), m_qtTexture.data() };
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
QSGTexture *tex = textures[i%2];
|
||||
QPointF fromPos(-tex->textureSize().width(), QRandomGenerator::getReal() * (height() - tex->textureSize().height()));
|
||||
QPointF toPos(width(), QRandomGenerator::getReal() * height() * 1.5 - height() * 0.25);
|
||||
QPointF fromPos(-tex->textureSize().width(), QRandomGenerator::global()->generateDouble() * (height() - tex->textureSize().height()));
|
||||
QPointF toPos(width(), QRandomGenerator::global()->generateDouble() * height() * 1.5 - height() * 0.25);
|
||||
m_items.append(QSharedPointer<Item>::create(m_sgRootNode.data(), tex, fromPos, toPos));
|
||||
}
|
||||
update();
|
||||
|
|
|
@ -108,8 +108,8 @@ QPointF QQuickAngleDirection::sample(const QPointF &from)
|
|||
{
|
||||
Q_UNUSED(from);
|
||||
QPointF ret;
|
||||
qreal theta = m_angle*CONV - m_angleVariation*CONV + QRandomGenerator::getReal() * m_angleVariation*CONV * 2;
|
||||
qreal mag = m_magnitude- m_magnitudeVariation + QRandomGenerator::getReal() * m_magnitudeVariation * 2;
|
||||
qreal theta = m_angle*CONV - m_angleVariation*CONV + QRandomGenerator::global()->generateDouble() * m_angleVariation*CONV * 2;
|
||||
qreal mag = m_magnitude- m_magnitudeVariation + QRandomGenerator::global()->generateDouble() * m_magnitudeVariation * 2;
|
||||
ret.setX(mag * qCos(theta));
|
||||
ret.setY(mag * qSin(theta));
|
||||
return ret;
|
||||
|
|
|
@ -425,7 +425,7 @@ void QQuickCustomParticle::buildData(QQuickOpenGLShaderEffectNode *rootNode)
|
|||
void QQuickCustomParticle::initialize(int gIdx, int pIdx)
|
||||
{
|
||||
QQuickParticleData* datum = m_system->groupData[gIdx]->data[pIdx];
|
||||
datum->r = QRandomGenerator::getReal();
|
||||
datum->r = QRandomGenerator::global()->generateDouble();
|
||||
}
|
||||
|
||||
void QQuickCustomParticle::commit(int gIdx, int pIdx)
|
||||
|
|
|
@ -68,8 +68,8 @@ QQuickEllipseExtruder::QQuickEllipseExtruder(QObject *parent) :
|
|||
|
||||
QPointF QQuickEllipseExtruder::extrude(const QRectF & r)
|
||||
{
|
||||
qreal theta = QRandomGenerator::bounded(2 * M_PI);
|
||||
qreal mag = m_fill ? QRandomGenerator::getReal() : 1;
|
||||
qreal theta = QRandomGenerator::global()->bounded(2 * M_PI);
|
||||
qreal mag = m_fill ? QRandomGenerator::global()->generateDouble() : 1;
|
||||
return QPointF(r.x() + r.width()/2 + mag * (r.width()/2) * qCos(theta),
|
||||
r.y() + r.height()/2 + mag * (r.height()/2) * qSin(theta));
|
||||
}
|
||||
|
|
|
@ -1730,9 +1730,9 @@ void QQuickImageParticle::initialize(int gIdx, int pIdx)
|
|||
if (!datum->rotationOwner)
|
||||
datum->rotationOwner = this;
|
||||
rotation =
|
||||
(m_rotation + (m_rotationVariation - 2*QRandomGenerator::bounded(m_rotationVariation)) ) * CONV;
|
||||
(m_rotation + (m_rotationVariation - 2*QRandomGenerator::global()->bounded(m_rotationVariation)) ) * CONV;
|
||||
rotationVelocity =
|
||||
(m_rotationVelocity + (m_rotationVelocityVariation - 2*QRandomGenerator::bounded(m_rotationVelocityVariation)) ) * CONV;
|
||||
(m_rotationVelocity + (m_rotationVelocityVariation - 2*QRandomGenerator::global()->bounded(m_rotationVelocityVariation)) ) * CONV;
|
||||
autoRotate = m_autoRotation?1.0:0.0;
|
||||
if (datum->rotationOwner == this) {
|
||||
datum->rotation = rotation;
|
||||
|
@ -1751,10 +1751,10 @@ void QQuickImageParticle::initialize(int gIdx, int pIdx)
|
|||
if (m_explicitColor) {
|
||||
if (!datum->colorOwner)
|
||||
datum->colorOwner = this;
|
||||
color.r = m_color.red() * (1 - redVariation) + QRandomGenerator::bounded(256) * redVariation;
|
||||
color.g = m_color.green() * (1 - greenVariation) + QRandomGenerator::bounded(256) * greenVariation;
|
||||
color.b = m_color.blue() * (1 - blueVariation) + QRandomGenerator::bounded(256) * blueVariation;
|
||||
color.a = m_alpha * m_color.alpha() * (1 - m_alphaVariation) + QRandomGenerator::bounded(256) * m_alphaVariation;
|
||||
color.r = m_color.red() * (1 - redVariation) + QRandomGenerator::global()->bounded(256) * redVariation;
|
||||
color.g = m_color.green() * (1 - greenVariation) + QRandomGenerator::global()->bounded(256) * greenVariation;
|
||||
color.b = m_color.blue() * (1 - blueVariation) + QRandomGenerator::global()->bounded(256) * blueVariation;
|
||||
color.a = m_alpha * m_color.alpha() * (1 - m_alphaVariation) + QRandomGenerator::global()->bounded(256) * m_alphaVariation;
|
||||
if (datum->colorOwner == this)
|
||||
datum->color = color;
|
||||
else
|
||||
|
|
|
@ -69,10 +69,10 @@ QPointF QQuickLineExtruder::extrude(const QRectF &r)
|
|||
{
|
||||
qreal x,y;
|
||||
if (!r.height()){
|
||||
x = r.width() * QRandomGenerator::getReal();
|
||||
x = r.width() * QRandomGenerator::global()->generateDouble();
|
||||
y = 0;
|
||||
}else{
|
||||
y = r.height() * QRandomGenerator::getReal();
|
||||
y = r.height() * QRandomGenerator::global()->generateDouble();
|
||||
if (!r.width()){
|
||||
x = 0;
|
||||
}else{
|
||||
|
|
|
@ -103,7 +103,7 @@ QPointF QQuickMaskExtruder::extrude(const QRectF &r)
|
|||
ensureInitialized(r);
|
||||
if (!m_mask.count() || m_img.isNull())
|
||||
return r.topLeft();
|
||||
const QPointF p = m_mask[QRandomGenerator::bounded(m_mask.count())];
|
||||
const QPointF p = m_mask[QRandomGenerator::global()->bounded(m_mask.count())];
|
||||
//### Should random sub-pixel positioning be added?
|
||||
return p + r.topLeft();
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
|
|||
datum->t = pt;
|
||||
datum->lifeSpan =
|
||||
(m_particleDuration
|
||||
+ (QRandomGenerator::bounded((m_particleDurationVariation*2) + 1) - m_particleDurationVariation))
|
||||
+ (QRandomGenerator::global()->bounded((m_particleDurationVariation*2) + 1) - m_particleDurationVariation))
|
||||
/ 1000.0;
|
||||
|
||||
if (datum->lifeSpan >= m_system->maxLife){
|
||||
|
@ -462,7 +462,7 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
|
|||
|
||||
// Particle size
|
||||
float sizeVariation = -m_particleSizeVariation
|
||||
+ QRandomGenerator::bounded(m_particleSizeVariation * 2);
|
||||
+ QRandomGenerator::global()->bounded(m_particleSizeVariation * 2);
|
||||
|
||||
float size = qMax((qreal)0.0 , m_particleSize + sizeVariation);
|
||||
float endSize = qMax((qreal)0.0 , sizeAtEnd + sizeVariation);
|
||||
|
|
|
@ -59,8 +59,8 @@ QQuickParticleExtruder::QQuickParticleExtruder(QObject *parent) :
|
|||
|
||||
QPointF QQuickParticleExtruder::extrude(const QRectF &rect)
|
||||
{
|
||||
return QPointF(QRandomGenerator::getReal() * rect.width() + rect.x(),
|
||||
QRandomGenerator::getReal() * rect.height() + rect.y());
|
||||
return QPointF(QRandomGenerator::global()->generateDouble() * rect.width() + rect.x(),
|
||||
QRandomGenerator::global()->generateDouble() * rect.height() + rect.y());
|
||||
}
|
||||
|
||||
bool QQuickParticleExtruder::contains(const QRectF &bounds, const QPointF &point)
|
||||
|
|
|
@ -78,8 +78,8 @@ QQuickPointDirection::QQuickPointDirection(QObject *parent) :
|
|||
QPointF QQuickPointDirection::sample(const QPointF &)
|
||||
{
|
||||
QPointF ret;
|
||||
ret.setX(m_x - m_xVariation + QRandomGenerator::getReal() * m_xVariation * 2);
|
||||
ret.setY(m_y - m_yVariation + QRandomGenerator::getReal() * m_yVariation * 2);
|
||||
ret.setX(m_x - m_xVariation + QRandomGenerator::global()->generateDouble() * m_xVariation * 2);
|
||||
ret.setY(m_y - m_yVariation + QRandomGenerator::global()->generateDouble() * m_yVariation * 2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,21 +60,21 @@ QQuickRectangleExtruder::QQuickRectangleExtruder(QObject *parent) :
|
|||
QPointF QQuickRectangleExtruder::extrude(const QRectF &rect)
|
||||
{
|
||||
if (m_fill)
|
||||
return QPointF(QRandomGenerator::getReal() * rect.width() + rect.x(),
|
||||
QRandomGenerator::getReal() * rect.height() + rect.y());
|
||||
int side = QRandomGenerator::bounded(4);
|
||||
return QPointF(QRandomGenerator::global()->generateDouble() * rect.width() + rect.x(),
|
||||
QRandomGenerator::global()->generateDouble() * rect.height() + rect.y());
|
||||
int side = QRandomGenerator::global()->bounded(4);
|
||||
switch (side){//TODO: Doesn't this overlap the corners?
|
||||
case 0:
|
||||
return QPointF(rect.x(),
|
||||
QRandomGenerator::getReal() * rect.height() + rect.y());
|
||||
QRandomGenerator::global()->generateDouble() * rect.height() + rect.y());
|
||||
case 1:
|
||||
return QPointF(rect.width() + rect.x(),
|
||||
QRandomGenerator::getReal() * rect.height() + rect.y());
|
||||
QRandomGenerator::global()->generateDouble() * rect.height() + rect.y());
|
||||
case 2:
|
||||
return QPointF(QRandomGenerator::getReal() * rect.width() + rect.x(),
|
||||
return QPointF(QRandomGenerator::global()->generateDouble() * rect.width() + rect.x(),
|
||||
rect.y());
|
||||
default:
|
||||
return QPointF(QRandomGenerator::getReal() * rect.width() + rect.x(),
|
||||
return QPointF(QRandomGenerator::global()->generateDouble() * rect.width() + rect.x(),
|
||||
rect.height() + rect.y());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,10 +118,10 @@ QPointF QQuickTargetDirection::sample(const QPointF &from)
|
|||
targetX = m_targetX;
|
||||
targetY = m_targetY;
|
||||
}
|
||||
targetX += 0 - from.x() - m_targetVariation + QRandomGenerator::getReal() * m_targetVariation*2;
|
||||
targetY += 0 - from.y() - m_targetVariation + QRandomGenerator::getReal() * m_targetVariation*2;
|
||||
targetX += 0 - from.x() - m_targetVariation + QRandomGenerator::global()->generateDouble() * m_targetVariation*2;
|
||||
targetY += 0 - from.y() - m_targetVariation + QRandomGenerator::global()->generateDouble() * m_targetVariation*2;
|
||||
qreal theta = std::atan2(targetY, targetX);
|
||||
qreal mag = m_magnitude + QRandomGenerator::getReal() * m_magnitudeVariation * 2 - m_magnitudeVariation;
|
||||
qreal mag = m_magnitude + QRandomGenerator::global()->generateDouble() * m_magnitudeVariation * 2 - m_magnitudeVariation;
|
||||
if (m_proportionalMagnitude)
|
||||
mag *= std::sqrt(targetX * targetX + targetY * targetY);
|
||||
ret.setX(mag * std::cos(theta));
|
||||
|
|
|
@ -208,7 +208,7 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
|
|||
datum->t = pt;
|
||||
datum->lifeSpan =
|
||||
(m_particleDuration
|
||||
+ (QRandomGenerator::bounded((m_particleDurationVariation*2) + 1) - m_particleDurationVariation))
|
||||
+ (QRandomGenerator::global()->bounded((m_particleDurationVariation*2) + 1) - m_particleDurationVariation))
|
||||
/ 1000.0;
|
||||
|
||||
// Particle position
|
||||
|
@ -241,7 +241,7 @@ void QQuickTrailEmitter::emitWindow(int timeStamp)
|
|||
|
||||
// Particle size
|
||||
float sizeVariation = -m_particleSizeVariation
|
||||
+ QRandomGenerator::getReal() * m_particleSizeVariation * 2;
|
||||
+ QRandomGenerator::global()->generateDouble() * m_particleSizeVariation * 2;
|
||||
|
||||
float size = qMax((qreal)0.0, m_particleSize + sizeVariation);
|
||||
float endSize = qMax((qreal)0.0, sizeAtEnd + sizeVariation);
|
||||
|
|
|
@ -103,8 +103,8 @@ WanderData* QQuickWanderAffector::getData(int idx)
|
|||
d->y_vel = 0;
|
||||
d->x_peak = m_xVariance;
|
||||
d->y_peak = m_yVariance;
|
||||
d->x_var = m_pace * QRandomGenerator::getReal();
|
||||
d->y_var = m_pace * QRandomGenerator::getReal();
|
||||
d->x_var = m_pace * QRandomGenerator::global()->generateDouble();
|
||||
d->y_var = m_pace * QRandomGenerator::global()->generateDouble();
|
||||
|
||||
m_wanderData.insert(idx, d);
|
||||
return d;
|
||||
|
@ -125,7 +125,7 @@ bool QQuickWanderAffector::affectParticle(QQuickParticleData* data, qreal dt)
|
|||
if (m_xVariance != 0.) {
|
||||
if ((d->x_vel > d->x_peak && d->x_var > 0.0) || (d->x_vel < -d->x_peak && d->x_var < 0.0)) {
|
||||
d->x_var = -d->x_var;
|
||||
d->x_peak = m_xVariance + m_xVariance * QRandomGenerator::getReal();
|
||||
d->x_peak = m_xVariance + m_xVariance * QRandomGenerator::global()->generateDouble();
|
||||
}
|
||||
d->x_vel += d->x_var * dt;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ bool QQuickWanderAffector::affectParticle(QQuickParticleData* data, qreal dt)
|
|||
if (m_yVariance != 0.) {
|
||||
if ((d->y_vel > d->y_peak && d->y_var > 0.0) || (d->y_vel < -d->y_peak && d->y_var < 0.0)) {
|
||||
d->y_var = -d->y_var;
|
||||
d->y_peak = m_yVariance + m_yVariance * QRandomGenerator::getReal();
|
||||
d->y_peak = m_yVariance + m_yVariance * QRandomGenerator::global()->generateDouble();
|
||||
}
|
||||
d->y_vel += d->y_var * dt;
|
||||
}
|
||||
|
@ -147,8 +147,8 @@ bool QQuickWanderAffector::affectParticle(QQuickParticleData* data, qreal dt)
|
|||
p->y += dy;
|
||||
return true;
|
||||
*/
|
||||
qreal dx = dt * m_pace * (2 * QRandomGenerator::getReal() - 1);
|
||||
qreal dy = dt * m_pace * (2 * QRandomGenerator::getReal() - 1);
|
||||
qreal dx = dt * m_pace * (2 * QRandomGenerator::global()->generateDouble() - 1);
|
||||
qreal dy = dt * m_pace * (2 * QRandomGenerator::global()->generateDouble() - 1);
|
||||
qreal newX, newY;
|
||||
switch (m_affectedParameter){
|
||||
case Position:
|
||||
|
|
|
@ -620,7 +620,7 @@ signals:
|
|||
|
||||
private slots:
|
||||
void updateProperty() {
|
||||
m_targetProperty.write(QRandomGenerator::bounded(m_maxValue));
|
||||
m_targetProperty.write(QRandomGenerator::global()->bounded(m_maxValue));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -277,7 +277,7 @@ ReturnedValue MathObject::method_pow(const FunctionObject *, const Value *, cons
|
|||
|
||||
ReturnedValue MathObject::method_random(const FunctionObject *, const Value *, const Value *, int)
|
||||
{
|
||||
RETURN_RESULT(Encode(QRandomGenerator::getReal()));
|
||||
RETURN_RESULT(Encode(QRandomGenerator::global()->generateDouble()));
|
||||
}
|
||||
|
||||
ReturnedValue MathObject::method_round(const FunctionObject *, const Value *, const Value *argv, int argc)
|
||||
|
|
|
@ -237,12 +237,12 @@ int QQuickSprite::variedDuration() const //Deals with precedence when multiple d
|
|||
|
||||
if (m_frameRate != unsetDuration) {
|
||||
qreal fpms = (m_frameRate
|
||||
+ (m_frameRateVariation * QRandomGenerator::getReal() * 2)
|
||||
+ (m_frameRateVariation * QRandomGenerator::global()->generateDouble() * 2)
|
||||
- m_frameRateVariation) / 1000.0;
|
||||
return qMax(qreal(0.0) , m_frames / fpms);
|
||||
} else if (m_frameDuration != unsetDuration) {
|
||||
int mspf = m_frameDuration
|
||||
+ (m_frameDurationVariation * QRandomGenerator::getReal() * 2)
|
||||
+ (m_frameDurationVariation * QRandomGenerator::global()->generateDouble() * 2)
|
||||
- m_frameDurationVariation;
|
||||
return qMax(0, m_frames * mspf);
|
||||
} else if (duration() >= 0) {
|
||||
|
|
|
@ -544,7 +544,7 @@ void QQuickStochasticEngine::restart(int index)
|
|||
if (m_addAdvance)
|
||||
m_startTimes[index] += m_advanceTime.elapsed();
|
||||
if (randomStart)
|
||||
m_startTimes[index] -= QRandomGenerator::bounded(m_duration.at(index));
|
||||
m_startTimes[index] -= QRandomGenerator::global()->bounded(m_duration.at(index));
|
||||
int time = m_duration.at(index) + m_startTimes.at(index);
|
||||
for (int i=0; i<m_stateUpdates.count(); i++)
|
||||
m_stateUpdates[i].second.removeAll(index);
|
||||
|
@ -558,13 +558,13 @@ void QQuickSpriteEngine::restart(int index) //Reimplemented to recognize and han
|
|||
if (m_loaded && m_sprites.at(m_things.at(index))->frameSync()) {//Manually advanced
|
||||
m_startTimes[index] = 0;
|
||||
if (randomStart && m_sprites.at(m_things.at(index))->m_generatedCount)
|
||||
m_startTimes[index] += QRandomGenerator::bounded(m_sprites.at(m_things.at(index))->m_generatedCount);
|
||||
m_startTimes[index] += QRandomGenerator::global()->bounded(m_sprites.at(m_things.at(index))->m_generatedCount);
|
||||
} else {
|
||||
m_startTimes[index] = m_timeOffset;
|
||||
if (m_addAdvance)
|
||||
m_startTimes[index] += m_advanceTime.elapsed();
|
||||
if (randomStart)
|
||||
m_startTimes[index] -= QRandomGenerator::bounded(m_duration.at(index));
|
||||
m_startTimes[index] -= QRandomGenerator::global()->bounded(m_duration.at(index));
|
||||
int time = spriteDuration(index) + m_startTimes.at(index);
|
||||
if (randomStart) {
|
||||
int curTime = m_timeOffset + (m_addAdvance ? m_advanceTime.elapsed() : 0);
|
||||
|
@ -630,7 +630,7 @@ int QQuickStochasticEngine::nextState(int curState, int curThing)
|
|||
int nextIdx = -1;
|
||||
int goalPath = goalSeek(curState, curThing);
|
||||
if (goalPath == -1){//Random
|
||||
qreal r = QRandomGenerator::getReal();
|
||||
qreal r = QRandomGenerator::global()->generateDouble();
|
||||
qreal total = 0.0;
|
||||
for (QVariantMap::const_iterator iter=m_states.at(curState)->m_to.constBegin();
|
||||
iter!=m_states.at(curState)->m_to.constEnd(); ++iter)
|
||||
|
@ -720,7 +720,7 @@ int QQuickStochasticEngine::goalSeek(int curIdx, int spriteIdx, int dist)
|
|||
if (options.count()==1)
|
||||
return *(options.begin());
|
||||
int option = -1;
|
||||
qreal r = QRandomGenerator::getReal();
|
||||
qreal r = QRandomGenerator::global()->generateDouble();
|
||||
qreal total = 0;
|
||||
for (QSet<int>::const_iterator iter=options.constBegin();
|
||||
iter!=options.constEnd(); ++iter)
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
virtual int variedDuration() const
|
||||
{
|
||||
return qMax(qreal(0.0) , m_duration
|
||||
+ (m_durationVariation * QRandomGenerator::bounded(2.0))
|
||||
+ (m_durationVariation * QRandomGenerator::global()->bounded(2.0))
|
||||
- m_durationVariation);
|
||||
}
|
||||
|
||||
|
|
|
@ -1487,27 +1487,27 @@ void tst_qqmlchangeset::random()
|
|||
for (int j = 0; j < combinations; ++j) {
|
||||
QQmlChangeSet set;
|
||||
for (int k = 0; k < depth; ++k) {
|
||||
switch (-QRandomGenerator::bounded(3)) {
|
||||
switch (-QRandomGenerator::global()->bounded(3)) {
|
||||
case InsertOp: {
|
||||
int index = QRandomGenerator::bounded(modelCount + 1);
|
||||
int count = QRandomGenerator::bounded(5) + 1;
|
||||
int index = QRandomGenerator::global()->bounded(modelCount + 1);
|
||||
int count = QRandomGenerator::global()->bounded(5) + 1;
|
||||
set.insert(index, count);
|
||||
input.append(Insert(index, count));
|
||||
modelCount += count;
|
||||
break;
|
||||
}
|
||||
case RemoveOp: {
|
||||
const int index = QRandomGenerator::bounded(modelCount + 1);
|
||||
const int count = QRandomGenerator::bounded(modelCount - index + 1);
|
||||
const int index = QRandomGenerator::global()->bounded(modelCount + 1);
|
||||
const int count = QRandomGenerator::global()->bounded(modelCount - index + 1);
|
||||
set.remove(index, count);
|
||||
input.append(Remove(index, count));
|
||||
modelCount -= count;
|
||||
break;
|
||||
}
|
||||
case MoveOp: {
|
||||
const int from = QRandomGenerator::bounded(modelCount + 1);
|
||||
const int count = QRandomGenerator::bounded(modelCount - from + 1);
|
||||
const int to = QRandomGenerator::bounded(modelCount - count + 1);
|
||||
const int from = QRandomGenerator::global()->bounded(modelCount + 1);
|
||||
const int count = QRandomGenerator::global()->bounded(modelCount - from + 1);
|
||||
const int to = QRandomGenerator::global()->bounded(modelCount - count + 1);
|
||||
const int moveId = moveCount++;
|
||||
set.move(from, to, count, moveId);
|
||||
input.append(Move(from, to, count, moveId));
|
||||
|
|
|
@ -74,14 +74,14 @@ QVariant RandomSortModel::data(const QModelIndex& index, int role) const
|
|||
|
||||
void RandomSortModel::randomize()
|
||||
{
|
||||
const int row = QRandomGenerator::bounded(mData.count());
|
||||
const int row = QRandomGenerator::global()->bounded(mData.count());
|
||||
int random;
|
||||
bool exists = false;
|
||||
// Make sure we won't end up with two items with the same weight, as that
|
||||
// would make unit-testing much harder
|
||||
do {
|
||||
exists = false;
|
||||
random = QRandomGenerator::bounded(mData.count() * 10);
|
||||
random = QRandomGenerator::global()->bounded(mData.count() * 10);
|
||||
QList<QPair<QString, int> >::ConstIterator iter, end;
|
||||
for (iter = mData.constBegin(), end = mData.constEnd(); iter != end; ++iter) {
|
||||
if ((*iter).second == random) {
|
||||
|
|
|
@ -374,7 +374,7 @@ void QQuickViewTestUtil::StressTestModel::updateModel()
|
|||
{
|
||||
if (m_rowCount > 10) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
int rnum = QRandomGenerator::bounded(m_rowCount);
|
||||
int rnum = QRandomGenerator::global()->bounded(m_rowCount);
|
||||
beginRemoveRows(QModelIndex(), rnum, rnum);
|
||||
m_rowCount--;
|
||||
endRemoveRows();
|
||||
|
@ -382,7 +382,7 @@ void QQuickViewTestUtil::StressTestModel::updateModel()
|
|||
}
|
||||
if (m_rowCount < 20) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
int rnum = QRandomGenerator::bounded(m_rowCount);
|
||||
int rnum = QRandomGenerator::global()->bounded(m_rowCount);
|
||||
beginInsertRows(QModelIndex(), rnum, rnum);
|
||||
m_rowCount++;
|
||||
endInsertRows();
|
||||
|
|
|
@ -224,7 +224,7 @@ public:
|
|||
{
|
||||
QPixmap pv(150, 150);
|
||||
pv.fill(Qt::green);
|
||||
int choice = QRandomGenerator::bounded(4);
|
||||
int choice = QRandomGenerator::global()->bounded(4);
|
||||
switch (choice) {
|
||||
case 0: setArbitraryVariant(QVariant(QString(QLatin1String("string variant value")))); break;
|
||||
case 1: setArbitraryVariant(QVariant(QColor(110, 120, 130))); break;
|
||||
|
@ -254,7 +254,7 @@ public:
|
|||
QVariant retn;
|
||||
QPixmap pv(randomFactorOne % 300, randomFactorTwo % 300);
|
||||
pv.fill(QColor(randomFactorOne % 256, randomFactorTwo % 256, randomFactorThree % 256));
|
||||
int choice = QRandomGenerator::bounded(4);
|
||||
int choice = QRandomGenerator::global()->bounded(4);
|
||||
switch (choice) {
|
||||
case 0: retn = QVariant(QString(QLatin1String("string variant value"))); break;
|
||||
case 1: retn = QVariant(QColor(randomFactorThree % 256, randomFactorTwo % 256, randomFactorOne % 256)); break;
|
||||
|
|
|
@ -322,7 +322,7 @@ public:
|
|||
int len = strlen(chars);
|
||||
for (int i = 0; i < lines; ++i) {
|
||||
for (int j = 0; j < 60; j++) {
|
||||
strings[i] += QChar(chars[QRandomGenerator::bounded(len)]);
|
||||
strings[i] += QChar(chars[QRandomGenerator::global()->bounded(len)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue