Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
KGeography
Commits
53f6e9f6
Commit
53f6e9f6
authored
Jul 24, 2020
by
Albert Astals Cid
Browse files
Port away from KRandom
parent
1a0c955e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/boxasker.cpp
View file @
53f6e9f6
...
...
@@ -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
...
...
src/divisioncapitalasker.cpp
View file @
53f6e9f6
...
...
@@ -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
));
...
...
src/map.cpp
View file @
53f6e9f6
...
...
@@ -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
];
}
...
...
src/mapasker.cpp
View file @
53f6e9f6
...
...
@@ -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
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment