Commit 53f6e9f6 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Port away from KRandom

parent 1a0c955e
......@@ -10,11 +10,8 @@
#include "boxasker.h"
#include <stdlib.h> // for RAND_MAX
#include <KAcceleratorManager>
#include <KLocalizedString>
#include <KRandom>
#include <QButtonGroup>
#include <QGroupBox>
......@@ -22,6 +19,7 @@
#include <QLabel>
#include <QLayout>
#include <QRadioButton>
#include <QRandomGenerator>
#include <QPushButton>
#include <QKeyEvent>
......@@ -193,7 +191,7 @@ void boxAsker::nextQuestionHook(const division *div)
auxList << div -> getUntranslatedName ();
// we put the division in a random place
p_position = (int)((float)NB_CHOICES * KRandom::random() / (RAND_MAX + 1.0));
p_position = QRandomGenerator::global()->bounded(NB_CHOICES);
nextBoxAskerQuestionHook(div, p_position, true);
// fill the other names
......
......@@ -11,9 +11,9 @@
#include "divisioncapitalasker.h"
#include <KLocalizedString>
#include <KRandom>
#include <QRadioButton>
#include <QRandomGenerator>
#include "map.h"
......@@ -41,7 +41,7 @@ bool divisionCapitalAsker::nextBoxAskerQuestionHook(const division *div, int i,
{
if (index != i)
{
int random = (int)((float)falseCapitals.size() * KRandom::random() / (RAND_MAX + 1.0));
const int random = QRandomGenerator::global()->bounded(falseCapitals.size());
QString falseCapital = falseCapitals.at(random);
falseCapitals.removeAt(random);
p_radioButtons[index] -> setText(i18nc("@option:radio The capital of <Region> is...", "%1", falseCapital));
......
......@@ -10,13 +10,11 @@
#include "map.h"
#include <stdlib.h> // for RAND_MAX
#include <KLocalizedString>
#include <KRandom>
#include <QFile>
#include <QFileInfo>
#include <QRandomGenerator>
#include "division.h"
......@@ -154,7 +152,7 @@ QString KGmap::getDivisionsString() const
division *KGmap::getRandomDivision(division::askMode am) const
{
QList<division*> aux;
int i = (int)((float)p_divisions.size() * KRandom::random() / (RAND_MAX + 1.0));
const int i = QRandomGenerator::global()->bounded(p_divisions.size());
if (!p_divisions[i] -> canAsk(am)) return getRandomDivision(am);
else return p_divisions[i];
}
......
......@@ -11,11 +11,11 @@
#include "mapasker.h"
#include <KMessageBox>
#include <KRandom>
#include <KLocalizedString>
#include <QLabel>
#include <QLayout>
#include <QRandomGenerator>
#include <QScrollBar>
#include <QString>
......@@ -235,7 +235,7 @@ void mapAsker::showEvent(QShowEvent *)
const int n = swapableIndexes.size();
for ( int i = 2; i < n ; ++i )
{
int o = int(float(i) * KRandom::random() / (RAND_MAX + 1.0));
int o = QRandomGenerator::global()->bounded(i);
int ci = shuffling[i];
int co = shuffling[o];
qSwap(shuffling[i], shuffling[o]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment